From a9c74eac71f81110c8497d53d5dcbc13869f482a Mon Sep 17 00:00:00 2001 From: azure-sdk Date: Wed, 20 May 2026 02:58:41 +0000 Subject: [PATCH 1/3] Configurations: 'specification/cdn/resource-manager/Microsoft.Cdn/Cdn/tspconfig.yaml', API Version: 2025-12-01, SDK Release Type: stable, and CommitSHA: '2283827e2d3992938b814e5b23b6b288093423d5' in SpecRepo: 'https://github.com/Azure/azure-rest-api-specs' Pipeline run: https://dev.azure.com/azure-sdk/internal/_build/results?buildId=6324712 Refer to https://eng.ms/docs/products/azure-developer-experience/develop/sdk-release/sdk-release-prerequisites to prepare for SDK release. --- sdk/cdn/azure-mgmt-cdn/CHANGELOG.md | 325 + sdk/cdn/azure-mgmt-cdn/MANIFEST.in | 9 +- sdk/cdn/azure-mgmt-cdn/README.md | 6 +- sdk/cdn/azure-mgmt-cdn/_meta.json | 11 - sdk/cdn/azure-mgmt-cdn/_metadata.json | 10 + .../azure-mgmt-cdn/apiview-properties.json | 609 + sdk/cdn/azure-mgmt-cdn/azure/__init__.py | 2 +- sdk/cdn/azure-mgmt-cdn/azure/mgmt/__init__.py | 2 +- .../azure-mgmt-cdn/azure/mgmt/cdn/__init__.py | 14 +- .../{_cdn_management_client.py => _client.py} | 117 +- .../azure/mgmt/cdn/_configuration.py | 35 +- .../azure-mgmt-cdn/azure/mgmt/cdn/_patch.py | 38 +- .../azure/mgmt/cdn/_utils/__init__.py | 6 + .../azure/mgmt/cdn/_utils/model_base.py | 1453 + .../serialization.py} | 607 +- .../cdn/{aio/_vendor.py => _utils/utils.py} | 21 +- .../azure/mgmt/cdn/_validation.py | 66 + .../azure-mgmt-cdn/azure/mgmt/cdn/_vendor.py | 36 - .../azure-mgmt-cdn/azure/mgmt/cdn/_version.py | 4 +- .../azure/mgmt/cdn/aio/__init__.py | 14 +- .../{_cdn_management_client.py => _client.py} | 119 +- .../azure/mgmt/cdn/aio/_configuration.py | 35 +- .../azure/mgmt/cdn/aio/_patch.py | 38 +- .../azure/mgmt/cdn/aio/operations/__init__.py | 69 +- .../_afd_custom_domains_operations.py | 869 - .../operations/_afd_endpoints_operations.py | 1219 - .../_afd_origin_groups_operations.py | 848 - .../aio/operations/_afd_origins_operations.py | 790 - .../operations/_afd_profiles_operations.py | 757 - .../_cdn_management_client_operations.py | 488 - .../operations/_custom_domains_operations.py | 929 - .../aio/operations/_edge_nodes_operations.py | 136 - .../aio/operations/_endpoints_operations.py | 1638 -- .../operations/_log_analytics_operations.py | 547 - .../_managed_rule_sets_operations.py | 138 - .../mgmt/cdn/aio/operations/_operations.py | 18513 ++++++++++++- .../operations/_origin_groups_operations.py | 791 - .../cdn/aio/operations/_origins_operations.py | 781 - .../azure/mgmt/cdn/aio/operations/_patch.py | 12 +- .../aio/operations/_policies_operations.py | 672 - .../aio/operations/_profiles_operations.py | 1467 -- .../operations/_resource_usage_operations.py | 136 - .../cdn/aio/operations/_routes_operations.py | 792 - .../aio/operations/_rule_sets_operations.py | 485 - .../cdn/aio/operations/_rules_operations.py | 775 - .../cdn/aio/operations/_secrets_operations.py | 534 - .../_security_policies_operations.py | 749 - .../azure/mgmt/cdn/models/__init__.py | 885 +- ...n_management_client_enums.py => _enums.py} | 905 +- .../azure/mgmt/cdn/models/_models.py | 12397 +++++++++ .../azure/mgmt/cdn/models/_models_py3.py | 13637 ---------- .../azure/mgmt/cdn/models/_patch.py | 12 +- .../azure/mgmt/cdn/operations/__init__.py | 69 +- .../_afd_custom_domains_operations.py | 1062 - .../operations/_afd_endpoints_operations.py | 1490 -- .../_afd_origin_groups_operations.py | 1048 - .../cdn/operations/_afd_origins_operations.py | 976 - .../operations/_afd_profiles_operations.py | 932 - .../_cdn_management_client_operations.py | 598 - .../operations/_custom_domains_operations.py | 1163 - .../cdn/operations/_edge_nodes_operations.py | 157 - .../cdn/operations/_endpoints_operations.py | 2005 -- .../operations/_log_analytics_operations.py | 829 - .../_managed_rule_sets_operations.py | 166 - .../azure/mgmt/cdn/operations/_operations.py | 21826 +++++++++++++++- .../operations/_origin_groups_operations.py | 986 - .../cdn/operations/_origins_operations.py | 970 - .../azure/mgmt/cdn/operations/_patch.py | 12 +- .../cdn/operations/_policies_operations.py | 849 - .../cdn/operations/_profiles_operations.py | 1834 -- .../operations/_resource_usage_operations.py | 162 - .../mgmt/cdn/operations/_routes_operations.py | 984 - .../cdn/operations/_rule_sets_operations.py | 644 - .../mgmt/cdn/operations/_rules_operations.py | 947 - .../cdn/operations/_secrets_operations.py | 661 - .../_security_policies_operations.py | 916 - .../afd_custom_domains_create.py | 18 +- .../afd_custom_domains_delete.py | 6 +- .../afd_custom_domains_get.py | 6 +- .../afd_custom_domains_list_by_profile.py | 6 +- ...custom_domains_refresh_validation_token.py | 6 +- .../afd_custom_domains_update.py | 18 +- .../generated_samples/afd_endpoints_create.py | 8 +- .../generated_samples/afd_endpoints_delete.py | 6 +- .../generated_samples/afd_endpoints_get.py | 6 +- .../afd_endpoints_list_by_profile.py | 6 +- .../afd_endpoints_list_resource_usage.py | 6 +- .../afd_endpoints_purge_content.py | 8 +- .../generated_samples/afd_endpoints_update.py | 8 +- .../afd_endpoints_validate_custom_domain.py | 8 +- .../afd_origin_groups_create.py | 16 +- .../afd_origin_groups_delete.py | 6 +- .../afd_origin_groups_get.py | 6 +- .../afd_origin_groups_list_by_profile.py | 6 +- .../afd_origin_groups_list_resource_usage.py | 6 +- .../afd_origin_groups_update.py | 16 +- .../generated_samples/afd_origins_create.py | 8 +- .../generated_samples/afd_origins_delete.py | 6 +- .../generated_samples/afd_origins_get.py | 6 +- .../afd_origins_list_by_origin_group.py | 6 +- .../generated_samples/afd_origins_update.py | 8 +- ...ofiles_check_endpoint_name_availability.py | 8 +- ...d_profiles_check_host_name_availability.py | 8 +- .../afd_profiles_list_resource_usage.py | 6 +- .../generated_samples/afd_profiles_upgrade.py | 9 +- .../afd_profiles_validate_secret.py | 9 +- .../cdn_profiles_can_migrate.py | 42 + .../generated_samples/cdn_profiles_migrate.py | 43 + .../check_endpoint_name_availability.py | 8 +- .../check_name_availability.py | 6 +- ...eck_name_availability_with_subscription.py | 8 +- .../custom_domains_create.py | 8 +- .../custom_domains_delete.py | 6 +- .../custom_domains_disable_custom_https.py | 6 +- ..._domains_enable_custom_https_using_byoc.py | 6 +- ...tom_https_using_cdn_managed_certificate.py | 6 +- .../generated_samples/custom_domains_get.py | 6 +- .../custom_domains_list_by_endpoint.py | 6 +- .../generated_samples/edge_nodes_list.py | 4 +- .../generated_samples/endpoints_create.py | 9 +- .../generated_samples/endpoints_delete.py | 6 +- .../generated_samples/endpoints_get.py | 6 +- .../endpoints_list_by_profile.py | 6 +- .../endpoints_list_resource_usage.py | 6 +- .../endpoints_load_content.py | 8 +- .../endpoints_purge_content.py | 8 +- .../generated_samples/endpoints_start.py | 6 +- .../generated_samples/endpoints_stop.py | 6 +- .../generated_samples/endpoints_update.py | 8 +- .../endpoints_validate_custom_domain.py | 8 +- ...g_analytics_get_log_analytics_locations.py | 6 +- ...log_analytics_get_log_analytics_metrics.py | 11 +- ...og_analytics_get_log_analytics_rankings.py | 11 +- ...g_analytics_get_log_analytics_resources.py | 6 +- ...analytics_get_waf_log_analytics_metrics.py | 11 +- ...nalytics_get_waf_log_analytics_rankings.py | 11 +- .../generated_samples/operations_list.py | 4 +- .../generated_samples/origin_groups_create.py | 9 +- .../generated_samples/origin_groups_delete.py | 6 +- .../generated_samples/origin_groups_get.py | 6 +- .../origin_groups_list_by_endpoint.py | 6 +- .../generated_samples/origin_groups_update.py | 9 +- .../generated_samples/origins_create.py | 9 +- .../generated_samples/origins_delete.py | 6 +- .../generated_samples/origins_get.py | 6 +- .../origins_list_by_endpoint.py | 6 +- .../generated_samples/origins_update.py | 8 +- .../generated_samples/profiles_can_migrate.py | 8 +- .../generated_samples/profiles_create.py | 8 +- .../generated_samples/profiles_delete.py | 6 +- .../profiles_generate_sso_uri.py | 6 +- .../generated_samples/profiles_get.py | 6 +- .../generated_samples/profiles_list.py | 6 +- .../profiles_list_by_resource_group.py | 6 +- .../profiles_list_resource_usage.py | 6 +- ...files_list_supported_optimization_types.py | 6 +- .../generated_samples/profiles_migrate.py | 8 +- .../profiles_migration_abort.py | 41 + .../profiles_migration_commit.py | 6 +- .../generated_samples/profiles_update.py | 8 +- .../generated_samples/resource_usage_list.py | 6 +- .../generated_samples/routes_create.py | 9 +- .../generated_samples/routes_delete.py | 6 +- .../generated_samples/routes_get.py | 6 +- .../routes_list_by_endpoint.py | 6 +- .../generated_samples/routes_update.py | 9 +- .../generated_samples/rule_sets_create.py | 10 +- .../generated_samples/rule_sets_delete.py | 6 +- .../generated_samples/rule_sets_get.py | 6 +- .../rule_sets_list_by_profile.py | 6 +- .../rule_sets_list_resource_usage.py | 6 +- .../generated_samples/rules_create.py | 8 +- .../generated_samples/rules_delete.py | 6 +- .../generated_samples/rules_get.py | 6 +- .../rules_list_by_rule_set.py | 6 +- .../generated_samples/rules_update.py | 8 +- .../generated_samples/secrets_create.py | 9 +- .../generated_samples/secrets_delete.py | 6 +- .../generated_samples/secrets_get.py | 6 +- .../secrets_list_by_profile.py | 6 +- .../security_policies_create.py | 9 +- .../security_policies_delete.py | 6 +- .../security_policies_get.py | 6 +- .../security_policies_list_by_profile.py | 6 +- .../security_policies_patch.py | 9 +- .../generated_samples/validate_probe.py | 8 +- .../waf_list_managed_rule_sets.py | 6 +- .../generated_samples/waf_list_policies.py | 6 +- .../generated_samples/waf_patch_policy.py | 8 +- .../waf_policy_create_or_update.py | 9 +- .../generated_samples/waf_policy_delete.py | 6 +- .../generated_samples/waf_policy_get.py | 6 +- .../generated_tests/conftest.py | 35 + .../generated_tests/test_cdn_management.py | 64 + ...anagement_afd_custom_domains_operations.py | 141 + ...ent_afd_custom_domains_operations_async.py | 150 + ...cdn_management_afd_endpoints_operations.py | 143 + ...nagement_afd_endpoints_operations_async.py | 152 + ...management_afd_origin_groups_operations.py | 141 + ...ment_afd_origin_groups_operations_async.py | 148 + ...t_cdn_management_afd_origins_operations.py | 138 + ...management_afd_origins_operations_async.py | 145 + ..._cdn_management_afd_profiles_operations.py | 84 + ...anagement_afd_profiles_operations_async.py | 87 + .../test_cdn_management_async.py | 65 + ...dn_management_custom_domains_operations.py | 97 + ...agement_custom_domains_operations_async.py | 106 + ...st_cdn_management_edge_nodes_operations.py | 27 + ..._management_edge_nodes_operations_async.py | 28 + ...est_cdn_management_endpoints_operations.py | 290 + ...n_management_endpoints_operations_async.py | 305 + ...cdn_management_log_analytics_operations.py | 105 + ...nagement_log_analytics_operations_async.py | 106 + ...management_managed_rule_sets_operations.py | 27 + ...ment_managed_rule_sets_operations_async.py | 28 + .../test_cdn_management_operations.py | 27 + .../test_cdn_management_operations_async.py | 28 + ...cdn_management_origin_groups_operations.py | 130 + ...nagement_origin_groups_operations_async.py | 137 + .../test_cdn_management_origins_operations.py | 127 + ...cdn_management_origins_operations_async.py | 134 + ...test_cdn_management_policies_operations.py | 161 + ...dn_management_policies_operations_async.py | 166 + ...test_cdn_management_profiles_operations.py | 245 + ...dn_management_profiles_operations_async.py | 274 + ...dn_management_resource_usage_operations.py | 27 + ...agement_resource_usage_operations_async.py | 28 + .../test_cdn_management_routes_operations.py | 136 + ..._cdn_management_routes_operations_async.py | 143 + ...est_cdn_management_rule_sets_operations.py | 78 + ...n_management_rule_sets_operations_async.py | 83 + .../test_cdn_management_rules_operations.py | 114 + ...t_cdn_management_rules_operations_async.py | 121 + .../test_cdn_management_secrets_operations.py | 85 + ...cdn_management_secrets_operations_async.py | 90 + ...management_security_policies_operations.py | 98 + ...ment_security_policies_operations_async.py | 107 + sdk/cdn/azure-mgmt-cdn/pyproject.toml | 81 + sdk/cdn/azure-mgmt-cdn/sdk_packaging.toml | 7 - sdk/cdn/azure-mgmt-cdn/setup.py | 82 - sdk/cdn/azure-mgmt-cdn/tests/conftest.py | 3 +- .../tests/disable_test_cli_mgmt_cdn.py | 228 +- sdk/cdn/azure-mgmt-cdn/tsp-location.yaml | 4 + 243 files changed, 62752 insertions(+), 50590 deletions(-) delete mode 100644 sdk/cdn/azure-mgmt-cdn/_meta.json create mode 100644 sdk/cdn/azure-mgmt-cdn/_metadata.json create mode 100644 sdk/cdn/azure-mgmt-cdn/apiview-properties.json rename sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/{_cdn_management_client.py => _client.py} (77%) create mode 100644 sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/_utils/__init__.py create mode 100644 sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/_utils/model_base.py rename sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/{_serialization.py => _utils/serialization.py} (81%) rename sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/{aio/_vendor.py => _utils/utils.py} (53%) create mode 100644 sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/_validation.py delete mode 100644 sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/_vendor.py rename sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/{_cdn_management_client.py => _client.py} (78%) delete mode 100644 sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_afd_custom_domains_operations.py delete mode 100644 sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_afd_endpoints_operations.py delete mode 100644 sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_afd_origin_groups_operations.py delete mode 100644 sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_afd_origins_operations.py delete mode 100644 sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_afd_profiles_operations.py delete mode 100644 sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_cdn_management_client_operations.py delete mode 100644 sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_custom_domains_operations.py delete mode 100644 sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_edge_nodes_operations.py delete mode 100644 sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_endpoints_operations.py delete mode 100644 sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_log_analytics_operations.py delete mode 100644 sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_managed_rule_sets_operations.py delete mode 100644 sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_origin_groups_operations.py delete mode 100644 sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_origins_operations.py delete mode 100644 sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_policies_operations.py delete mode 100644 sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_profiles_operations.py delete mode 100644 sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_resource_usage_operations.py delete mode 100644 sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_routes_operations.py delete mode 100644 sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_rule_sets_operations.py delete mode 100644 sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_rules_operations.py delete mode 100644 sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_secrets_operations.py delete mode 100644 sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_security_policies_operations.py rename sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/models/{_cdn_management_client_enums.py => _enums.py} (65%) create mode 100644 sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/models/_models.py delete mode 100644 sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/models/_models_py3.py delete mode 100644 sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_afd_custom_domains_operations.py delete mode 100644 sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_afd_endpoints_operations.py delete mode 100644 sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_afd_origin_groups_operations.py delete mode 100644 sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_afd_origins_operations.py delete mode 100644 sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_afd_profiles_operations.py delete mode 100644 sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_cdn_management_client_operations.py delete mode 100644 sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_custom_domains_operations.py delete mode 100644 sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_edge_nodes_operations.py delete mode 100644 sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_endpoints_operations.py delete mode 100644 sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_log_analytics_operations.py delete mode 100644 sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_managed_rule_sets_operations.py delete mode 100644 sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_origin_groups_operations.py delete mode 100644 sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_origins_operations.py delete mode 100644 sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_policies_operations.py delete mode 100644 sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_profiles_operations.py delete mode 100644 sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_resource_usage_operations.py delete mode 100644 sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_routes_operations.py delete mode 100644 sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_rule_sets_operations.py delete mode 100644 sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_rules_operations.py delete mode 100644 sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_secrets_operations.py delete mode 100644 sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_security_policies_operations.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 delete mode 100644 sdk/cdn/azure-mgmt-cdn/sdk_packaging.toml delete mode 100644 sdk/cdn/azure-mgmt-cdn/setup.py create mode 100644 sdk/cdn/azure-mgmt-cdn/tsp-location.yaml diff --git a/sdk/cdn/azure-mgmt-cdn/CHANGELOG.md b/sdk/cdn/azure-mgmt-cdn/CHANGELOG.md index d3fbb1381f6d..5ae4379974e0 100644 --- a/sdk/cdn/azure-mgmt-cdn/CHANGELOG.md +++ b/sdk/cdn/azure-mgmt-cdn/CHANGELOG.md @@ -1,5 +1,330 @@ # Release History +## 14.0.0 (2026-05-20) + +### Features Added + + - Client `CdnManagementClient` added parameter `cloud_setting` in method `__init__` + - Client `CdnManagementClient` added method `send_request` + - Model `AFDDomain` added property `properties` + - Model `AFDDomainHttpsParameters` added property `cipher_suite_set_type` + - Model `AFDDomainHttpsParameters` added property `customized_cipher_suite_set` + - Model `AFDEndpoint` added property `properties` + - Model `AFDEndpointUpdateParameters` added property `properties` + - Model `AFDOrigin` added property `properties` + - Model `AFDOriginGroup` added property `properties` + - Model `AFDOriginGroupProperties` added property `authentication` + - Model `AFDOriginGroupUpdatePropertiesParameters` added property `authentication` + - Enum `AfdMinimumTlsVersion` added member `TLS13` + - Model `CanMigrateResult` added property `properties` + - Model `Endpoint` added property `properties` + - Model `EndpointUpdateParameters` added property `properties` + - Enum `MatchProcessingBehavior` added member `CONTINUE` + - Model `Operation` added property `operation_properties` + - Model `Origin` added property `properties` + - Model `OriginGroup` added property `properties` + - Model `ProfileUpdateParameters` added property `properties` + - Model `Route` added property `properties` + - Model `Rule` added property `properties` + - Model `RuleSet` added property `properties` + - Model `RuleSetProperties` added property `batch_mode` + - Model `RuleSetProperties` added property `rules` + - Model `Secret` added property `properties` + - Model `SecurityPolicy` added property `properties` + - Added model `AFDDomainHttpsCustomizedCipherSuiteSet` + - Added enum `AfdCipherSuiteSetType` + - Added enum `AfdCustomizedCipherSuiteForTls12` + - Added enum `AfdCustomizedCipherSuiteForTls13` + - Added model `BatchRuleProperties` + - Added model `CanMigrateProperties` + - Added model `CdnMigrationToAfdParameters` + - Added model `CertificateSourceParameters` + - Added enum `CertificateSourceParametersType` + - Added enum `CreatedByType` + - Added model `CustomDomainPropertiesParameters` + - Added enum `DeliveryRuleActionName` + - Added model `DeliveryRuleActionParameters` + - Added enum `DeliveryRuleActionParametersType` + - Added model `DeliveryRuleConditionParameters` + - Added enum `DeliveryRuleConditionParametersType` + - Added enum `IsDeviceMatchValue` + - Added enum `KeyVaultSigningKeyParametersType` + - Added model `MigrationEndpointMapping` + - Added model `OperationProperties` + - Added model `OriginAuthenticationProperties` + - Added enum `OriginAuthenticationType` + - Added model `ProfilePropertiesUpdateParameters` + - Added enum `RequestMethodMatchValue` + - Added enum `RequestSchemeMatchValue` + - Added model `SecurityPolicyUpdateProperties` + - 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` + - Model `RuleSetsOperations` added method `begin_create` + +### Breaking Changes + + - Model `AFDDomain` deleted or renamed its instance variable `profile_name` + - Model `AFDDomain` deleted or renamed its instance variable `tls_settings` + - Model `AFDDomain` deleted or renamed its instance variable `azure_dns_zone` + - Model `AFDDomain` deleted or renamed its instance variable `pre_validated_custom_domain_resource_id` + - Model `AFDDomain` deleted or renamed its instance variable `provisioning_state` + - Model `AFDDomain` deleted or renamed its instance variable `deployment_status` + - Model `AFDDomain` deleted or renamed its instance variable `domain_validation_state` + - Model `AFDDomain` deleted or renamed its instance variable `host_name` + - Model `AFDDomain` deleted or renamed its instance variable `extended_properties` + - Model `AFDDomain` deleted or renamed its instance variable `validation_properties` + - Model `AFDDomainUpdateParameters` deleted or renamed its instance variable `profile_name` + - Model `AFDDomainUpdateParameters` deleted or renamed its instance variable `tls_settings` + - Model `AFDDomainUpdateParameters` deleted or renamed its instance variable `azure_dns_zone` + - Model `AFDDomainUpdateParameters` deleted or renamed its instance variable `pre_validated_custom_domain_resource_id` + - Model `AFDEndpoint` deleted or renamed its instance variable `profile_name` + - Model `AFDEndpoint` deleted or renamed its instance variable `enabled_state` + - Model `AFDEndpoint` deleted or renamed its instance variable `provisioning_state` + - Model `AFDEndpoint` deleted or renamed its instance variable `deployment_status` + - Model `AFDEndpoint` deleted or renamed its instance variable `host_name` + - Model `AFDEndpoint` deleted or renamed its instance variable `auto_generated_domain_name_label_scope` + - Model `AFDEndpointUpdateParameters` deleted or renamed its instance variable `profile_name` + - Model `AFDEndpointUpdateParameters` deleted or renamed its instance variable `enabled_state` + - Model `AFDOrigin` deleted or renamed its instance variable `origin_group_name` + - Model `AFDOrigin` deleted or renamed its instance variable `azure_origin` + - Model `AFDOrigin` deleted or renamed its instance variable `host_name` + - Model `AFDOrigin` deleted or renamed its instance variable `http_port` + - Model `AFDOrigin` deleted or renamed its instance variable `https_port` + - Model `AFDOrigin` deleted or renamed its instance variable `origin_host_header` + - Model `AFDOrigin` deleted or renamed its instance variable `priority` + - Model `AFDOrigin` deleted or renamed its instance variable `weight` + - Model `AFDOrigin` deleted or renamed its instance variable `shared_private_link_resource` + - Model `AFDOrigin` deleted or renamed its instance variable `enabled_state` + - Model `AFDOrigin` deleted or renamed its instance variable `enforce_certificate_name_check` + - Model `AFDOrigin` deleted or renamed its instance variable `provisioning_state` + - Model `AFDOrigin` deleted or renamed its instance variable `deployment_status` + - Model `AFDOriginGroup` deleted or renamed its instance variable `profile_name` + - Model `AFDOriginGroup` deleted or renamed its instance variable `load_balancing_settings` + - Model `AFDOriginGroup` deleted or renamed its instance variable `health_probe_settings` + - Model `AFDOriginGroup` deleted or renamed its instance variable `traffic_restoration_time_to_healed_or_new_endpoints_in_minutes` + - Model `AFDOriginGroup` deleted or renamed its instance variable `session_affinity_state` + - Model `AFDOriginGroup` deleted or renamed its instance variable `provisioning_state` + - Model `AFDOriginGroup` deleted or renamed its instance variable `deployment_status` + - Model `AFDOriginGroupUpdateParameters` deleted or renamed its instance variable `profile_name` + - Model `AFDOriginGroupUpdateParameters` deleted or renamed its instance variable `load_balancing_settings` + - Model `AFDOriginGroupUpdateParameters` deleted or renamed its instance variable `health_probe_settings` + - Model `AFDOriginGroupUpdateParameters` deleted or renamed its instance variable `traffic_restoration_time_to_healed_or_new_endpoints_in_minutes` + - Model `AFDOriginGroupUpdateParameters` deleted or renamed its instance variable `session_affinity_state` + - Model `AFDOriginUpdateParameters` deleted or renamed its instance variable `origin_group_name` + - Model `AFDOriginUpdateParameters` deleted or renamed its instance variable `azure_origin` + - Model `AFDOriginUpdateParameters` deleted or renamed its instance variable `host_name` + - Model `AFDOriginUpdateParameters` deleted or renamed its instance variable `http_port` + - Model `AFDOriginUpdateParameters` deleted or renamed its instance variable `https_port` + - Model `AFDOriginUpdateParameters` deleted or renamed its instance variable `origin_host_header` + - Model `AFDOriginUpdateParameters` deleted or renamed its instance variable `priority` + - Model `AFDOriginUpdateParameters` deleted or renamed its instance variable `weight` + - Model `AFDOriginUpdateParameters` deleted or renamed its instance variable `shared_private_link_resource` + - Model `AFDOriginUpdateParameters` deleted or renamed its instance variable `enabled_state` + - Model `AFDOriginUpdateParameters` deleted or renamed its instance variable `enforce_certificate_name_check` + - Model `CanMigrateResult` deleted or renamed its instance variable `can_migrate` + - Model `CanMigrateResult` deleted or renamed its instance variable `default_sku` + - Model `CanMigrateResult` deleted or renamed its instance variable `errors` + - Model `CustomDomainParameters` deleted or renamed its instance variable `host_name` + - Model `Endpoint` deleted or renamed its instance variable `origin_path` + - Model `Endpoint` deleted or renamed its instance variable `content_types_to_compress` + - Model `Endpoint` deleted or renamed its instance variable `origin_host_header` + - Model `Endpoint` deleted or renamed its instance variable `is_compression_enabled` + - Model `Endpoint` deleted or renamed its instance variable `is_http_allowed` + - Model `Endpoint` deleted or renamed its instance variable `is_https_allowed` + - Model `Endpoint` deleted or renamed its instance variable `query_string_caching_behavior` + - Model `Endpoint` deleted or renamed its instance variable `optimization_type` + - Model `Endpoint` deleted or renamed its instance variable `probe_path` + - Model `Endpoint` deleted or renamed its instance variable `geo_filters` + - Model `Endpoint` deleted or renamed its instance variable `default_origin_group` + - Model `Endpoint` deleted or renamed its instance variable `url_signing_keys` + - Model `Endpoint` deleted or renamed its instance variable `delivery_policy` + - Model `Endpoint` deleted or renamed its instance variable `web_application_firewall_policy_link` + - Model `Endpoint` deleted or renamed its instance variable `host_name` + - Model `Endpoint` deleted or renamed its instance variable `origins` + - Model `Endpoint` deleted or renamed its instance variable `origin_groups` + - Model `Endpoint` deleted or renamed its instance variable `custom_domains` + - Model `Endpoint` deleted or renamed its instance variable `resource_state` + - Model `Endpoint` deleted or renamed its instance variable `provisioning_state` + - Model `EndpointUpdateParameters` deleted or renamed its instance variable `origin_path` + - Model `EndpointUpdateParameters` deleted or renamed its instance variable `content_types_to_compress` + - Model `EndpointUpdateParameters` deleted or renamed its instance variable `origin_host_header` + - Model `EndpointUpdateParameters` deleted or renamed its instance variable `is_compression_enabled` + - Model `EndpointUpdateParameters` deleted or renamed its instance variable `is_http_allowed` + - Model `EndpointUpdateParameters` deleted or renamed its instance variable `is_https_allowed` + - Model `EndpointUpdateParameters` deleted or renamed its instance variable `query_string_caching_behavior` + - Model `EndpointUpdateParameters` deleted or renamed its instance variable `optimization_type` + - Model `EndpointUpdateParameters` deleted or renamed its instance variable `probe_path` + - Model `EndpointUpdateParameters` deleted or renamed its instance variable `geo_filters` + - Model `EndpointUpdateParameters` deleted or renamed its instance variable `default_origin_group` + - Model `EndpointUpdateParameters` deleted or renamed its instance variable `url_signing_keys` + - Model `EndpointUpdateParameters` deleted or renamed its instance variable `delivery_policy` + - Model `EndpointUpdateParameters` deleted or renamed its instance variable `web_application_firewall_policy_link` + - Deleted or renamed enum value `MatchProcessingBehavior.CONTINUE_ENUM` + - Model `Operation` deleted or renamed its instance variable `service_specification` + - Model `Origin` deleted or renamed its instance variable `host_name` + - Model `Origin` deleted or renamed its instance variable `http_port` + - Model `Origin` deleted or renamed its instance variable `https_port` + - Model `Origin` deleted or renamed its instance variable `origin_host_header` + - Model `Origin` deleted or renamed its instance variable `priority` + - Model `Origin` deleted or renamed its instance variable `weight` + - Model `Origin` deleted or renamed its instance variable `enabled` + - Model `Origin` deleted or renamed its instance variable `private_link_alias` + - Model `Origin` deleted or renamed its instance variable `private_link_resource_id` + - Model `Origin` deleted or renamed its instance variable `private_link_location` + - Model `Origin` deleted or renamed its instance variable `private_link_approval_message` + - Model `Origin` deleted or renamed its instance variable `resource_state` + - Model `Origin` deleted or renamed its instance variable `provisioning_state` + - Model `Origin` deleted or renamed its instance variable `private_endpoint_status` + - Model `OriginGroup` deleted or renamed its instance variable `health_probe_settings` + - Model `OriginGroup` deleted or renamed its instance variable `origins` + - Model `OriginGroup` deleted or renamed its instance variable `traffic_restoration_time_to_healed_or_new_endpoints_in_minutes` + - Model `OriginGroup` deleted or renamed its instance variable `response_based_origin_error_detection_settings` + - Model `OriginGroup` deleted or renamed its instance variable `resource_state` + - Model `OriginGroup` deleted or renamed its instance variable `provisioning_state` + - Model `OriginGroupUpdateParameters` deleted or renamed its instance variable `health_probe_settings` + - Model `OriginGroupUpdateParameters` deleted or renamed its instance variable `origins` + - Model `OriginGroupUpdateParameters` deleted or renamed its instance variable `traffic_restoration_time_to_healed_or_new_endpoints_in_minutes` + - Model `OriginGroupUpdateParameters` deleted or renamed its instance variable `response_based_origin_error_detection_settings` + - Model `OriginUpdateParameters` deleted or renamed its instance variable `host_name` + - Model `OriginUpdateParameters` deleted or renamed its instance variable `http_port` + - Model `OriginUpdateParameters` deleted or renamed its instance variable `https_port` + - Model `OriginUpdateParameters` deleted or renamed its instance variable `origin_host_header` + - Model `OriginUpdateParameters` deleted or renamed its instance variable `priority` + - Model `OriginUpdateParameters` deleted or renamed its instance variable `weight` + - Model `OriginUpdateParameters` deleted or renamed its instance variable `enabled` + - Model `OriginUpdateParameters` deleted or renamed its instance variable `private_link_alias` + - Model `OriginUpdateParameters` deleted or renamed its instance variable `private_link_resource_id` + - Model `OriginUpdateParameters` deleted or renamed its instance variable `private_link_location` + - Model `OriginUpdateParameters` deleted or renamed its instance variable `private_link_approval_message` + - Model `ProfileUpdateParameters` deleted or renamed its instance variable `origin_response_timeout_seconds` + - Model `ProfileUpdateParameters` deleted or renamed its instance variable `log_scrubbing` + - Model `Route` deleted or renamed its instance variable `endpoint_name` + - Model `Route` deleted or renamed its instance variable `custom_domains` + - Model `Route` deleted or renamed its instance variable `origin_group` + - Model `Route` deleted or renamed its instance variable `origin_path` + - Model `Route` deleted or renamed its instance variable `rule_sets` + - Model `Route` deleted or renamed its instance variable `supported_protocols` + - Model `Route` deleted or renamed its instance variable `patterns_to_match` + - Model `Route` deleted or renamed its instance variable `cache_configuration` + - Model `Route` deleted or renamed its instance variable `forwarding_protocol` + - Model `Route` deleted or renamed its instance variable `link_to_default_domain` + - Model `Route` deleted or renamed its instance variable `https_redirect` + - Model `Route` deleted or renamed its instance variable `enabled_state` + - Model `Route` deleted or renamed its instance variable `provisioning_state` + - Model `Route` deleted or renamed its instance variable `deployment_status` + - Model `RouteUpdateParameters` deleted or renamed its instance variable `endpoint_name` + - Model `RouteUpdateParameters` deleted or renamed its instance variable `custom_domains` + - Model `RouteUpdateParameters` deleted or renamed its instance variable `origin_group` + - Model `RouteUpdateParameters` deleted or renamed its instance variable `origin_path` + - Model `RouteUpdateParameters` deleted or renamed its instance variable `rule_sets` + - Model `RouteUpdateParameters` deleted or renamed its instance variable `supported_protocols` + - Model `RouteUpdateParameters` deleted or renamed its instance variable `patterns_to_match` + - Model `RouteUpdateParameters` deleted or renamed its instance variable `cache_configuration` + - Model `RouteUpdateParameters` deleted or renamed its instance variable `forwarding_protocol` + - Model `RouteUpdateParameters` deleted or renamed its instance variable `link_to_default_domain` + - Model `RouteUpdateParameters` deleted or renamed its instance variable `https_redirect` + - Model `RouteUpdateParameters` deleted or renamed its instance variable `enabled_state` + - Model `Rule` deleted or renamed its instance variable `rule_set_name` + - Model `Rule` deleted or renamed its instance variable `order` + - Model `Rule` deleted or renamed its instance variable `conditions` + - Model `Rule` deleted or renamed its instance variable `actions` + - Model `Rule` deleted or renamed its instance variable `match_processing_behavior` + - Model `Rule` deleted or renamed its instance variable `provisioning_state` + - Model `Rule` deleted or renamed its instance variable `deployment_status` + - Model `RuleSet` deleted or renamed its instance variable `provisioning_state` + - Model `RuleSet` deleted or renamed its instance variable `deployment_status` + - Model `RuleSet` deleted or renamed its instance variable `profile_name` + - Model `RuleUpdateParameters` deleted or renamed its instance variable `rule_set_name` + - Model `RuleUpdateParameters` deleted or renamed its instance variable `order` + - Model `RuleUpdateParameters` deleted or renamed its instance variable `conditions` + - Model `RuleUpdateParameters` deleted or renamed its instance variable `actions` + - Model `RuleUpdateParameters` deleted or renamed its instance variable `match_processing_behavior` + - Model `Secret` deleted or renamed its instance variable `provisioning_state` + - Model `Secret` deleted or renamed its instance variable `deployment_status` + - Model `Secret` deleted or renamed its instance variable `profile_name` + - Model `Secret` deleted or renamed its instance variable `parameters` + - Model `SecurityPolicy` deleted or renamed its instance variable `provisioning_state` + - Model `SecurityPolicy` deleted or renamed its instance variable `deployment_status` + - Model `SecurityPolicy` deleted or renamed its instance variable `profile_name` + - Model `SecurityPolicy` deleted or renamed its instance variable `parameters` + - Model `SecurityPolicyUpdateParameters` deleted or renamed its instance variable `parameters` + - Deleted or renamed model `AfdErrorResponse` + - Deleted or renamed model `AzureFirstPartyManagedCertificate` + - Deleted or renamed model `CacheExpirationActionParametersTypeName` + - Deleted or renamed model `CacheKeyQueryStringActionParametersTypeName` + - Deleted or renamed model `CdnCertificateSourceParametersTypeName` + - Deleted or renamed model `CdnWebApplicationFirewallPolicyList` + - Deleted or renamed model `Certificate` + - Deleted or renamed model `ClientPortMatchConditionParametersTypeName` + - Deleted or renamed model `CookiesMatchConditionParametersTypeName` + - Deleted or renamed model `CustomerCertificate` + - Deleted or renamed model `DeliveryRuleActionEnum` + - Deleted or renamed model `EdgenodeResult` + - Deleted or renamed model `HeaderActionParametersTypeName` + - Deleted or renamed model `HostNameMatchConditionParametersTypeName` + - Deleted or renamed model `HttpVersionMatchConditionParametersTypeName` + - Deleted or renamed model `IdentityType` + - Deleted or renamed model `IsDeviceMatchConditionParametersMatchValuesItem` + - Deleted or renamed model `IsDeviceMatchConditionParametersTypeName` + - Deleted or renamed model `KeyVaultCertificateSourceParametersTypeName` + - Deleted or renamed model `KeyVaultSigningKeyParametersTypeName` + - Deleted or renamed model `ManagedCertificate` + - Deleted or renamed model `ManagedRuleSetDefinitionList` + - 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` + - Deleted or renamed model `ValidationToken` + - Method `LogAnalyticsOperations.get_log_analytics_metrics` changed its parameter `metrics` from `positional_or_keyword` to `keyword_only` + - Method `LogAnalyticsOperations.get_log_analytics_metrics` changed its parameter `date_time_begin` from `positional_or_keyword` to `keyword_only` + - Method `LogAnalyticsOperations.get_log_analytics_metrics` changed its parameter `date_time_end` from `positional_or_keyword` to `keyword_only` + - Method `LogAnalyticsOperations.get_log_analytics_metrics` changed its parameter `granularity` from `positional_or_keyword` to `keyword_only` + - Method `LogAnalyticsOperations.get_log_analytics_metrics` changed its parameter `custom_domains` from `positional_or_keyword` to `keyword_only` + - Method `LogAnalyticsOperations.get_log_analytics_metrics` changed its parameter `protocols` from `positional_or_keyword` to `keyword_only` + - Method `LogAnalyticsOperations.get_log_analytics_metrics` changed its parameter `group_by` from `positional_or_keyword` to `keyword_only` + - Method `LogAnalyticsOperations.get_log_analytics_metrics` changed its parameter `continents` from `positional_or_keyword` to `keyword_only` + - Method `LogAnalyticsOperations.get_log_analytics_metrics` changed its parameter `country_or_regions` from `positional_or_keyword` to `keyword_only` + - Method `LogAnalyticsOperations.get_log_analytics_rankings` changed its parameter `rankings` from `positional_or_keyword` to `keyword_only` + - Method `LogAnalyticsOperations.get_log_analytics_rankings` changed its parameter `metrics` from `positional_or_keyword` to `keyword_only` + - Method `LogAnalyticsOperations.get_log_analytics_rankings` changed its parameter `max_ranking` from `positional_or_keyword` to `keyword_only` + - Method `LogAnalyticsOperations.get_log_analytics_rankings` changed its parameter `date_time_begin` from `positional_or_keyword` to `keyword_only` + - Method `LogAnalyticsOperations.get_log_analytics_rankings` changed its parameter `date_time_end` from `positional_or_keyword` to `keyword_only` + - Method `LogAnalyticsOperations.get_log_analytics_rankings` changed its parameter `custom_domains` from `positional_or_keyword` to `keyword_only` + - Method `LogAnalyticsOperations.get_waf_log_analytics_metrics` changed its parameter `metrics` from `positional_or_keyword` to `keyword_only` + - Method `LogAnalyticsOperations.get_waf_log_analytics_metrics` changed its parameter `date_time_begin` from `positional_or_keyword` to `keyword_only` + - Method `LogAnalyticsOperations.get_waf_log_analytics_metrics` changed its parameter `date_time_end` from `positional_or_keyword` to `keyword_only` + - Method `LogAnalyticsOperations.get_waf_log_analytics_metrics` changed its parameter `granularity` from `positional_or_keyword` to `keyword_only` + - Method `LogAnalyticsOperations.get_waf_log_analytics_metrics` changed its parameter `actions` from `positional_or_keyword` to `keyword_only` + - Method `LogAnalyticsOperations.get_waf_log_analytics_metrics` changed its parameter `group_by` from `positional_or_keyword` to `keyword_only` + - Method `LogAnalyticsOperations.get_waf_log_analytics_metrics` changed its parameter `rule_types` from `positional_or_keyword` to `keyword_only` + - Method `LogAnalyticsOperations.get_waf_log_analytics_rankings` changed its parameter `metrics` from `positional_or_keyword` to `keyword_only` + - Method `LogAnalyticsOperations.get_waf_log_analytics_rankings` changed its parameter `date_time_begin` from `positional_or_keyword` to `keyword_only` + - Method `LogAnalyticsOperations.get_waf_log_analytics_rankings` changed its parameter `date_time_end` from `positional_or_keyword` to `keyword_only` + - Method `LogAnalyticsOperations.get_waf_log_analytics_rankings` changed its parameter `max_ranking` from `positional_or_keyword` to `keyword_only` + - Method `LogAnalyticsOperations.get_waf_log_analytics_rankings` changed its parameter `rankings` from `positional_or_keyword` to `keyword_only` + - Method `LogAnalyticsOperations.get_waf_log_analytics_rankings` changed its parameter `actions` from `positional_or_keyword` to `keyword_only` + - Method `LogAnalyticsOperations.get_waf_log_analytics_rankings` changed its parameter `rule_types` from `positional_or_keyword` to `keyword_only` + - Deleted or renamed method `RuleSetsOperations.create` + - Deleted or renamed model `CdnManagementClientOperationsMixin` + ## 13.1.1 (2024-06-12) ### Bugs Fixed diff --git a/sdk/cdn/azure-mgmt-cdn/MANIFEST.in b/sdk/cdn/azure-mgmt-cdn/MANIFEST.in index 83cdb3bd0252..513bb2791590 100644 --- a/sdk/cdn/azure-mgmt-cdn/MANIFEST.in +++ b/sdk/cdn/azure-mgmt-cdn/MANIFEST.in @@ -1,8 +1,7 @@ -include _meta.json -recursive-include tests *.py *.json -recursive-include samples *.py *.md include *.md -include azure/__init__.py -include azure/mgmt/__init__.py include LICENSE include azure/mgmt/cdn/py.typed +recursive-include tests *.py +recursive-include samples *.py *.md +include azure/__init__.py +include azure/mgmt/__init__.py diff --git a/sdk/cdn/azure-mgmt-cdn/README.md b/sdk/cdn/azure-mgmt-cdn/README.md index 6aa59315c876..0a9b8cd2f27b 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.10+. For a more complete view of Azure libraries, see the [azure sdk python release](https://aka.ms/azsdk/python/all). ## _Disclaimer_ @@ -12,7 +12,7 @@ _Azure SDK Python packages support for Python 2.7 has ended 01 January 2022. For ### Prerequisites -- Python 3.8+ is required to use this package. +- Python 3.10+ is required to use this package. - [Azure subscription](https://azure.microsoft.com/free/) ### Install the package @@ -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 deleted file mode 100644 index a5cd8e2186b3..000000000000 --- a/sdk/cdn/azure-mgmt-cdn/_meta.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "commit": "de1f3772629b6f4d3ac01548a5f6d719bfb97c9e", - "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest": "3.10.2", - "use": [ - "@autorest/python@6.13.19", - "@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", - "readme": "specification/cdn/resource-manager/readme.md" -} \ No newline at end of file diff --git a/sdk/cdn/azure-mgmt-cdn/_metadata.json b/sdk/cdn/azure-mgmt-cdn/_metadata.json new file mode 100644 index 000000000000..eb6aa370899f --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/_metadata.json @@ -0,0 +1,10 @@ +{ + "apiVersion": "2025-12-01", + "apiVersions": { + "Microsoft.Cdn": "2025-12-01" + }, + "commit": "2283827e2d3992938b814e5b23b6b288093423d5", + "repository_url": "https://github.com/Azure/azure-rest-api-specs", + "typespec_src": "specification/cdn/resource-manager/Microsoft.Cdn/Cdn", + "emitterVersion": "0.62.1" +} \ No newline at end of file diff --git a/sdk/cdn/azure-mgmt-cdn/apiview-properties.json b/sdk/cdn/azure-mgmt-cdn/apiview-properties.json new file mode 100644 index 000000000000..3b356fbf1e70 --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/apiview-properties.json @@ -0,0 +1,609 @@ +{ + "CrossLanguagePackageId": "Microsoft.Cdn", + "CrossLanguageDefinitionId": { + "azure.mgmt.cdn.models.ActivatedResourceReference": "Microsoft.Cdn.ActivatedResourceReference", + "azure.mgmt.cdn.models.Resource": "Azure.ResourceManager.CommonTypes.Resource", + "azure.mgmt.cdn.models.ProxyResource": "Azure.ResourceManager.CommonTypes.ProxyResource", + "azure.mgmt.cdn.models.AFDDomain": "Microsoft.Cdn.AFDDomain", + "azure.mgmt.cdn.models.AFDDomainHttpsCustomizedCipherSuiteSet": "Microsoft.Cdn.AFDDomainHttpsCustomizedCipherSuiteSet", + "azure.mgmt.cdn.models.AFDDomainHttpsParameters": "Microsoft.Cdn.AFDDomainHttpsParameters", + "azure.mgmt.cdn.models.AFDDomainProperties": "Microsoft.Cdn.AFDDomainProperties", + "azure.mgmt.cdn.models.AFDDomainUpdateParameters": "Microsoft.Cdn.AFDDomainUpdateParameters", + "azure.mgmt.cdn.models.AFDDomainUpdatePropertiesParameters": "Microsoft.Cdn.AFDDomainUpdatePropertiesParameters", + "azure.mgmt.cdn.models.TrackedResource": "Azure.ResourceManager.CommonTypes.TrackedResource", + "azure.mgmt.cdn.models.AFDEndpoint": "Microsoft.Cdn.AFDEndpoint", + "azure.mgmt.cdn.models.AFDEndpointProperties": "Microsoft.Cdn.AFDEndpointProperties", + "azure.mgmt.cdn.models.AFDEndpointPropertiesUpdateParameters": "Microsoft.Cdn.AFDEndpointPropertiesUpdateParameters", + "azure.mgmt.cdn.models.AFDEndpointUpdateParameters": "Microsoft.Cdn.AFDEndpointUpdateParameters", + "azure.mgmt.cdn.models.AFDOrigin": "Microsoft.Cdn.AFDOrigin", + "azure.mgmt.cdn.models.AFDOriginGroup": "Microsoft.Cdn.AFDOriginGroup", + "azure.mgmt.cdn.models.AFDOriginGroupProperties": "Microsoft.Cdn.AFDOriginGroupProperties", + "azure.mgmt.cdn.models.AFDOriginGroupUpdateParameters": "Microsoft.Cdn.AFDOriginGroupUpdateParameters", + "azure.mgmt.cdn.models.AFDOriginGroupUpdatePropertiesParameters": "Microsoft.Cdn.AFDOriginGroupUpdatePropertiesParameters", + "azure.mgmt.cdn.models.AFDOriginProperties": "Microsoft.Cdn.AFDOriginProperties", + "azure.mgmt.cdn.models.AFDOriginUpdateParameters": "Microsoft.Cdn.AFDOriginUpdateParameters", + "azure.mgmt.cdn.models.AFDOriginUpdatePropertiesParameters": "Microsoft.Cdn.AFDOriginUpdatePropertiesParameters", + "azure.mgmt.cdn.models.AfdPurgeParameters": "Microsoft.Cdn.AfdPurgeParameters", + "azure.mgmt.cdn.models.AfdRouteCacheConfiguration": "Microsoft.Cdn.AfdRouteCacheConfiguration", + "azure.mgmt.cdn.models.AFDStateProperties": "Microsoft.Cdn.AFDStateProperties", + "azure.mgmt.cdn.models.SecretParameters": "Microsoft.Cdn.SecretParameters", + "azure.mgmt.cdn.models.AzureFirstPartyManagedCertificateParameters": "Microsoft.Cdn.AzureFirstPartyManagedCertificateParameters", + "azure.mgmt.cdn.models.BatchRuleProperties": "Microsoft.Cdn.BatchRuleProperties", + "azure.mgmt.cdn.models.CacheConfiguration": "Microsoft.Cdn.CacheConfiguration", + "azure.mgmt.cdn.models.DeliveryRuleActionParameters": "Microsoft.Cdn.DeliveryRuleActionParameters", + "azure.mgmt.cdn.models.CacheExpirationActionParameters": "Microsoft.Cdn.CacheExpirationActionParameters", + "azure.mgmt.cdn.models.CacheKeyQueryStringActionParameters": "Microsoft.Cdn.CacheKeyQueryStringActionParameters", + "azure.mgmt.cdn.models.CanMigrateParameters": "Microsoft.Cdn.CanMigrateParameters", + "azure.mgmt.cdn.models.CanMigrateProperties": "Microsoft.Cdn.CanMigrateProperties", + "azure.mgmt.cdn.models.CanMigrateResult": "Microsoft.Cdn.CanMigrateResult", + "azure.mgmt.cdn.models.CertificateSourceParameters": "Microsoft.Cdn.CertificateSourceParameters", + "azure.mgmt.cdn.models.CdnCertificateSourceParameters": "Microsoft.Cdn.CdnCertificateSourceParameters", + "azure.mgmt.cdn.models.CdnEndpoint": "Microsoft.Cdn.CdnEndpoint", + "azure.mgmt.cdn.models.CustomDomainHttpsParameters": "Microsoft.Cdn.CustomDomainHttpsParameters", + "azure.mgmt.cdn.models.CdnManagedHttpsParameters": "Microsoft.Cdn.CdnManagedHttpsParameters", + "azure.mgmt.cdn.models.CdnMigrationToAfdParameters": "Microsoft.Cdn.CdnMigrationToAfdParameters", + "azure.mgmt.cdn.models.CdnWebApplicationFirewallPolicy": "Microsoft.Cdn.CdnWebApplicationFirewallPolicy", + "azure.mgmt.cdn.models.CdnWebApplicationFirewallPolicyPatchParameters": "Microsoft.Cdn.CdnWebApplicationFirewallPolicyPatchParameters", + "azure.mgmt.cdn.models.CdnWebApplicationFirewallPolicyProperties": "Microsoft.Cdn.CdnWebApplicationFirewallPolicyProperties", + "azure.mgmt.cdn.models.CheckEndpointNameAvailabilityInput": "Microsoft.Cdn.CheckEndpointNameAvailabilityInput", + "azure.mgmt.cdn.models.CheckEndpointNameAvailabilityOutput": "Microsoft.Cdn.CheckEndpointNameAvailabilityOutput", + "azure.mgmt.cdn.models.CheckHostNameAvailabilityInput": "Microsoft.Cdn.CheckHostNameAvailabilityInput", + "azure.mgmt.cdn.models.CheckNameAvailabilityInput": "Microsoft.Cdn.CheckNameAvailabilityInput", + "azure.mgmt.cdn.models.CheckNameAvailabilityOutput": "Microsoft.Cdn.CheckNameAvailabilityOutput", + "azure.mgmt.cdn.models.CidrIpAddress": "Microsoft.Cdn.CidrIpAddress", + "azure.mgmt.cdn.models.DeliveryRuleConditionParameters": "Microsoft.Cdn.DeliveryRuleConditionParameters", + "azure.mgmt.cdn.models.ClientPortMatchConditionParameters": "Microsoft.Cdn.ClientPortMatchConditionParameters", + "azure.mgmt.cdn.models.Components18OrqelSchemasWafmetricsresponsePropertiesSeriesItemsPropertiesDataItems": "Microsoft.Cdn.Components18OrqelSchemasWafmetricsresponsePropertiesSeriesItemsPropertiesDataItems", + "azure.mgmt.cdn.models.Components1Gs0LlpSchemasMetricsresponsePropertiesSeriesItemsPropertiesDataItems": "Microsoft.Cdn.Components1Gs0LlpSchemasMetricsresponsePropertiesSeriesItemsPropertiesDataItems", + "azure.mgmt.cdn.models.ComponentsKpo1PjSchemasWafrankingsresponsePropertiesDataItemsPropertiesMetricsItems": "Microsoft.Cdn.ComponentsKpo1PjSchemasWafrankingsresponsePropertiesDataItemsPropertiesMetricsItems", + "azure.mgmt.cdn.models.CompressionSettings": "Microsoft.Cdn.CompressionSettings", + "azure.mgmt.cdn.models.ContinentsResponse": "Microsoft.Cdn.ContinentsResponse", + "azure.mgmt.cdn.models.ContinentsResponseContinentsItem": "Microsoft.Cdn.ContinentsResponseContinentsItem", + "azure.mgmt.cdn.models.ContinentsResponseCountryOrRegionsItem": "Microsoft.Cdn.ContinentsResponseCountryOrRegionsItem", + "azure.mgmt.cdn.models.CookiesMatchConditionParameters": "Microsoft.Cdn.CookiesMatchConditionParameters", + "azure.mgmt.cdn.models.CustomDomain": "Microsoft.Cdn.CustomDomain", + "azure.mgmt.cdn.models.CustomDomainParameters": "Microsoft.Cdn.CustomDomainParameters", + "azure.mgmt.cdn.models.CustomDomainProperties": "Microsoft.Cdn.CustomDomainProperties", + "azure.mgmt.cdn.models.CustomDomainPropertiesParameters": "Microsoft.Cdn.CustomDomainPropertiesParameters", + "azure.mgmt.cdn.models.CustomerCertificateParameters": "Microsoft.Cdn.CustomerCertificateParameters", + "azure.mgmt.cdn.models.CustomRule": "Microsoft.Cdn.CustomRule", + "azure.mgmt.cdn.models.CustomRuleList": "Microsoft.Cdn.CustomRuleList", + "azure.mgmt.cdn.models.DeepCreatedCustomDomain": "Microsoft.Cdn.DeepCreatedCustomDomain", + "azure.mgmt.cdn.models.DeepCreatedCustomDomainProperties": "Microsoft.Cdn.DeepCreatedCustomDomainProperties", + "azure.mgmt.cdn.models.DeepCreatedOrigin": "Microsoft.Cdn.DeepCreatedOrigin", + "azure.mgmt.cdn.models.DeepCreatedOriginGroup": "Microsoft.Cdn.DeepCreatedOriginGroup", + "azure.mgmt.cdn.models.DeepCreatedOriginGroupProperties": "Microsoft.Cdn.DeepCreatedOriginGroupProperties", + "azure.mgmt.cdn.models.DeepCreatedOriginProperties": "Microsoft.Cdn.DeepCreatedOriginProperties", + "azure.mgmt.cdn.models.DeliveryRule": "Microsoft.Cdn.DeliveryRule", + "azure.mgmt.cdn.models.DeliveryRuleAction": "Microsoft.Cdn.DeliveryRuleAction", + "azure.mgmt.cdn.models.DeliveryRuleCacheExpirationAction": "Microsoft.Cdn.DeliveryRuleCacheExpirationAction", + "azure.mgmt.cdn.models.DeliveryRuleCacheKeyQueryStringAction": "Microsoft.Cdn.DeliveryRuleCacheKeyQueryStringAction", + "azure.mgmt.cdn.models.DeliveryRuleCondition": "Microsoft.Cdn.DeliveryRuleCondition", + "azure.mgmt.cdn.models.DeliveryRuleClientPortCondition": "Microsoft.Cdn.DeliveryRuleClientPortCondition", + "azure.mgmt.cdn.models.DeliveryRuleCookiesCondition": "Microsoft.Cdn.DeliveryRuleCookiesCondition", + "azure.mgmt.cdn.models.DeliveryRuleHostNameCondition": "Microsoft.Cdn.DeliveryRuleHostNameCondition", + "azure.mgmt.cdn.models.DeliveryRuleHttpVersionCondition": "Microsoft.Cdn.DeliveryRuleHttpVersionCondition", + "azure.mgmt.cdn.models.DeliveryRuleIsDeviceCondition": "Microsoft.Cdn.DeliveryRuleIsDeviceCondition", + "azure.mgmt.cdn.models.DeliveryRulePostArgsCondition": "Microsoft.Cdn.DeliveryRulePostArgsCondition", + "azure.mgmt.cdn.models.DeliveryRuleQueryStringCondition": "Microsoft.Cdn.DeliveryRuleQueryStringCondition", + "azure.mgmt.cdn.models.DeliveryRuleRemoteAddressCondition": "Microsoft.Cdn.DeliveryRuleRemoteAddressCondition", + "azure.mgmt.cdn.models.DeliveryRuleRequestBodyCondition": "Microsoft.Cdn.DeliveryRuleRequestBodyCondition", + "azure.mgmt.cdn.models.DeliveryRuleRequestHeaderAction": "Microsoft.Cdn.DeliveryRuleRequestHeaderAction", + "azure.mgmt.cdn.models.DeliveryRuleRequestHeaderCondition": "Microsoft.Cdn.DeliveryRuleRequestHeaderCondition", + "azure.mgmt.cdn.models.DeliveryRuleRequestMethodCondition": "Microsoft.Cdn.DeliveryRuleRequestMethodCondition", + "azure.mgmt.cdn.models.DeliveryRuleRequestSchemeCondition": "Microsoft.Cdn.DeliveryRuleRequestSchemeCondition", + "azure.mgmt.cdn.models.DeliveryRuleRequestUriCondition": "Microsoft.Cdn.DeliveryRuleRequestUriCondition", + "azure.mgmt.cdn.models.DeliveryRuleResponseHeaderAction": "Microsoft.Cdn.DeliveryRuleResponseHeaderAction", + "azure.mgmt.cdn.models.DeliveryRuleRouteConfigurationOverrideAction": "Microsoft.Cdn.DeliveryRuleRouteConfigurationOverrideAction", + "azure.mgmt.cdn.models.DeliveryRuleServerPortCondition": "Microsoft.Cdn.DeliveryRuleServerPortCondition", + "azure.mgmt.cdn.models.DeliveryRuleSocketAddrCondition": "Microsoft.Cdn.DeliveryRuleSocketAddrCondition", + "azure.mgmt.cdn.models.DeliveryRuleSslProtocolCondition": "Microsoft.Cdn.DeliveryRuleSslProtocolCondition", + "azure.mgmt.cdn.models.DeliveryRuleUrlFileExtensionCondition": "Microsoft.Cdn.DeliveryRuleUrlFileExtensionCondition", + "azure.mgmt.cdn.models.DeliveryRuleUrlFileNameCondition": "Microsoft.Cdn.DeliveryRuleUrlFileNameCondition", + "azure.mgmt.cdn.models.DeliveryRuleUrlPathCondition": "Microsoft.Cdn.DeliveryRuleUrlPathCondition", + "azure.mgmt.cdn.models.DimensionProperties": "Microsoft.Cdn.DimensionProperties", + "azure.mgmt.cdn.models.DomainValidationProperties": "Microsoft.Cdn.DomainValidationProperties", + "azure.mgmt.cdn.models.EdgeNode": "Microsoft.Cdn.EdgeNode", + "azure.mgmt.cdn.models.EdgeNodeProperties": "Microsoft.Cdn.EdgeNodeProperties", + "azure.mgmt.cdn.models.Endpoint": "Microsoft.Cdn.Endpoint", + "azure.mgmt.cdn.models.EndpointPropertiesUpdateParameters": "Microsoft.Cdn.EndpointPropertiesUpdateParameters", + "azure.mgmt.cdn.models.EndpointProperties": "Microsoft.Cdn.EndpointProperties", + "azure.mgmt.cdn.models.EndpointPropertiesUpdateParametersDeliveryPolicy": "Microsoft.Cdn.EndpointPropertiesUpdateParametersDeliveryPolicy", + "azure.mgmt.cdn.models.EndpointPropertiesUpdateParametersWebApplicationFirewallPolicyLink": "Microsoft.Cdn.EndpointPropertiesUpdateParametersWebApplicationFirewallPolicyLink", + "azure.mgmt.cdn.models.EndpointUpdateParameters": "Microsoft.Cdn.EndpointUpdateParameters", + "azure.mgmt.cdn.models.ErrorAdditionalInfo": "Azure.ResourceManager.CommonTypes.ErrorAdditionalInfo", + "azure.mgmt.cdn.models.ErrorDetail": "Azure.ResourceManager.CommonTypes.ErrorDetail", + "azure.mgmt.cdn.models.ErrorResponse": "Azure.ResourceManager.CommonTypes.ErrorResponse", + "azure.mgmt.cdn.models.GeoFilter": "Microsoft.Cdn.GeoFilter", + "azure.mgmt.cdn.models.HeaderActionParameters": "Microsoft.Cdn.HeaderActionParameters", + "azure.mgmt.cdn.models.HealthProbeParameters": "Microsoft.Cdn.HealthProbeParameters", + "azure.mgmt.cdn.models.HostNameMatchConditionParameters": "Microsoft.Cdn.HostNameMatchConditionParameters", + "azure.mgmt.cdn.models.HttpErrorRangeParameters": "Microsoft.Cdn.HttpErrorRangeParameters", + "azure.mgmt.cdn.models.HttpVersionMatchConditionParameters": "Microsoft.Cdn.HttpVersionMatchConditionParameters", + "azure.mgmt.cdn.models.IpAddressGroup": "Microsoft.Cdn.IpAddressGroup", + "azure.mgmt.cdn.models.IsDeviceMatchConditionParameters": "Microsoft.Cdn.IsDeviceMatchConditionParameters", + "azure.mgmt.cdn.models.KeyVaultCertificateSourceParameters": "Microsoft.Cdn.KeyVaultCertificateSourceParameters", + "azure.mgmt.cdn.models.KeyVaultSigningKeyParameters": "Microsoft.Cdn.KeyVaultSigningKeyParameters", + "azure.mgmt.cdn.models.LoadBalancingSettingsParameters": "Microsoft.Cdn.LoadBalancingSettingsParameters", + "azure.mgmt.cdn.models.LoadParameters": "Microsoft.Cdn.LoadParameters", + "azure.mgmt.cdn.models.LogSpecification": "Microsoft.Cdn.LogSpecification", + "azure.mgmt.cdn.models.ManagedCertificateParameters": "Microsoft.Cdn.ManagedCertificateParameters", + "azure.mgmt.cdn.models.ManagedRuleDefinition": "Microsoft.Cdn.ManagedRuleDefinition", + "azure.mgmt.cdn.models.ManagedRuleGroupDefinition": "Microsoft.Cdn.ManagedRuleGroupDefinition", + "azure.mgmt.cdn.models.ManagedRuleGroupOverride": "Microsoft.Cdn.ManagedRuleGroupOverride", + "azure.mgmt.cdn.models.ManagedRuleOverride": "Microsoft.Cdn.ManagedRuleOverride", + "azure.mgmt.cdn.models.ManagedRuleSet": "Microsoft.Cdn.ManagedRuleSet", + "azure.mgmt.cdn.models.ManagedRuleSetDefinition": "Microsoft.Cdn.ManagedRuleSetDefinition", + "azure.mgmt.cdn.models.ManagedRuleSetDefinitionProperties": "Microsoft.Cdn.ManagedRuleSetDefinitionProperties", + "azure.mgmt.cdn.models.ManagedRuleSetList": "Microsoft.Cdn.ManagedRuleSetList", + "azure.mgmt.cdn.models.ManagedServiceIdentity": "Azure.ResourceManager.CommonTypes.ManagedServiceIdentity", + "azure.mgmt.cdn.models.MatchCondition": "Microsoft.Cdn.MatchCondition", + "azure.mgmt.cdn.models.MetricAvailability": "Microsoft.Cdn.MetricAvailability", + "azure.mgmt.cdn.models.MetricSpecification": "Microsoft.Cdn.MetricSpecification", + "azure.mgmt.cdn.models.MetricsResponse": "Microsoft.Cdn.MetricsResponse", + "azure.mgmt.cdn.models.MetricsResponseSeriesItem": "Microsoft.Cdn.MetricsResponseSeriesItem", + "azure.mgmt.cdn.models.MetricsResponseSeriesPropertiesItemsItem": "Microsoft.Cdn.MetricsResponseSeriesPropertiesItemsItem", + "azure.mgmt.cdn.models.MigrateResult": "Microsoft.Cdn.MigrateResult", + "azure.mgmt.cdn.models.MigrateResultProperties": "Microsoft.Cdn.MigrateResultProperties", + "azure.mgmt.cdn.models.MigrationEndpointMapping": "Microsoft.Cdn.MigrationEndpointMapping", + "azure.mgmt.cdn.models.MigrationErrorType": "Microsoft.Cdn.MigrationErrorType", + "azure.mgmt.cdn.models.MigrationParameters": "Microsoft.Cdn.MigrationParameters", + "azure.mgmt.cdn.models.MigrationWebApplicationFirewallMapping": "Microsoft.Cdn.MigrationWebApplicationFirewallMapping", + "azure.mgmt.cdn.models.Operation": "Microsoft.Cdn.Operation", + "azure.mgmt.cdn.models.OperationDisplay": "Microsoft.Cdn.OperationDisplay", + "azure.mgmt.cdn.models.OperationProperties": "Microsoft.Cdn.OperationProperties", + "azure.mgmt.cdn.models.Origin": "Microsoft.Cdn.Origin", + "azure.mgmt.cdn.models.OriginAuthenticationProperties": "Microsoft.Cdn.OriginAuthenticationProperties", + "azure.mgmt.cdn.models.OriginGroup": "Microsoft.Cdn.OriginGroup", + "azure.mgmt.cdn.models.OriginGroupOverride": "Microsoft.Cdn.OriginGroupOverride", + "azure.mgmt.cdn.models.OriginGroupOverrideAction": "Microsoft.Cdn.OriginGroupOverrideAction", + "azure.mgmt.cdn.models.OriginGroupOverrideActionParameters": "Microsoft.Cdn.OriginGroupOverrideActionParameters", + "azure.mgmt.cdn.models.OriginGroupUpdatePropertiesParameters": "Microsoft.Cdn.OriginGroupUpdatePropertiesParameters", + "azure.mgmt.cdn.models.OriginGroupProperties": "Microsoft.Cdn.OriginGroupProperties", + "azure.mgmt.cdn.models.OriginGroupUpdateParameters": "Microsoft.Cdn.OriginGroupUpdateParameters", + "azure.mgmt.cdn.models.OriginUpdatePropertiesParameters": "Microsoft.Cdn.OriginUpdatePropertiesParameters", + "azure.mgmt.cdn.models.OriginProperties": "Microsoft.Cdn.OriginProperties", + "azure.mgmt.cdn.models.OriginUpdateParameters": "Microsoft.Cdn.OriginUpdateParameters", + "azure.mgmt.cdn.models.PolicySettings": "Microsoft.Cdn.PolicySettings", + "azure.mgmt.cdn.models.PostArgsMatchConditionParameters": "Microsoft.Cdn.PostArgsMatchConditionParameters", + "azure.mgmt.cdn.models.Profile": "Microsoft.Cdn.Profile", + "azure.mgmt.cdn.models.ProfileChangeSkuWafMapping": "Microsoft.Cdn.ProfileChangeSkuWafMapping", + "azure.mgmt.cdn.models.ProfileLogScrubbing": "Microsoft.Cdn.ProfileLogScrubbing", + "azure.mgmt.cdn.models.ProfileProperties": "Microsoft.Cdn.ProfileProperties", + "azure.mgmt.cdn.models.ProfilePropertiesUpdateParameters": "Microsoft.Cdn.ProfilePropertiesUpdateParameters", + "azure.mgmt.cdn.models.ProfileScrubbingRules": "Microsoft.Cdn.ProfileScrubbingRules", + "azure.mgmt.cdn.models.ProfileUpdateParameters": "Microsoft.Cdn.ProfileUpdateParameters", + "azure.mgmt.cdn.models.ProfileUpgradeParameters": "Microsoft.Cdn.ProfileUpgradeParameters", + "azure.mgmt.cdn.models.PurgeParameters": "Microsoft.Cdn.PurgeParameters", + "azure.mgmt.cdn.models.QueryStringMatchConditionParameters": "Microsoft.Cdn.QueryStringMatchConditionParameters", + "azure.mgmt.cdn.models.RankingsResponse": "Microsoft.Cdn.RankingsResponse", + "azure.mgmt.cdn.models.RankingsResponseTablesItem": "Microsoft.Cdn.RankingsResponseTablesItem", + "azure.mgmt.cdn.models.RankingsResponseTablesPropertiesItemsItem": "Microsoft.Cdn.RankingsResponseTablesPropertiesItemsItem", + "azure.mgmt.cdn.models.RankingsResponseTablesPropertiesItemsMetricsItem": "Microsoft.Cdn.RankingsResponseTablesPropertiesItemsMetricsItem", + "azure.mgmt.cdn.models.RateLimitRule": "Microsoft.Cdn.RateLimitRule", + "azure.mgmt.cdn.models.RateLimitRuleList": "Microsoft.Cdn.RateLimitRuleList", + "azure.mgmt.cdn.models.RemoteAddressMatchConditionParameters": "Microsoft.Cdn.RemoteAddressMatchConditionParameters", + "azure.mgmt.cdn.models.RequestBodyMatchConditionParameters": "Microsoft.Cdn.RequestBodyMatchConditionParameters", + "azure.mgmt.cdn.models.RequestHeaderMatchConditionParameters": "Microsoft.Cdn.RequestHeaderMatchConditionParameters", + "azure.mgmt.cdn.models.RequestMethodMatchConditionParameters": "Microsoft.Cdn.RequestMethodMatchConditionParameters", + "azure.mgmt.cdn.models.RequestSchemeMatchConditionParameters": "Microsoft.Cdn.RequestSchemeMatchConditionParameters", + "azure.mgmt.cdn.models.RequestUriMatchConditionParameters": "Microsoft.Cdn.RequestUriMatchConditionParameters", + "azure.mgmt.cdn.models.ResourceReference": "Microsoft.Cdn.ResourceReference", + "azure.mgmt.cdn.models.ResourcesResponse": "Microsoft.Cdn.ResourcesResponse", + "azure.mgmt.cdn.models.ResourcesResponseCustomDomainsItem": "Microsoft.Cdn.ResourcesResponseCustomDomainsItem", + "azure.mgmt.cdn.models.ResourcesResponseEndpointsItem": "Microsoft.Cdn.ResourcesResponseEndpointsItem", + "azure.mgmt.cdn.models.ResourcesResponseEndpointsPropertiesItemsItem": "Microsoft.Cdn.ResourcesResponseEndpointsPropertiesItemsItem", + "azure.mgmt.cdn.models.ResourceUsage": "Microsoft.Cdn.ResourceUsage", + "azure.mgmt.cdn.models.ResponseBasedOriginErrorDetectionParameters": "Microsoft.Cdn.ResponseBasedOriginErrorDetectionParameters", + "azure.mgmt.cdn.models.Route": "Microsoft.Cdn.Route", + "azure.mgmt.cdn.models.RouteConfigurationOverrideActionParameters": "Microsoft.Cdn.RouteConfigurationOverrideActionParameters", + "azure.mgmt.cdn.models.RouteProperties": "Microsoft.Cdn.RouteProperties", + "azure.mgmt.cdn.models.RouteUpdateParameters": "Microsoft.Cdn.RouteUpdateParameters", + "azure.mgmt.cdn.models.RouteUpdatePropertiesParameters": "Microsoft.Cdn.RouteUpdatePropertiesParameters", + "azure.mgmt.cdn.models.Rule": "Microsoft.Cdn.Rule", + "azure.mgmt.cdn.models.RuleProperties": "Microsoft.Cdn.RuleProperties", + "azure.mgmt.cdn.models.RuleSet": "Microsoft.Cdn.RuleSet", + "azure.mgmt.cdn.models.RuleSetProperties": "Microsoft.Cdn.RuleSetProperties", + "azure.mgmt.cdn.models.RuleUpdateParameters": "Microsoft.Cdn.RuleUpdateParameters", + "azure.mgmt.cdn.models.RuleUpdatePropertiesParameters": "Microsoft.Cdn.RuleUpdatePropertiesParameters", + "azure.mgmt.cdn.models.Secret": "Microsoft.Cdn.Secret", + "azure.mgmt.cdn.models.SecretProperties": "Microsoft.Cdn.SecretProperties", + "azure.mgmt.cdn.models.SecurityPolicy": "Microsoft.Cdn.SecurityPolicy", + "azure.mgmt.cdn.models.SecurityPolicyProperties": "Microsoft.Cdn.SecurityPolicyProperties", + "azure.mgmt.cdn.models.SecurityPolicyPropertiesParameters": "Microsoft.Cdn.SecurityPolicyPropertiesParameters", + "azure.mgmt.cdn.models.SecurityPolicyUpdateParameters": "Microsoft.Cdn.SecurityPolicyUpdateParameters", + "azure.mgmt.cdn.models.SecurityPolicyUpdateProperties": "Microsoft.Cdn.SecurityPolicyUpdateProperties", + "azure.mgmt.cdn.models.SecurityPolicyWebApplicationFirewallAssociation": "Microsoft.Cdn.SecurityPolicyWebApplicationFirewallAssociation", + "azure.mgmt.cdn.models.SecurityPolicyWebApplicationFirewallParameters": "Microsoft.Cdn.SecurityPolicyWebApplicationFirewallParameters", + "azure.mgmt.cdn.models.ServerPortMatchConditionParameters": "Microsoft.Cdn.ServerPortMatchConditionParameters", + "azure.mgmt.cdn.models.ServiceSpecification": "Microsoft.Cdn.ServiceSpecification", + "azure.mgmt.cdn.models.SharedPrivateLinkResourceProperties": "Microsoft.Cdn.SharedPrivateLinkResourceProperties", + "azure.mgmt.cdn.models.Sku": "Microsoft.Cdn.Sku", + "azure.mgmt.cdn.models.SocketAddrMatchConditionParameters": "Microsoft.Cdn.SocketAddrMatchConditionParameters", + "azure.mgmt.cdn.models.SslProtocolMatchConditionParameters": "Microsoft.Cdn.SslProtocolMatchConditionParameters", + "azure.mgmt.cdn.models.SsoUri": "Microsoft.Cdn.SsoUri", + "azure.mgmt.cdn.models.SupportedOptimizationTypesListResult": "Microsoft.Cdn.SupportedOptimizationTypesListResult", + "azure.mgmt.cdn.models.SystemData": "Azure.ResourceManager.CommonTypes.SystemData", + "azure.mgmt.cdn.models.UrlFileExtensionMatchConditionParameters": "Microsoft.Cdn.UrlFileExtensionMatchConditionParameters", + "azure.mgmt.cdn.models.UrlFileNameMatchConditionParameters": "Microsoft.Cdn.UrlFileNameMatchConditionParameters", + "azure.mgmt.cdn.models.UrlPathMatchConditionParameters": "Microsoft.Cdn.UrlPathMatchConditionParameters", + "azure.mgmt.cdn.models.UrlRedirectAction": "Microsoft.Cdn.UrlRedirectAction", + "azure.mgmt.cdn.models.UrlRedirectActionParameters": "Microsoft.Cdn.UrlRedirectActionParameters", + "azure.mgmt.cdn.models.UrlRewriteAction": "Microsoft.Cdn.UrlRewriteAction", + "azure.mgmt.cdn.models.UrlRewriteActionParameters": "Microsoft.Cdn.UrlRewriteActionParameters", + "azure.mgmt.cdn.models.UrlSigningAction": "Microsoft.Cdn.UrlSigningAction", + "azure.mgmt.cdn.models.UrlSigningActionParameters": "Microsoft.Cdn.UrlSigningActionParameters", + "azure.mgmt.cdn.models.UrlSigningKey": "Microsoft.Cdn.UrlSigningKey", + "azure.mgmt.cdn.models.UrlSigningKeyParameters": "Microsoft.Cdn.UrlSigningKeyParameters", + "azure.mgmt.cdn.models.UrlSigningParamIdentifier": "Microsoft.Cdn.UrlSigningParamIdentifier", + "azure.mgmt.cdn.models.Usage": "Microsoft.Cdn.Usage", + "azure.mgmt.cdn.models.UsageName": "Microsoft.Cdn.UsageName", + "azure.mgmt.cdn.models.UserAssignedIdentity": "Azure.ResourceManager.CommonTypes.UserAssignedIdentity", + "azure.mgmt.cdn.models.UserManagedHttpsParameters": "Microsoft.Cdn.UserManagedHttpsParameters", + "azure.mgmt.cdn.models.ValidateCustomDomainInput": "Microsoft.Cdn.ValidateCustomDomainInput", + "azure.mgmt.cdn.models.ValidateCustomDomainOutput": "Microsoft.Cdn.ValidateCustomDomainOutput", + "azure.mgmt.cdn.models.ValidateProbeInput": "Microsoft.Cdn.ValidateProbeInput", + "azure.mgmt.cdn.models.ValidateProbeOutput": "Microsoft.Cdn.ValidateProbeOutput", + "azure.mgmt.cdn.models.ValidateSecretInput": "Microsoft.Cdn.ValidateSecretInput", + "azure.mgmt.cdn.models.ValidateSecretOutput": "Microsoft.Cdn.ValidateSecretOutput", + "azure.mgmt.cdn.models.WafMetricsResponse": "Microsoft.Cdn.WafMetricsResponse", + "azure.mgmt.cdn.models.WafMetricsResponseSeriesItem": "Microsoft.Cdn.WafMetricsResponseSeriesItem", + "azure.mgmt.cdn.models.WafMetricsResponseSeriesPropertiesItemsItem": "Microsoft.Cdn.WafMetricsResponseSeriesPropertiesItemsItem", + "azure.mgmt.cdn.models.WafRankingsResponse": "Microsoft.Cdn.WafRankingsResponse", + "azure.mgmt.cdn.models.WafRankingsResponseDataItem": "Microsoft.Cdn.WafRankingsResponseDataItem", + "azure.mgmt.cdn.models.CreatedByType": "Azure.ResourceManager.CommonTypes.createdByType", + "azure.mgmt.cdn.models.ProfileResourceState": "Microsoft.Cdn.ProfileResourceState", + "azure.mgmt.cdn.models.ProfileProvisioningState": "Microsoft.Cdn.ProfileProvisioningState", + "azure.mgmt.cdn.models.ProfileScrubbingState": "Microsoft.Cdn.ProfileScrubbingState", + "azure.mgmt.cdn.models.ScrubbingRuleEntryMatchVariable": "Microsoft.Cdn.ScrubbingRuleEntryMatchVariable", + "azure.mgmt.cdn.models.ScrubbingRuleEntryMatchOperator": "Microsoft.Cdn.ScrubbingRuleEntryMatchOperator", + "azure.mgmt.cdn.models.ScrubbingRuleEntryState": "Microsoft.Cdn.ScrubbingRuleEntryState", + "azure.mgmt.cdn.models.SkuName": "Microsoft.Cdn.SkuName", + "azure.mgmt.cdn.models.ManagedServiceIdentityType": "Azure.ResourceManager.CommonTypes.ManagedServiceIdentityType", + "azure.mgmt.cdn.models.OptimizationType": "Microsoft.Cdn.OptimizationType", + "azure.mgmt.cdn.models.ResourceUsageUnit": "Microsoft.Cdn.ResourceUsageUnit", + "azure.mgmt.cdn.models.CanMigrateDefaultSku": "Microsoft.Cdn.CanMigrateDefaultSku", + "azure.mgmt.cdn.models.EnabledState": "Microsoft.Cdn.EnabledState", + "azure.mgmt.cdn.models.AfdProvisioningState": "Microsoft.Cdn.AfdProvisioningState", + "azure.mgmt.cdn.models.DeploymentStatus": "Microsoft.Cdn.DeploymentStatus", + "azure.mgmt.cdn.models.AutoGeneratedDomainNameLabelScope": "Microsoft.Cdn.AutoGeneratedDomainNameLabelScope", + "azure.mgmt.cdn.models.UsageUnit": "Microsoft.Cdn.UsageUnit", + "azure.mgmt.cdn.models.HealthProbeRequestType": "Microsoft.Cdn.HealthProbeRequestType", + "azure.mgmt.cdn.models.ProbeProtocol": "Microsoft.Cdn.ProbeProtocol", + "azure.mgmt.cdn.models.OriginAuthenticationType": "Microsoft.Cdn.OriginAuthenticationType", + "azure.mgmt.cdn.models.SharedPrivateLinkResourceStatus": "Microsoft.Cdn.SharedPrivateLinkResourceStatus", + "azure.mgmt.cdn.models.AFDEndpointProtocols": "Microsoft.Cdn.AFDEndpointProtocols", + "azure.mgmt.cdn.models.AfdQueryStringCachingBehavior": "Microsoft.Cdn.AfdQueryStringCachingBehavior", + "azure.mgmt.cdn.models.ForwardingProtocol": "Microsoft.Cdn.ForwardingProtocol", + "azure.mgmt.cdn.models.LinkToDefaultDomain": "Microsoft.Cdn.LinkToDefaultDomain", + "azure.mgmt.cdn.models.HttpsRedirect": "Microsoft.Cdn.HttpsRedirect", + "azure.mgmt.cdn.models.MatchVariable": "Microsoft.Cdn.MatchVariable", + "azure.mgmt.cdn.models.DeliveryRuleConditionParametersType": "Microsoft.Cdn.DeliveryRuleConditionParametersType", + "azure.mgmt.cdn.models.CookiesOperator": "Microsoft.Cdn.CookiesOperator", + "azure.mgmt.cdn.models.Transform": "Microsoft.Cdn.Transform", + "azure.mgmt.cdn.models.HostNameOperator": "Microsoft.Cdn.HostNameOperator", + "azure.mgmt.cdn.models.HttpVersionOperator": "Microsoft.Cdn.HttpVersionOperator", + "azure.mgmt.cdn.models.IsDeviceOperator": "Microsoft.Cdn.IsDeviceOperator", + "azure.mgmt.cdn.models.IsDeviceMatchValue": "Microsoft.Cdn.IsDeviceMatchValue", + "azure.mgmt.cdn.models.PostArgsOperator": "Microsoft.Cdn.PostArgsOperator", + "azure.mgmt.cdn.models.QueryStringOperator": "Microsoft.Cdn.QueryStringOperator", + "azure.mgmt.cdn.models.RemoteAddressOperator": "Microsoft.Cdn.RemoteAddressOperator", + "azure.mgmt.cdn.models.RequestBodyOperator": "Microsoft.Cdn.RequestBodyOperator", + "azure.mgmt.cdn.models.RequestHeaderOperator": "Microsoft.Cdn.RequestHeaderOperator", + "azure.mgmt.cdn.models.RequestMethodOperator": "Microsoft.Cdn.RequestMethodOperator", + "azure.mgmt.cdn.models.RequestMethodMatchValue": "Microsoft.Cdn.RequestMethodMatchValue", + "azure.mgmt.cdn.models.RequestSchemeMatchConditionParametersOperator": "Microsoft.Cdn.RequestSchemeMatchConditionParametersOperator", + "azure.mgmt.cdn.models.RequestSchemeMatchValue": "Microsoft.Cdn.RequestSchemeMatchValue", + "azure.mgmt.cdn.models.RequestUriOperator": "Microsoft.Cdn.RequestUriOperator", + "azure.mgmt.cdn.models.ServerPortOperator": "Microsoft.Cdn.ServerPortOperator", + "azure.mgmt.cdn.models.SocketAddrOperator": "Microsoft.Cdn.SocketAddrOperator", + "azure.mgmt.cdn.models.SslProtocolOperator": "Microsoft.Cdn.SslProtocolOperator", + "azure.mgmt.cdn.models.SslProtocol": "Microsoft.Cdn.SslProtocol", + "azure.mgmt.cdn.models.UrlFileExtensionOperator": "Microsoft.Cdn.UrlFileExtensionOperator", + "azure.mgmt.cdn.models.UrlFileNameOperator": "Microsoft.Cdn.UrlFileNameOperator", + "azure.mgmt.cdn.models.UrlPathOperator": "Microsoft.Cdn.UrlPathOperator", + "azure.mgmt.cdn.models.ClientPortOperator": "Microsoft.Cdn.ClientPortOperator", + "azure.mgmt.cdn.models.DeliveryRuleActionName": "Microsoft.Cdn.DeliveryRuleActionName", + "azure.mgmt.cdn.models.DeliveryRuleActionParametersType": "Microsoft.Cdn.DeliveryRuleActionParametersType", + "azure.mgmt.cdn.models.QueryStringBehavior": "Microsoft.Cdn.QueryStringBehavior", + "azure.mgmt.cdn.models.HeaderAction": "Microsoft.Cdn.HeaderAction", + "azure.mgmt.cdn.models.RuleQueryStringCachingBehavior": "Microsoft.Cdn.RuleQueryStringCachingBehavior", + "azure.mgmt.cdn.models.RuleIsCompressionEnabled": "Microsoft.Cdn.RuleIsCompressionEnabled", + "azure.mgmt.cdn.models.RuleCacheBehavior": "Microsoft.Cdn.RuleCacheBehavior", + "azure.mgmt.cdn.models.RedirectType": "Microsoft.Cdn.RedirectType", + "azure.mgmt.cdn.models.DestinationProtocol": "Microsoft.Cdn.DestinationProtocol", + "azure.mgmt.cdn.models.Algorithm": "Microsoft.Cdn.Algorithm", + "azure.mgmt.cdn.models.ParamIndicator": "Microsoft.Cdn.ParamIndicator", + "azure.mgmt.cdn.models.CacheBehavior": "Microsoft.Cdn.CacheBehavior", + "azure.mgmt.cdn.models.CacheType": "Microsoft.Cdn.CacheType", + "azure.mgmt.cdn.models.MatchProcessingBehavior": "Microsoft.Cdn.MatchProcessingBehavior", + "azure.mgmt.cdn.models.SecurityPolicyType": "Microsoft.Cdn.SecurityPolicyType", + "azure.mgmt.cdn.models.SecretType": "Microsoft.Cdn.SecretType", + "azure.mgmt.cdn.models.QueryStringCachingBehavior": "Microsoft.Cdn.QueryStringCachingBehavior", + "azure.mgmt.cdn.models.GeoFilterActions": "Microsoft.Cdn.GeoFilterActions", + "azure.mgmt.cdn.models.KeyVaultSigningKeyParametersType": "Microsoft.Cdn.KeyVaultSigningKeyParametersType", + "azure.mgmt.cdn.models.PrivateEndpointStatus": "Microsoft.Cdn.PrivateEndpointStatus", + "azure.mgmt.cdn.models.ResponseBasedDetectedErrorTypes": "Microsoft.Cdn.ResponseBasedDetectedErrorTypes", + "azure.mgmt.cdn.models.EndpointResourceState": "Microsoft.Cdn.EndpointResourceState", + "azure.mgmt.cdn.models.EndpointProvisioningState": "Microsoft.Cdn.EndpointProvisioningState", + "azure.mgmt.cdn.models.OriginResourceState": "Microsoft.Cdn.OriginResourceState", + "azure.mgmt.cdn.models.OriginProvisioningState": "Microsoft.Cdn.OriginProvisioningState", + "azure.mgmt.cdn.models.OriginGroupResourceState": "Microsoft.Cdn.OriginGroupResourceState", + "azure.mgmt.cdn.models.OriginGroupProvisioningState": "Microsoft.Cdn.OriginGroupProvisioningState", + "azure.mgmt.cdn.models.CustomDomainResourceState": "Microsoft.Cdn.CustomDomainResourceState", + "azure.mgmt.cdn.models.CustomHttpsProvisioningState": "Microsoft.Cdn.CustomHttpsProvisioningState", + "azure.mgmt.cdn.models.CustomHttpsProvisioningSubstate": "Microsoft.Cdn.CustomHttpsProvisioningSubstate", + "azure.mgmt.cdn.models.CertificateSource": "Microsoft.Cdn.CertificateSource", + "azure.mgmt.cdn.models.ProtocolType": "Microsoft.Cdn.ProtocolType", + "azure.mgmt.cdn.models.MinimumTlsVersion": "Microsoft.Cdn.MinimumTlsVersion", + "azure.mgmt.cdn.models.CertificateSourceParametersType": "Microsoft.Cdn.CertificateSourceParametersType", + "azure.mgmt.cdn.models.CertificateType": "Microsoft.Cdn.CertificateType", + "azure.mgmt.cdn.models.UpdateRule": "Microsoft.Cdn.UpdateRule", + "azure.mgmt.cdn.models.DeleteRule": "Microsoft.Cdn.DeleteRule", + "azure.mgmt.cdn.models.AfdCertificateType": "Microsoft.Cdn.AfdCertificateType", + "azure.mgmt.cdn.models.AfdCipherSuiteSetType": "Microsoft.Cdn.AfdCipherSuiteSetType", + "azure.mgmt.cdn.models.AfdMinimumTlsVersion": "Microsoft.Cdn.AfdMinimumTlsVersion", + "azure.mgmt.cdn.models.AfdCustomizedCipherSuiteForTls12": "Microsoft.Cdn.AfdCustomizedCipherSuiteForTls12", + "azure.mgmt.cdn.models.AfdCustomizedCipherSuiteForTls13": "Microsoft.Cdn.AfdCustomizedCipherSuiteForTls13", + "azure.mgmt.cdn.models.DomainValidationState": "Microsoft.Cdn.DomainValidationState", + "azure.mgmt.cdn.models.ResourceType": "Microsoft.Cdn.ResourceType", + "azure.mgmt.cdn.models.Status": "Microsoft.Cdn.Status", + "azure.mgmt.cdn.models.MetricsGranularity": "Microsoft.Cdn.MetricsGranularity", + "azure.mgmt.cdn.models.MetricsSeriesUnit": "Microsoft.Cdn.MetricsSeriesUnit", + "azure.mgmt.cdn.models.LogMetric": "Microsoft.Cdn.LogMetric", + "azure.mgmt.cdn.models.LogMetricsGranularity": "Microsoft.Cdn.LogMetricsGranularity", + "azure.mgmt.cdn.models.LogMetricsGroupBy": "Microsoft.Cdn.LogMetricsGroupBy", + "azure.mgmt.cdn.models.LogRanking": "Microsoft.Cdn.LogRanking", + "azure.mgmt.cdn.models.LogRankingMetric": "Microsoft.Cdn.LogRankingMetric", + "azure.mgmt.cdn.models.WafMetricsGranularity": "Microsoft.Cdn.WafMetricsGranularity", + "azure.mgmt.cdn.models.WafMetricsSeriesUnit": "Microsoft.Cdn.WafMetricsSeriesUnit", + "azure.mgmt.cdn.models.WafMetric": "Microsoft.Cdn.WafMetric", + "azure.mgmt.cdn.models.WafGranularity": "Microsoft.Cdn.WafGranularity", + "azure.mgmt.cdn.models.WafAction": "Microsoft.Cdn.WafAction", + "azure.mgmt.cdn.models.WafRankingGroupBy": "Microsoft.Cdn.WafRankingGroupBy", + "azure.mgmt.cdn.models.WafRuleType": "Microsoft.Cdn.WafRuleType", + "azure.mgmt.cdn.models.WafRankingType": "Microsoft.Cdn.WafRankingType", + "azure.mgmt.cdn.models.PolicyEnabledState": "Microsoft.Cdn.PolicyEnabledState", + "azure.mgmt.cdn.models.PolicyMode": "Microsoft.Cdn.PolicyMode", + "azure.mgmt.cdn.models.PolicySettingsDefaultCustomBlockResponseStatusCode": "Microsoft.Cdn.PolicySettingsDefaultCustomBlockResponseStatusCode", + "azure.mgmt.cdn.models.CustomRuleEnabledState": "Microsoft.Cdn.CustomRuleEnabledState", + "azure.mgmt.cdn.models.WafMatchVariable": "Microsoft.Cdn.WafMatchVariable", + "azure.mgmt.cdn.models.Operator": "Microsoft.Cdn.Operator", + "azure.mgmt.cdn.models.TransformType": "Microsoft.Cdn.TransformType", + "azure.mgmt.cdn.models.ActionType": "Microsoft.Cdn.ActionType", + "azure.mgmt.cdn.models.ManagedRuleEnabledState": "Microsoft.Cdn.ManagedRuleEnabledState", + "azure.mgmt.cdn.models.ProvisioningState": "Microsoft.Cdn.ProvisioningState", + "azure.mgmt.cdn.models.PolicyResourceState": "Microsoft.Cdn.PolicyResourceState", + "azure.mgmt.cdn.operations.Operations.list": "Azure.ResourceManager.Legacy.Operations.list", + "azure.mgmt.cdn.aio.operations.Operations.list": "Azure.ResourceManager.Legacy.Operations.list", + "azure.mgmt.cdn.operations.ProfilesOperations.get": "Microsoft.Cdn.Profiles.get", + "azure.mgmt.cdn.aio.operations.ProfilesOperations.get": "Microsoft.Cdn.Profiles.get", + "azure.mgmt.cdn.operations.ProfilesOperations.begin_create": "Microsoft.Cdn.Profiles.create", + "azure.mgmt.cdn.aio.operations.ProfilesOperations.begin_create": "Microsoft.Cdn.Profiles.create", + "azure.mgmt.cdn.operations.ProfilesOperations.begin_update": "Microsoft.Cdn.Profiles.update", + "azure.mgmt.cdn.aio.operations.ProfilesOperations.begin_update": "Microsoft.Cdn.Profiles.update", + "azure.mgmt.cdn.operations.ProfilesOperations.begin_delete": "Microsoft.Cdn.Profiles.delete", + "azure.mgmt.cdn.aio.operations.ProfilesOperations.begin_delete": "Microsoft.Cdn.Profiles.delete", + "azure.mgmt.cdn.operations.ProfilesOperations.list_by_resource_group": "Microsoft.Cdn.Profiles.listByResourceGroup", + "azure.mgmt.cdn.aio.operations.ProfilesOperations.list_by_resource_group": "Microsoft.Cdn.Profiles.listByResourceGroup", + "azure.mgmt.cdn.operations.ProfilesOperations.list": "Microsoft.Cdn.Profiles.list", + "azure.mgmt.cdn.aio.operations.ProfilesOperations.list": "Microsoft.Cdn.Profiles.list", + "azure.mgmt.cdn.operations.ProfilesOperations.begin_migration_commit": "Microsoft.Cdn.Profiles.migrationCommit", + "azure.mgmt.cdn.aio.operations.ProfilesOperations.begin_migration_commit": "Microsoft.Cdn.Profiles.migrationCommit", + "azure.mgmt.cdn.operations.ProfilesOperations.generate_sso_uri": "Microsoft.Cdn.Profiles.generateSsoUri", + "azure.mgmt.cdn.aio.operations.ProfilesOperations.generate_sso_uri": "Microsoft.Cdn.Profiles.generateSsoUri", + "azure.mgmt.cdn.operations.ProfilesOperations.list_supported_optimization_types": "Microsoft.Cdn.Profiles.listSupportedOptimizationTypes", + "azure.mgmt.cdn.aio.operations.ProfilesOperations.list_supported_optimization_types": "Microsoft.Cdn.Profiles.listSupportedOptimizationTypes", + "azure.mgmt.cdn.operations.ProfilesOperations.list_resource_usage": "Microsoft.Cdn.Profiles.profilesListResourceUsage", + "azure.mgmt.cdn.aio.operations.ProfilesOperations.list_resource_usage": "Microsoft.Cdn.Profiles.profilesListResourceUsage", + "azure.mgmt.cdn.operations.ProfilesOperations.begin_cdn_can_migrate_to_afd": "Microsoft.Cdn.Profiles.cdnCanMigrateToAfd", + "azure.mgmt.cdn.aio.operations.ProfilesOperations.begin_cdn_can_migrate_to_afd": "Microsoft.Cdn.Profiles.cdnCanMigrateToAfd", + "azure.mgmt.cdn.operations.ProfilesOperations.begin_cdn_migrate_to_afd": "Microsoft.Cdn.Profiles.cdnMigrateToAfd", + "azure.mgmt.cdn.aio.operations.ProfilesOperations.begin_cdn_migrate_to_afd": "Microsoft.Cdn.Profiles.cdnMigrateToAfd", + "azure.mgmt.cdn.operations.ProfilesOperations.begin_migration_abort": "Microsoft.Cdn.Profiles.migrationAbort", + "azure.mgmt.cdn.aio.operations.ProfilesOperations.begin_migration_abort": "Microsoft.Cdn.Profiles.migrationAbort", + "azure.mgmt.cdn.operations.ProfilesOperations.begin_can_migrate": "Microsoft.Cdn.ProfilesOperationGroup.canMigrate", + "azure.mgmt.cdn.aio.operations.ProfilesOperations.begin_can_migrate": "Microsoft.Cdn.ProfilesOperationGroup.canMigrate", + "azure.mgmt.cdn.operations.ProfilesOperations.begin_migrate": "Microsoft.Cdn.ProfilesOperationGroup.migrate", + "azure.mgmt.cdn.aio.operations.ProfilesOperations.begin_migrate": "Microsoft.Cdn.ProfilesOperationGroup.migrate", + "azure.mgmt.cdn.operations.AFDEndpointsOperations.get": "Microsoft.Cdn.AFDEndpoints.get", + "azure.mgmt.cdn.aio.operations.AFDEndpointsOperations.get": "Microsoft.Cdn.AFDEndpoints.get", + "azure.mgmt.cdn.operations.AFDEndpointsOperations.begin_create": "Microsoft.Cdn.AFDEndpoints.create", + "azure.mgmt.cdn.aio.operations.AFDEndpointsOperations.begin_create": "Microsoft.Cdn.AFDEndpoints.create", + "azure.mgmt.cdn.operations.AFDEndpointsOperations.begin_update": "Microsoft.Cdn.AFDEndpoints.update", + "azure.mgmt.cdn.aio.operations.AFDEndpointsOperations.begin_update": "Microsoft.Cdn.AFDEndpoints.update", + "azure.mgmt.cdn.operations.AFDEndpointsOperations.begin_delete": "Microsoft.Cdn.AFDEndpoints.delete", + "azure.mgmt.cdn.aio.operations.AFDEndpointsOperations.begin_delete": "Microsoft.Cdn.AFDEndpoints.delete", + "azure.mgmt.cdn.operations.AFDEndpointsOperations.list_by_profile": "Microsoft.Cdn.AFDEndpoints.listByProfile", + "azure.mgmt.cdn.aio.operations.AFDEndpointsOperations.list_by_profile": "Microsoft.Cdn.AFDEndpoints.listByProfile", + "azure.mgmt.cdn.operations.AFDEndpointsOperations.begin_purge_content": "Microsoft.Cdn.AFDEndpoints.purgeContent", + "azure.mgmt.cdn.aio.operations.AFDEndpointsOperations.begin_purge_content": "Microsoft.Cdn.AFDEndpoints.purgeContent", + "azure.mgmt.cdn.operations.AFDEndpointsOperations.list_resource_usage": "Microsoft.Cdn.AFDEndpoints.listResourceUsage", + "azure.mgmt.cdn.aio.operations.AFDEndpointsOperations.list_resource_usage": "Microsoft.Cdn.AFDEndpoints.listResourceUsage", + "azure.mgmt.cdn.operations.AFDEndpointsOperations.validate_custom_domain": "Microsoft.Cdn.AFDEndpoints.validateCustomDomain", + "azure.mgmt.cdn.aio.operations.AFDEndpointsOperations.validate_custom_domain": "Microsoft.Cdn.AFDEndpoints.validateCustomDomain", + "azure.mgmt.cdn.operations.AFDOriginGroupsOperations.get": "Microsoft.Cdn.AFDOriginGroups.get", + "azure.mgmt.cdn.aio.operations.AFDOriginGroupsOperations.get": "Microsoft.Cdn.AFDOriginGroups.get", + "azure.mgmt.cdn.operations.AFDOriginGroupsOperations.begin_create": "Microsoft.Cdn.AFDOriginGroups.create", + "azure.mgmt.cdn.aio.operations.AFDOriginGroupsOperations.begin_create": "Microsoft.Cdn.AFDOriginGroups.create", + "azure.mgmt.cdn.operations.AFDOriginGroupsOperations.begin_update": "Microsoft.Cdn.AFDOriginGroups.update", + "azure.mgmt.cdn.aio.operations.AFDOriginGroupsOperations.begin_update": "Microsoft.Cdn.AFDOriginGroups.update", + "azure.mgmt.cdn.operations.AFDOriginGroupsOperations.begin_delete": "Microsoft.Cdn.AFDOriginGroups.delete", + "azure.mgmt.cdn.aio.operations.AFDOriginGroupsOperations.begin_delete": "Microsoft.Cdn.AFDOriginGroups.delete", + "azure.mgmt.cdn.operations.AFDOriginGroupsOperations.list_by_profile": "Microsoft.Cdn.AFDOriginGroups.listByProfile", + "azure.mgmt.cdn.aio.operations.AFDOriginGroupsOperations.list_by_profile": "Microsoft.Cdn.AFDOriginGroups.listByProfile", + "azure.mgmt.cdn.operations.AFDOriginGroupsOperations.list_resource_usage": "Microsoft.Cdn.AFDOriginGroups.listResourceUsage", + "azure.mgmt.cdn.aio.operations.AFDOriginGroupsOperations.list_resource_usage": "Microsoft.Cdn.AFDOriginGroups.listResourceUsage", + "azure.mgmt.cdn.operations.AFDOriginsOperations.get": "Microsoft.Cdn.AFDOrigins.get", + "azure.mgmt.cdn.aio.operations.AFDOriginsOperations.get": "Microsoft.Cdn.AFDOrigins.get", + "azure.mgmt.cdn.operations.AFDOriginsOperations.begin_create": "Microsoft.Cdn.AFDOrigins.create", + "azure.mgmt.cdn.aio.operations.AFDOriginsOperations.begin_create": "Microsoft.Cdn.AFDOrigins.create", + "azure.mgmt.cdn.operations.AFDOriginsOperations.begin_update": "Microsoft.Cdn.AFDOrigins.update", + "azure.mgmt.cdn.aio.operations.AFDOriginsOperations.begin_update": "Microsoft.Cdn.AFDOrigins.update", + "azure.mgmt.cdn.operations.AFDOriginsOperations.begin_delete": "Microsoft.Cdn.AFDOrigins.delete", + "azure.mgmt.cdn.aio.operations.AFDOriginsOperations.begin_delete": "Microsoft.Cdn.AFDOrigins.delete", + "azure.mgmt.cdn.operations.AFDOriginsOperations.list_by_origin_group": "Microsoft.Cdn.AFDOrigins.listByOriginGroup", + "azure.mgmt.cdn.aio.operations.AFDOriginsOperations.list_by_origin_group": "Microsoft.Cdn.AFDOrigins.listByOriginGroup", + "azure.mgmt.cdn.operations.RoutesOperations.get": "Microsoft.Cdn.Routes.get", + "azure.mgmt.cdn.aio.operations.RoutesOperations.get": "Microsoft.Cdn.Routes.get", + "azure.mgmt.cdn.operations.RoutesOperations.begin_create": "Microsoft.Cdn.Routes.create", + "azure.mgmt.cdn.aio.operations.RoutesOperations.begin_create": "Microsoft.Cdn.Routes.create", + "azure.mgmt.cdn.operations.RoutesOperations.begin_update": "Microsoft.Cdn.Routes.update", + "azure.mgmt.cdn.aio.operations.RoutesOperations.begin_update": "Microsoft.Cdn.Routes.update", + "azure.mgmt.cdn.operations.RoutesOperations.begin_delete": "Microsoft.Cdn.Routes.delete", + "azure.mgmt.cdn.aio.operations.RoutesOperations.begin_delete": "Microsoft.Cdn.Routes.delete", + "azure.mgmt.cdn.operations.RoutesOperations.list_by_endpoint": "Microsoft.Cdn.Routes.listByEndpoint", + "azure.mgmt.cdn.aio.operations.RoutesOperations.list_by_endpoint": "Microsoft.Cdn.Routes.listByEndpoint", + "azure.mgmt.cdn.operations.RuleSetsOperations.get": "Microsoft.Cdn.RuleSets.get", + "azure.mgmt.cdn.aio.operations.RuleSetsOperations.get": "Microsoft.Cdn.RuleSets.get", + "azure.mgmt.cdn.operations.RuleSetsOperations.begin_create": "Microsoft.Cdn.RuleSets.create", + "azure.mgmt.cdn.aio.operations.RuleSetsOperations.begin_create": "Microsoft.Cdn.RuleSets.create", + "azure.mgmt.cdn.operations.RuleSetsOperations.begin_delete": "Microsoft.Cdn.RuleSets.delete", + "azure.mgmt.cdn.aio.operations.RuleSetsOperations.begin_delete": "Microsoft.Cdn.RuleSets.delete", + "azure.mgmt.cdn.operations.RuleSetsOperations.list_by_profile": "Microsoft.Cdn.RuleSets.listByProfile", + "azure.mgmt.cdn.aio.operations.RuleSetsOperations.list_by_profile": "Microsoft.Cdn.RuleSets.listByProfile", + "azure.mgmt.cdn.operations.RuleSetsOperations.list_resource_usage": "Microsoft.Cdn.RuleSets.listResourceUsage", + "azure.mgmt.cdn.aio.operations.RuleSetsOperations.list_resource_usage": "Microsoft.Cdn.RuleSets.listResourceUsage", + "azure.mgmt.cdn.operations.RulesOperations.get": "Microsoft.Cdn.Rules.get", + "azure.mgmt.cdn.aio.operations.RulesOperations.get": "Microsoft.Cdn.Rules.get", + "azure.mgmt.cdn.operations.RulesOperations.begin_create": "Microsoft.Cdn.Rules.create", + "azure.mgmt.cdn.aio.operations.RulesOperations.begin_create": "Microsoft.Cdn.Rules.create", + "azure.mgmt.cdn.operations.RulesOperations.begin_update": "Microsoft.Cdn.Rules.update", + "azure.mgmt.cdn.aio.operations.RulesOperations.begin_update": "Microsoft.Cdn.Rules.update", + "azure.mgmt.cdn.operations.RulesOperations.begin_delete": "Microsoft.Cdn.Rules.delete", + "azure.mgmt.cdn.aio.operations.RulesOperations.begin_delete": "Microsoft.Cdn.Rules.delete", + "azure.mgmt.cdn.operations.RulesOperations.list_by_rule_set": "Microsoft.Cdn.Rules.listByRuleSet", + "azure.mgmt.cdn.aio.operations.RulesOperations.list_by_rule_set": "Microsoft.Cdn.Rules.listByRuleSet", + "azure.mgmt.cdn.operations.SecurityPoliciesOperations.get": "Microsoft.Cdn.SecurityPolicies.get", + "azure.mgmt.cdn.aio.operations.SecurityPoliciesOperations.get": "Microsoft.Cdn.SecurityPolicies.get", + "azure.mgmt.cdn.operations.SecurityPoliciesOperations.begin_create": "Microsoft.Cdn.SecurityPolicies.create", + "azure.mgmt.cdn.aio.operations.SecurityPoliciesOperations.begin_create": "Microsoft.Cdn.SecurityPolicies.create", + "azure.mgmt.cdn.operations.SecurityPoliciesOperations.begin_patch": "Microsoft.Cdn.SecurityPolicies.patch", + "azure.mgmt.cdn.aio.operations.SecurityPoliciesOperations.begin_patch": "Microsoft.Cdn.SecurityPolicies.patch", + "azure.mgmt.cdn.operations.SecurityPoliciesOperations.begin_delete": "Microsoft.Cdn.SecurityPolicies.delete", + "azure.mgmt.cdn.aio.operations.SecurityPoliciesOperations.begin_delete": "Microsoft.Cdn.SecurityPolicies.delete", + "azure.mgmt.cdn.operations.SecurityPoliciesOperations.list_by_profile": "Microsoft.Cdn.SecurityPolicies.listByProfile", + "azure.mgmt.cdn.aio.operations.SecurityPoliciesOperations.list_by_profile": "Microsoft.Cdn.SecurityPolicies.listByProfile", + "azure.mgmt.cdn.operations.SecretsOperations.get": "Microsoft.Cdn.Secrets.get", + "azure.mgmt.cdn.aio.operations.SecretsOperations.get": "Microsoft.Cdn.Secrets.get", + "azure.mgmt.cdn.operations.SecretsOperations.begin_create": "Microsoft.Cdn.Secrets.create", + "azure.mgmt.cdn.aio.operations.SecretsOperations.begin_create": "Microsoft.Cdn.Secrets.create", + "azure.mgmt.cdn.operations.SecretsOperations.begin_delete": "Microsoft.Cdn.Secrets.delete", + "azure.mgmt.cdn.aio.operations.SecretsOperations.begin_delete": "Microsoft.Cdn.Secrets.delete", + "azure.mgmt.cdn.operations.SecretsOperations.list_by_profile": "Microsoft.Cdn.Secrets.listByProfile", + "azure.mgmt.cdn.aio.operations.SecretsOperations.list_by_profile": "Microsoft.Cdn.Secrets.listByProfile", + "azure.mgmt.cdn.operations.EndpointsOperations.get": "Microsoft.Cdn.Endpoints.get", + "azure.mgmt.cdn.aio.operations.EndpointsOperations.get": "Microsoft.Cdn.Endpoints.get", + "azure.mgmt.cdn.operations.EndpointsOperations.begin_create": "Microsoft.Cdn.Endpoints.create", + "azure.mgmt.cdn.aio.operations.EndpointsOperations.begin_create": "Microsoft.Cdn.Endpoints.create", + "azure.mgmt.cdn.operations.EndpointsOperations.begin_update": "Microsoft.Cdn.Endpoints.update", + "azure.mgmt.cdn.aio.operations.EndpointsOperations.begin_update": "Microsoft.Cdn.Endpoints.update", + "azure.mgmt.cdn.operations.EndpointsOperations.begin_delete": "Microsoft.Cdn.Endpoints.delete", + "azure.mgmt.cdn.aio.operations.EndpointsOperations.begin_delete": "Microsoft.Cdn.Endpoints.delete", + "azure.mgmt.cdn.operations.EndpointsOperations.list_by_profile": "Microsoft.Cdn.Endpoints.listByProfile", + "azure.mgmt.cdn.aio.operations.EndpointsOperations.list_by_profile": "Microsoft.Cdn.Endpoints.listByProfile", + "azure.mgmt.cdn.operations.EndpointsOperations.begin_start": "Microsoft.Cdn.Endpoints.start", + "azure.mgmt.cdn.aio.operations.EndpointsOperations.begin_start": "Microsoft.Cdn.Endpoints.start", + "azure.mgmt.cdn.operations.EndpointsOperations.begin_stop": "Microsoft.Cdn.Endpoints.stop", + "azure.mgmt.cdn.aio.operations.EndpointsOperations.begin_stop": "Microsoft.Cdn.Endpoints.stop", + "azure.mgmt.cdn.operations.EndpointsOperations.begin_purge_content": "Microsoft.Cdn.Endpoints.purgeContent", + "azure.mgmt.cdn.aio.operations.EndpointsOperations.begin_purge_content": "Microsoft.Cdn.Endpoints.purgeContent", + "azure.mgmt.cdn.operations.EndpointsOperations.begin_load_content": "Microsoft.Cdn.Endpoints.loadContent", + "azure.mgmt.cdn.aio.operations.EndpointsOperations.begin_load_content": "Microsoft.Cdn.Endpoints.loadContent", + "azure.mgmt.cdn.operations.EndpointsOperations.validate_custom_domain": "Microsoft.Cdn.Endpoints.validateCustomDomain", + "azure.mgmt.cdn.aio.operations.EndpointsOperations.validate_custom_domain": "Microsoft.Cdn.Endpoints.validateCustomDomain", + "azure.mgmt.cdn.operations.EndpointsOperations.list_resource_usage": "Microsoft.Cdn.Endpoints.listResourceUsage", + "azure.mgmt.cdn.aio.operations.EndpointsOperations.list_resource_usage": "Microsoft.Cdn.Endpoints.listResourceUsage", + "azure.mgmt.cdn.operations.OriginsOperations.get": "Microsoft.Cdn.Origins.get", + "azure.mgmt.cdn.aio.operations.OriginsOperations.get": "Microsoft.Cdn.Origins.get", + "azure.mgmt.cdn.operations.OriginsOperations.begin_create": "Microsoft.Cdn.Origins.create", + "azure.mgmt.cdn.aio.operations.OriginsOperations.begin_create": "Microsoft.Cdn.Origins.create", + "azure.mgmt.cdn.operations.OriginsOperations.begin_update": "Microsoft.Cdn.Origins.update", + "azure.mgmt.cdn.aio.operations.OriginsOperations.begin_update": "Microsoft.Cdn.Origins.update", + "azure.mgmt.cdn.operations.OriginsOperations.begin_delete": "Microsoft.Cdn.Origins.delete", + "azure.mgmt.cdn.aio.operations.OriginsOperations.begin_delete": "Microsoft.Cdn.Origins.delete", + "azure.mgmt.cdn.operations.OriginsOperations.list_by_endpoint": "Microsoft.Cdn.Origins.listByEndpoint", + "azure.mgmt.cdn.aio.operations.OriginsOperations.list_by_endpoint": "Microsoft.Cdn.Origins.listByEndpoint", + "azure.mgmt.cdn.operations.OriginGroupsOperations.get": "Microsoft.Cdn.OriginGroups.get", + "azure.mgmt.cdn.aio.operations.OriginGroupsOperations.get": "Microsoft.Cdn.OriginGroups.get", + "azure.mgmt.cdn.operations.OriginGroupsOperations.begin_create": "Microsoft.Cdn.OriginGroups.create", + "azure.mgmt.cdn.aio.operations.OriginGroupsOperations.begin_create": "Microsoft.Cdn.OriginGroups.create", + "azure.mgmt.cdn.operations.OriginGroupsOperations.begin_update": "Microsoft.Cdn.OriginGroups.update", + "azure.mgmt.cdn.aio.operations.OriginGroupsOperations.begin_update": "Microsoft.Cdn.OriginGroups.update", + "azure.mgmt.cdn.operations.OriginGroupsOperations.begin_delete": "Microsoft.Cdn.OriginGroups.delete", + "azure.mgmt.cdn.aio.operations.OriginGroupsOperations.begin_delete": "Microsoft.Cdn.OriginGroups.delete", + "azure.mgmt.cdn.operations.OriginGroupsOperations.list_by_endpoint": "Microsoft.Cdn.OriginGroups.listByEndpoint", + "azure.mgmt.cdn.aio.operations.OriginGroupsOperations.list_by_endpoint": "Microsoft.Cdn.OriginGroups.listByEndpoint", + "azure.mgmt.cdn.operations.CustomDomainsOperations.get": "Microsoft.Cdn.CustomDomains.get", + "azure.mgmt.cdn.aio.operations.CustomDomainsOperations.get": "Microsoft.Cdn.CustomDomains.get", + "azure.mgmt.cdn.operations.CustomDomainsOperations.begin_create": "Microsoft.Cdn.CustomDomains.create", + "azure.mgmt.cdn.aio.operations.CustomDomainsOperations.begin_create": "Microsoft.Cdn.CustomDomains.create", + "azure.mgmt.cdn.operations.CustomDomainsOperations.begin_delete": "Microsoft.Cdn.CustomDomains.delete", + "azure.mgmt.cdn.aio.operations.CustomDomainsOperations.begin_delete": "Microsoft.Cdn.CustomDomains.delete", + "azure.mgmt.cdn.operations.CustomDomainsOperations.list_by_endpoint": "Microsoft.Cdn.CustomDomains.listByEndpoint", + "azure.mgmt.cdn.aio.operations.CustomDomainsOperations.list_by_endpoint": "Microsoft.Cdn.CustomDomains.listByEndpoint", + "azure.mgmt.cdn.operations.CustomDomainsOperations.begin_disable_custom_https": "Microsoft.Cdn.CustomDomains.disableCustomHttps", + "azure.mgmt.cdn.aio.operations.CustomDomainsOperations.begin_disable_custom_https": "Microsoft.Cdn.CustomDomains.disableCustomHttps", + "azure.mgmt.cdn.operations.CustomDomainsOperations.begin_enable_custom_https": "Microsoft.Cdn.CustomDomains.enableCustomHttps", + "azure.mgmt.cdn.aio.operations.CustomDomainsOperations.begin_enable_custom_https": "Microsoft.Cdn.CustomDomains.enableCustomHttps", + "azure.mgmt.cdn.operations.AFDCustomDomainsOperations.get": "Microsoft.Cdn.AFDDomains.get", + "azure.mgmt.cdn.aio.operations.AFDCustomDomainsOperations.get": "Microsoft.Cdn.AFDDomains.get", + "azure.mgmt.cdn.operations.AFDCustomDomainsOperations.begin_create": "Microsoft.Cdn.AFDDomains.create", + "azure.mgmt.cdn.aio.operations.AFDCustomDomainsOperations.begin_create": "Microsoft.Cdn.AFDDomains.create", + "azure.mgmt.cdn.operations.AFDCustomDomainsOperations.begin_update": "Microsoft.Cdn.AFDDomains.update", + "azure.mgmt.cdn.aio.operations.AFDCustomDomainsOperations.begin_update": "Microsoft.Cdn.AFDDomains.update", + "azure.mgmt.cdn.operations.AFDCustomDomainsOperations.begin_delete": "Microsoft.Cdn.AFDDomains.delete", + "azure.mgmt.cdn.aio.operations.AFDCustomDomainsOperations.begin_delete": "Microsoft.Cdn.AFDDomains.delete", + "azure.mgmt.cdn.operations.AFDCustomDomainsOperations.list_by_profile": "Microsoft.Cdn.AFDDomains.listByProfile", + "azure.mgmt.cdn.aio.operations.AFDCustomDomainsOperations.list_by_profile": "Microsoft.Cdn.AFDDomains.listByProfile", + "azure.mgmt.cdn.operations.AFDCustomDomainsOperations.begin_refresh_validation_token": "Microsoft.Cdn.AFDDomains.refreshValidationToken", + "azure.mgmt.cdn.aio.operations.AFDCustomDomainsOperations.begin_refresh_validation_token": "Microsoft.Cdn.AFDDomains.refreshValidationToken", + "azure.mgmt.cdn.operations.AFDProfilesOperations.check_endpoint_name_availability": "Microsoft.Cdn.Profiles.checkEndpointNameAvailability", + "azure.mgmt.cdn.aio.operations.AFDProfilesOperations.check_endpoint_name_availability": "Microsoft.Cdn.Profiles.checkEndpointNameAvailability", + "azure.mgmt.cdn.operations.AFDProfilesOperations.list_resource_usage": "Microsoft.Cdn.Profiles.listResourceUsage", + "azure.mgmt.cdn.aio.operations.AFDProfilesOperations.list_resource_usage": "Microsoft.Cdn.Profiles.listResourceUsage", + "azure.mgmt.cdn.operations.AFDProfilesOperations.check_host_name_availability": "Microsoft.Cdn.Profiles.checkHostNameAvailability", + "azure.mgmt.cdn.aio.operations.AFDProfilesOperations.check_host_name_availability": "Microsoft.Cdn.Profiles.checkHostNameAvailability", + "azure.mgmt.cdn.operations.AFDProfilesOperations.validate_secret": "Microsoft.Cdn.Profiles.validateSecret", + "azure.mgmt.cdn.aio.operations.AFDProfilesOperations.validate_secret": "Microsoft.Cdn.Profiles.validateSecret", + "azure.mgmt.cdn.operations.AFDProfilesOperations.begin_upgrade": "Microsoft.Cdn.Profiles.upgrade", + "azure.mgmt.cdn.aio.operations.AFDProfilesOperations.begin_upgrade": "Microsoft.Cdn.Profiles.upgrade", + "azure.mgmt.cdn.operations.LogAnalyticsOperations.get_log_analytics_metrics": "Microsoft.Cdn.Profiles.getLogAnalyticsMetrics", + "azure.mgmt.cdn.aio.operations.LogAnalyticsOperations.get_log_analytics_metrics": "Microsoft.Cdn.Profiles.getLogAnalyticsMetrics", + "azure.mgmt.cdn.operations.LogAnalyticsOperations.get_log_analytics_rankings": "Microsoft.Cdn.Profiles.getLogAnalyticsRankings", + "azure.mgmt.cdn.aio.operations.LogAnalyticsOperations.get_log_analytics_rankings": "Microsoft.Cdn.Profiles.getLogAnalyticsRankings", + "azure.mgmt.cdn.operations.LogAnalyticsOperations.get_log_analytics_locations": "Microsoft.Cdn.Profiles.getLogAnalyticsLocations", + "azure.mgmt.cdn.aio.operations.LogAnalyticsOperations.get_log_analytics_locations": "Microsoft.Cdn.Profiles.getLogAnalyticsLocations", + "azure.mgmt.cdn.operations.LogAnalyticsOperations.get_log_analytics_resources": "Microsoft.Cdn.Profiles.getLogAnalyticsResources", + "azure.mgmt.cdn.aio.operations.LogAnalyticsOperations.get_log_analytics_resources": "Microsoft.Cdn.Profiles.getLogAnalyticsResources", + "azure.mgmt.cdn.operations.LogAnalyticsOperations.get_waf_log_analytics_metrics": "Microsoft.Cdn.Profiles.getWafLogAnalyticsMetrics", + "azure.mgmt.cdn.aio.operations.LogAnalyticsOperations.get_waf_log_analytics_metrics": "Microsoft.Cdn.Profiles.getWafLogAnalyticsMetrics", + "azure.mgmt.cdn.operations.LogAnalyticsOperations.get_waf_log_analytics_rankings": "Microsoft.Cdn.Profiles.getWafLogAnalyticsRankings", + "azure.mgmt.cdn.aio.operations.LogAnalyticsOperations.get_waf_log_analytics_rankings": "Microsoft.Cdn.Profiles.getWafLogAnalyticsRankings", + "azure.mgmt.cdn.operations.PoliciesOperations.get": "Microsoft.Cdn.CdnWebApplicationFirewallPolicies.get", + "azure.mgmt.cdn.aio.operations.PoliciesOperations.get": "Microsoft.Cdn.CdnWebApplicationFirewallPolicies.get", + "azure.mgmt.cdn.operations.PoliciesOperations.begin_create_or_update": "Microsoft.Cdn.CdnWebApplicationFirewallPolicies.createOrUpdate", + "azure.mgmt.cdn.aio.operations.PoliciesOperations.begin_create_or_update": "Microsoft.Cdn.CdnWebApplicationFirewallPolicies.createOrUpdate", + "azure.mgmt.cdn.operations.PoliciesOperations.begin_update": "Microsoft.Cdn.CdnWebApplicationFirewallPolicies.update", + "azure.mgmt.cdn.aio.operations.PoliciesOperations.begin_update": "Microsoft.Cdn.CdnWebApplicationFirewallPolicies.update", + "azure.mgmt.cdn.operations.PoliciesOperations.delete": "Microsoft.Cdn.CdnWebApplicationFirewallPolicies.delete", + "azure.mgmt.cdn.aio.operations.PoliciesOperations.delete": "Microsoft.Cdn.CdnWebApplicationFirewallPolicies.delete", + "azure.mgmt.cdn.operations.PoliciesOperations.list": "Microsoft.Cdn.CdnWebApplicationFirewallPolicies.list", + "azure.mgmt.cdn.aio.operations.PoliciesOperations.list": "Microsoft.Cdn.CdnWebApplicationFirewallPolicies.list", + "azure.mgmt.cdn.operations.ResourceUsageOperations.list": "Microsoft.Cdn.ResourceUsageOperationGroup.list", + "azure.mgmt.cdn.aio.operations.ResourceUsageOperations.list": "Microsoft.Cdn.ResourceUsageOperationGroup.list", + "azure.mgmt.cdn.operations.EdgeNodesOperations.list": "Microsoft.Cdn.EdgeNodesOperationGroup.list", + "azure.mgmt.cdn.aio.operations.EdgeNodesOperations.list": "Microsoft.Cdn.EdgeNodesOperationGroup.list", + "azure.mgmt.cdn.operations.ManagedRuleSetsOperations.list": "Microsoft.Cdn.ManagedRuleSetsOperationGroup.list", + "azure.mgmt.cdn.aio.operations.ManagedRuleSetsOperations.list": "Microsoft.Cdn.ManagedRuleSetsOperationGroup.list", + "azure.mgmt.cdn.CdnManagementClient.check_endpoint_name_availability": "Microsoft.Cdn.checkEndpointNameAvailability", + "azure.mgmt.cdn.aio.CdnManagementClient.check_endpoint_name_availability": "Microsoft.Cdn.checkEndpointNameAvailability", + "azure.mgmt.cdn.CdnManagementClient.check_name_availability": "Microsoft.Cdn.checkNameAvailability", + "azure.mgmt.cdn.aio.CdnManagementClient.check_name_availability": "Microsoft.Cdn.checkNameAvailability", + "azure.mgmt.cdn.CdnManagementClient.check_name_availability_with_subscription": "Microsoft.Cdn.checkNameAvailabilityWithSubscription", + "azure.mgmt.cdn.aio.CdnManagementClient.check_name_availability_with_subscription": "Microsoft.Cdn.checkNameAvailabilityWithSubscription", + "azure.mgmt.cdn.CdnManagementClient.validate_probe": "Microsoft.Cdn.validateProbe", + "azure.mgmt.cdn.aio.CdnManagementClient.validate_probe": "Microsoft.Cdn.validateProbe" + }, + "CrossLanguageVersion": "42158dc71d23" +} \ No newline at end of file diff --git a/sdk/cdn/azure-mgmt-cdn/azure/__init__.py b/sdk/cdn/azure-mgmt-cdn/azure/__init__.py index 8db66d3d0f0f..d55ccad1f573 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/__init__.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/__init__.py @@ -1 +1 @@ -__path__ = __import__("pkgutil").extend_path(__path__, __name__) +__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/__init__.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/__init__.py index 8db66d3d0f0f..d55ccad1f573 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/__init__.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/__init__.py @@ -1 +1 @@ -__path__ = __import__("pkgutil").extend_path(__path__, __name__) +__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore 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..f4f0231e6e2e 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/__init__.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/__init__.py @@ -2,18 +2,24 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._cdn_management_client import CdnManagementClient +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._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/_client.py similarity index 77% rename from sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/_cdn_management_client.py rename to sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/_client.py index 99307737ccda..f7748afac2d0 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/_cdn_management_client.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/_client.py @@ -2,28 +2,29 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, TYPE_CHECKING +import sys +from typing import Any, Optional, TYPE_CHECKING, cast 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, AFDOriginGroupsOperations, AFDOriginsOperations, AFDProfilesOperations, - CdnManagementClientOperationsMixin, CustomDomainsOperations, EdgeNodesOperations, EndpointsOperations, @@ -40,22 +41,27 @@ RulesOperations, SecretsOperations, SecurityPoliciesOperations, + _CdnManagementClientOperationsMixin, ) +if sys.version_info >= (3, 11): + from typing import Self +else: + from typing_extensions import Self # type: ignore + if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports + from azure.core import AzureClouds from azure.core.credentials import TokenCredential -class CdnManagementClient( - CdnManagementClientOperationsMixin -): # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes - """Cdn Management Client. +class CdnManagementClient(_CdnManagementClientOperationsMixin): # pylint: disable=too-many-instance-attributes + """Use these APIs to manage Azure Front Door and CDN resources through the Azure Resource Manager. + You must make sure that requests made to these resources are secure. - :ivar afd_profiles: AFDProfilesOperations operations - :vartype afd_profiles: azure.mgmt.cdn.operations.AFDProfilesOperations - :ivar afd_custom_domains: AFDCustomDomainsOperations operations - :vartype afd_custom_domains: azure.mgmt.cdn.operations.AFDCustomDomainsOperations + :ivar operations: Operations operations + :vartype operations: azure.mgmt.cdn.operations.Operations + :ivar profiles: ProfilesOperations operations + :vartype profiles: azure.mgmt.cdn.operations.ProfilesOperations :ivar afd_endpoints: AFDEndpointsOperations operations :vartype afd_endpoints: azure.mgmt.cdn.operations.AFDEndpointsOperations :ivar afd_origin_groups: AFDOriginGroupsOperations operations @@ -72,10 +78,6 @@ class CdnManagementClient( :vartype security_policies: azure.mgmt.cdn.operations.SecurityPoliciesOperations :ivar secrets: SecretsOperations operations :vartype secrets: azure.mgmt.cdn.operations.SecretsOperations - :ivar log_analytics: LogAnalyticsOperations operations - :vartype log_analytics: azure.mgmt.cdn.operations.LogAnalyticsOperations - :ivar profiles: ProfilesOperations operations - :vartype profiles: azure.mgmt.cdn.operations.ProfilesOperations :ivar endpoints: EndpointsOperations operations :vartype endpoints: azure.mgmt.cdn.operations.EndpointsOperations :ivar origins: OriginsOperations operations @@ -84,24 +86,32 @@ class CdnManagementClient( :vartype origin_groups: azure.mgmt.cdn.operations.OriginGroupsOperations :ivar custom_domains: CustomDomainsOperations operations :vartype custom_domains: azure.mgmt.cdn.operations.CustomDomainsOperations + :ivar afd_custom_domains: AFDCustomDomainsOperations operations + :vartype afd_custom_domains: azure.mgmt.cdn.operations.AFDCustomDomainsOperations + :ivar afd_profiles: AFDProfilesOperations operations + :vartype afd_profiles: azure.mgmt.cdn.operations.AFDProfilesOperations + :ivar log_analytics: LogAnalyticsOperations operations + :vartype log_analytics: azure.mgmt.cdn.operations.LogAnalyticsOperations + :ivar policies: PoliciesOperations operations + :vartype policies: azure.mgmt.cdn.operations.PoliciesOperations :ivar resource_usage: ResourceUsageOperations operations :vartype resource_usage: azure.mgmt.cdn.operations.ResourceUsageOperations - :ivar operations: Operations operations - :vartype operations: azure.mgmt.cdn.operations.Operations :ivar edge_nodes: EdgeNodesOperations operations :vartype edge_nodes: azure.mgmt.cdn.operations.EdgeNodesOperations - :ivar policies: PoliciesOperations operations - :vartype policies: azure.mgmt.cdn.operations.PoliciesOperations :ivar managed_rule_sets: ManagedRuleSetsOperations operations :vartype managed_rule_sets: azure.mgmt.cdn.operations.ManagedRuleSetsOperations - :param credential: Credential needed for the client to connect to Azure. Required. + :param credential: Credential used to authenticate requests to the service. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: Azure Subscription ID. Required. + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". + :param base_url: Service host. Default value is None. :type base_url: str - :keyword api_version: Api Version. Default value is "2024-02-01". Note that overriding this - default value may result in unsupported behavior. + :keyword cloud_setting: The cloud setting for which to get the ARM endpoint. Default value is + None. + :paramtype cloud_setting: ~azure.core.AzureClouds + :keyword api_version: The API version to use for this operation. Known values are "2025-12-01" + and None. Default value is None. If not set, the operation's default API version will be used. + Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. @@ -111,12 +121,26 @@ def __init__( self, credential: "TokenCredential", subscription_id: str, - base_url: str = "https://management.azure.com", + base_url: Optional[str] = None, + *, + cloud_setting: Optional["AzureClouds"] = None, **kwargs: Any ) -> None: + _endpoint = "{endpoint}" + _cloud = cloud_setting or settings.current.azure_cloud # type: ignore + _endpoints = get_arm_endpoints(_cloud) + if not base_url: + 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, + base_url=cast(str, base_url), + cloud_setting=cloud_setting, + credential_scopes=credential_scopes, + **kwargs ) + _policies = kwargs.pop("policies", None) if _policies is None: _policies = [ @@ -135,16 +159,13 @@ 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, _endpoint), policies=_policies, **kwargs) - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) + self._serialize = Serializer() + self._deserialize = Deserializer() self._serialize.client_side_validation = False - self.afd_profiles = AFDProfilesOperations(self._client, self._config, self._serialize, self._deserialize) - self.afd_custom_domains = AFDCustomDomainsOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.profiles = ProfilesOperations(self._client, self._config, self._serialize, self._deserialize) self.afd_endpoints = AFDEndpointsOperations(self._client, self._config, self._serialize, self._deserialize) self.afd_origin_groups = AFDOriginGroupsOperations( self._client, self._config, self._serialize, self._deserialize @@ -157,27 +178,29 @@ def __init__( self._client, self._config, self._serialize, self._deserialize ) self.secrets = SecretsOperations(self._client, self._config, self._serialize, self._deserialize) - self.log_analytics = LogAnalyticsOperations(self._client, self._config, self._serialize, self._deserialize) - self.profiles = ProfilesOperations(self._client, self._config, self._serialize, self._deserialize) self.endpoints = EndpointsOperations(self._client, self._config, self._serialize, self._deserialize) self.origins = OriginsOperations(self._client, self._config, self._serialize, self._deserialize) self.origin_groups = OriginGroupsOperations(self._client, self._config, self._serialize, self._deserialize) self.custom_domains = CustomDomainsOperations(self._client, self._config, self._serialize, self._deserialize) + self.afd_custom_domains = AFDCustomDomainsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.afd_profiles = AFDProfilesOperations(self._client, self._config, self._serialize, self._deserialize) + self.log_analytics = LogAnalyticsOperations(self._client, self._config, self._serialize, self._deserialize) + self.policies = PoliciesOperations(self._client, self._config, self._serialize, self._deserialize) self.resource_usage = ResourceUsageOperations(self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) self.edge_nodes = EdgeNodesOperations(self._client, self._config, self._serialize, self._deserialize) - self.policies = PoliciesOperations(self._client, self._config, self._serialize, self._deserialize) self.managed_rule_sets = ManagedRuleSetsOperations( self._client, self._config, self._serialize, self._deserialize ) - def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: + def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest >>> request = HttpRequest("GET", "https://www.example.org/") - >>> response = client._send_request(request) + >>> response = client.send_request(request) For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request @@ -190,13 +213,17 @@ def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: """ request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore def close(self) -> None: 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..ecd7fe11d060 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/_configuration.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/_configuration.py @@ -2,11 +2,11 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, TYPE_CHECKING +from typing import Any, Optional, TYPE_CHECKING from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy @@ -14,27 +14,40 @@ from ._version import VERSION if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports + from azure.core import AzureClouds 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 attributes. - :param credential: Credential needed for the client to connect to Azure. Required. + :param credential: Credential used to authenticate requests to the service. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: Azure Subscription ID. Required. + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. :type subscription_id: str - :keyword api_version: Api Version. Default value is "2024-02-01". Note that overriding this - default value may result in unsupported behavior. + :param base_url: Service host. Default value is "https://management.azure.com". + :type base_url: str + :param cloud_setting: The cloud setting for which to get the ARM endpoint. Default value is + None. + :type cloud_setting: ~azure.core.AzureClouds + :keyword api_version: The API version to use for this operation. Known values are "2025-12-01" + and None. Default value is None. If not set, the operation's default API version will be used. + 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") + def __init__( + self, + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + cloud_setting: Optional["AzureClouds"] = None, + **kwargs: Any + ) -> None: + api_version: str = kwargs.pop("api_version", "2025-12-01") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -43,6 +56,8 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs self.credential = credential self.subscription_id = subscription_id + self.base_url = base_url + self.cloud_setting = cloud_setting self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-cdn/{}".format(VERSION)) diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/_patch.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/_patch.py index 17dbc073e01b..ea765788358a 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/_patch.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/_patch.py @@ -1,32 +1,20 @@ # coding=utf-8 # -------------------------------------------------------------------------- -# # Copyright (c) Microsoft Corporation. All rights reserved. -# -# The MIT License (MIT) -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the ""Software""), to -# deal in the Software without restriction, including without limitation the -# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -# sell copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -# IN THE SOFTWARE. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # -------------------------------------------------------------------------- +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" + +__all__: list[str] = [] # Add all objects you want publicly available to users at this package level -# This file is used for handwritten extensions to the generated code. Example: -# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/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..8026245c2abc --- /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) Python 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/_utils/model_base.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/_utils/model_base.py new file mode 100644 index 000000000000..4102784f9a85 --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/_utils/model_base.py @@ -0,0 +1,1453 @@ +# pylint: disable=line-too-long,useless-suppression,too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +# pylint: disable=protected-access, broad-except + +import copy +import calendar +import decimal +import functools +import sys +import logging +import base64 +import re +import typing +import enum +import email.utils +from datetime import datetime, date, time, timedelta, timezone +from json import JSONEncoder +import xml.etree.ElementTree as ET +from collections.abc import MutableMapping +import isodate +from azure.core.exceptions import DeserializationError +from azure.core import CaseInsensitiveEnumMeta +from azure.core.pipeline import PipelineResponse +from azure.core.serialization import _Null + +from azure.core.rest import HttpResponse + +if sys.version_info >= (3, 11): + from typing import Self +else: + from typing_extensions import Self + +_LOGGER = logging.getLogger(__name__) + +__all__ = ["SdkJSONEncoder", "Model", "rest_field", "rest_discriminator"] + +TZ_UTC = timezone.utc +_T = typing.TypeVar("_T") +_NONE_TYPE = type(None) + + +def _timedelta_as_isostr(td: timedelta) -> str: + """Converts a datetime.timedelta object into an ISO 8601 formatted string, e.g. 'P4DT12H30M05S' + + Function adapted from the Tin Can Python project: https://github.com/RusticiSoftware/TinCanPython + + :param timedelta td: The timedelta to convert + :rtype: str + :return: ISO8601 version of this timedelta + """ + + # Split seconds to larger units + seconds = td.total_seconds() + minutes, seconds = divmod(seconds, 60) + hours, minutes = divmod(minutes, 60) + days, hours = divmod(hours, 24) + + days, hours, minutes = list(map(int, (days, hours, minutes))) + seconds = round(seconds, 6) + + # Build date + date_str = "" + if days: + date_str = "%sD" % days + + if hours or minutes or seconds: + # Build time + time_str = "T" + + # Hours + bigger_exists = date_str or hours + if bigger_exists: + time_str += "{:02}H".format(hours) + + # Minutes + bigger_exists = bigger_exists or minutes + if bigger_exists: + time_str += "{:02}M".format(minutes) + + # Seconds + try: + if seconds.is_integer(): + seconds_string = "{:02}".format(int(seconds)) + else: + # 9 chars long w/ leading 0, 6 digits after decimal + seconds_string = "%09.6f" % seconds + # Remove trailing zeros + seconds_string = seconds_string.rstrip("0") + except AttributeError: # int.is_integer() raises + seconds_string = "{:02}".format(seconds) + + time_str += "{}S".format(seconds_string) + else: + time_str = "" + + return "P" + date_str + time_str + + +def _serialize_bytes(o, format: typing.Optional[str] = None) -> str: + encoded = base64.b64encode(o).decode() + if format == "base64url": + return encoded.strip("=").replace("+", "-").replace("/", "_") + return encoded + + +def _serialize_datetime(o, format: typing.Optional[str] = None): + if hasattr(o, "year") and hasattr(o, "hour"): + if format == "rfc7231": + return email.utils.format_datetime(o, usegmt=True) + if format == "unix-timestamp": + return int(calendar.timegm(o.utctimetuple())) + + # astimezone() fails for naive times in Python 2.7, so make make sure o is aware (tzinfo is set) + if not o.tzinfo: + iso_formatted = o.replace(tzinfo=TZ_UTC).isoformat() + else: + iso_formatted = o.astimezone(TZ_UTC).isoformat() + # Replace the trailing "+00:00" UTC offset with "Z" (RFC 3339: https://www.ietf.org/rfc/rfc3339.txt) + return iso_formatted.replace("+00:00", "Z") + # Next try datetime.date or datetime.time + return o.isoformat() + + +def _is_readonly(p): + try: + return p._visibility == ["read"] + except AttributeError: + return False + + +class SdkJSONEncoder(JSONEncoder): + """A JSON encoder that's capable of serializing datetime objects and bytes.""" + + def __init__(self, *args, exclude_readonly: bool = False, format: typing.Optional[str] = None, **kwargs): + super().__init__(*args, **kwargs) + self.exclude_readonly = exclude_readonly + self.format = format + + def default(self, o): # pylint: disable=too-many-return-statements + if _is_model(o): + if self.exclude_readonly: + readonly_props = [p._rest_name for p in o._attr_to_rest_field.values() if _is_readonly(p)] + return {k: v for k, v in o.items() if k not in readonly_props} + return dict(o.items()) + try: + return super(SdkJSONEncoder, self).default(o) + except TypeError: + if isinstance(o, _Null): + return None + if isinstance(o, decimal.Decimal): + return float(o) + if isinstance(o, (bytes, bytearray)): + return _serialize_bytes(o, self.format) + try: + # First try datetime.datetime + return _serialize_datetime(o, self.format) + except AttributeError: + pass + # Last, try datetime.timedelta + try: + return _timedelta_as_isostr(o) + except AttributeError: + # This will be raised when it hits value.total_seconds in the method above + pass + return super(SdkJSONEncoder, self).default(o) + + +_VALID_DATE = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}" + r"\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") +_VALID_RFC7231 = re.compile( + r"(Mon|Tue|Wed|Thu|Fri|Sat|Sun),\s\d{2}\s" + r"(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s\d{4}\s\d{2}:\d{2}:\d{2}\sGMT" +) + +_ARRAY_ENCODE_MAPPING = { + "pipeDelimited": "|", + "spaceDelimited": " ", + "commaDelimited": ",", + "newlineDelimited": "\n", +} + + +def _deserialize_array_encoded(delimit: str, attr): + if isinstance(attr, str): + if attr == "": + return [] + return attr.split(delimit) + return attr + + +def _deserialize_datetime(attr: typing.Union[str, datetime]) -> datetime: + """Deserialize ISO-8601 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: ~datetime.datetime + :returns: The datetime object from that input + """ + if isinstance(attr, datetime): + # i'm already deserialized + return attr + attr = attr.upper() + match = _VALID_DATE.match(attr) + if not match: + raise ValueError("Invalid datetime string: " + attr) + + check_decimal = attr.split(".") + if len(check_decimal) > 1: + decimal_str = "" + for digit in check_decimal[1]: + if digit.isdigit(): + decimal_str += digit + else: + break + if len(decimal_str) > 6: + attr = attr.replace(decimal_str, decimal_str[0:6]) + + date_obj = isodate.parse_datetime(attr) + test_utc = date_obj.utctimetuple() + if test_utc.tm_year > 9999 or test_utc.tm_year < 1: + raise OverflowError("Hit max or min date") + return date_obj # type: ignore[no-any-return] + + +def _deserialize_datetime_rfc7231(attr: typing.Union[str, datetime]) -> datetime: + """Deserialize RFC7231 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: ~datetime.datetime + :returns: The datetime object from that input + """ + if isinstance(attr, datetime): + # i'm already deserialized + return attr + match = _VALID_RFC7231.match(attr) + if not match: + raise ValueError("Invalid datetime string: " + attr) + + return email.utils.parsedate_to_datetime(attr) + + +def _deserialize_datetime_unix_timestamp(attr: typing.Union[float, datetime]) -> datetime: + """Deserialize unix timestamp into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: ~datetime.datetime + :returns: The datetime object from that input + """ + if isinstance(attr, datetime): + # i'm already deserialized + return attr + return datetime.fromtimestamp(attr, TZ_UTC) + + +def _deserialize_date(attr: typing.Union[str, date]) -> date: + """Deserialize ISO-8601 formatted string into Date object. + :param str attr: response string to be deserialized. + :rtype: date + :returns: The date object from that input + """ + # This must NOT use defaultmonth/defaultday. Using None ensure this raises an exception. + if isinstance(attr, date): + return attr + return isodate.parse_date(attr, defaultmonth=None, defaultday=None) # type: ignore + + +def _deserialize_time(attr: typing.Union[str, time]) -> time: + """Deserialize ISO-8601 formatted string into time object. + + :param str attr: response string to be deserialized. + :rtype: datetime.time + :returns: The time object from that input + """ + if isinstance(attr, time): + return attr + return isodate.parse_time(attr) # type: ignore[no-any-return] + + +def _deserialize_bytes(attr): + if isinstance(attr, (bytes, bytearray)): + return attr + return bytes(base64.b64decode(attr)) + + +def _deserialize_bytes_base64(attr): + if isinstance(attr, (bytes, bytearray)): + return attr + padding = "=" * (3 - (len(attr) + 3) % 4) # type: ignore + attr = attr + padding # type: ignore + encoded = attr.replace("-", "+").replace("_", "/") + return bytes(base64.b64decode(encoded)) + + +def _deserialize_duration(attr): + if isinstance(attr, timedelta): + return attr + return isodate.parse_duration(attr) + + +def _deserialize_decimal(attr): + if isinstance(attr, decimal.Decimal): + return attr + return decimal.Decimal(str(attr)) + + +def _deserialize_int_as_str(attr): + if isinstance(attr, int): + return attr + return int(attr) + + +_DESERIALIZE_MAPPING = { + datetime: _deserialize_datetime, + date: _deserialize_date, + time: _deserialize_time, + bytes: _deserialize_bytes, + bytearray: _deserialize_bytes, + timedelta: _deserialize_duration, + typing.Any: lambda x: x, + decimal.Decimal: _deserialize_decimal, +} + +_DESERIALIZE_MAPPING_WITHFORMAT = { + "rfc3339": _deserialize_datetime, + "rfc7231": _deserialize_datetime_rfc7231, + "unix-timestamp": _deserialize_datetime_unix_timestamp, + "base64": _deserialize_bytes, + "base64url": _deserialize_bytes_base64, +} + + +def get_deserializer(annotation: typing.Any, rf: typing.Optional["_RestField"] = None): + if annotation is int and rf and rf._format == "str": + return _deserialize_int_as_str + if annotation is str and rf and rf._format in _ARRAY_ENCODE_MAPPING: + return functools.partial(_deserialize_array_encoded, _ARRAY_ENCODE_MAPPING[rf._format]) + if rf and rf._format: + return _DESERIALIZE_MAPPING_WITHFORMAT.get(rf._format) + return _DESERIALIZE_MAPPING.get(annotation) # pyright: ignore + + +def _get_type_alias_type(module_name: str, alias_name: str): + types = { + k: v + for k, v in sys.modules[module_name].__dict__.items() + if isinstance(v, typing._GenericAlias) # type: ignore + } + if alias_name not in types: + return alias_name + return types[alias_name] + + +def _get_model(module_name: str, model_name: str): + models = {k: v for k, v in sys.modules[module_name].__dict__.items() if isinstance(v, type)} + module_end = module_name.rsplit(".", 1)[0] + models.update({k: v for k, v in sys.modules[module_end].__dict__.items() if isinstance(v, type)}) + if isinstance(model_name, str): + model_name = model_name.split(".")[-1] + if model_name not in models: + return model_name + return models[model_name] + + +_UNSET = object() + + +class _MyMutableMapping(MutableMapping[str, typing.Any]): + def __init__(self, data: dict[str, typing.Any]) -> None: + self._data = data + + def __contains__(self, key: typing.Any) -> bool: + return key in self._data + + def __getitem__(self, key: str) -> typing.Any: + # If this key has been deserialized (for mutable types), we need to handle serialization + if hasattr(self, "_attr_to_rest_field"): + cache_attr = f"_deserialized_{key}" + if hasattr(self, cache_attr): + rf = _get_rest_field(getattr(self, "_attr_to_rest_field"), key) + if rf: + value = self._data.get(key) + if isinstance(value, (dict, list, set)): + # For mutable types, serialize and return + # But also update _data with serialized form and clear flag + # so mutations via this returned value affect _data + serialized = _serialize(value, rf._format) + # If serialized form is same type (no transformation needed), + # return _data directly so mutations work + if isinstance(serialized, type(value)) and serialized == value: + return self._data.get(key) + # Otherwise return serialized copy and clear flag + try: + object.__delattr__(self, cache_attr) + except AttributeError: + pass + # Store serialized form back + self._data[key] = serialized + return serialized + return self._data.__getitem__(key) + + def __setitem__(self, key: str, value: typing.Any) -> None: + # Clear any cached deserialized value when setting through dictionary access + cache_attr = f"_deserialized_{key}" + try: + object.__delattr__(self, cache_attr) + except AttributeError: + pass + self._data.__setitem__(key, value) + + def __delitem__(self, key: str) -> None: + self._data.__delitem__(key) + + def __iter__(self) -> typing.Iterator[typing.Any]: + return self._data.__iter__() + + def __len__(self) -> int: + return self._data.__len__() + + def __ne__(self, other: typing.Any) -> bool: + return not self.__eq__(other) + + def keys(self) -> typing.KeysView[str]: + """ + :returns: a set-like object providing a view on D's keys + :rtype: ~typing.KeysView + """ + return self._data.keys() + + def values(self) -> typing.ValuesView[typing.Any]: + """ + :returns: an object providing a view on D's values + :rtype: ~typing.ValuesView + """ + return self._data.values() + + def items(self) -> typing.ItemsView[str, typing.Any]: + """ + :returns: set-like object providing a view on D's items + :rtype: ~typing.ItemsView + """ + return self._data.items() + + def get(self, key: str, default: typing.Any = None) -> typing.Any: + """ + Get the value for key if key is in the dictionary, else default. + :param str key: The key to look up. + :param any default: The value to return if key is not in the dictionary. Defaults to None + :returns: D[k] if k in D, else d. + :rtype: any + """ + try: + return self[key] + except KeyError: + return default + + @typing.overload + def pop(self, key: str) -> typing.Any: ... # pylint: disable=arguments-differ + + @typing.overload + def pop(self, key: str, default: _T) -> _T: ... # pylint: disable=signature-differs + + @typing.overload + def pop(self, key: str, default: typing.Any) -> typing.Any: ... # pylint: disable=signature-differs + + def pop(self, key: str, default: typing.Any = _UNSET) -> typing.Any: + """ + Removes specified key and return the corresponding value. + :param str key: The key to pop. + :param any default: The value to return if key is not in the dictionary + :returns: The value corresponding to the key. + :rtype: any + :raises KeyError: If key is not found and default is not given. + """ + if default is _UNSET: + return self._data.pop(key) + return self._data.pop(key, default) + + def popitem(self) -> tuple[str, typing.Any]: + """ + Removes and returns some (key, value) pair + :returns: The (key, value) pair. + :rtype: tuple + :raises KeyError: if D is empty. + """ + return self._data.popitem() + + def clear(self) -> None: + """ + Remove all items from D. + """ + self._data.clear() + + def update(self, *args: typing.Any, **kwargs: typing.Any) -> None: # pylint: disable=arguments-differ + """ + Updates D from mapping/iterable E and F. + :param any args: Either a mapping object or an iterable of key-value pairs. + """ + self._data.update(*args, **kwargs) + + @typing.overload + def setdefault(self, key: str, default: None = None) -> None: ... + + @typing.overload + def setdefault(self, key: str, default: typing.Any) -> typing.Any: ... # pylint: disable=signature-differs + + def setdefault(self, key: str, default: typing.Any = _UNSET) -> typing.Any: + """ + Same as calling D.get(k, d), and setting D[k]=d if k not found + :param str key: The key to look up. + :param any default: The value to set if key is not in the dictionary + :returns: D[k] if k in D, else d. + :rtype: any + """ + if default is _UNSET: + return self._data.setdefault(key) + return self._data.setdefault(key, default) + + def __eq__(self, other: typing.Any) -> bool: + if isinstance(other, _MyMutableMapping): + return self._data == other._data + try: + other_model = self.__class__(other) + except Exception: + return False + return self._data == other_model._data + + def __repr__(self) -> str: + return str(self._data) + + +def _is_model(obj: typing.Any) -> bool: + return getattr(obj, "_is_model", False) + + +def _serialize(o, format: typing.Optional[str] = None): # pylint: disable=too-many-return-statements + if isinstance(o, list): + if format in _ARRAY_ENCODE_MAPPING and all(isinstance(x, str) for x in o): + return _ARRAY_ENCODE_MAPPING[format].join(o) + return [_serialize(x, format) for x in o] + if isinstance(o, dict): + return {k: _serialize(v, format) for k, v in o.items()} + if isinstance(o, set): + return {_serialize(x, format) for x in o} + if isinstance(o, tuple): + return tuple(_serialize(x, format) for x in o) + if isinstance(o, (bytes, bytearray)): + return _serialize_bytes(o, format) + if isinstance(o, decimal.Decimal): + return float(o) + if isinstance(o, enum.Enum): + return o.value + if isinstance(o, int): + if format == "str": + return str(o) + return o + try: + # First try datetime.datetime + return _serialize_datetime(o, format) + except AttributeError: + pass + # Last, try datetime.timedelta + try: + return _timedelta_as_isostr(o) + except AttributeError: + # This will be raised when it hits value.total_seconds in the method above + pass + return o + + +def _get_rest_field(attr_to_rest_field: dict[str, "_RestField"], rest_name: str) -> typing.Optional["_RestField"]: + try: + return next(rf for rf in attr_to_rest_field.values() if rf._rest_name == rest_name) + except StopIteration: + return None + + +def _create_value(rf: typing.Optional["_RestField"], value: typing.Any) -> typing.Any: + if not rf: + return _serialize(value, None) + if rf._is_multipart_file_input: + return value + if rf._is_model: + return _deserialize(rf._type, value) + if isinstance(value, ET.Element): + value = _deserialize(rf._type, value) + return _serialize(value, rf._format) + + +class Model(_MyMutableMapping): + _is_model = True + # label whether current class's _attr_to_rest_field has been calculated + # could not see _attr_to_rest_field directly because subclass inherits it from parent class + _calculated: set[str] = set() + + def __init__(self, *args: typing.Any, **kwargs: typing.Any) -> None: + class_name = self.__class__.__name__ + if len(args) > 1: + raise TypeError(f"{class_name}.__init__() takes 2 positional arguments but {len(args) + 1} were given") + dict_to_pass: dict[str, typing.Any] = {} + if args: + if isinstance(args[0], ET.Element): + dict_to_pass.update(self._init_from_xml(args[0])) + else: + dict_to_pass.update( + {k: _create_value(_get_rest_field(self._attr_to_rest_field, k), v) for k, v in args[0].items()} + ) + else: + non_attr_kwargs = [k for k in kwargs if k not in self._attr_to_rest_field] + if non_attr_kwargs: + # actual type errors only throw the first wrong keyword arg they see, so following that. + raise TypeError(f"{class_name}.__init__() got an unexpected keyword argument '{non_attr_kwargs[0]}'") + dict_to_pass.update( + { + self._attr_to_rest_field[k]._rest_name: _create_value(self._attr_to_rest_field[k], v) + for k, v in kwargs.items() + if v is not None + } + ) + # Apply client default values for fields the caller didn't set so that + # defaults are part of `_data` and therefore included during serialization. + for rf in self._attr_to_rest_field.values(): + if rf._default is _UNSET: + continue + if rf._rest_name in dict_to_pass: + continue + dict_to_pass[rf._rest_name] = _create_value(rf, rf._default) + super().__init__(dict_to_pass) + + def _init_from_xml(self, element: ET.Element) -> dict[str, typing.Any]: + """Deserialize an XML element into a dict mapping rest field names to values. + + :param ET.Element element: The XML element to deserialize from. + :returns: A dictionary of rest_name to deserialized value pairs. + :rtype: dict + """ + result: dict[str, typing.Any] = {} + model_meta = getattr(self, "_xml", {}) + existed_attr_keys: list[str] = [] + + for rf in self._attr_to_rest_field.values(): + prop_meta = getattr(rf, "_xml", {}) + xml_name = prop_meta.get("name", rf._rest_name) + xml_ns = _resolve_xml_ns(prop_meta, model_meta) + if xml_ns: + xml_name = "{" + xml_ns + "}" + xml_name + + # attribute + if prop_meta.get("attribute", False) and element.get(xml_name) is not None: + existed_attr_keys.append(xml_name) + result[rf._rest_name] = _deserialize(rf._type, element.get(xml_name)) + continue + + # unwrapped element is array + if prop_meta.get("unwrapped", False): + # unwrapped array could either use prop items meta/prop meta + _items_name = prop_meta.get("itemsName") + if _items_name: + xml_name = _items_name + _items_ns = prop_meta.get("itemsNs") + if _items_ns is not None: + xml_ns = _items_ns + if xml_ns: + xml_name = "{" + xml_ns + "}" + xml_name + items = element.findall(xml_name) # pyright: ignore + if len(items) > 0: + existed_attr_keys.append(xml_name) + result[rf._rest_name] = _deserialize(rf._type, items) + elif not rf._is_optional: + existed_attr_keys.append(xml_name) + result[rf._rest_name] = [] + continue + + # text element is primitive type + if prop_meta.get("text", False): + if element.text is not None: + result[rf._rest_name] = _deserialize(rf._type, element.text) + continue + + # wrapped element could be normal property or array, it should only have one element + item = element.find(xml_name) + if item is not None: + existed_attr_keys.append(xml_name) + result[rf._rest_name] = _deserialize(rf._type, item) + + # rest thing is additional properties + for e in element: + if e.tag not in existed_attr_keys: + result[e.tag] = _convert_element(e) + + return result + + def copy(self) -> "Model": + return Model(self.__dict__) + + def __new__(cls, *args: typing.Any, **kwargs: typing.Any) -> Self: + if f"{cls.__module__}.{cls.__qualname__}" not in cls._calculated: + # we know the last nine classes in mro are going to be 'Model', '_MyMutableMapping', 'MutableMapping', + # 'Mapping', 'Collection', 'Sized', 'Iterable', 'Container' and 'object' + mros = cls.__mro__[:-9][::-1] # ignore parents, and reverse the mro order + attr_to_rest_field: dict[str, _RestField] = { # map attribute name to rest_field property + k: v for mro_class in mros for k, v in mro_class.__dict__.items() if k[0] != "_" and hasattr(v, "_type") + } + annotations = { + k: v + for mro_class in mros + if hasattr(mro_class, "__annotations__") + for k, v in mro_class.__annotations__.items() + } + for attr, rf in attr_to_rest_field.items(): + rf._module = cls.__module__ + if not rf._type: + rf._type = rf._get_deserialize_callable_from_annotation(annotations.get(attr, None)) + if not rf._rest_name_input: + rf._rest_name_input = attr + cls._attr_to_rest_field: dict[str, _RestField] = dict(attr_to_rest_field.items()) + cls._calculated.add(f"{cls.__module__}.{cls.__qualname__}") + + return super().__new__(cls) + + def __init_subclass__(cls, discriminator: typing.Optional[str] = None) -> None: + for base in cls.__bases__: + if hasattr(base, "__mapping__"): + base.__mapping__[discriminator or cls.__name__] = cls # type: ignore + + @classmethod + def _get_discriminator(cls, exist_discriminators) -> typing.Optional["_RestField"]: + for v in cls.__dict__.values(): + if isinstance(v, _RestField) and v._is_discriminator and v._rest_name not in exist_discriminators: + return v + return None + + @classmethod + def _deserialize(cls, data, exist_discriminators): + if not hasattr(cls, "__mapping__"): + return cls(data) + discriminator = cls._get_discriminator(exist_discriminators) + if discriminator is None: + return cls(data) + exist_discriminators.append(discriminator._rest_name) + if isinstance(data, ET.Element): + model_meta = getattr(cls, "_xml", {}) + prop_meta = getattr(discriminator, "_xml", {}) + xml_name = prop_meta.get("name", discriminator._rest_name) + xml_ns = _resolve_xml_ns(prop_meta, model_meta) + if xml_ns: + xml_name = "{" + xml_ns + "}" + xml_name + + if data.get(xml_name) is not None: + discriminator_value = data.get(xml_name) + else: + discriminator_value = data.find(xml_name).text # pyright: ignore + else: + discriminator_value = data.get(discriminator._rest_name) + mapped_cls = cls.__mapping__.get(discriminator_value, cls) # pyright: ignore # pylint: disable=no-member + return mapped_cls._deserialize(data, exist_discriminators) + + def as_dict(self, *, exclude_readonly: bool = False) -> dict[str, typing.Any]: + """Return a dict that can be turned into json using json.dump. + + :keyword bool exclude_readonly: Whether to remove the readonly properties. + :returns: A dict JSON compatible object + :rtype: dict + """ + + result = {} + readonly_props = [] + if exclude_readonly: + readonly_props = [p._rest_name for p in self._attr_to_rest_field.values() if _is_readonly(p)] + for k, v in self.items(): + if exclude_readonly and k in readonly_props: # pyright: ignore + continue + is_multipart_file_input = False + try: + is_multipart_file_input = next( + rf for rf in self._attr_to_rest_field.values() if rf._rest_name == k + )._is_multipart_file_input + except StopIteration: + pass + result[k] = v if is_multipart_file_input else Model._as_dict_value(v, exclude_readonly=exclude_readonly) + return result + + @staticmethod + def _as_dict_value(v: typing.Any, exclude_readonly: bool = False) -> typing.Any: + if v is None or isinstance(v, _Null): + return None + if isinstance(v, (list, tuple, set)): + return type(v)(Model._as_dict_value(x, exclude_readonly=exclude_readonly) for x in v) + if isinstance(v, dict): + return {dk: Model._as_dict_value(dv, exclude_readonly=exclude_readonly) for dk, dv in v.items()} + return v.as_dict(exclude_readonly=exclude_readonly) if hasattr(v, "as_dict") else v + + +def _deserialize_model(model_deserializer: typing.Optional[typing.Callable], obj): + if _is_model(obj): + return obj + return _deserialize(model_deserializer, obj) + + +def _deserialize_with_optional(if_obj_deserializer: typing.Optional[typing.Callable], obj): + if obj is None: + return obj + return _deserialize_with_callable(if_obj_deserializer, obj) + + +def _deserialize_with_union(deserializers, obj): + for deserializer in deserializers: + try: + return _deserialize(deserializer, obj) + except DeserializationError: + pass + raise DeserializationError() + + +def _deserialize_dict( + value_deserializer: typing.Optional[typing.Callable], + module: typing.Optional[str], + obj: dict[typing.Any, typing.Any], +): + if obj is None: + return obj + if isinstance(obj, ET.Element): + obj = {child.tag: child for child in obj} + return {k: _deserialize(value_deserializer, v, module) for k, v in obj.items()} + + +def _deserialize_multiple_sequence( + entry_deserializers: list[typing.Optional[typing.Callable]], + module: typing.Optional[str], + obj, +): + if obj is None: + return obj + return type(obj)(_deserialize(deserializer, entry, module) for entry, deserializer in zip(obj, entry_deserializers)) + + +def _is_array_encoded_deserializer(deserializer: functools.partial) -> bool: + return ( + isinstance(deserializer, functools.partial) + and isinstance(deserializer.args[0], functools.partial) + and deserializer.args[0].func == _deserialize_array_encoded # pylint: disable=comparison-with-callable + ) + + +def _deserialize_sequence( + deserializer: typing.Optional[typing.Callable], + module: typing.Optional[str], + obj, +): + if obj is None: + return obj + if isinstance(obj, ET.Element): + obj = list(obj) + + # encoded string may be deserialized to sequence + if isinstance(obj, str) and isinstance(deserializer, functools.partial): + # for list[str] + if _is_array_encoded_deserializer(deserializer): + return deserializer(obj) + + # for list[Union[...]] + if isinstance(deserializer.args[0], list): + for sub_deserializer in deserializer.args[0]: + if _is_array_encoded_deserializer(sub_deserializer): + return sub_deserializer(obj) + + return type(obj)(_deserialize(deserializer, entry, module) for entry in obj) + + +def _sorted_annotations(types: list[typing.Any]) -> list[typing.Any]: + return sorted( + types, + key=lambda x: hasattr(x, "__name__") and x.__name__.lower() in ("str", "float", "int", "bool"), + ) + + +def _get_deserialize_callable_from_annotation( # pylint: disable=too-many-return-statements, too-many-statements, too-many-branches + annotation: typing.Any, + module: typing.Optional[str], + rf: typing.Optional["_RestField"] = None, +) -> typing.Optional[typing.Callable[[typing.Any], typing.Any]]: + if not annotation: + return None + + # is it a type alias? + if isinstance(annotation, str): + if module is not None: + annotation = _get_type_alias_type(module, annotation) + + # is it a forward ref / in quotes? + if isinstance(annotation, (str, typing.ForwardRef)): + try: + model_name = annotation.__forward_arg__ # type: ignore + except AttributeError: + model_name = annotation + if module is not None: + annotation = _get_model(module, model_name) # type: ignore + + try: + if module and _is_model(annotation): + if rf: + rf._is_model = True + + return functools.partial(_deserialize_model, annotation) # pyright: ignore + except Exception: + pass + + # is it a literal? + try: + if annotation.__origin__ is typing.Literal: # pyright: ignore + return None + except AttributeError: + pass + + # is it optional? + try: + if any(a is _NONE_TYPE for a in annotation.__args__): # pyright: ignore + if rf: + rf._is_optional = True + if len(annotation.__args__) <= 2: # pyright: ignore + if_obj_deserializer = _get_deserialize_callable_from_annotation( + next(a for a in annotation.__args__ if a is not _NONE_TYPE), module, rf # pyright: ignore + ) + + return functools.partial(_deserialize_with_optional, if_obj_deserializer) + # the type is Optional[Union[...]], we need to remove the None type from the Union + annotation_copy = copy.copy(annotation) + annotation_copy.__args__ = [a for a in annotation_copy.__args__ if a is not _NONE_TYPE] # pyright: ignore + return _get_deserialize_callable_from_annotation(annotation_copy, module, rf) + except AttributeError: + pass + + # is it union? + if getattr(annotation, "__origin__", None) is typing.Union: + # initial ordering is we make `string` the last deserialization option, because it is often them most generic + deserializers = [ + _get_deserialize_callable_from_annotation(arg, module, rf) + for arg in _sorted_annotations(annotation.__args__) # pyright: ignore + ] + + return functools.partial(_deserialize_with_union, deserializers) + + try: + annotation_name = ( + annotation.__name__ if hasattr(annotation, "__name__") else annotation._name # pyright: ignore + ) + if annotation_name.lower() == "dict": + value_deserializer = _get_deserialize_callable_from_annotation( + annotation.__args__[1], module, rf # pyright: ignore + ) + + return functools.partial( + _deserialize_dict, + value_deserializer, + module, + ) + except (AttributeError, IndexError): + pass + try: + annotation_name = ( + annotation.__name__ if hasattr(annotation, "__name__") else annotation._name # pyright: ignore + ) + if annotation_name.lower() in ["list", "set", "tuple", "sequence"]: + if len(annotation.__args__) > 1: # pyright: ignore + entry_deserializers = [ + _get_deserialize_callable_from_annotation(dt, module, rf) + for dt in annotation.__args__ # pyright: ignore + ] + return functools.partial(_deserialize_multiple_sequence, entry_deserializers, module) + deserializer = _get_deserialize_callable_from_annotation( + annotation.__args__[0], module, rf # pyright: ignore + ) + + return functools.partial(_deserialize_sequence, deserializer, module) + except (TypeError, IndexError, AttributeError, SyntaxError): + pass + + def _deserialize_default( + deserializer, + obj, + ): + if obj is None: + return obj + try: + return _deserialize_with_callable(deserializer, obj) + except Exception: + pass + return obj + + if get_deserializer(annotation, rf): + return functools.partial(_deserialize_default, get_deserializer(annotation, rf)) + + return functools.partial(_deserialize_default, annotation) + + +def _deserialize_with_callable( + deserializer: typing.Optional[typing.Callable[[typing.Any], typing.Any]], + value: typing.Any, +): # pylint: disable=too-many-return-statements + try: + if value is None or isinstance(value, _Null): + return None + if isinstance(value, ET.Element): + if deserializer is str: + return value.text or "" + if deserializer is int: + return int(value.text) if value.text else None + if deserializer is float: + return float(value.text) if value.text else None + if deserializer is bool: + return value.text == "true" if value.text else None + if deserializer and deserializer in _DESERIALIZE_MAPPING.values(): + return deserializer(value.text) if value.text else None + if deserializer and deserializer in _DESERIALIZE_MAPPING_WITHFORMAT.values(): + return deserializer(value.text) if value.text else None + if deserializer is None: + return value + if deserializer in [int, float, bool]: + return deserializer(value) + if isinstance(deserializer, CaseInsensitiveEnumMeta): + try: + return deserializer(value.text if isinstance(value, ET.Element) else value) + except ValueError: + # for unknown value, return raw value + return value.text if isinstance(value, ET.Element) else value + if isinstance(deserializer, type) and issubclass(deserializer, Model): + return deserializer._deserialize(value, []) + return typing.cast(typing.Callable[[typing.Any], typing.Any], deserializer)(value) + except Exception as e: + raise DeserializationError() from e + + +def _deserialize( + deserializer: typing.Any, + value: typing.Any, + module: typing.Optional[str] = None, + rf: typing.Optional["_RestField"] = None, + format: typing.Optional[str] = None, +) -> typing.Any: + if isinstance(value, PipelineResponse): + value = value.http_response.json() + if rf is None and format: + rf = _RestField(format=format) + if not isinstance(deserializer, functools.partial): + deserializer = _get_deserialize_callable_from_annotation(deserializer, module, rf) + return _deserialize_with_callable(deserializer, value) + + +def _failsafe_deserialize( + deserializer: typing.Any, + response: HttpResponse, + module: typing.Optional[str] = None, + rf: typing.Optional["_RestField"] = None, + format: typing.Optional[str] = None, +) -> typing.Any: + try: + return _deserialize(deserializer, response.json(), module, rf, format) + except Exception: # pylint: disable=broad-except + _LOGGER.warning( + "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True + ) + return None + + +def _failsafe_deserialize_xml( + deserializer: typing.Any, + response: HttpResponse, +) -> typing.Any: + try: + return _deserialize_xml(deserializer, response.text()) + except Exception: # pylint: disable=broad-except + _LOGGER.warning( + "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True + ) + return None + + +# pylint: disable=too-many-instance-attributes +class _RestField: + def __init__( + self, + *, + name: typing.Optional[str] = None, + type: typing.Optional[typing.Callable] = None, # pylint: disable=redefined-builtin + is_discriminator: bool = False, + visibility: typing.Optional[list[str]] = None, + default: typing.Any = _UNSET, + format: typing.Optional[str] = None, + is_multipart_file_input: bool = False, + xml: typing.Optional[dict[str, typing.Any]] = None, + ): + self._type = type + self._rest_name_input = name + self._module: typing.Optional[str] = None + self._is_discriminator = is_discriminator + self._visibility = visibility + self._is_model = False + self._is_optional = False + self._default = default + self._format = format + self._is_multipart_file_input = is_multipart_file_input + self._xml = xml if xml is not None else {} + + @property + def _class_type(self) -> typing.Any: + result = getattr(self._type, "args", [None])[0] + # type may be wrapped by nested functools.partial so we need to check for that + if isinstance(result, functools.partial): + return getattr(result, "args", [None])[0] + return result + + @property + def _rest_name(self) -> str: + if self._rest_name_input is None: + raise ValueError("Rest name was never set") + return self._rest_name_input + + def __get__(self, obj: Model, type=None): # pylint: disable=redefined-builtin + # by this point, type and rest_name will have a value bc we default + # them in __new__ of the Model class + # Use _data.get() directly to avoid triggering __getitem__ which clears the cache + item = obj._data.get(self._rest_name, _UNSET) + if item is _UNSET: + # Field not set by user; return the client default if one exists, otherwise None + return self._default if self._default is not _UNSET else None + if item is None: + return item + if self._is_model: + return item + + # For mutable types, we want mutations to directly affect _data + # Check if we've already deserialized this value + cache_attr = f"_deserialized_{self._rest_name}" + if hasattr(obj, cache_attr): + # Return the value from _data directly (it's been deserialized in place) + return obj._data.get(self._rest_name) + + deserialized = _deserialize(self._type, _serialize(item, self._format), rf=self) + + # For mutable types, store the deserialized value back in _data + # so mutations directly affect _data + if isinstance(deserialized, (dict, list, set)): + obj._data[self._rest_name] = deserialized + object.__setattr__(obj, cache_attr, True) # Mark as deserialized + return deserialized + + return deserialized + + def __set__(self, obj: Model, value) -> None: + # Clear the cached deserialized object when setting a new value + cache_attr = f"_deserialized_{self._rest_name}" + if hasattr(obj, cache_attr): + object.__delattr__(obj, cache_attr) + + if value is None: + # we want to wipe out entries if users set attr to None + try: + obj.__delitem__(self._rest_name) + except KeyError: + pass + return + if self._is_model: + if not _is_model(value): + value = _deserialize(self._type, value) + obj.__setitem__(self._rest_name, value) + return + obj.__setitem__(self._rest_name, _serialize(value, self._format)) + + def _get_deserialize_callable_from_annotation( + self, annotation: typing.Any + ) -> typing.Optional[typing.Callable[[typing.Any], typing.Any]]: + return _get_deserialize_callable_from_annotation(annotation, self._module, self) + + +def rest_field( + *, + name: typing.Optional[str] = None, + type: typing.Optional[typing.Callable] = None, # pylint: disable=redefined-builtin + visibility: typing.Optional[list[str]] = None, + default: typing.Any = _UNSET, + format: typing.Optional[str] = None, + is_multipart_file_input: bool = False, + xml: typing.Optional[dict[str, typing.Any]] = None, +) -> typing.Any: + return _RestField( + name=name, + type=type, + visibility=visibility, + default=default, + format=format, + is_multipart_file_input=is_multipart_file_input, + xml=xml, + ) + + +def rest_discriminator( + *, + name: typing.Optional[str] = None, + type: typing.Optional[typing.Callable] = None, # pylint: disable=redefined-builtin + visibility: typing.Optional[list[str]] = None, + xml: typing.Optional[dict[str, typing.Any]] = None, +) -> typing.Any: + return _RestField(name=name, type=type, is_discriminator=True, visibility=visibility, xml=xml) + + +def serialize_xml(model: Model, exclude_readonly: bool = False) -> str: + """Serialize a model to XML. + + :param Model model: The model to serialize. + :param bool exclude_readonly: Whether to exclude readonly properties. + :returns: The XML representation of the model. + :rtype: str + """ + return ET.tostring(_get_element(model, exclude_readonly), encoding="unicode") # type: ignore + + +def _get_xml_ns(meta: dict[str, typing.Any]) -> typing.Optional[str]: + """Return the XML namespace from a metadata dict, checking both 'ns' (old-style) and 'namespace' (DPG) keys. + + :param dict meta: The metadata dictionary to extract namespace from. + :returns: The namespace string if 'ns' or 'namespace' key is present, None otherwise. + :rtype: str or None + """ + ns = meta.get("ns") + if ns is None: + ns = meta.get("namespace") + return ns + + +def _resolve_xml_ns( + prop_meta: dict[str, typing.Any], model_meta: typing.Optional[dict[str, typing.Any]] = None +) -> typing.Optional[str]: + """Resolve XML namespace for a property, falling back to model namespace when appropriate. + + Checks the property metadata first; if no namespace is found and the model does not declare + an explicit prefix, falls back to the model-level namespace. + + :param dict prop_meta: The property metadata dictionary. + :param dict model_meta: The model metadata dictionary, used as fallback. + :returns: The resolved namespace string, or None. + :rtype: str or None + """ + ns = _get_xml_ns(prop_meta) + if ns is None and model_meta is not None and not model_meta.get("prefix"): + ns = _get_xml_ns(model_meta) + return ns + + +def _set_xml_attribute(element: ET.Element, name: str, value: typing.Any, prop_meta: dict[str, typing.Any]) -> None: + """Set an XML attribute on an element, handling namespace prefix registration. + + :param ET.Element element: The element to set the attribute on. + :param str name: The default attribute name (wire name). + :param any value: The attribute value. + :param dict prop_meta: The property metadata dictionary. + """ + xml_name = prop_meta.get("name", name) + _attr_ns = _get_xml_ns(prop_meta) + if _attr_ns: + _attr_prefix = prop_meta.get("prefix") + if _attr_prefix: + _safe_register_namespace(_attr_prefix, _attr_ns) + xml_name = "{" + _attr_ns + "}" + xml_name + element.set(xml_name, _get_primitive_type_value(value)) + + +def _get_element( + o: typing.Any, + exclude_readonly: bool = False, + parent_meta: typing.Optional[dict[str, typing.Any]] = None, + wrapped_element: typing.Optional[ET.Element] = None, +) -> typing.Union[ET.Element, list[ET.Element]]: + if _is_model(o): + model_meta = getattr(o, "_xml", {}) + + # if prop is a model, then use the prop element directly, else generate a wrapper of model + if wrapped_element is None: + # When serializing as an array item (parent_meta is set), check if the parent has an + # explicit itemsName. This ensures correct element names for unwrapped arrays (where + # the element tag is the property/items name, not the model type name). + _items_name = parent_meta.get("itemsName") if parent_meta is not None else None + element_name = _items_name if _items_name else (model_meta.get("name") or o.__class__.__name__) + _model_ns = _get_xml_ns(model_meta) + wrapped_element = _create_xml_element( + element_name, + model_meta.get("prefix"), + _model_ns, + ) + + readonly_props = [] + if exclude_readonly: + readonly_props = [p._rest_name for p in o._attr_to_rest_field.values() if _is_readonly(p)] + + for k, v in o.items(): + # do not serialize readonly properties + if exclude_readonly and k in readonly_props: + continue + + prop_rest_field = _get_rest_field(o._attr_to_rest_field, k) + if prop_rest_field: + prop_meta = getattr(prop_rest_field, "_xml").copy() + # use the wire name as xml name if no specific name is set + if prop_meta.get("name") is None: + prop_meta["name"] = k + else: + # additional properties will not have rest field, use the wire name as xml name + prop_meta = {"name": k} + + # Propagate model namespace to properties only for old-style "ns"-keyed models. + # DPG-generated models use the "namespace" key and explicitly declare namespace on + # each property that needs it, so propagation is intentionally skipped for them. + if prop_meta.get("ns") is None and model_meta.get("ns"): + prop_meta["ns"] = model_meta.get("ns") + prop_meta["prefix"] = model_meta.get("prefix") + + if prop_meta.get("unwrapped", False): + # unwrapped could only set on array + wrapped_element.extend(_get_element(v, exclude_readonly, prop_meta)) + elif prop_meta.get("text", False): + # text could only set on primitive type + wrapped_element.text = _get_primitive_type_value(v) + elif prop_meta.get("attribute", False): + _set_xml_attribute(wrapped_element, k, v, prop_meta) + else: + # other wrapped prop element + wrapped_element.append(_get_wrapped_element(v, exclude_readonly, prop_meta)) + return wrapped_element + if isinstance(o, list): + return [_get_element(x, exclude_readonly, parent_meta) for x in o] # type: ignore + if isinstance(o, dict): + result = [] + _dict_ns = _get_xml_ns(parent_meta) if parent_meta else None + for k, v in o.items(): + result.append( + _get_wrapped_element( + v, + exclude_readonly, + { + "name": k, + "ns": _dict_ns, + "prefix": parent_meta.get("prefix") if parent_meta else None, + }, + ) + ) + return result + + # primitive case need to create element based on parent_meta + if parent_meta: + _items_ns = parent_meta.get("itemsNs") + if _items_ns is None: + _items_ns = _get_xml_ns(parent_meta) + return _get_wrapped_element( + o, + exclude_readonly, + { + "name": parent_meta.get("itemsName", parent_meta.get("name")), + "prefix": parent_meta.get("itemsPrefix", parent_meta.get("prefix")), + "ns": _items_ns, + }, + ) + + raise ValueError("Could not serialize value into xml: " + o) + + +def _get_wrapped_element( + v: typing.Any, + exclude_readonly: bool, + meta: typing.Optional[dict[str, typing.Any]], +) -> ET.Element: + _meta_ns = _get_xml_ns(meta) if meta else None + wrapped_element = _create_xml_element( + meta.get("name") if meta else None, meta.get("prefix") if meta else None, _meta_ns + ) + if isinstance(v, (dict, list)): + wrapped_element.extend(_get_element(v, exclude_readonly, meta)) + elif _is_model(v): + _get_element(v, exclude_readonly, meta, wrapped_element) + else: + wrapped_element.text = _get_primitive_type_value(v) + return wrapped_element # type: ignore[no-any-return] + + +def _get_primitive_type_value(v) -> str: + if v is True: + return "true" + if v is False: + return "false" + if isinstance(v, _Null): + return "" + return str(v) + + +def _safe_register_namespace(prefix: str, ns: str) -> None: + """Register an XML namespace prefix, handling reserved prefix patterns. + + Some prefixes (e.g. 'ns2') match Python's reserved 'ns\\d+' pattern used for + auto-generated prefixes, causing register_namespace to raise ValueError. + Falls back to directly registering in the internal namespace map. + + :param str prefix: The namespace prefix to register. + :param str ns: The namespace URI. + """ + try: + ET.register_namespace(prefix, ns) + except ValueError: + _ns_map = getattr(ET, "_namespace_map", None) + if _ns_map is not None: + _ns_map[ns] = prefix + + +def _create_xml_element( + tag: typing.Any, prefix: typing.Optional[str] = None, ns: typing.Optional[str] = None +) -> ET.Element: + if prefix and ns: + _safe_register_namespace(prefix, ns) + if ns: + return ET.Element("{" + ns + "}" + tag) + return ET.Element(tag) + + +def _deserialize_xml( + deserializer: typing.Any, + value: str, +) -> typing.Any: + element = ET.fromstring(value) # nosec + return _deserialize(deserializer, element) + + +def _convert_element(e: ET.Element): + # dict case + if len(e.attrib) > 0 or len({child.tag for child in e}) > 1: + dict_result: dict[str, typing.Any] = {} + for child in e: + if dict_result.get(child.tag) is not None: + if isinstance(dict_result[child.tag], list): + dict_result[child.tag].append(_convert_element(child)) + else: + dict_result[child.tag] = [dict_result[child.tag], _convert_element(child)] + else: + dict_result[child.tag] = _convert_element(child) + dict_result.update(e.attrib) + return dict_result + # array case + if len(e) > 0: + array_result: list[typing.Any] = [] + for child in e: + array_result.append(_convert_element(child)) + return array_result + # primitive case + return e.text diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/_serialization.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/_utils/serialization.py similarity index 81% 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..954bf7ebffa7 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) Python 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 @@ -39,7 +21,6 @@ import sys import codecs from typing import ( - Dict, Any, cast, Optional, @@ -48,11 +29,7 @@ IO, Mapping, Callable, - TypeVar, MutableMapping, - Type, - List, - Mapping, ) try: @@ -66,9 +43,13 @@ from azure.core.exceptions import DeserializationError, SerializationError from azure.core.serialization import NULL as CoreNull +if sys.version_info >= (3, 11): + from typing import Self +else: + from typing_extensions import Self + _BOM = codecs.BOM_UTF8.decode(encoding="utf-8") -ModelType = TypeVar("ModelType", bound="Model") JSON = MutableMapping[str, Any] @@ -91,6 +72,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 +95,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 +127,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 +138,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 +167,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: + self.additional_properties: Optional[dict[str, Any]] = {} + 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 +246,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 +282,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,12 +306,14 @@ 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, keep_readonly: bool = True, - key_transformer: Callable[[str, Dict[str, Any], Any], Any] = attribute_transformer, + key_transformer: Callable[[str, dict[str, Any], Any], Any] = attribute_transformer, **kwargs: Any ) -> JSON: """Return a dict that can be serialized using json.dump. @@ -378,12 +342,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 +360,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, + 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 +392,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 +416,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 |= 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 +473,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 +514,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, @@ -554,17 +530,20 @@ def __init__(self, classes: Optional[Mapping[str, type]] = None): "[]": self.serialize_iter, "{}": self.serialize_dict, } - self.dependencies: Dict[str, type] = dict(classes) if classes else {} + self.dependencies: dict[str, type] = dict(classes) if classes else {} 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,17 +569,19 @@ 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"] == "": if target_obj.additional_properties is not None: - serialized.update(target_obj.additional_properties) + serialized |= target_obj.additional_properties continue try: @@ -631,7 +612,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 +644,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 +683,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 +692,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 +710,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 +740,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 +762,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,12 +786,12 @@ 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 # It has to be a subclass of Enum anyway - enum_type = self.dependencies.get(data_type, data.__class__) + enum_type = self.dependencies.get(data_type, cast(type, data.__class__)) if issubclass(enum_type, Enum): return Serializer.serialize_enum(data, enum_obj=enum_type) @@ -819,11 +802,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 +821,33 @@ 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 + :raises TypeError: raise if data_type is not one of str, int, float, bool. """ custom_serializer = cls._get_custom_serializers(data_type, **kwargs) if custom_serializer: return custom_serializer(data) if data_type == "str": return cls.serialize_unicode(data) - return eval(data_type)(data) # nosec + if data_type == "int": + return int(data) + if data_type == "float": + return float(data) + if data_type == "bool": + return bool(data) + raise TypeError("Unknown basic data type: {}".format(data_type)) @classmethod def serialize_unicode(cls, data): """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 +861,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 +871,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 +932,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 +957,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 +965,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 +990,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 +1021,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 +1083,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 +1098,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 +1136,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 +1168,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,17 +1183,17 @@ 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 while "." in key: # Need the cast, as for some reasons "split" is typed as list[str | Any] - dict_keys = cast(List[str], _FLATTEN.split(key)) + dict_keys = cast(list[str], _FLATTEN.split(key)) if len(dict_keys) == 1: key = _decode_attribute_map_key(dict_keys[0]) break @@ -1209,7 +1208,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 +1231,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 +1290,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 +1342,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 +1364,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 +1373,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, @@ -1383,7 +1395,7 @@ def __init__(self, classes: Optional[Mapping[str, type]] = None): "duration": (isodate.Duration, datetime.timedelta), "iso-8601": (datetime.datetime), } - self.dependencies: Dict[str, type] = dict(classes) if classes else {} + self.dependencies: dict[str, type] = dict(classes) if classes else {} self.key_extractors = [rest_key_extractor, xml_key_extractor] # Additional properties only works if the "rest_key_extractor" is used to # extract the keys. Making it to work whatever the key extractor is too much @@ -1399,27 +1411,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 +1452,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 +1488,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 +1516,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 +1529,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 +1544,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 +1567,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 +1596,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 +1633,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 +1656,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 +1680,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 +1704,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 +1715,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 +1755,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 +1766,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 or data_type is not one of str, int, float, bool. """ # If we're here, data is supposed to be a basic type. # If it's still an XML node, take the text @@ -1741,24 +1778,27 @@ 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 + if data_type == "int": + return int(attr) + if data_type == "float": + return float(attr) + raise TypeError("Unknown basic data type: {}".format(data_type)) @staticmethod def deserialize_unicode(data): @@ -1766,6 +1806,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 +1820,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 +1832,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 +1843,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 +1861,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 +1874,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 +1890,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 +1907,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 +1920,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 +1931,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 +1954,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 +1969,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 +2022,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 +2030,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 +2042,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 53% 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..35c9c836f85f 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 @@ -1,28 +1,25 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from 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/_validation.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/_validation.py new file mode 100644 index 000000000000..f5af3a4eb8a2 --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/_validation.py @@ -0,0 +1,66 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import functools + + +def api_version_validation(**kwargs): + params_added_on = kwargs.pop("params_added_on", {}) + method_added_on = kwargs.pop("method_added_on", "") + api_versions_list = kwargs.pop("api_versions_list", []) + + def _index_with_default(value: str, default: int = -1) -> int: + """Get the index of value in lst, or return default if not found. + + :param value: The value to search for in the api_versions_list. + :type value: str + :param default: The default value to return if the value is not found. + :type default: int + :return: The index of the value in the list, or the default value if not found. + :rtype: int + """ + try: + return api_versions_list.index(value) + except ValueError: + return default + + def decorator(func): + @functools.wraps(func) + def wrapper(*args, **kwargs): + try: + # this assumes the client has an _api_version attribute + client = args[0] + client_api_version = client._config.api_version # pylint: disable=protected-access + except AttributeError: + return func(*args, **kwargs) + + if _index_with_default(method_added_on) > _index_with_default(client_api_version): + raise ValueError( + f"'{func.__name__}' is not available in API version " + f"{client_api_version}. Pass service API version {method_added_on} or newer to your client." + ) + + unsupported = { + parameter: api_version + for api_version, parameters in params_added_on.items() + for parameter in parameters + if parameter in kwargs and _index_with_default(api_version) > _index_with_default(client_api_version) + } + if unsupported: + raise ValueError( + "".join( + [ + f"'{param}' is not available in API version {client_api_version}. " + f"Use service API version {version} or newer.\n" + for param, version in unsupported.items() + ] + ) + ) + return func(*args, **kwargs) + + return wrapper + + return decorator diff --git a/sdk/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..2b8e66c6bc52 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/_version.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/_version.py @@ -2,8 +2,8 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "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..12376979086b 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 @@ -2,15 +2,21 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._cdn_management_client import CdnManagementClient +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._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/_client.py similarity index 78% rename from sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/_cdn_management_client.py rename to sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/_client.py index d0f896981425..2436d94984a6 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/_client.py @@ -2,20 +2,22 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Awaitable, TYPE_CHECKING +import sys +from typing import Any, Awaitable, Optional, TYPE_CHECKING, cast 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, @@ -23,7 +25,6 @@ AFDOriginGroupsOperations, AFDOriginsOperations, AFDProfilesOperations, - CdnManagementClientOperationsMixin, CustomDomainsOperations, EdgeNodesOperations, EndpointsOperations, @@ -40,22 +41,27 @@ RulesOperations, SecretsOperations, SecurityPoliciesOperations, + _CdnManagementClientOperationsMixin, ) +if sys.version_info >= (3, 11): + from typing import Self +else: + from typing_extensions import Self # type: ignore + if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports + from azure.core import AzureClouds from azure.core.credentials_async import AsyncTokenCredential -class CdnManagementClient( - CdnManagementClientOperationsMixin -): # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes - """Cdn Management Client. +class CdnManagementClient(_CdnManagementClientOperationsMixin): # pylint: disable=too-many-instance-attributes + """Use these APIs to manage Azure Front Door and CDN resources through the Azure Resource Manager. + You must make sure that requests made to these resources are secure. - :ivar afd_profiles: AFDProfilesOperations operations - :vartype afd_profiles: azure.mgmt.cdn.aio.operations.AFDProfilesOperations - :ivar afd_custom_domains: AFDCustomDomainsOperations operations - :vartype afd_custom_domains: azure.mgmt.cdn.aio.operations.AFDCustomDomainsOperations + :ivar operations: Operations operations + :vartype operations: azure.mgmt.cdn.aio.operations.Operations + :ivar profiles: ProfilesOperations operations + :vartype profiles: azure.mgmt.cdn.aio.operations.ProfilesOperations :ivar afd_endpoints: AFDEndpointsOperations operations :vartype afd_endpoints: azure.mgmt.cdn.aio.operations.AFDEndpointsOperations :ivar afd_origin_groups: AFDOriginGroupsOperations operations @@ -72,10 +78,6 @@ class CdnManagementClient( :vartype security_policies: azure.mgmt.cdn.aio.operations.SecurityPoliciesOperations :ivar secrets: SecretsOperations operations :vartype secrets: azure.mgmt.cdn.aio.operations.SecretsOperations - :ivar log_analytics: LogAnalyticsOperations operations - :vartype log_analytics: azure.mgmt.cdn.aio.operations.LogAnalyticsOperations - :ivar profiles: ProfilesOperations operations - :vartype profiles: azure.mgmt.cdn.aio.operations.ProfilesOperations :ivar endpoints: EndpointsOperations operations :vartype endpoints: azure.mgmt.cdn.aio.operations.EndpointsOperations :ivar origins: OriginsOperations operations @@ -84,24 +86,32 @@ class CdnManagementClient( :vartype origin_groups: azure.mgmt.cdn.aio.operations.OriginGroupsOperations :ivar custom_domains: CustomDomainsOperations operations :vartype custom_domains: azure.mgmt.cdn.aio.operations.CustomDomainsOperations + :ivar afd_custom_domains: AFDCustomDomainsOperations operations + :vartype afd_custom_domains: azure.mgmt.cdn.aio.operations.AFDCustomDomainsOperations + :ivar afd_profiles: AFDProfilesOperations operations + :vartype afd_profiles: azure.mgmt.cdn.aio.operations.AFDProfilesOperations + :ivar log_analytics: LogAnalyticsOperations operations + :vartype log_analytics: azure.mgmt.cdn.aio.operations.LogAnalyticsOperations + :ivar policies: PoliciesOperations operations + :vartype policies: azure.mgmt.cdn.aio.operations.PoliciesOperations :ivar resource_usage: ResourceUsageOperations operations :vartype resource_usage: azure.mgmt.cdn.aio.operations.ResourceUsageOperations - :ivar operations: Operations operations - :vartype operations: azure.mgmt.cdn.aio.operations.Operations :ivar edge_nodes: EdgeNodesOperations operations :vartype edge_nodes: azure.mgmt.cdn.aio.operations.EdgeNodesOperations - :ivar policies: PoliciesOperations operations - :vartype policies: azure.mgmt.cdn.aio.operations.PoliciesOperations :ivar managed_rule_sets: ManagedRuleSetsOperations operations :vartype managed_rule_sets: azure.mgmt.cdn.aio.operations.ManagedRuleSetsOperations - :param credential: Credential needed for the client to connect to Azure. Required. + :param credential: Credential used to authenticate requests to the service. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: Azure Subscription ID. Required. + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". + :param base_url: Service host. Default value is None. :type base_url: str - :keyword api_version: Api Version. Default value is "2024-02-01". Note that overriding this - default value may result in unsupported behavior. + :keyword cloud_setting: The cloud setting for which to get the ARM endpoint. Default value is + None. + :paramtype cloud_setting: ~azure.core.AzureClouds + :keyword api_version: The API version to use for this operation. Known values are "2025-12-01" + and None. Default value is None. If not set, the operation's default API version will be used. + Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. @@ -111,12 +121,26 @@ def __init__( self, credential: "AsyncTokenCredential", subscription_id: str, - base_url: str = "https://management.azure.com", + base_url: Optional[str] = None, + *, + cloud_setting: Optional["AzureClouds"] = None, **kwargs: Any ) -> None: + _endpoint = "{endpoint}" + _cloud = cloud_setting or settings.current.azure_cloud # type: ignore + _endpoints = get_arm_endpoints(_cloud) + if not base_url: + 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, + base_url=cast(str, base_url), + cloud_setting=cloud_setting, + credential_scopes=credential_scopes, + **kwargs ) + _policies = kwargs.pop("policies", None) if _policies is None: _policies = [ @@ -135,16 +159,15 @@ 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, _endpoint), policies=_policies, **kwargs + ) - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) + self._serialize = Serializer() + self._deserialize = Deserializer() self._serialize.client_side_validation = False - self.afd_profiles = AFDProfilesOperations(self._client, self._config, self._serialize, self._deserialize) - self.afd_custom_domains = AFDCustomDomainsOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.profiles = ProfilesOperations(self._client, self._config, self._serialize, self._deserialize) self.afd_endpoints = AFDEndpointsOperations(self._client, self._config, self._serialize, self._deserialize) self.afd_origin_groups = AFDOriginGroupsOperations( self._client, self._config, self._serialize, self._deserialize @@ -157,21 +180,23 @@ def __init__( self._client, self._config, self._serialize, self._deserialize ) self.secrets = SecretsOperations(self._client, self._config, self._serialize, self._deserialize) - self.log_analytics = LogAnalyticsOperations(self._client, self._config, self._serialize, self._deserialize) - self.profiles = ProfilesOperations(self._client, self._config, self._serialize, self._deserialize) self.endpoints = EndpointsOperations(self._client, self._config, self._serialize, self._deserialize) self.origins = OriginsOperations(self._client, self._config, self._serialize, self._deserialize) self.origin_groups = OriginGroupsOperations(self._client, self._config, self._serialize, self._deserialize) self.custom_domains = CustomDomainsOperations(self._client, self._config, self._serialize, self._deserialize) + self.afd_custom_domains = AFDCustomDomainsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.afd_profiles = AFDProfilesOperations(self._client, self._config, self._serialize, self._deserialize) + self.log_analytics = LogAnalyticsOperations(self._client, self._config, self._serialize, self._deserialize) + self.policies = PoliciesOperations(self._client, self._config, self._serialize, self._deserialize) self.resource_usage = ResourceUsageOperations(self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) self.edge_nodes = EdgeNodesOperations(self._client, self._config, self._serialize, self._deserialize) - self.policies = PoliciesOperations(self._client, self._config, self._serialize, self._deserialize) self.managed_rule_sets = ManagedRuleSetsOperations( self._client, self._config, self._serialize, self._deserialize ) - def _send_request( + def send_request( self, request: HttpRequest, *, stream: bool = False, **kwargs: Any ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. @@ -179,7 +204,7 @@ def _send_request( >>> from azure.core.rest import HttpRequest >>> request = HttpRequest("GET", "https://www.example.org/") - >>> response = await client._send_request(request) + >>> response = await client.send_request(request) For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request @@ -192,13 +217,17 @@ def _send_request( """ request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore async def close(self) -> None: 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..dbe933abb159 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 @@ -2,11 +2,11 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, TYPE_CHECKING +from typing import Any, Optional, TYPE_CHECKING from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy @@ -14,27 +14,40 @@ from .._version import VERSION if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports + from azure.core import AzureClouds 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 attributes. - :param credential: Credential needed for the client to connect to Azure. Required. + :param credential: Credential used to authenticate requests to the service. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: Azure Subscription ID. Required. + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. :type subscription_id: str - :keyword api_version: Api Version. Default value is "2024-02-01". Note that overriding this - default value may result in unsupported behavior. + :param base_url: Service host. Default value is "https://management.azure.com". + :type base_url: str + :param cloud_setting: The cloud setting for which to get the ARM endpoint. Default value is + None. + :type cloud_setting: ~azure.core.AzureClouds + :keyword api_version: The API version to use for this operation. Known values are "2025-12-01" + and None. Default value is None. If not set, the operation's default API version will be used. + 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") + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + cloud_setting: Optional["AzureClouds"] = None, + **kwargs: Any + ) -> None: + api_version: str = kwargs.pop("api_version", "2025-12-01") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -43,6 +56,8 @@ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **k self.credential = credential self.subscription_id = subscription_id + self.base_url = base_url + self.cloud_setting = cloud_setting self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-cdn/{}".format(VERSION)) diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/_patch.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/_patch.py index 17dbc073e01b..ea765788358a 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/_patch.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/_patch.py @@ -1,32 +1,20 @@ # coding=utf-8 # -------------------------------------------------------------------------- -# # Copyright (c) Microsoft Corporation. All rights reserved. -# -# The MIT License (MIT) -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the ""Software""), to -# deal in the Software without restriction, including without limitation the -# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -# sell copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -# IN THE SOFTWARE. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # -------------------------------------------------------------------------- +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" + +__all__: list[str] = [] # Add all objects you want publicly available to users at this package level -# This file is used for handwritten extensions to the generated code. Example: -# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/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..cdd6e66a84f4 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 @@ -2,41 +2,46 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -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 ._operations import Operations # type: ignore +from ._operations import ProfilesOperations # type: ignore +from ._operations import AFDEndpointsOperations # type: ignore +from ._operations import AFDOriginGroupsOperations # type: ignore +from ._operations import AFDOriginsOperations # type: ignore +from ._operations import RoutesOperations # type: ignore +from ._operations import RuleSetsOperations # type: ignore +from ._operations import RulesOperations # type: ignore +from ._operations import SecurityPoliciesOperations # type: ignore +from ._operations import SecretsOperations # type: ignore +from ._operations import EndpointsOperations # type: ignore +from ._operations import OriginsOperations # type: ignore +from ._operations import OriginGroupsOperations # type: ignore +from ._operations import CustomDomainsOperations # type: ignore +from ._operations import AFDCustomDomainsOperations # type: ignore +from ._operations import AFDProfilesOperations # type: ignore +from ._operations import LogAnalyticsOperations # type: ignore +from ._operations import PoliciesOperations # type: ignore +from ._operations import ResourceUsageOperations # type: ignore +from ._operations import EdgeNodesOperations # type: ignore +from ._operations import ManagedRuleSetsOperations # type: ignore +from ._operations import _CdnManagementClientOperationsMixin # type: ignore # pylint: disable=unused-import 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__ = [ - "CdnManagementClientOperationsMixin", - "AFDProfilesOperations", - "AFDCustomDomainsOperations", + "Operations", + "ProfilesOperations", "AFDEndpointsOperations", "AFDOriginGroupsOperations", "AFDOriginsOperations", @@ -45,17 +50,17 @@ "RulesOperations", "SecurityPoliciesOperations", "SecretsOperations", - "LogAnalyticsOperations", - "ProfilesOperations", "EndpointsOperations", "OriginsOperations", "OriginGroupsOperations", "CustomDomainsOperations", + "AFDCustomDomainsOperations", + "AFDProfilesOperations", + "LogAnalyticsOperations", + "PoliciesOperations", "ResourceUsageOperations", - "Operations", "EdgeNodesOperations", - "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 deleted file mode 100644 index 92e5deeb37d6..000000000000 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_afd_custom_domains_operations.py +++ /dev/null @@ -1,869 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._afd_custom_domains_operations import ( - build_create_request, - build_delete_request, - build_get_request, - build_list_by_profile_request, - build_refresh_validation_token_request, - build_update_request, -) -from .._vendor import CdnManagementClientMixinABC - -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 AFDCustomDomainsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.cdn.aio.CdnManagementClient`'s - :attr:`afd_custom_domains` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_profile( - self, resource_group_name: str, profile_name: str, **kwargs: Any - ) -> AsyncIterable["_models.AFDDomain"]: - """Lists existing AzureFrontDoor domains. - - :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. - :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] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - 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]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_profile_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 = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("AFDDomainListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, resource_group_name: str, profile_name: str, custom_domain_name: str, **kwargs: Any - ) -> _models.AFDDomain: - """Gets an existing AzureFrontDoor domain with the specified domain name under the specified - subscription, resource group and 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. - :type profile_name: str - :param custom_domain_name: Name of the domain under the profile which is unique globally. - Required. - :type custom_domain_name: str - :return: AFDDomain or the result of cls(response) - :rtype: ~azure.mgmt.cdn.models.AFDDomain - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.AFDDomain] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - custom_domain_name=custom_domain_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AFDDomain", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_initial( - self, - resource_group_name: str, - profile_name: str, - custom_domain_name: str, - custom_domain: Union[_models.AFDDomain, IO[bytes]], - **kwargs: Any - ) -> _models.AFDDomain: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_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.AFDDomain] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(custom_domain, (IOBase, bytes)): - _content = custom_domain - else: - _json = self._serialize.body(custom_domain, "AFDDomain") - - _request = build_create_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - custom_domain_name=custom_domain_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201, 202]: - 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) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create( - self, - resource_group_name: str, - profile_name: str, - custom_domain_name: str, - custom_domain: _models.AFDDomain, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.AFDDomain]: - """Creates a new domain within the specified 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. - :type profile_name: str - :param custom_domain_name: Name of the domain under the profile which is unique globally. - Required. - :type custom_domain_name: str - :param custom_domain: Domain properties. Required. - :type custom_domain: ~azure.mgmt.cdn.models.AFDDomain - :keyword content_type: Body Parameter 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 AFDDomain or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.AFDDomain] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create( - self, - resource_group_name: str, - profile_name: str, - custom_domain_name: str, - custom_domain: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.AFDDomain]: - """Creates a new domain within the specified 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. - :type profile_name: str - :param custom_domain_name: Name of the domain under the profile which is unique globally. - Required. - :type custom_domain_name: str - :param custom_domain: Domain properties. Required. - :type custom_domain: IO[bytes] - :keyword content_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 AFDDomain or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.AFDDomain] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create( - self, - resource_group_name: str, - profile_name: str, - custom_domain_name: str, - custom_domain: Union[_models.AFDDomain, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.AFDDomain]: - """Creates a new domain within the specified 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. - :type profile_name: str - :param custom_domain_name: Name of the domain under the profile which is unique globally. - Required. - :type custom_domain_name: str - :param custom_domain: Domain properties. Is either a AFDDomain type or a IO[bytes] type. - Required. - :type custom_domain: ~azure.mgmt.cdn.models.AFDDomain or IO[bytes] - :return: An instance of AsyncLROPoller that returns either AFDDomain or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.AFDDomain] - :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.AFDDomain] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._create_initial( - resource_group_name=resource_group_name, - profile_name=profile_name, - custom_domain_name=custom_domain_name, - custom_domain=custom_domain, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("AFDDomain", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, - AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.AFDDomain].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.AFDDomain]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _update_initial( - self, - resource_group_name: str, - profile_name: str, - custom_domain_name: str, - custom_domain_update_properties: Union[_models.AFDDomainUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> _models.AFDDomain: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_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.AFDDomain] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(custom_domain_update_properties, (IOBase, bytes)): - _content = custom_domain_update_properties - else: - _json = self._serialize.body(custom_domain_update_properties, "AFDDomainUpdateParameters") - - _request = build_update_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - custom_domain_name=custom_domain_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.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) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_update( - self, - resource_group_name: str, - profile_name: str, - custom_domain_name: str, - custom_domain_update_properties: _models.AFDDomainUpdateParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.AFDDomain]: - """Updates an existing domain within a 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. - :type profile_name: str - :param custom_domain_name: Name of the domain under the profile which is unique globally. - Required. - :type custom_domain_name: str - :param custom_domain_update_properties: Domain properties. Required. - :type custom_domain_update_properties: ~azure.mgmt.cdn.models.AFDDomainUpdateParameters - :keyword content_type: Body Parameter 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 AFDDomain or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.AFDDomain] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - profile_name: str, - custom_domain_name: str, - custom_domain_update_properties: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.AFDDomain]: - """Updates an existing domain within a 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. - :type profile_name: str - :param custom_domain_name: Name of the domain under the profile which is unique globally. - Required. - :type custom_domain_name: str - :param custom_domain_update_properties: Domain properties. Required. - :type custom_domain_update_properties: IO[bytes] - :keyword content_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 AFDDomain or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.AFDDomain] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - profile_name: str, - custom_domain_name: str, - custom_domain_update_properties: Union[_models.AFDDomainUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.AFDDomain]: - """Updates an existing domain within a 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. - :type profile_name: str - :param custom_domain_name: Name of the domain under the profile which is unique globally. - Required. - :type custom_domain_name: str - :param custom_domain_update_properties: Domain properties. Is either a - AFDDomainUpdateParameters type or a IO[bytes] type. Required. - :type custom_domain_update_properties: ~azure.mgmt.cdn.models.AFDDomainUpdateParameters or - IO[bytes] - :return: An instance of AsyncLROPoller that returns either AFDDomain or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.AFDDomain] - :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.AFDDomain] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._update_initial( - resource_group_name=resource_group_name, - profile_name=profile_name, - custom_domain_name=custom_domain_name, - custom_domain_update_properties=custom_domain_update_properties, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("AFDDomain", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, - AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.AFDDomain].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.AFDDomain]( - 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, custom_domain_name: str, **kwargs: Any - ) -> None: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - custom_domain_name=custom_domain_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - 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 == 202: - response_headers["location"] = self._deserialize("str", response.headers.get("location")) - - if cls: - return cls(pipeline_response, None, response_headers) # type: ignore - - @distributed_trace_async - async def begin_delete( - self, resource_group_name: str, profile_name: str, custom_domain_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes an existing AzureFrontDoor domain with the specified domain name under the specified - subscription, resource group and 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. - :type profile_name: str - :param custom_domain_name: Name of the domain under the profile which is unique globally. - Required. - :type custom_domain_name: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_initial( # type: ignore - resource_group_name=resource_group_name, - profile_name=profile_name, - custom_domain_name=custom_domain_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, - AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _refresh_validation_token_initial( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, profile_name: str, custom_domain_name: str, **kwargs: Any - ) -> None: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_refresh_validation_token_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - custom_domain_name=custom_domain_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, 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")) - - if cls: - return cls(pipeline_response, None, response_headers) # type: ignore - - @distributed_trace_async - async def begin_refresh_validation_token( - self, resource_group_name: str, profile_name: str, custom_domain_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Updates the domain 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. - :type profile_name: str - :param custom_domain_name: Name of the domain under the profile which is unique globally. - Required. - :type custom_domain_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._refresh_validation_token_initial( # type: ignore - resource_group_name=resource_group_name, - profile_name=profile_name, - custom_domain_name=custom_domain_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, - AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore 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 deleted file mode 100644 index d9fde2ce9580..000000000000 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_afd_endpoints_operations.py +++ /dev/null @@ -1,1219 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._afd_endpoints_operations import ( - build_create_request, - build_delete_request, - build_get_request, - build_list_by_profile_request, - build_list_resource_usage_request, - build_purge_content_request, - build_update_request, - build_validate_custom_domain_request, -) -from .._vendor import CdnManagementClientMixinABC - -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 AFDEndpointsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.cdn.aio.CdnManagementClient`'s - :attr:`afd_endpoints` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_profile( - self, resource_group_name: str, profile_name: str, **kwargs: Any - ) -> AsyncIterable["_models.AFDEndpoint"]: - """Lists existing AzureFrontDoor endpoints. - - :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. - :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] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - 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]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_profile_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 = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("AFDEndpointListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, resource_group_name: str, profile_name: str, endpoint_name: str, **kwargs: Any - ) -> _models.AFDEndpoint: - """Gets an existing AzureFrontDoor endpoint with the specified endpoint name under the specified - subscription, resource group and 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. - :type profile_name: str - :param endpoint_name: Name of the endpoint under the profile which is unique globally. - Required. - :type endpoint_name: str - :return: AFDEndpoint or the result of cls(response) - :rtype: ~azure.mgmt.cdn.models.AFDEndpoint - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.AFDEndpoint] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AFDEndpoint", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_initial( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - endpoint: Union[_models.AFDEndpoint, IO[bytes]], - **kwargs: Any - ) -> _models.AFDEndpoint: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_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.AFDEndpoint] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(endpoint, (IOBase, bytes)): - _content = endpoint - else: - _json = self._serialize.body(endpoint, "AFDEndpoint") - - _request = build_create_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201, 202]: - 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) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - endpoint: _models.AFDEndpoint, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.AFDEndpoint]: - """Creates a new AzureFrontDoor endpoint with the specified endpoint name under the specified - subscription, resource group and 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. - :type profile_name: str - :param endpoint_name: Name of the endpoint under the profile which is unique globally. - Required. - :type endpoint_name: str - :param endpoint: Endpoint properties. Required. - :type endpoint: ~azure.mgmt.cdn.models.AFDEndpoint - :keyword content_type: Body Parameter 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 AFDEndpoint or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.AFDEndpoint] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - endpoint: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.AFDEndpoint]: - """Creates a new AzureFrontDoor endpoint with the specified endpoint name under the specified - subscription, resource group and 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. - :type profile_name: str - :param endpoint_name: Name of the endpoint under the profile which is unique globally. - Required. - :type endpoint_name: str - :param endpoint: Endpoint properties. Required. - :type endpoint: IO[bytes] - :keyword content_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 AFDEndpoint or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.AFDEndpoint] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - endpoint: Union[_models.AFDEndpoint, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.AFDEndpoint]: - """Creates a new AzureFrontDoor endpoint with the specified endpoint name under the specified - subscription, resource group and 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. - :type profile_name: str - :param endpoint_name: Name of the endpoint under the profile which is unique globally. - Required. - :type endpoint_name: str - :param endpoint: Endpoint properties. Is either a AFDEndpoint type or a IO[bytes] type. - Required. - :type endpoint: ~azure.mgmt.cdn.models.AFDEndpoint or IO[bytes] - :return: An instance of AsyncLROPoller that returns either AFDEndpoint or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.AFDEndpoint] - :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.AFDEndpoint] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._create_initial( - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - endpoint=endpoint, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("AFDEndpoint", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, - AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.AFDEndpoint].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.AFDEndpoint]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _update_initial( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - endpoint_update_properties: Union[_models.AFDEndpointUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> _models.AFDEndpoint: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_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.AFDEndpoint] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(endpoint_update_properties, (IOBase, bytes)): - _content = endpoint_update_properties - else: - _json = self._serialize.body(endpoint_update_properties, "AFDEndpointUpdateParameters") - - _request = build_update_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.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) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_update( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - endpoint_update_properties: _models.AFDEndpointUpdateParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.AFDEndpoint]: - """Updates an existing AzureFrontDoor endpoint with the specified endpoint name under the - specified subscription, resource group and profile. Only tags can be updated after creating an - endpoint. To update origins, use the Update Origin operation. To update origin groups, use the - Update Origin group operation. To update domains, use the Update Custom Domain operation. - - :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. - :type profile_name: str - :param endpoint_name: Name of the endpoint under the profile which is unique globally. - Required. - :type endpoint_name: str - :param endpoint_update_properties: Endpoint update properties. Required. - :type endpoint_update_properties: ~azure.mgmt.cdn.models.AFDEndpointUpdateParameters - :keyword content_type: Body Parameter 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 AFDEndpoint or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.AFDEndpoint] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - endpoint_update_properties: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.AFDEndpoint]: - """Updates an existing AzureFrontDoor endpoint with the specified endpoint name under the - specified subscription, resource group and profile. Only tags can be updated after creating an - endpoint. To update origins, use the Update Origin operation. To update origin groups, use the - Update Origin group operation. To update domains, use the Update Custom Domain operation. - - :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. - :type profile_name: str - :param endpoint_name: Name of the endpoint under the profile which is unique globally. - Required. - :type endpoint_name: str - :param endpoint_update_properties: Endpoint update properties. Required. - :type endpoint_update_properties: IO[bytes] - :keyword content_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 AFDEndpoint or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.AFDEndpoint] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - endpoint_update_properties: Union[_models.AFDEndpointUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.AFDEndpoint]: - """Updates an existing AzureFrontDoor endpoint with the specified endpoint name under the - specified subscription, resource group and profile. Only tags can be updated after creating an - endpoint. To update origins, use the Update Origin operation. To update origin groups, use the - Update Origin group operation. To update domains, use the Update Custom Domain operation. - - :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. - :type profile_name: str - :param endpoint_name: Name of the endpoint under the profile which is unique globally. - Required. - :type endpoint_name: str - :param endpoint_update_properties: Endpoint update properties. Is either a - AFDEndpointUpdateParameters type or a IO[bytes] type. Required. - :type endpoint_update_properties: ~azure.mgmt.cdn.models.AFDEndpointUpdateParameters or - IO[bytes] - :return: An instance of AsyncLROPoller that returns either AFDEndpoint or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.AFDEndpoint] - :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.AFDEndpoint] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._update_initial( - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - endpoint_update_properties=endpoint_update_properties, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("AFDEndpoint", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, - AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.AFDEndpoint].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.AFDEndpoint]( - 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, endpoint_name: str, **kwargs: Any - ) -> None: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - 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 == 202: - response_headers["location"] = self._deserialize("str", response.headers.get("location")) - - if cls: - return cls(pipeline_response, None, response_headers) # type: ignore - - @distributed_trace_async - async def begin_delete( - self, resource_group_name: str, profile_name: str, endpoint_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes an existing AzureFrontDoor endpoint with the specified endpoint name under the - specified subscription, resource group and 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. - :type profile_name: str - :param endpoint_name: Name of the endpoint under the profile which is unique globally. - Required. - :type endpoint_name: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_initial( # type: ignore - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, - AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _purge_content_initial( # pylint: disable=inconsistent-return-statements - 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]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(contents, (IOBase, bytes)): - _content = contents - else: - _json = self._serialize.body(contents, "AfdPurgeParameters") - - _request = build_purge_content_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, 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")) - - if cls: - return cls(pipeline_response, None, response_headers) # type: ignore - - @overload - async def begin_purge_content( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - contents: _models.AfdPurgeParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Removes a content from AzureFrontDoor. - - :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. - :type profile_name: str - :param endpoint_name: Name of the endpoint under the profile which is unique globally. - Required. - :type endpoint_name: str - :param contents: The list of paths to the content and the list of linked domains to be purged. - Path can be a full URL, e.g. '/pictures/city.png' which removes a single file, or a directory - with a wildcard, e.g. '/pictures/*' which removes all folders and files in the directory. - Required. - :type contents: ~azure.mgmt.cdn.models.AfdPurgeParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_purge_content( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - contents: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Removes a content from AzureFrontDoor. - - :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. - :type profile_name: str - :param endpoint_name: Name of the endpoint under the profile which is unique globally. - Required. - :type endpoint_name: str - :param contents: The list of paths to the content and the list of linked domains to be purged. - Path can be a full URL, e.g. '/pictures/city.png' which removes a single file, or a directory - with a wildcard, e.g. '/pictures/*' which removes all folders and files in the directory. - Required. - :type contents: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_purge_content( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - contents: Union[_models.AfdPurgeParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Removes a content from AzureFrontDoor. - - :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. - :type profile_name: str - :param endpoint_name: Name of the endpoint under the profile which is unique globally. - Required. - :type endpoint_name: str - :param contents: The list of paths to the content and the list of linked domains to be purged. - Path can be a full URL, e.g. '/pictures/city.png' which removes a single file, or a directory - with a wildcard, e.g. '/pictures/*' which removes all folders and files in the directory. Is - either a AfdPurgeParameters type or a IO[bytes] type. Required. - :type contents: ~azure.mgmt.cdn.models.AfdPurgeParameters or IO[bytes] - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._purge_content_initial( # type: ignore - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - contents=contents, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, - AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def list_resource_usage( - self, resource_group_name: str, profile_name: str, endpoint_name: str, **kwargs: Any - ) -> AsyncIterable["_models.Usage"]: - """Checks the quota and actual usage of endpoints under the given Azure Front Door 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. - :type profile_name: str - :param endpoint_name: Name of the endpoint under the profile which is unique globally. - Required. - :type endpoint_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] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - 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]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_resource_usage_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("UsagesListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @overload - async def validate_custom_domain( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - custom_domain_properties: _models.ValidateCustomDomainInput, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ValidateCustomDomainOutput: - """Validates the custom domain mapping to ensure it maps to the correct Azure Front Door endpoint - in DNS. - - :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. - :type profile_name: str - :param endpoint_name: Name of the endpoint under the profile which is unique globally. - Required. - :type endpoint_name: str - :param custom_domain_properties: Custom domain to be validated. Required. - :type custom_domain_properties: ~azure.mgmt.cdn.models.ValidateCustomDomainInput - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: ValidateCustomDomainOutput or the result of cls(response) - :rtype: ~azure.mgmt.cdn.models.ValidateCustomDomainOutput - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def validate_custom_domain( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - custom_domain_properties: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ValidateCustomDomainOutput: - """Validates the custom domain mapping to ensure it maps to the correct Azure Front Door endpoint - in DNS. - - :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. - :type profile_name: str - :param endpoint_name: Name of the endpoint under the profile which is unique globally. - Required. - :type endpoint_name: str - :param custom_domain_properties: Custom domain to be validated. Required. - :type custom_domain_properties: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: ValidateCustomDomainOutput or the result of cls(response) - :rtype: ~azure.mgmt.cdn.models.ValidateCustomDomainOutput - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def validate_custom_domain( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - custom_domain_properties: Union[_models.ValidateCustomDomainInput, IO[bytes]], - **kwargs: Any - ) -> _models.ValidateCustomDomainOutput: - """Validates the custom domain mapping to ensure it maps to the correct Azure Front Door endpoint - in DNS. - - :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. - :type profile_name: str - :param endpoint_name: Name of the endpoint under the profile which is unique globally. - Required. - :type endpoint_name: str - :param custom_domain_properties: Custom domain to be validated. Is either a - ValidateCustomDomainInput type or a IO[bytes] type. Required. - :type custom_domain_properties: ~azure.mgmt.cdn.models.ValidateCustomDomainInput or IO[bytes] - :return: ValidateCustomDomainOutput or the result of cls(response) - :rtype: ~azure.mgmt.cdn.models.ValidateCustomDomainOutput - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_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.ValidateCustomDomainOutput] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(custom_domain_properties, (IOBase, bytes)): - _content = custom_domain_properties - else: - _json = self._serialize.body(custom_domain_properties, "ValidateCustomDomainInput") - - _request = build_validate_custom_domain_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ValidateCustomDomainOutput", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return 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 deleted file mode 100644 index c40286f25555..000000000000 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_afd_origin_groups_operations.py +++ /dev/null @@ -1,848 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._afd_origin_groups_operations import ( - build_create_request, - build_delete_request, - build_get_request, - build_list_by_profile_request, - build_list_resource_usage_request, - build_update_request, -) -from .._vendor import CdnManagementClientMixinABC - -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 AFDOriginGroupsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.cdn.aio.CdnManagementClient`'s - :attr:`afd_origin_groups` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_profile( - self, resource_group_name: str, profile_name: str, **kwargs: Any - ) -> AsyncIterable["_models.AFDOriginGroup"]: - """Lists all of the existing origin groups within a 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. - :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] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - 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]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_profile_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 = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("AFDOriginGroupListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, resource_group_name: str, profile_name: str, origin_group_name: str, **kwargs: Any - ) -> _models.AFDOriginGroup: - """Gets an existing origin group within a 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. - :type profile_name: str - :param origin_group_name: Name of the origin group which is unique within the endpoint. - Required. - :type origin_group_name: str - :return: AFDOriginGroup or the result of cls(response) - :rtype: ~azure.mgmt.cdn.models.AFDOriginGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.AFDOriginGroup] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - origin_group_name=origin_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AFDOriginGroup", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_initial( - self, - resource_group_name: str, - profile_name: str, - origin_group_name: str, - origin_group: Union[_models.AFDOriginGroup, IO[bytes]], - **kwargs: Any - ) -> _models.AFDOriginGroup: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_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.AFDOriginGroup] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(origin_group, (IOBase, bytes)): - _content = origin_group - else: - _json = self._serialize.body(origin_group, "AFDOriginGroup") - - _request = build_create_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - origin_group_name=origin_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201, 202]: - 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) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create( - self, - resource_group_name: str, - profile_name: str, - origin_group_name: str, - origin_group: _models.AFDOriginGroup, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.AFDOriginGroup]: - """Creates a new origin group within the specified 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. - :type profile_name: str - :param origin_group_name: Name of the origin group which is unique within the endpoint. - Required. - :type origin_group_name: str - :param origin_group: Origin group properties. Required. - :type origin_group: ~azure.mgmt.cdn.models.AFDOriginGroup - :keyword content_type: Body Parameter 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 AFDOriginGroup or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.AFDOriginGroup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create( - self, - resource_group_name: str, - profile_name: str, - origin_group_name: str, - origin_group: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.AFDOriginGroup]: - """Creates a new origin group within the specified 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. - :type profile_name: str - :param origin_group_name: Name of the origin group which is unique within the endpoint. - Required. - :type origin_group_name: str - :param origin_group: Origin group properties. Required. - :type origin_group: IO[bytes] - :keyword content_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 AFDOriginGroup or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.AFDOriginGroup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create( - self, - resource_group_name: str, - profile_name: str, - origin_group_name: str, - origin_group: Union[_models.AFDOriginGroup, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.AFDOriginGroup]: - """Creates a new origin group within the specified 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. - :type profile_name: str - :param origin_group_name: Name of the origin group which is unique within the endpoint. - Required. - :type origin_group_name: str - :param origin_group: Origin group properties. Is either a AFDOriginGroup type or a IO[bytes] - type. Required. - :type origin_group: ~azure.mgmt.cdn.models.AFDOriginGroup or IO[bytes] - :return: An instance of AsyncLROPoller that returns either AFDOriginGroup or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.AFDOriginGroup] - :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.AFDOriginGroup] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._create_initial( - resource_group_name=resource_group_name, - profile_name=profile_name, - origin_group_name=origin_group_name, - origin_group=origin_group, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("AFDOriginGroup", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, - AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.AFDOriginGroup].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.AFDOriginGroup]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _update_initial( - self, - resource_group_name: str, - profile_name: str, - origin_group_name: str, - origin_group_update_properties: Union[_models.AFDOriginGroupUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> _models.AFDOriginGroup: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_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.AFDOriginGroup] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(origin_group_update_properties, (IOBase, bytes)): - _content = origin_group_update_properties - else: - _json = self._serialize.body(origin_group_update_properties, "AFDOriginGroupUpdateParameters") - - _request = build_update_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - origin_group_name=origin_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.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) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_update( - self, - resource_group_name: str, - profile_name: str, - origin_group_name: str, - origin_group_update_properties: _models.AFDOriginGroupUpdateParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.AFDOriginGroup]: - """Updates an existing origin group within a 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. - :type profile_name: str - :param origin_group_name: Name of the origin group which is unique within the profile. - Required. - :type origin_group_name: str - :param origin_group_update_properties: Origin group properties. Required. - :type origin_group_update_properties: ~azure.mgmt.cdn.models.AFDOriginGroupUpdateParameters - :keyword content_type: Body Parameter 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 AFDOriginGroup or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.AFDOriginGroup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - profile_name: str, - origin_group_name: str, - origin_group_update_properties: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.AFDOriginGroup]: - """Updates an existing origin group within a 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. - :type profile_name: str - :param origin_group_name: Name of the origin group which is unique within the profile. - Required. - :type origin_group_name: str - :param origin_group_update_properties: Origin group properties. Required. - :type origin_group_update_properties: IO[bytes] - :keyword content_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 AFDOriginGroup or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.AFDOriginGroup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - profile_name: str, - origin_group_name: str, - origin_group_update_properties: Union[_models.AFDOriginGroupUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.AFDOriginGroup]: - """Updates an existing origin group within a 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. - :type profile_name: str - :param origin_group_name: Name of the origin group which is unique within the profile. - Required. - :type origin_group_name: str - :param origin_group_update_properties: Origin group properties. Is either a - AFDOriginGroupUpdateParameters type or a IO[bytes] type. Required. - :type origin_group_update_properties: ~azure.mgmt.cdn.models.AFDOriginGroupUpdateParameters or - IO[bytes] - :return: An instance of AsyncLROPoller that returns either AFDOriginGroup or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.AFDOriginGroup] - :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.AFDOriginGroup] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._update_initial( - resource_group_name=resource_group_name, - profile_name=profile_name, - origin_group_name=origin_group_name, - origin_group_update_properties=origin_group_update_properties, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("AFDOriginGroup", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, - AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.AFDOriginGroup].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.AFDOriginGroup]( - 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, origin_group_name: str, **kwargs: Any - ) -> None: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - origin_group_name=origin_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - 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 == 202: - response_headers["location"] = self._deserialize("str", response.headers.get("location")) - - if cls: - return cls(pipeline_response, None, response_headers) # type: ignore - - @distributed_trace_async - async def begin_delete( - self, resource_group_name: str, profile_name: str, origin_group_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes an existing origin group within a 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. - :type profile_name: str - :param origin_group_name: Name of the origin group which is unique within the profile. - Required. - :type origin_group_name: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_initial( # type: ignore - resource_group_name=resource_group_name, - profile_name=profile_name, - origin_group_name=origin_group_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, - AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def list_resource_usage( - self, resource_group_name: str, profile_name: str, origin_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.Usage"]: - """Checks the quota and actual usage of endpoints under the given Azure Front Door 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. - :type profile_name: str - :param origin_group_name: Name of the origin group which is unique within the endpoint. - Required. - :type origin_group_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] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - 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]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_resource_usage_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - origin_group_name=origin_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("UsagesListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) 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 deleted file mode 100644 index 49f79d669942..000000000000 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_afd_origins_operations.py +++ /dev/null @@ -1,790 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._afd_origins_operations import ( - build_create_request, - build_delete_request, - build_get_request, - build_list_by_origin_group_request, - build_update_request, -) -from .._vendor import CdnManagementClientMixinABC - -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 AFDOriginsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.cdn.aio.CdnManagementClient`'s - :attr:`afd_origins` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_origin_group( - self, resource_group_name: str, profile_name: str, origin_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.AFDOrigin"]: - """Lists all of the existing origins within an 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. - :type profile_name: str - :param origin_group_name: Name of the origin group which is unique within the profile. - Required. - :type origin_group_name: str - :return: An iterator like instance of either AFDOrigin or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cdn.models.AFDOrigin] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - 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]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_origin_group_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - origin_group_name=origin_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("AFDOriginListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, resource_group_name: str, profile_name: str, origin_group_name: str, origin_name: str, **kwargs: Any - ) -> _models.AFDOrigin: - """Gets an existing origin within an 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. - :type profile_name: str - :param origin_group_name: Name of the origin group which is unique within the profile. - Required. - :type origin_group_name: str - :param origin_name: Name of the origin which is unique within the profile. Required. - :type origin_name: str - :return: AFDOrigin or the result of cls(response) - :rtype: ~azure.mgmt.cdn.models.AFDOrigin - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.AFDOrigin] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - origin_group_name=origin_group_name, - origin_name=origin_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AFDOrigin", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_initial( - self, - resource_group_name: str, - profile_name: str, - origin_group_name: str, - origin_name: str, - origin: Union[_models.AFDOrigin, IO[bytes]], - **kwargs: Any - ) -> _models.AFDOrigin: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_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.AFDOrigin] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(origin, (IOBase, bytes)): - _content = origin - else: - _json = self._serialize.body(origin, "AFDOrigin") - - _request = build_create_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - origin_group_name=origin_group_name, - origin_name=origin_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201, 202]: - 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) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create( - self, - resource_group_name: str, - profile_name: str, - origin_group_name: str, - origin_name: str, - origin: _models.AFDOrigin, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.AFDOrigin]: - """Creates a new origin within the specified 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. - :type profile_name: str - :param origin_group_name: Name of the origin group which is unique within the profile. - Required. - :type origin_group_name: str - :param origin_name: Name of the origin that is unique within the profile. Required. - :type origin_name: str - :param origin: Origin properties. Required. - :type origin: ~azure.mgmt.cdn.models.AFDOrigin - :keyword content_type: Body Parameter 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 AFDOrigin or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.AFDOrigin] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create( - self, - resource_group_name: str, - profile_name: str, - origin_group_name: str, - origin_name: str, - origin: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.AFDOrigin]: - """Creates a new origin within the specified 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. - :type profile_name: str - :param origin_group_name: Name of the origin group which is unique within the profile. - Required. - :type origin_group_name: str - :param origin_name: Name of the origin that is unique within the profile. Required. - :type origin_name: str - :param origin: Origin properties. Required. - :type origin: IO[bytes] - :keyword content_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 AFDOrigin or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.AFDOrigin] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create( - self, - resource_group_name: str, - profile_name: str, - origin_group_name: str, - origin_name: str, - origin: Union[_models.AFDOrigin, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.AFDOrigin]: - """Creates a new origin within the specified 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. - :type profile_name: str - :param origin_group_name: Name of the origin group which is unique within the profile. - Required. - :type origin_group_name: str - :param origin_name: Name of the origin that is unique within the profile. Required. - :type origin_name: str - :param origin: Origin properties. Is either a AFDOrigin type or a IO[bytes] type. Required. - :type origin: ~azure.mgmt.cdn.models.AFDOrigin or IO[bytes] - :return: An instance of AsyncLROPoller that returns either AFDOrigin or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.AFDOrigin] - :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.AFDOrigin] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._create_initial( - resource_group_name=resource_group_name, - profile_name=profile_name, - origin_group_name=origin_group_name, - origin_name=origin_name, - origin=origin, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("AFDOrigin", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, - AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.AFDOrigin].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.AFDOrigin]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _update_initial( - self, - resource_group_name: str, - profile_name: str, - origin_group_name: str, - origin_name: str, - origin_update_properties: Union[_models.AFDOriginUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> _models.AFDOrigin: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_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.AFDOrigin] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(origin_update_properties, (IOBase, bytes)): - _content = origin_update_properties - else: - _json = self._serialize.body(origin_update_properties, "AFDOriginUpdateParameters") - - _request = build_update_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - origin_group_name=origin_group_name, - origin_name=origin_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.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) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_update( - self, - resource_group_name: str, - profile_name: str, - origin_group_name: str, - origin_name: str, - origin_update_properties: _models.AFDOriginUpdateParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.AFDOrigin]: - """Updates an existing origin within an 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. - :type profile_name: str - :param origin_group_name: Name of the origin group which is unique within the profile. - Required. - :type origin_group_name: str - :param origin_name: Name of the origin which is unique within the profile. Required. - :type origin_name: str - :param origin_update_properties: Origin properties. Required. - :type origin_update_properties: ~azure.mgmt.cdn.models.AFDOriginUpdateParameters - :keyword content_type: Body Parameter 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 AFDOrigin or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.AFDOrigin] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - profile_name: str, - origin_group_name: str, - origin_name: str, - origin_update_properties: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.AFDOrigin]: - """Updates an existing origin within an 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. - :type profile_name: str - :param origin_group_name: Name of the origin group which is unique within the profile. - Required. - :type origin_group_name: str - :param origin_name: Name of the origin which is unique within the profile. Required. - :type origin_name: str - :param origin_update_properties: Origin properties. Required. - :type origin_update_properties: IO[bytes] - :keyword content_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 AFDOrigin or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.AFDOrigin] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - profile_name: str, - origin_group_name: str, - origin_name: str, - origin_update_properties: Union[_models.AFDOriginUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.AFDOrigin]: - """Updates an existing origin within an 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. - :type profile_name: str - :param origin_group_name: Name of the origin group which is unique within the profile. - Required. - :type origin_group_name: str - :param origin_name: Name of the origin which is unique within the profile. Required. - :type origin_name: str - :param origin_update_properties: Origin properties. Is either a AFDOriginUpdateParameters type - or a IO[bytes] type. Required. - :type origin_update_properties: ~azure.mgmt.cdn.models.AFDOriginUpdateParameters or IO[bytes] - :return: An instance of AsyncLROPoller that returns either AFDOrigin or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.AFDOrigin] - :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.AFDOrigin] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._update_initial( - resource_group_name=resource_group_name, - profile_name=profile_name, - origin_group_name=origin_group_name, - origin_name=origin_name, - origin_update_properties=origin_update_properties, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("AFDOrigin", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, - AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.AFDOrigin].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.AFDOrigin]( - 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, origin_group_name: str, origin_name: str, **kwargs: Any - ) -> None: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - origin_group_name=origin_group_name, - origin_name=origin_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - 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 == 202: - response_headers["location"] = self._deserialize("str", response.headers.get("location")) - - if cls: - return cls(pipeline_response, None, response_headers) # type: ignore - - @distributed_trace_async - async def begin_delete( - self, resource_group_name: str, profile_name: str, origin_group_name: str, origin_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes an existing origin within an 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. - :type profile_name: str - :param origin_group_name: Name of the origin group which is unique within the profile. - Required. - :type origin_group_name: str - :param origin_name: Name of the origin which is unique within the profile. Required. - :type origin_name: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_initial( # type: ignore - resource_group_name=resource_group_name, - profile_name=profile_name, - origin_group_name=origin_group_name, - origin_name=origin_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, - AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore 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 deleted file mode 100644 index 169e0eca6ed8..000000000000 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_afd_profiles_operations.py +++ /dev/null @@ -1,757 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._afd_profiles_operations import ( - build_check_endpoint_name_availability_request, - build_check_host_name_availability_request, - build_list_resource_usage_request, - build_upgrade_request, - build_validate_secret_request, -) -from .._vendor import CdnManagementClientMixinABC - -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 AFDProfilesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.cdn.aio.CdnManagementClient`'s - :attr:`afd_profiles` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @overload - async def check_endpoint_name_availability( - self, - resource_group_name: str, - profile_name: str, - check_endpoint_name_availability_input: _models.CheckEndpointNameAvailabilityInput, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.CheckEndpointNameAvailabilityOutput: - """Check the availability of an afdx endpoint name, and return the globally unique endpoint host - name. - - :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 which is - unique within the resource group. Required. - :type profile_name: str - :param check_endpoint_name_availability_input: Input to check. Required. - :type check_endpoint_name_availability_input: - ~azure.mgmt.cdn.models.CheckEndpointNameAvailabilityInput - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: CheckEndpointNameAvailabilityOutput or the result of cls(response) - :rtype: ~azure.mgmt.cdn.models.CheckEndpointNameAvailabilityOutput - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def check_endpoint_name_availability( - self, - resource_group_name: str, - profile_name: str, - check_endpoint_name_availability_input: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.CheckEndpointNameAvailabilityOutput: - """Check the availability of an afdx endpoint name, and return the globally unique endpoint host - name. - - :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 which is - unique within the resource group. Required. - :type profile_name: str - :param check_endpoint_name_availability_input: Input to check. Required. - :type check_endpoint_name_availability_input: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: CheckEndpointNameAvailabilityOutput or the result of cls(response) - :rtype: ~azure.mgmt.cdn.models.CheckEndpointNameAvailabilityOutput - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def check_endpoint_name_availability( - self, - resource_group_name: str, - profile_name: str, - check_endpoint_name_availability_input: Union[_models.CheckEndpointNameAvailabilityInput, IO[bytes]], - **kwargs: Any - ) -> _models.CheckEndpointNameAvailabilityOutput: - """Check the availability of an afdx endpoint name, and return the globally unique endpoint host - name. - - :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 which is - unique within the resource group. Required. - :type profile_name: str - :param check_endpoint_name_availability_input: Input to check. Is either a - CheckEndpointNameAvailabilityInput type or a IO[bytes] type. Required. - :type check_endpoint_name_availability_input: - ~azure.mgmt.cdn.models.CheckEndpointNameAvailabilityInput or IO[bytes] - :return: CheckEndpointNameAvailabilityOutput or the result of cls(response) - :rtype: ~azure.mgmt.cdn.models.CheckEndpointNameAvailabilityOutput - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_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.CheckEndpointNameAvailabilityOutput] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(check_endpoint_name_availability_input, (IOBase, bytes)): - _content = check_endpoint_name_availability_input - else: - _json = self._serialize.body(check_endpoint_name_availability_input, "CheckEndpointNameAvailabilityInput") - - _request = build_check_endpoint_name_availability_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 = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("CheckEndpointNameAvailabilityOutput", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_resource_usage( - self, resource_group_name: str, profile_name: str, **kwargs: Any - ) -> AsyncIterable["_models.Usage"]: - """Checks the quota and actual usage of endpoints under the given Azure Front Door 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. - :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] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - 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]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_resource_usage_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 = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("UsagesListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @overload - async def check_host_name_availability( - self, - resource_group_name: str, - profile_name: str, - check_host_name_availability_input: _models.CheckHostNameAvailabilityInput, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.CheckNameAvailabilityOutput: - """Validates the custom domain mapping to ensure it maps to the correct Azure Front Door endpoint - in DNS. - - :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. - :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 - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: CheckNameAvailabilityOutput or the result of cls(response) - :rtype: ~azure.mgmt.cdn.models.CheckNameAvailabilityOutput - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def check_host_name_availability( - self, - resource_group_name: str, - profile_name: str, - check_host_name_availability_input: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.CheckNameAvailabilityOutput: - """Validates the custom domain mapping to ensure it maps to the correct Azure Front Door endpoint - in DNS. - - :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. - :type profile_name: str - :param check_host_name_availability_input: Custom domain to be validated. Required. - :type check_host_name_availability_input: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: CheckNameAvailabilityOutput or the result of cls(response) - :rtype: ~azure.mgmt.cdn.models.CheckNameAvailabilityOutput - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def check_host_name_availability( - self, - resource_group_name: str, - profile_name: str, - check_host_name_availability_input: Union[_models.CheckHostNameAvailabilityInput, IO[bytes]], - **kwargs: Any - ) -> _models.CheckNameAvailabilityOutput: - """Validates the custom domain mapping to ensure it maps to the correct Azure Front Door endpoint - in DNS. - - :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. - :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. - :type check_host_name_availability_input: ~azure.mgmt.cdn.models.CheckHostNameAvailabilityInput - or IO[bytes] - :return: CheckNameAvailabilityOutput or the result of cls(response) - :rtype: ~azure.mgmt.cdn.models.CheckNameAvailabilityOutput - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_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.CheckNameAvailabilityOutput] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(check_host_name_availability_input, (IOBase, bytes)): - _content = check_host_name_availability_input - else: - _json = self._serialize.body(check_host_name_availability_input, "CheckHostNameAvailabilityInput") - - _request = build_check_host_name_availability_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 = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("CheckNameAvailabilityOutput", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def validate_secret( - self, - resource_group_name: str, - profile_name: str, - validate_secret_input: _models.ValidateSecretInput, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ValidateSecretOutput: - """Validate a Secret in the 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 which is - unique within the resource group. Required. - :type profile_name: str - :param validate_secret_input: The Secret source. Required. - :type validate_secret_input: ~azure.mgmt.cdn.models.ValidateSecretInput - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: ValidateSecretOutput or the result of cls(response) - :rtype: ~azure.mgmt.cdn.models.ValidateSecretOutput - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def validate_secret( - self, - resource_group_name: str, - profile_name: str, - validate_secret_input: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ValidateSecretOutput: - """Validate a Secret in the 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 which is - unique within the resource group. Required. - :type profile_name: str - :param validate_secret_input: The Secret source. Required. - :type validate_secret_input: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: ValidateSecretOutput or the result of cls(response) - :rtype: ~azure.mgmt.cdn.models.ValidateSecretOutput - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def validate_secret( - self, - resource_group_name: str, - profile_name: str, - validate_secret_input: Union[_models.ValidateSecretInput, IO[bytes]], - **kwargs: Any - ) -> _models.ValidateSecretOutput: - """Validate a Secret in the 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 which is - unique within the resource group. Required. - :type profile_name: str - :param validate_secret_input: The Secret source. Is either a ValidateSecretInput type or a - IO[bytes] type. Required. - :type validate_secret_input: ~azure.mgmt.cdn.models.ValidateSecretInput or IO[bytes] - :return: ValidateSecretOutput or the result of cls(response) - :rtype: ~azure.mgmt.cdn.models.ValidateSecretOutput - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_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.ValidateSecretOutput] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(validate_secret_input, (IOBase, bytes)): - _content = validate_secret_input - else: - _json = self._serialize.body(validate_secret_input, "ValidateSecretInput") - - _request = build_validate_secret_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 = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ValidateSecretOutput", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _upgrade_initial( - self, - resource_group_name: str, - profile_name: str, - profile_upgrade_parameters: Union[_models.ProfileUpgradeParameters, IO[bytes]], - **kwargs: Any - ) -> _models.Profile: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_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.Profile] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(profile_upgrade_parameters, (IOBase, bytes)): - _content = profile_upgrade_parameters - else: - _json = self._serialize.body(profile_upgrade_parameters, "ProfileUpgradeParameters") - - _request = build_upgrade_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 = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.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) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_upgrade( - self, - resource_group_name: str, - profile_name: str, - profile_upgrade_parameters: _models.ProfileUpgradeParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Profile]: - """Upgrade a profile from Standard_AzureFrontDoor to Premium_AzureFrontDoor. - - :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 which is - unique within the resource group. Required. - :type profile_name: str - :param profile_upgrade_parameters: Profile upgrade input parameter. Required. - :type profile_upgrade_parameters: ~azure.mgmt.cdn.models.ProfileUpgradeParameters - :keyword content_type: Body Parameter 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 Profile or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Profile] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_upgrade( - self, - resource_group_name: str, - profile_name: str, - profile_upgrade_parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Profile]: - """Upgrade a profile from Standard_AzureFrontDoor to Premium_AzureFrontDoor. - - :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 which is - unique within the resource group. Required. - :type profile_name: str - :param profile_upgrade_parameters: Profile upgrade input parameter. Required. - :type profile_upgrade_parameters: IO[bytes] - :keyword content_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 Profile or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Profile] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_upgrade( - self, - resource_group_name: str, - profile_name: str, - profile_upgrade_parameters: Union[_models.ProfileUpgradeParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.Profile]: - """Upgrade a profile from Standard_AzureFrontDoor to Premium_AzureFrontDoor. - - :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 which is - unique within the resource group. Required. - :type profile_name: str - :param profile_upgrade_parameters: Profile upgrade input parameter. Is either a - ProfileUpgradeParameters type or a IO[bytes] type. Required. - :type profile_upgrade_parameters: ~azure.mgmt.cdn.models.ProfileUpgradeParameters or IO[bytes] - :return: An instance of AsyncLROPoller that returns either Profile or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Profile] - :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.Profile] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._upgrade_initial( - resource_group_name=resource_group_name, - profile_name=profile_name, - profile_upgrade_parameters=profile_upgrade_parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Profile", pipeline_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.Profile].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Profile]( - 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/_cdn_management_client_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_cdn_management_client_operations.py deleted file mode 100644 index adef934cf76f..000000000000 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_cdn_management_client_operations.py +++ /dev/null @@ -1,488 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._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 - -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): - - @overload - async def check_endpoint_name_availability( - self, - resource_group_name: str, - check_endpoint_name_availability_input: _models.CheckEndpointNameAvailabilityInput, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.CheckEndpointNameAvailabilityOutput: - """Check the availability of a resource name. This is needed for resources where name is globally - unique, such as a afdx endpoint. - - :param resource_group_name: Name of the Resource group within the Azure subscription. Required. - :type resource_group_name: str - :param check_endpoint_name_availability_input: Input to check. Required. - :type check_endpoint_name_availability_input: - ~azure.mgmt.cdn.models.CheckEndpointNameAvailabilityInput - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: CheckEndpointNameAvailabilityOutput or the result of cls(response) - :rtype: ~azure.mgmt.cdn.models.CheckEndpointNameAvailabilityOutput - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def check_endpoint_name_availability( - self, - resource_group_name: str, - check_endpoint_name_availability_input: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.CheckEndpointNameAvailabilityOutput: - """Check the availability of a resource name. This is needed for resources where name is globally - unique, such as a afdx endpoint. - - :param resource_group_name: Name of the Resource group within the Azure subscription. Required. - :type resource_group_name: str - :param check_endpoint_name_availability_input: Input to check. Required. - :type check_endpoint_name_availability_input: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: CheckEndpointNameAvailabilityOutput or the result of cls(response) - :rtype: ~azure.mgmt.cdn.models.CheckEndpointNameAvailabilityOutput - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def check_endpoint_name_availability( - self, - resource_group_name: str, - check_endpoint_name_availability_input: Union[_models.CheckEndpointNameAvailabilityInput, IO[bytes]], - **kwargs: Any - ) -> _models.CheckEndpointNameAvailabilityOutput: - """Check the availability of a resource name. This is needed for resources where name is globally - unique, such as a afdx endpoint. - - :param resource_group_name: Name of the Resource group within the Azure subscription. Required. - :type resource_group_name: str - :param check_endpoint_name_availability_input: Input to check. Is either a - CheckEndpointNameAvailabilityInput type or a IO[bytes] type. Required. - :type check_endpoint_name_availability_input: - ~azure.mgmt.cdn.models.CheckEndpointNameAvailabilityInput or IO[bytes] - :return: CheckEndpointNameAvailabilityOutput or the result of cls(response) - :rtype: ~azure.mgmt.cdn.models.CheckEndpointNameAvailabilityOutput - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_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.CheckEndpointNameAvailabilityOutput] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(check_endpoint_name_availability_input, (IOBase, bytes)): - _content = check_endpoint_name_availability_input - else: - _json = self._serialize.body(check_endpoint_name_availability_input, "CheckEndpointNameAvailabilityInput") - - _request = build_check_endpoint_name_availability_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("CheckEndpointNameAvailabilityOutput", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def check_name_availability( - self, - check_name_availability_input: _models.CheckNameAvailabilityInput, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.CheckNameAvailabilityOutput: - """Check the availability of a resource name. This is needed for resources where name is globally - unique, such as a CDN endpoint. - - :param check_name_availability_input: Input to check. Required. - :type check_name_availability_input: ~azure.mgmt.cdn.models.CheckNameAvailabilityInput - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: CheckNameAvailabilityOutput or the result of cls(response) - :rtype: ~azure.mgmt.cdn.models.CheckNameAvailabilityOutput - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def check_name_availability( - self, check_name_availability_input: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.CheckNameAvailabilityOutput: - """Check the availability of a resource name. This is needed for resources where name is globally - unique, such as a CDN endpoint. - - :param check_name_availability_input: Input to check. Required. - :type check_name_availability_input: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: CheckNameAvailabilityOutput or the result of cls(response) - :rtype: ~azure.mgmt.cdn.models.CheckNameAvailabilityOutput - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def check_name_availability( - self, check_name_availability_input: Union[_models.CheckNameAvailabilityInput, IO[bytes]], **kwargs: Any - ) -> _models.CheckNameAvailabilityOutput: - """Check the availability of a resource name. This is needed for resources where name is globally - unique, such as a CDN endpoint. - - :param check_name_availability_input: Input to check. Is either a CheckNameAvailabilityInput - type or a IO[bytes] type. Required. - :type check_name_availability_input: ~azure.mgmt.cdn.models.CheckNameAvailabilityInput or - IO[bytes] - :return: CheckNameAvailabilityOutput or the result of cls(response) - :rtype: ~azure.mgmt.cdn.models.CheckNameAvailabilityOutput - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_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.CheckNameAvailabilityOutput] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(check_name_availability_input, (IOBase, bytes)): - _content = check_name_availability_input - else: - _json = self._serialize.body(check_name_availability_input, "CheckNameAvailabilityInput") - - _request = build_check_name_availability_request( - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("CheckNameAvailabilityOutput", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def check_name_availability_with_subscription( # pylint: disable=name-too-long - self, - check_name_availability_input: _models.CheckNameAvailabilityInput, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.CheckNameAvailabilityOutput: - """Check the availability of a resource name. This is needed for resources where name is globally - unique, such as a CDN endpoint. - - :param check_name_availability_input: Input to check. Required. - :type check_name_availability_input: ~azure.mgmt.cdn.models.CheckNameAvailabilityInput - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: CheckNameAvailabilityOutput or the result of cls(response) - :rtype: ~azure.mgmt.cdn.models.CheckNameAvailabilityOutput - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def check_name_availability_with_subscription( # pylint: disable=name-too-long - self, check_name_availability_input: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.CheckNameAvailabilityOutput: - """Check the availability of a resource name. This is needed for resources where name is globally - unique, such as a CDN endpoint. - - :param check_name_availability_input: Input to check. Required. - :type check_name_availability_input: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: CheckNameAvailabilityOutput or the result of cls(response) - :rtype: ~azure.mgmt.cdn.models.CheckNameAvailabilityOutput - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def check_name_availability_with_subscription( # pylint: disable=name-too-long - self, check_name_availability_input: Union[_models.CheckNameAvailabilityInput, IO[bytes]], **kwargs: Any - ) -> _models.CheckNameAvailabilityOutput: - """Check the availability of a resource name. This is needed for resources where name is globally - unique, such as a CDN endpoint. - - :param check_name_availability_input: Input to check. Is either a CheckNameAvailabilityInput - type or a IO[bytes] type. Required. - :type check_name_availability_input: ~azure.mgmt.cdn.models.CheckNameAvailabilityInput or - IO[bytes] - :return: CheckNameAvailabilityOutput or the result of cls(response) - :rtype: ~azure.mgmt.cdn.models.CheckNameAvailabilityOutput - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_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.CheckNameAvailabilityOutput] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(check_name_availability_input, (IOBase, bytes)): - _content = check_name_availability_input - else: - _json = self._serialize.body(check_name_availability_input, "CheckNameAvailabilityInput") - - _request = build_check_name_availability_with_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("CheckNameAvailabilityOutput", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def validate_probe( - self, validate_probe_input: _models.ValidateProbeInput, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.ValidateProbeOutput: - """Check if the probe path is a valid path and the file can be accessed. Probe path is the path to - a file hosted on the origin server to help accelerate the delivery of dynamic content via the - CDN endpoint. This path is relative to the origin path specified in the endpoint configuration. - - :param validate_probe_input: Input to check. Required. - :type validate_probe_input: ~azure.mgmt.cdn.models.ValidateProbeInput - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: ValidateProbeOutput or the result of cls(response) - :rtype: ~azure.mgmt.cdn.models.ValidateProbeOutput - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def validate_probe( - self, validate_probe_input: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.ValidateProbeOutput: - """Check if the probe path is a valid path and the file can be accessed. Probe path is the path to - a file hosted on the origin server to help accelerate the delivery of dynamic content via the - CDN endpoint. This path is relative to the origin path specified in the endpoint configuration. - - :param validate_probe_input: Input to check. Required. - :type validate_probe_input: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: ValidateProbeOutput or the result of cls(response) - :rtype: ~azure.mgmt.cdn.models.ValidateProbeOutput - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def validate_probe( - self, validate_probe_input: Union[_models.ValidateProbeInput, IO[bytes]], **kwargs: Any - ) -> _models.ValidateProbeOutput: - """Check if the probe path is a valid path and the file can be accessed. Probe path is the path to - a file hosted on the origin server to help accelerate the delivery of dynamic content via the - CDN endpoint. This path is relative to the origin path specified in the endpoint configuration. - - :param validate_probe_input: Input to check. Is either a ValidateProbeInput type or a IO[bytes] - type. Required. - :type validate_probe_input: ~azure.mgmt.cdn.models.ValidateProbeInput or IO[bytes] - :return: ValidateProbeOutput or the result of cls(response) - :rtype: ~azure.mgmt.cdn.models.ValidateProbeOutput - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_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.ValidateProbeOutput] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(validate_probe_input, (IOBase, bytes)): - _content = validate_probe_input - else: - _json = self._serialize.body(validate_probe_input, "ValidateProbeInput") - - _request = build_validate_probe_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ValidateProbeOutput", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return 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 deleted file mode 100644 index 52a4b04d3882..000000000000 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_custom_domains_operations.py +++ /dev/null @@ -1,929 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._custom_domains_operations import ( - build_create_request, - build_delete_request, - build_disable_custom_https_request, - build_enable_custom_https_request, - build_get_request, - build_list_by_endpoint_request, -) -from .._vendor import CdnManagementClientMixinABC - -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 CustomDomainsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.cdn.aio.CdnManagementClient`'s - :attr:`custom_domains` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_endpoint( - self, resource_group_name: str, profile_name: str, endpoint_name: str, **kwargs: Any - ) -> AsyncIterable["_models.CustomDomain"]: - """Lists all of the existing custom domains within an 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 CDN profile 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. - :type endpoint_name: str - :return: An iterator like instance of either CustomDomain or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cdn.models.CustomDomain] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - 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]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_endpoint_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("CustomDomainListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, resource_group_name: str, profile_name: str, endpoint_name: str, custom_domain_name: str, **kwargs: Any - ) -> _models.CustomDomain: - """Gets an existing custom domain within an 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 CDN profile 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. - :type endpoint_name: str - :param custom_domain_name: Name of the custom domain within an endpoint. Required. - :type custom_domain_name: str - :return: CustomDomain or the result of cls(response) - :rtype: ~azure.mgmt.cdn.models.CustomDomain - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_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) - - _request = build_get_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - custom_domain_name=custom_domain_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("CustomDomain", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_initial( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - custom_domain_name: str, - custom_domain_properties: Union[_models.CustomDomainParameters, IO[bytes]], - **kwargs: Any - ) -> _models.CustomDomain: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_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.CustomDomain] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(custom_domain_properties, (IOBase, bytes)): - _content = custom_domain_properties - else: - _json = self._serialize.body(custom_domain_properties, "CustomDomainParameters") - - _request = build_create_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - custom_domain_name=custom_domain_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - 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) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - custom_domain_name: str, - custom_domain_properties: _models.CustomDomainParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.CustomDomain]: - """Creates a new custom domain within an 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 CDN profile 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. - :type endpoint_name: str - :param custom_domain_name: Name of the custom domain within an endpoint. Required. - :type custom_domain_name: str - :param custom_domain_properties: Properties required to create a new custom domain. Required. - :type custom_domain_properties: ~azure.mgmt.cdn.models.CustomDomainParameters - :keyword content_type: Body Parameter 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 CustomDomain or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.CustomDomain] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - custom_domain_name: str, - custom_domain_properties: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.CustomDomain]: - """Creates a new custom domain within an 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 CDN profile 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. - :type endpoint_name: str - :param custom_domain_name: Name of the custom domain within an endpoint. Required. - :type custom_domain_name: str - :param custom_domain_properties: Properties required to create a new custom domain. Required. - :type custom_domain_properties: IO[bytes] - :keyword content_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 CustomDomain or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.CustomDomain] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - custom_domain_name: str, - custom_domain_properties: Union[_models.CustomDomainParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.CustomDomain]: - """Creates a new custom domain within an 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 CDN profile 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. - :type endpoint_name: str - :param custom_domain_name: Name of the custom domain within an endpoint. Required. - :type custom_domain_name: str - :param custom_domain_properties: Properties required to create a new custom domain. Is either a - CustomDomainParameters type or a IO[bytes] type. Required. - :type custom_domain_properties: ~azure.mgmt.cdn.models.CustomDomainParameters or IO[bytes] - :return: An instance of AsyncLROPoller that returns either CustomDomain or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.CustomDomain] - :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.CustomDomain] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._create_initial( - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - custom_domain_name=custom_domain_name, - custom_domain_properties=custom_domain_properties, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("CustomDomain", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.CustomDomain].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.CustomDomain]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - 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]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = 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) - - _request = build_delete_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - custom_domain_name=custom_domain_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - map_error(status_code=response.status_code, 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) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_delete( - self, resource_group_name: str, profile_name: str, endpoint_name: str, custom_domain_name: str, **kwargs: Any - ) -> AsyncLROPoller[_models.CustomDomain]: - """Deletes an existing custom domain within an 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 CDN profile 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. - :type endpoint_name: str - :param custom_domain_name: Name of the custom domain within an endpoint. Required. - :type custom_domain_name: str - :return: An instance of AsyncLROPoller that returns either CustomDomain or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.CustomDomain] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_initial( - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - custom_domain_name=custom_domain_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - response_headers = {} - response = pipeline_response.http_response - response_headers["location"] = self._deserialize("str", response.headers.get("location")) - - deserialized = self._deserialize("CustomDomain", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.CustomDomain].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.CustomDomain]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - 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]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_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) - - _request = build_disable_custom_https_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - custom_domain_name=custom_domain_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - 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) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_disable_custom_https( - self, resource_group_name: str, profile_name: str, endpoint_name: str, custom_domain_name: str, **kwargs: Any - ) -> AsyncLROPoller[_models.CustomDomain]: - """Disable https delivery of the 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 CDN profile 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. - :type endpoint_name: str - :param custom_domain_name: Name of the custom domain within an endpoint. Required. - :type custom_domain_name: str - :return: An instance of AsyncLROPoller that returns either CustomDomain or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.CustomDomain] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_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) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._disable_custom_https_initial( - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - custom_domain_name=custom_domain_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("CustomDomain", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.CustomDomain].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.CustomDomain]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _enable_custom_https_initial( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - 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]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_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.CustomDomain] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(custom_domain_https_parameters, (IOBase, bytes)): - _content = custom_domain_https_parameters - else: - if custom_domain_https_parameters is not None: - _json = self._serialize.body(custom_domain_https_parameters, "CustomDomainHttpsParameters") - else: - _json = None - - _request = build_enable_custom_https_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - custom_domain_name=custom_domain_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - 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) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_enable_custom_https( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - custom_domain_name: str, - custom_domain_https_parameters: Optional[_models.CustomDomainHttpsParameters] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.CustomDomain]: - """Enable https delivery of the 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 CDN profile 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. - :type endpoint_name: str - :param custom_domain_name: Name of the custom domain within an endpoint. Required. - :type custom_domain_name: str - :param custom_domain_https_parameters: The configuration specifying how to enable HTTPS for the - custom domain - using CDN managed certificate or user's own certificate. If not specified, - enabling ssl uses CDN managed certificate by default. Default value is None. - :type custom_domain_https_parameters: ~azure.mgmt.cdn.models.CustomDomainHttpsParameters - :keyword content_type: Body Parameter 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 CustomDomain or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.CustomDomain] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_enable_custom_https( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - custom_domain_name: str, - custom_domain_https_parameters: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.CustomDomain]: - """Enable https delivery of the 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 CDN profile 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. - :type endpoint_name: str - :param custom_domain_name: Name of the custom domain within an endpoint. Required. - :type custom_domain_name: str - :param custom_domain_https_parameters: The configuration specifying how to enable HTTPS for the - custom domain - using CDN managed certificate or user's own certificate. If not specified, - enabling ssl uses CDN managed certificate by default. Default value is None. - :type custom_domain_https_parameters: IO[bytes] - :keyword content_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 CustomDomain or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.CustomDomain] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_enable_custom_https( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - custom_domain_name: str, - custom_domain_https_parameters: Optional[Union[_models.CustomDomainHttpsParameters, IO[bytes]]] = None, - **kwargs: Any - ) -> AsyncLROPoller[_models.CustomDomain]: - """Enable https delivery of the 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 CDN profile 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. - :type endpoint_name: str - :param custom_domain_name: Name of the custom domain within an endpoint. Required. - :type custom_domain_name: str - :param custom_domain_https_parameters: The configuration specifying how to enable HTTPS for the - custom domain - using CDN managed certificate or user's own certificate. If not specified, - enabling ssl uses CDN managed certificate by default. Is either a CustomDomainHttpsParameters - type or a IO[bytes] type. Default value is None. - :type custom_domain_https_parameters: ~azure.mgmt.cdn.models.CustomDomainHttpsParameters or - IO[bytes] - :return: An instance of AsyncLROPoller that returns either CustomDomain or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.CustomDomain] - :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.CustomDomain] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._enable_custom_https_initial( - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - custom_domain_name=custom_domain_name, - custom_domain_https_parameters=custom_domain_https_parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("CustomDomain", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.CustomDomain].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.CustomDomain]( - 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/_edge_nodes_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_edge_nodes_operations.py deleted file mode 100644 index 4cb0f22ba810..000000000000 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_edge_nodes_operations.py +++ /dev/null @@ -1,136 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._edge_nodes_operations import build_list_request -from .._vendor import CdnManagementClientMixinABC - -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 EdgeNodesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.cdn.aio.CdnManagementClient`'s - :attr:`edge_nodes` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list(self, **kwargs: Any) -> AsyncIterable["_models.EdgeNode"]: - """Edgenodes are the global Point of Presence (POP) locations used to deliver CDN content to end - users. - - :return: An iterator like instance of either EdgeNode or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cdn.models.EdgeNode] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - 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]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("EdgenodeResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) diff --git a/sdk/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 deleted file mode 100644 index 3e51c9b51c27..000000000000 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_endpoints_operations.py +++ /dev/null @@ -1,1638 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._endpoints_operations import ( - build_create_request, - build_delete_request, - build_get_request, - build_list_by_profile_request, - build_list_resource_usage_request, - build_load_content_request, - build_purge_content_request, - build_start_request, - build_stop_request, - build_update_request, - build_validate_custom_domain_request, -) -from .._vendor import CdnManagementClientMixinABC - -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 EndpointsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.cdn.aio.CdnManagementClient`'s - :attr:`endpoints` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_profile( - self, resource_group_name: str, profile_name: str, **kwargs: Any - ) -> AsyncIterable["_models.Endpoint"]: - """Lists existing CDN endpoints. - - :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 CDN profile which is unique within the resource group. - Required. - :type profile_name: str - :return: An iterator like instance of either Endpoint or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cdn.models.Endpoint] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - 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]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_profile_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 = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("EndpointListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, resource_group_name: str, profile_name: str, endpoint_name: str, **kwargs: Any - ) -> _models.Endpoint: - """Gets an existing CDN endpoint with the specified endpoint name under the specified - subscription, resource group and 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 CDN profile 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. - :type endpoint_name: str - :return: Endpoint or the result of cls(response) - :rtype: ~azure.mgmt.cdn.models.Endpoint - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_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) - - _request = build_get_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Endpoint", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_initial( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - endpoint: Union[_models.Endpoint, IO[bytes]], - **kwargs: Any - ) -> _models.Endpoint: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_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.Endpoint] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(endpoint, (IOBase, bytes)): - _content = endpoint - else: - _json = self._serialize.body(endpoint, "Endpoint") - - _request = build_create_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - 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) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - endpoint: _models.Endpoint, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Endpoint]: - """Creates a new CDN endpoint with the specified endpoint name under the specified subscription, - resource group and 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 CDN profile 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. - :type endpoint_name: str - :param endpoint: Endpoint properties. Required. - :type endpoint: ~azure.mgmt.cdn.models.Endpoint - :keyword content_type: Body Parameter 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 Endpoint or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Endpoint] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - endpoint: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Endpoint]: - """Creates a new CDN endpoint with the specified endpoint name under the specified subscription, - resource group and 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 CDN profile 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. - :type endpoint_name: str - :param endpoint: Endpoint properties. Required. - :type endpoint: IO[bytes] - :keyword content_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 Endpoint or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Endpoint] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - endpoint: Union[_models.Endpoint, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.Endpoint]: - """Creates a new CDN endpoint with the specified endpoint name under the specified subscription, - resource group and 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 CDN profile 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. - :type endpoint_name: str - :param endpoint: Endpoint properties. Is either a Endpoint type or a IO[bytes] type. Required. - :type endpoint: ~azure.mgmt.cdn.models.Endpoint or IO[bytes] - :return: An instance of AsyncLROPoller that returns either Endpoint or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Endpoint] - :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.Endpoint] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._create_initial( - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - endpoint=endpoint, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Endpoint", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.Endpoint].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Endpoint]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _update_initial( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - endpoint_update_properties: Union[_models.EndpointUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> _models.Endpoint: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_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.Endpoint] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(endpoint_update_properties, (IOBase, bytes)): - _content = endpoint_update_properties - else: - _json = self._serialize.body(endpoint_update_properties, "EndpointUpdateParameters") - - _request = build_update_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - 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) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_update( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - endpoint_update_properties: _models.EndpointUpdateParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Endpoint]: - """Updates an existing CDN endpoint with the specified endpoint name under the specified - subscription, resource group and profile. Only tags can be updated after creating an endpoint. - To update origins, use the Update Origin operation. To update origin groups, use the Update - Origin group operation. To update custom domains, use the Update Custom Domain operation. - - :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 CDN profile 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. - :type endpoint_name: str - :param endpoint_update_properties: Endpoint update properties. Required. - :type endpoint_update_properties: ~azure.mgmt.cdn.models.EndpointUpdateParameters - :keyword content_type: Body Parameter 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 Endpoint or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Endpoint] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - endpoint_update_properties: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Endpoint]: - """Updates an existing CDN endpoint with the specified endpoint name under the specified - subscription, resource group and profile. Only tags can be updated after creating an endpoint. - To update origins, use the Update Origin operation. To update origin groups, use the Update - Origin group operation. To update custom domains, use the Update Custom Domain operation. - - :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 CDN profile 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. - :type endpoint_name: str - :param endpoint_update_properties: Endpoint update properties. Required. - :type endpoint_update_properties: IO[bytes] - :keyword content_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 Endpoint or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Endpoint] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - endpoint_update_properties: Union[_models.EndpointUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.Endpoint]: - """Updates an existing CDN endpoint with the specified endpoint name under the specified - subscription, resource group and profile. Only tags can be updated after creating an endpoint. - To update origins, use the Update Origin operation. To update origin groups, use the Update - Origin group operation. To update custom domains, use the Update Custom Domain operation. - - :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 CDN profile 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. - :type endpoint_name: str - :param endpoint_update_properties: Endpoint update properties. Is either a - EndpointUpdateParameters type or a IO[bytes] type. Required. - :type endpoint_update_properties: ~azure.mgmt.cdn.models.EndpointUpdateParameters or IO[bytes] - :return: An instance of AsyncLROPoller that returns either Endpoint or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Endpoint] - :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.Endpoint] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._update_initial( - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - endpoint_update_properties=endpoint_update_properties, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Endpoint", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.Endpoint].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Endpoint]( - 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, endpoint_name: str, **kwargs: Any - ) -> None: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["location"] = self._deserialize("str", response.headers.get("location")) - - if cls: - return cls(pipeline_response, None, response_headers) # type: ignore - - @distributed_trace_async - async def begin_delete( - self, resource_group_name: str, profile_name: str, endpoint_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes an existing CDN endpoint with the specified endpoint name under the specified - subscription, resource group and 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 CDN profile 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. - :type endpoint_name: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_initial( # type: ignore - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _start_initial( - self, resource_group_name: str, profile_name: str, endpoint_name: str, **kwargs: Any - ) -> _models.Endpoint: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_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) - - _request = build_start_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - 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) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_start( - self, resource_group_name: str, profile_name: str, endpoint_name: str, **kwargs: Any - ) -> AsyncLROPoller[_models.Endpoint]: - """Starts an existing CDN endpoint that is on a stopped state. - - :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 CDN profile 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. - :type endpoint_name: str - :return: An instance of AsyncLROPoller that returns either Endpoint or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Endpoint] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_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) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._start_initial( - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Endpoint", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.Endpoint].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Endpoint]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - 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]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_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) - - _request = build_stop_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - 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) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_stop( - self, resource_group_name: str, profile_name: str, endpoint_name: str, **kwargs: Any - ) -> AsyncLROPoller[_models.Endpoint]: - """Stops an existing running CDN 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 CDN profile 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. - :type endpoint_name: str - :return: An instance of AsyncLROPoller that returns either Endpoint or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Endpoint] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_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) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._stop_initial( - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Endpoint", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.Endpoint].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Endpoint]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _purge_content_initial( # pylint: disable=inconsistent-return-statements - 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]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(content_file_paths, (IOBase, bytes)): - _content = content_file_paths - else: - _json = self._serialize.body(content_file_paths, "PurgeParameters") - - _request = build_purge_content_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["location"] = self._deserialize("str", response.headers.get("location")) - - if cls: - return cls(pipeline_response, None, response_headers) # type: ignore - - @overload - async def begin_purge_content( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - content_file_paths: _models.PurgeParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Removes a content from CDN. - - :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 CDN profile 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. - :type endpoint_name: str - :param content_file_paths: The path to the content to be purged. Path can be a full URL, e.g. - '/pictures/city.png' which removes a single file, or a directory with a wildcard, e.g. - '/pictures/*' which removes all folders and files in the directory. Required. - :type content_file_paths: ~azure.mgmt.cdn.models.PurgeParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_purge_content( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - content_file_paths: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Removes a content from CDN. - - :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 CDN profile 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. - :type endpoint_name: str - :param content_file_paths: The path to the content to be purged. Path can be a full URL, e.g. - '/pictures/city.png' which removes a single file, or a directory with a wildcard, e.g. - '/pictures/*' which removes all folders and files in the directory. Required. - :type content_file_paths: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_purge_content( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - content_file_paths: Union[_models.PurgeParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Removes a content from CDN. - - :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 CDN profile 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. - :type endpoint_name: str - :param content_file_paths: The path to the content to be purged. Path can be a full URL, e.g. - '/pictures/city.png' which removes a single file, or a directory with a wildcard, e.g. - '/pictures/*' which removes all folders and files in the directory. Is either a PurgeParameters - type or a IO[bytes] type. Required. - :type content_file_paths: ~azure.mgmt.cdn.models.PurgeParameters or IO[bytes] - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._purge_content_initial( # type: ignore - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - content_file_paths=content_file_paths, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _load_content_initial( # pylint: disable=inconsistent-return-statements - 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]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(content_file_paths, (IOBase, bytes)): - _content = content_file_paths - else: - _json = self._serialize.body(content_file_paths, "LoadParameters") - - _request = build_load_content_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["location"] = self._deserialize("str", response.headers.get("location")) - - if cls: - return cls(pipeline_response, None, response_headers) # type: ignore - - @overload - async def begin_load_content( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - content_file_paths: _models.LoadParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Pre-loads a content to CDN. Available for Verizon Profiles. - - :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 CDN profile 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. - :type endpoint_name: str - :param content_file_paths: The path to the content to be loaded. Path should be a full URL, - e.g. ‘/pictures/city.png' which loads a single file. Required. - :type content_file_paths: ~azure.mgmt.cdn.models.LoadParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_load_content( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - content_file_paths: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Pre-loads a content to CDN. Available for Verizon Profiles. - - :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 CDN profile 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. - :type endpoint_name: str - :param content_file_paths: The path to the content to be loaded. Path should be a full URL, - e.g. ‘/pictures/city.png' which loads a single file. Required. - :type content_file_paths: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_load_content( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - content_file_paths: Union[_models.LoadParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Pre-loads a content to CDN. Available for Verizon Profiles. - - :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 CDN profile 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. - :type endpoint_name: str - :param content_file_paths: The path to the content to be loaded. Path should be a full URL, - e.g. ‘/pictures/city.png' which loads a single file. Is either a LoadParameters type or a - IO[bytes] type. Required. - :type content_file_paths: ~azure.mgmt.cdn.models.LoadParameters or IO[bytes] - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._load_content_initial( # type: ignore - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - content_file_paths=content_file_paths, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @overload - async def validate_custom_domain( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - custom_domain_properties: _models.ValidateCustomDomainInput, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ValidateCustomDomainOutput: - """Validates the custom domain mapping to ensure it maps to the correct CDN endpoint in DNS. - - :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 CDN profile 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. - :type endpoint_name: str - :param custom_domain_properties: Custom domain to be validated. Required. - :type custom_domain_properties: ~azure.mgmt.cdn.models.ValidateCustomDomainInput - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: ValidateCustomDomainOutput or the result of cls(response) - :rtype: ~azure.mgmt.cdn.models.ValidateCustomDomainOutput - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def validate_custom_domain( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - custom_domain_properties: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ValidateCustomDomainOutput: - """Validates the custom domain mapping to ensure it maps to the correct CDN endpoint in DNS. - - :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 CDN profile 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. - :type endpoint_name: str - :param custom_domain_properties: Custom domain to be validated. Required. - :type custom_domain_properties: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: ValidateCustomDomainOutput or the result of cls(response) - :rtype: ~azure.mgmt.cdn.models.ValidateCustomDomainOutput - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def validate_custom_domain( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - custom_domain_properties: Union[_models.ValidateCustomDomainInput, IO[bytes]], - **kwargs: Any - ) -> _models.ValidateCustomDomainOutput: - """Validates the custom domain mapping to ensure it maps to the correct CDN endpoint in DNS. - - :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 CDN profile 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. - :type endpoint_name: str - :param custom_domain_properties: Custom domain to be validated. Is either a - ValidateCustomDomainInput type or a IO[bytes] type. Required. - :type custom_domain_properties: ~azure.mgmt.cdn.models.ValidateCustomDomainInput or IO[bytes] - :return: ValidateCustomDomainOutput or the result of cls(response) - :rtype: ~azure.mgmt.cdn.models.ValidateCustomDomainOutput - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_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.ValidateCustomDomainOutput] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(custom_domain_properties, (IOBase, bytes)): - _content = custom_domain_properties - else: - _json = self._serialize.body(custom_domain_properties, "ValidateCustomDomainInput") - - _request = build_validate_custom_domain_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ValidateCustomDomainOutput", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_resource_usage( - self, resource_group_name: str, profile_name: str, endpoint_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ResourceUsage"]: - """Checks the quota and usage of geo filters and custom domains under the given 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 CDN profile 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. - :type endpoint_name: str - :return: An iterator like instance of either ResourceUsage or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cdn.models.ResourceUsage] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - 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]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_resource_usage_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ResourceUsageListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) diff --git a/sdk/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 deleted file mode 100644 index a76b3c5219f4..000000000000 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_log_analytics_operations.py +++ /dev/null @@ -1,547 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for 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 datetime -import sys -from typing import Any, Callable, Dict, List, Optional, Type, TypeVar, Union - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._log_analytics_operations import ( - build_get_log_analytics_locations_request, - build_get_log_analytics_metrics_request, - build_get_log_analytics_rankings_request, - build_get_log_analytics_resources_request, - build_get_waf_log_analytics_metrics_request, - build_get_waf_log_analytics_rankings_request, -) -from .._vendor import CdnManagementClientMixinABC - -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 LogAnalyticsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.cdn.aio.CdnManagementClient`'s - :attr:`log_analytics` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async - async def get_log_analytics_metrics( - self, - resource_group_name: str, - profile_name: str, - metrics: List[Union[str, _models.LogMetric]], - date_time_begin: datetime.datetime, - date_time_end: datetime.datetime, - granularity: Union[str, _models.LogMetricsGranularity], - custom_domains: List[str], - protocols: List[str], - group_by: Optional[List[Union[str, _models.LogMetricsGroupBy]]] = None, - continents: Optional[List[str]] = None, - country_or_regions: Optional[List[str]] = None, - **kwargs: Any - ) -> _models.MetricsResponse: - """Get log report for AFD 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. which is unique within the resource group. Required. - :type profile_name: str - :param metrics: Required. - :type metrics: list[str or ~azure.mgmt.cdn.models.LogMetric] - :param date_time_begin: Required. - :type date_time_begin: ~datetime.datetime - :param date_time_end: Required. - :type date_time_end: ~datetime.datetime - :param granularity: Known values are: "PT5M", "PT1H", and "P1D". Required. - :type granularity: str or ~azure.mgmt.cdn.models.LogMetricsGranularity - :param custom_domains: Required. - :type custom_domains: list[str] - :param protocols: Required. - :type protocols: list[str] - :param group_by: Default value is None. - :type group_by: list[str or ~azure.mgmt.cdn.models.LogMetricsGroupBy] - :param continents: Default value is None. - :type continents: list[str] - :param country_or_regions: Default value is None. - :type country_or_regions: list[str] - :return: MetricsResponse or the result of cls(response) - :rtype: ~azure.mgmt.cdn.models.MetricsResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.MetricsResponse] = kwargs.pop("cls", None) - - _request = build_get_log_analytics_metrics_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - subscription_id=self._config.subscription_id, - metrics=metrics, - date_time_begin=date_time_begin, - date_time_end=date_time_end, - granularity=granularity, - custom_domains=custom_domains, - protocols=protocols, - group_by=group_by, - continents=continents, - country_or_regions=country_or_regions, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("MetricsResponse", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def get_log_analytics_rankings( - self, - resource_group_name: str, - profile_name: str, - rankings: List[Union[str, _models.LogRanking]], - metrics: List[Union[str, _models.LogRankingMetric]], - max_ranking: int, - date_time_begin: datetime.datetime, - date_time_end: datetime.datetime, - custom_domains: Optional[List[str]] = None, - **kwargs: Any - ) -> _models.RankingsResponse: - """Get log analytics ranking report for AFD 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. which is unique within the resource group. Required. - :type profile_name: str - :param rankings: Required. - :type rankings: list[str or ~azure.mgmt.cdn.models.LogRanking] - :param metrics: Required. - :type metrics: list[str or ~azure.mgmt.cdn.models.LogRankingMetric] - :param max_ranking: Required. - :type max_ranking: int - :param date_time_begin: Required. - :type date_time_begin: ~datetime.datetime - :param date_time_end: Required. - :type date_time_end: ~datetime.datetime - :param custom_domains: Default value is None. - :type custom_domains: list[str] - :return: RankingsResponse or the result of cls(response) - :rtype: ~azure.mgmt.cdn.models.RankingsResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.RankingsResponse] = kwargs.pop("cls", None) - - _request = build_get_log_analytics_rankings_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - subscription_id=self._config.subscription_id, - rankings=rankings, - metrics=metrics, - max_ranking=max_ranking, - date_time_begin=date_time_begin, - date_time_end=date_time_end, - custom_domains=custom_domains, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RankingsResponse", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def get_log_analytics_locations( - self, resource_group_name: str, profile_name: str, **kwargs: Any - ) -> _models.ContinentsResponse: - """Get all available location names for AFD log analytics report. - - :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. which is unique within the resource group. Required. - :type profile_name: str - :return: ContinentsResponse or the result of cls(response) - :rtype: ~azure.mgmt.cdn.models.ContinentsResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.ContinentsResponse] = kwargs.pop("cls", None) - - _request = build_get_log_analytics_locations_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 = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ContinentsResponse", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def get_log_analytics_resources( - self, resource_group_name: str, profile_name: str, **kwargs: Any - ) -> _models.ResourcesResponse: - """Get all endpoints and custom domains available for AFD log report. - - :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. which is unique within the resource group. Required. - :type profile_name: str - :return: ResourcesResponse or the result of cls(response) - :rtype: ~azure.mgmt.cdn.models.ResourcesResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.ResourcesResponse] = kwargs.pop("cls", None) - - _request = build_get_log_analytics_resources_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 = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ResourcesResponse", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def get_waf_log_analytics_metrics( - self, - resource_group_name: str, - profile_name: str, - metrics: List[Union[str, _models.WafMetric]], - date_time_begin: datetime.datetime, - date_time_end: datetime.datetime, - granularity: Union[str, _models.WafGranularity], - actions: Optional[List[Union[str, _models.WafAction]]] = None, - group_by: Optional[List[Union[str, _models.WafRankingGroupBy]]] = None, - rule_types: Optional[List[Union[str, _models.WafRuleType]]] = None, - **kwargs: Any - ) -> _models.WafMetricsResponse: - """Get Waf related log analytics report for AFD 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. which is unique within the resource group. Required. - :type profile_name: str - :param metrics: Required. - :type metrics: list[str or ~azure.mgmt.cdn.models.WafMetric] - :param date_time_begin: Required. - :type date_time_begin: ~datetime.datetime - :param date_time_end: Required. - :type date_time_end: ~datetime.datetime - :param granularity: Known values are: "PT5M", "PT1H", and "P1D". Required. - :type granularity: str or ~azure.mgmt.cdn.models.WafGranularity - :param actions: Default value is None. - :type actions: list[str or ~azure.mgmt.cdn.models.WafAction] - :param group_by: Default value is None. - :type group_by: list[str or ~azure.mgmt.cdn.models.WafRankingGroupBy] - :param rule_types: Default value is None. - :type rule_types: list[str or ~azure.mgmt.cdn.models.WafRuleType] - :return: WafMetricsResponse or the result of cls(response) - :rtype: ~azure.mgmt.cdn.models.WafMetricsResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.WafMetricsResponse] = kwargs.pop("cls", None) - - _request = build_get_waf_log_analytics_metrics_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - subscription_id=self._config.subscription_id, - metrics=metrics, - date_time_begin=date_time_begin, - date_time_end=date_time_end, - granularity=granularity, - actions=actions, - group_by=group_by, - rule_types=rule_types, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("WafMetricsResponse", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def get_waf_log_analytics_rankings( - self, - resource_group_name: str, - profile_name: str, - metrics: List[Union[str, _models.WafMetric]], - date_time_begin: datetime.datetime, - date_time_end: datetime.datetime, - max_ranking: int, - rankings: List[Union[str, _models.WafRankingType]], - actions: Optional[List[Union[str, _models.WafAction]]] = None, - rule_types: Optional[List[Union[str, _models.WafRuleType]]] = None, - **kwargs: Any - ) -> _models.WafRankingsResponse: - """Get WAF log analytics charts for AFD 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. which is unique within the resource group. Required. - :type profile_name: str - :param metrics: Required. - :type metrics: list[str or ~azure.mgmt.cdn.models.WafMetric] - :param date_time_begin: Required. - :type date_time_begin: ~datetime.datetime - :param date_time_end: Required. - :type date_time_end: ~datetime.datetime - :param max_ranking: Required. - :type max_ranking: int - :param rankings: Required. - :type rankings: list[str or ~azure.mgmt.cdn.models.WafRankingType] - :param actions: Default value is None. - :type actions: list[str or ~azure.mgmt.cdn.models.WafAction] - :param rule_types: Default value is None. - :type rule_types: list[str or ~azure.mgmt.cdn.models.WafRuleType] - :return: WafRankingsResponse or the result of cls(response) - :rtype: ~azure.mgmt.cdn.models.WafRankingsResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.WafRankingsResponse] = kwargs.pop("cls", None) - - _request = build_get_waf_log_analytics_rankings_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - subscription_id=self._config.subscription_id, - metrics=metrics, - date_time_begin=date_time_begin, - date_time_end=date_time_end, - max_ranking=max_ranking, - rankings=rankings, - actions=actions, - rule_types=rule_types, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("WafRankingsResponse", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return 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 deleted file mode 100644 index 2e8eb598ea06..000000000000 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_managed_rule_sets_operations.py +++ /dev/null @@ -1,138 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._managed_rule_sets_operations import build_list_request -from .._vendor import CdnManagementClientMixinABC - -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 ManagedRuleSetsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.cdn.aio.CdnManagementClient`'s - :attr:`managed_rule_sets` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list(self, **kwargs: Any) -> AsyncIterable["_models.ManagedRuleSetDefinition"]: - """Lists all available managed rule sets. - - :return: An iterator like instance of either ManagedRuleSetDefinition or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cdn.models.ManagedRuleSetDefinition] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - 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]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ManagedRuleSetDefinitionList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) diff --git a/sdk/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..bbdd5e604fa4 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,15 +1,19 @@ -# 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. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python 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 +import datetime +from io import IOBase +import json +from typing import Any, AsyncIterator, Callable, IO, Optional, TypeVar, Union, cast, overload import urllib.parse +from azure.core import AsyncPipelineClient from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, @@ -17,26 +21,147 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request -from ...operations._operations import build_list_request -from .._vendor import CdnManagementClientMixinABC - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +from ..._utils.model_base import SdkJSONEncoder, _deserialize, _failsafe_deserialize +from ..._utils.serialization import Deserializer, Serializer +from ..._utils.utils import ClientMixinABC +from ..._validation import api_version_validation +from ...operations._operations import ( + build_afd_custom_domains_create_request, + build_afd_custom_domains_delete_request, + build_afd_custom_domains_get_request, + build_afd_custom_domains_list_by_profile_request, + build_afd_custom_domains_refresh_validation_token_request, + build_afd_custom_domains_update_request, + build_afd_endpoints_create_request, + build_afd_endpoints_delete_request, + build_afd_endpoints_get_request, + build_afd_endpoints_list_by_profile_request, + build_afd_endpoints_list_resource_usage_request, + build_afd_endpoints_purge_content_request, + build_afd_endpoints_update_request, + build_afd_endpoints_validate_custom_domain_request, + build_afd_origin_groups_create_request, + build_afd_origin_groups_delete_request, + build_afd_origin_groups_get_request, + build_afd_origin_groups_list_by_profile_request, + build_afd_origin_groups_list_resource_usage_request, + build_afd_origin_groups_update_request, + build_afd_origins_create_request, + build_afd_origins_delete_request, + build_afd_origins_get_request, + build_afd_origins_list_by_origin_group_request, + build_afd_origins_update_request, + build_afd_profiles_check_endpoint_name_availability_request, + build_afd_profiles_check_host_name_availability_request, + build_afd_profiles_list_resource_usage_request, + build_afd_profiles_upgrade_request, + build_afd_profiles_validate_secret_request, + build_cdn_management_check_endpoint_name_availability_request, + build_cdn_management_check_name_availability_request, + build_cdn_management_check_name_availability_with_subscription_request, + build_cdn_management_validate_probe_request, + build_custom_domains_create_request, + build_custom_domains_delete_request, + build_custom_domains_disable_custom_https_request, + build_custom_domains_enable_custom_https_request, + build_custom_domains_get_request, + build_custom_domains_list_by_endpoint_request, + build_edge_nodes_list_request, + build_endpoints_create_request, + build_endpoints_delete_request, + build_endpoints_get_request, + build_endpoints_list_by_profile_request, + build_endpoints_list_resource_usage_request, + build_endpoints_load_content_request, + build_endpoints_purge_content_request, + build_endpoints_start_request, + build_endpoints_stop_request, + build_endpoints_update_request, + build_endpoints_validate_custom_domain_request, + build_log_analytics_get_log_analytics_locations_request, + build_log_analytics_get_log_analytics_metrics_request, + build_log_analytics_get_log_analytics_rankings_request, + build_log_analytics_get_log_analytics_resources_request, + build_log_analytics_get_waf_log_analytics_metrics_request, + build_log_analytics_get_waf_log_analytics_rankings_request, + build_managed_rule_sets_list_request, + build_operations_list_request, + build_origin_groups_create_request, + build_origin_groups_delete_request, + build_origin_groups_get_request, + build_origin_groups_list_by_endpoint_request, + build_origin_groups_update_request, + build_origins_create_request, + build_origins_delete_request, + build_origins_get_request, + build_origins_list_by_endpoint_request, + build_origins_update_request, + build_policies_create_or_update_request, + build_policies_delete_request, + build_policies_get_request, + build_policies_list_request, + build_policies_update_request, + build_profiles_can_migrate_request, + build_profiles_cdn_can_migrate_to_afd_request, + build_profiles_cdn_migrate_to_afd_request, + build_profiles_create_request, + build_profiles_delete_request, + build_profiles_generate_sso_uri_request, + build_profiles_get_request, + build_profiles_list_by_resource_group_request, + build_profiles_list_request, + build_profiles_list_resource_usage_request, + build_profiles_list_supported_optimization_types_request, + build_profiles_migrate_request, + build_profiles_migration_abort_request, + build_profiles_migration_commit_request, + build_profiles_update_request, + build_resource_usage_list_request, + build_routes_create_request, + build_routes_delete_request, + build_routes_get_request, + build_routes_list_by_endpoint_request, + build_routes_update_request, + build_rule_sets_create_request, + build_rule_sets_delete_request, + build_rule_sets_get_request, + build_rule_sets_list_by_profile_request, + build_rule_sets_list_resource_usage_request, + build_rules_create_request, + build_rules_delete_request, + build_rules_get_request, + build_rules_list_by_rule_set_request, + build_rules_update_request, + build_secrets_create_request, + build_secrets_delete_request, + build_secrets_get_request, + build_secrets_list_by_profile_request, + build_security_policies_create_request, + build_security_policies_delete_request, + build_security_policies_get_request, + build_security_policies_list_by_profile_request, + build_security_policies_patch_request, +) +from .._configuration import CdnManagementClientConfiguration + T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] +JSON = MutableMapping[str, Any] +List = list class Operations: @@ -49,30 +174,820 @@ class Operations: :attr:`operations` attribute. """ - models = _models - def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + 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"]: - """Lists all of the available CDN REST API operations. + def list(self, **kwargs: Any) -> AsyncItemPaged["_models.Operation"]: + """List the operations for the provider. - :return: An iterator like instance of either Operation or the result of cls(response) + :return: An iterator like instance of Operation :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cdn.models.Operation] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Operation]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_operations_list_request( + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.Operation], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class ProfilesOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cdn.aio.CdnManagementClient`'s + :attr:`profiles` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: 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(self, resource_group_name: str, profile_name: str, **kwargs: Any) -> _models.Profile: + """Gets an Azure Front Door Standard or Azure Front Door Premium or CDN profile with the specified + profile name under the specified subscription and resource group. + + :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 or CDN + profile which is unique within the resource group. Required. + :type profile_name: str + :return: Profile. The Profile is compatible with MutableMapping + :rtype: ~azure.mgmt.cdn.models.Profile + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.Profile] = kwargs.pop("cls", None) + + _request = build_profiles_get_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Profile, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_initial( + self, + resource_group_name: str, + profile_name: str, + profile: Union[_models.Profile, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(profile, (IOBase, bytes)): + _content = profile + else: + _content = json.dumps(profile, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_profiles_create_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create( + self, + resource_group_name: str, + profile_name: str, + profile: _models.Profile, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Profile]: + """Creates a new Azure Front Door Standard or Azure Front Door Premium or CDN profile with a + profile name under the specified subscription and resource group. + + :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 or CDN + profile which is unique within the resource group. Required. + :type profile_name: str + :param profile: Profile properties needed to create a new profile. Required. + :type profile: ~azure.mgmt.cdn.models.Profile + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns Profile. The Profile is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Profile] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + profile_name: str, + profile: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Profile]: + """Creates a new Azure Front Door Standard or Azure Front Door Premium or CDN profile with a + profile name under the specified subscription and resource group. + + :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 or CDN + profile which is unique within the resource group. Required. + :type profile_name: str + :param profile: Profile properties needed to create a new profile. Required. + :type profile: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns Profile. The Profile is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Profile] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + profile_name: str, + profile: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Profile]: + """Creates a new Azure Front Door Standard or Azure Front Door Premium or CDN profile with a + profile name under the specified subscription and resource group. + + :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 or CDN + profile which is unique within the resource group. Required. + :type profile_name: str + :param profile: Profile properties needed to create a new profile. Required. + :type profile: IO[bytes] + :keyword content_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 Profile. The Profile is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Profile] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + profile_name: str, + profile: Union[_models.Profile, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.Profile]: + """Creates a new Azure Front Door Standard or Azure Front Door Premium or CDN profile with a + profile name under the specified subscription and resource group. + + :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 or CDN + profile which is unique within the resource group. Required. + :type profile_name: str + :param profile: Profile properties needed to create a new profile. Is one of the following + types: Profile, JSON, IO[bytes] Required. + :type profile: ~azure.mgmt.cdn.models.Profile or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns Profile. The Profile is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Profile] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Profile] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_initial( + resource_group_name=resource_group_name, + profile_name=profile_name, + profile=profile, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.Profile, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.Profile].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.Profile]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _update_initial( + self, + resource_group_name: str, + profile_name: str, + profile_update_parameters: Union[_models.ProfileUpdateParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(profile_update_parameters, (IOBase, bytes)): + _content = profile_update_parameters + else: + _content = json.dumps(profile_update_parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_profiles_update_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_update( + self, + resource_group_name: str, + profile_name: str, + profile_update_parameters: _models.ProfileUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Profile]: + """Updates an existing Azure Front Door Standard or Azure Front Door Premium or CDN profile with + the specified profile name under the specified subscription and resource group. + + :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 or CDN + profile which is unique within the resource group. Required. + :type profile_name: str + :param profile_update_parameters: Profile properties needed to update an existing profile. + Required. + :type profile_update_parameters: ~azure.mgmt.cdn.models.ProfileUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns Profile. The Profile is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Profile] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + profile_name: str, + profile_update_parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Profile]: + """Updates an existing Azure Front Door Standard or Azure Front Door Premium or CDN profile with + the specified profile name under the specified subscription and resource group. + + :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 or CDN + profile which is unique within the resource group. Required. + :type profile_name: str + :param profile_update_parameters: Profile properties needed to update an existing profile. + Required. + :type profile_update_parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns Profile. The Profile is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Profile] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + profile_name: str, + profile_update_parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Profile]: + """Updates an existing Azure Front Door Standard or Azure Front Door Premium or CDN profile with + the specified profile name under the specified subscription and resource group. + + :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 or CDN + profile which is unique within the resource group. Required. + :type profile_name: str + :param profile_update_parameters: Profile properties needed to update an existing profile. + Required. + :type profile_update_parameters: IO[bytes] + :keyword content_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 Profile. The Profile is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Profile] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + profile_name: str, + profile_update_parameters: Union[_models.ProfileUpdateParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.Profile]: + """Updates an existing Azure Front Door Standard or Azure Front Door Premium or CDN profile with + the specified profile name under the specified subscription and resource group. + + :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 or CDN + profile which is unique within the resource group. Required. + :type profile_name: str + :param profile_update_parameters: Profile properties needed to update an existing profile. Is + one of the following types: ProfileUpdateParameters, JSON, IO[bytes] Required. + :type profile_update_parameters: ~azure.mgmt.cdn.models.ProfileUpdateParameters or JSON or + IO[bytes] + :return: An instance of AsyncLROPoller that returns Profile. The Profile is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Profile] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Profile] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._update_initial( + resource_group_name=resource_group_name, + profile_name=profile_name, + profile_update_parameters=profile_update_parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.Profile, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.Profile].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.Profile]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + 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, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_profiles_delete_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete(self, resource_group_name: str, profile_name: str, **kwargs: Any) -> AsyncLROPoller[None]: + """Deletes an existing Azure Front Door Standard or Azure Front Door Premium or CDN profile with + the specified parameters. Deleting a profile will result in the deletion of all of the + sub-resources including endpoints, origins and custom domains. + + :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 or CDN + profile which is unique within the resource group. Required. + :type profile_name: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + profile_name=profile_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncItemPaged["_models.Profile"]: + """Lists all of the Azure Front Door Standard, Azure Front Door Premium, and CDN profiles within a + resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :return: An iterator like instance of Profile + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cdn.models.Profile] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.OperationsListResult] = kwargs.pop("cls", None) + cls: ClsType[List[_models.Profile]] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -83,13 +998,19 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: def prepare_request(next_link=None): if not next_link: - _request = build_list_request( - api_version=api_version, + _request = build_profiles_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, headers=_headers, params=_params, ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) else: # make call to next link with the client's api-version @@ -102,19 +1023,29 @@ def prepare_request(next_link=None): ) _next_request_params["api-version"] = self._config.api_version _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + return _request async def extract_data(pipeline_response): - deserialized = self._deserialize("OperationsListResult", pipeline_response) - list_of_elem = deserialized.value + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.Profile], + deserialized.get("value", []), + ) if cls: list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) async def get_next(next_link=None): _request = prepare_request(next_link) @@ -127,9 +1058,17511 @@ async def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list(self, **kwargs: Any) -> AsyncItemPaged["_models.Profile"]: + """Lists all of the Azure Front Door Standard, Azure Front Door Premium, and CDN profiles within + an Azure subscription. + + :return: An iterator like instance of Profile + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cdn.models.Profile] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Profile]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_profiles_list_request( + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.Profile], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + async def _migration_commit_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 = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_profiles_migration_commit_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_migration_commit( + self, resource_group_name: str, profile_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Commit the migrated 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 or CDN + profile which is unique within the resource group. Required. + :type profile_name: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._migration_commit_initial( + resource_group_name=resource_group_name, + profile_name=profile_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace_async + async def generate_sso_uri(self, resource_group_name: str, profile_name: str, **kwargs: Any) -> _models.SsoUri: + """Generates a dynamic SSO URI used to sign in to the CDN supplemental portal. Supplemental portal + is used to configure advanced feature capabilities that are not yet available in the Azure + portal, such as core reports in a standard profile; rules engine, advanced HTTP reports, and + real-time stats and alerts in a premium profile. The SSO URI changes approximately every 10 + minutes. + + :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 or CDN + profile which is unique within the resource group. Required. + :type profile_name: str + :return: SsoUri. The SsoUri is compatible with MutableMapping + :rtype: ~azure.mgmt.cdn.models.SsoUri + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.SsoUri] = kwargs.pop("cls", None) + + _request = build_profiles_generate_sso_uri_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.SsoUri, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def list_supported_optimization_types( + self, resource_group_name: str, profile_name: str, **kwargs: Any + ) -> _models.SupportedOptimizationTypesListResult: + """Gets the supported optimization types for the current profile. A user can create an endpoint + with an optimization type from the listed values. + + :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 or CDN + profile which is unique within the resource group. Required. + :type profile_name: str + :return: SupportedOptimizationTypesListResult. The SupportedOptimizationTypesListResult is + compatible with MutableMapping + :rtype: ~azure.mgmt.cdn.models.SupportedOptimizationTypesListResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.SupportedOptimizationTypesListResult] = kwargs.pop("cls", None) + + _request = build_profiles_list_supported_optimization_types_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.SupportedOptimizationTypesListResult, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_resource_usage( + self, resource_group_name: str, profile_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.ResourceUsage"]: + """Checks the quota and actual usage of endpoints under the given Azure Front Door Standard or + Azure Front Door Premium or CDN 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 or CDN + profile which is unique within the resource group. Required. + :type profile_name: str + :return: An iterator like instance of ResourceUsage + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cdn.models.ResourceUsage] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ResourceUsage]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_profiles_list_resource_usage_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ResourceUsage], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + async def _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 = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_profiles_cdn_can_migrate_to_afd_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_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 or CDN + profile which is unique within the resource group. Required. + :type profile_name: str + :return: An instance of AsyncLROPoller that returns CanMigrateResult. The CanMigrateResult is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.CanMigrateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.CanMigrateResult, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.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, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(migration_parameters, (IOBase, bytes)): + _content = migration_parameters + else: + _content = json.dumps(migration_parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_profiles_cdn_migrate_to_afd_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_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 or CDN + profile 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 MigrateResult. The MigrateResult is + compatible with MutableMapping + :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: JSON, + *, + 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 or CDN + profile 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: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns MigrateResult. The MigrateResult is + compatible with MutableMapping + :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 or CDN + profile 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 MigrateResult. The MigrateResult is + compatible with MutableMapping + :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, JSON, 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 or CDN + profile which is unique within the resource group. Required. + :type profile_name: str + :param migration_parameters: Properties needed to migrate the profile. Is one of the following + types: CdnMigrationToAfdParameters, JSON, IO[bytes] Required. + :type migration_parameters: ~azure.mgmt.cdn.models.CdnMigrationToAfdParameters or JSON or + IO[bytes] + :return: An instance of AsyncLROPoller that returns MigrateResult. The MigrateResult is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.MigrateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.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, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.MigrateResult, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.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 = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_profiles_migration_abort_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @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 or CDN + profile which is unique within the resource group. Required. + :type profile_name: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._migration_abort_initial( + resource_group_name=resource_group_name, + profile_name=profile_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + async def _can_migrate_initial( + self, + resource_group_name: str, + can_migrate_parameters: Union[_models.CanMigrateParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(can_migrate_parameters, (IOBase, bytes)): + _content = can_migrate_parameters + else: + _content = json.dumps(can_migrate_parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_profiles_can_migrate_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_can_migrate( + self, + resource_group_name: str, + can_migrate_parameters: _models.CanMigrateParameters, + *, + content_type: str = "application/json", + **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 can_migrate_parameters: Properties needed to check if cdn profile or classic frontdoor + can be migrated. Required. + :type can_migrate_parameters: ~azure.mgmt.cdn.models.CanMigrateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns CanMigrateResult. The CanMigrateResult is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.CanMigrateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_can_migrate( + self, + resource_group_name: str, + can_migrate_parameters: JSON, + *, + content_type: str = "application/json", + **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 can_migrate_parameters: Properties needed to check if cdn profile or classic frontdoor + can be migrated. Required. + :type can_migrate_parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns CanMigrateResult. The CanMigrateResult is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.CanMigrateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_can_migrate( + self, + resource_group_name: str, + can_migrate_parameters: IO[bytes], + *, + content_type: str = "application/json", + **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 can_migrate_parameters: Properties needed to check if cdn profile or classic frontdoor + can be migrated. Required. + :type can_migrate_parameters: IO[bytes] + :keyword content_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 CanMigrateResult. The CanMigrateResult is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.CanMigrateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_can_migrate( + self, + resource_group_name: str, + can_migrate_parameters: Union[_models.CanMigrateParameters, JSON, IO[bytes]], + **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 can_migrate_parameters: Properties needed to check if cdn profile or classic frontdoor + can be migrated. Is one of the following types: CanMigrateParameters, JSON, IO[bytes] Required. + :type can_migrate_parameters: ~azure.mgmt.cdn.models.CanMigrateParameters or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns CanMigrateResult. The CanMigrateResult is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.CanMigrateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.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._can_migrate_initial( + resource_group_name=resource_group_name, + can_migrate_parameters=can_migrate_parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.CanMigrateResult, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.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 _migrate_initial( + self, + resource_group_name: str, + migration_parameters: Union[_models.MigrationParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(migration_parameters, (IOBase, bytes)): + _content = migration_parameters + else: + _content = json.dumps(migration_parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_profiles_migrate_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_migrate( + self, + resource_group_name: str, + migration_parameters: _models.MigrationParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.MigrateResult]: + """Migrate the CDN profile to Azure Frontdoor(Standard/Premium) profile. The change need to be + committed after this. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param migration_parameters: Properties needed to migrate the profile. Required. + :type migration_parameters: ~azure.mgmt.cdn.models.MigrationParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns MigrateResult. The MigrateResult is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.MigrateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_migrate( + self, + resource_group_name: str, + migration_parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.MigrateResult]: + """Migrate the CDN profile to Azure Frontdoor(Standard/Premium) profile. The change need to be + committed after this. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param migration_parameters: Properties needed to migrate the profile. Required. + :type migration_parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns MigrateResult. The MigrateResult is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.MigrateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_migrate( + self, + resource_group_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. The change need to be + committed after this. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_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 MigrateResult. The MigrateResult is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.MigrateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_migrate( + self, + resource_group_name: str, + migration_parameters: Union[_models.MigrationParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.MigrateResult]: + """Migrate the CDN profile to Azure Frontdoor(Standard/Premium) profile. The change need to be + committed after this. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param migration_parameters: Properties needed to migrate the profile. Is one of the following + types: MigrationParameters, JSON, IO[bytes] Required. + :type migration_parameters: ~azure.mgmt.cdn.models.MigrationParameters or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns MigrateResult. The MigrateResult is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.MigrateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.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._migrate_initial( + resource_group_name=resource_group_name, + migration_parameters=migration_parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.MigrateResult, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.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 + ) + + +class AFDEndpointsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cdn.aio.CdnManagementClient`'s + :attr:`afd_endpoints` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: 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( + self, resource_group_name: str, profile_name: str, endpoint_name: str, **kwargs: Any + ) -> _models.AFDEndpoint: + """Gets an existing AzureFrontDoor endpoint with the specified endpoint name under the specified + subscription, resource group and 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 or CDN + profile 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. + :type endpoint_name: str + :return: AFDEndpoint. The AFDEndpoint is compatible with MutableMapping + :rtype: ~azure.mgmt.cdn.models.AFDEndpoint + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.AFDEndpoint] = kwargs.pop("cls", None) + + _request = build_afd_endpoints_get_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.AFDEndpoint, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_initial( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + endpoint: Union[_models.AFDEndpoint, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(endpoint, (IOBase, bytes)): + _content = endpoint + else: + _content = json.dumps(endpoint, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_afd_endpoints_create_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + endpoint: _models.AFDEndpoint, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AFDEndpoint]: + """Creates a new AzureFrontDoor endpoint with the specified endpoint name under the specified + subscription, resource group and 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 or CDN + profile 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. + :type endpoint_name: str + :param endpoint: Endpoint properties. Required. + :type endpoint: ~azure.mgmt.cdn.models.AFDEndpoint + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns AFDEndpoint. The AFDEndpoint is compatible + with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.AFDEndpoint] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + endpoint: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AFDEndpoint]: + """Creates a new AzureFrontDoor endpoint with the specified endpoint name under the specified + subscription, resource group and 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 or CDN + profile 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. + :type endpoint_name: str + :param endpoint: Endpoint properties. Required. + :type endpoint: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns AFDEndpoint. The AFDEndpoint is compatible + with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.AFDEndpoint] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + endpoint: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AFDEndpoint]: + """Creates a new AzureFrontDoor endpoint with the specified endpoint name under the specified + subscription, resource group and 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 or CDN + profile 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. + :type endpoint_name: str + :param endpoint: Endpoint properties. Required. + :type endpoint: IO[bytes] + :keyword content_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 AFDEndpoint. The AFDEndpoint is compatible + with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.AFDEndpoint] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + endpoint: Union[_models.AFDEndpoint, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.AFDEndpoint]: + """Creates a new AzureFrontDoor endpoint with the specified endpoint name under the specified + subscription, resource group and 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 or CDN + profile 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. + :type endpoint_name: str + :param endpoint: Endpoint properties. Is one of the following types: AFDEndpoint, JSON, + IO[bytes] Required. + :type endpoint: ~azure.mgmt.cdn.models.AFDEndpoint or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns AFDEndpoint. The AFDEndpoint is compatible + with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.AFDEndpoint] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AFDEndpoint] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_initial( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + endpoint=endpoint, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.AFDEndpoint, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.AFDEndpoint].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.AFDEndpoint]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _update_initial( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + endpoint_update_properties: Union[_models.AFDEndpointUpdateParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(endpoint_update_properties, (IOBase, bytes)): + _content = endpoint_update_properties + else: + _content = json.dumps(endpoint_update_properties, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_afd_endpoints_update_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_update( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + endpoint_update_properties: _models.AFDEndpointUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AFDEndpoint]: + """Updates an existing AzureFrontDoor endpoint with the specified endpoint name under the + specified subscription, resource group and profile. Only tags can be updated after creating an + endpoint. To update origins, use the Update Origin operation. To update origin groups, use the + Update Origin group operation. To update domains, use the Update Custom Domain operation. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param endpoint_update_properties: Endpoint update properties. Required. + :type endpoint_update_properties: ~azure.mgmt.cdn.models.AFDEndpointUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns AFDEndpoint. The AFDEndpoint is compatible + with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.AFDEndpoint] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + endpoint_update_properties: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AFDEndpoint]: + """Updates an existing AzureFrontDoor endpoint with the specified endpoint name under the + specified subscription, resource group and profile. Only tags can be updated after creating an + endpoint. To update origins, use the Update Origin operation. To update origin groups, use the + Update Origin group operation. To update domains, use the Update Custom Domain operation. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param endpoint_update_properties: Endpoint update properties. Required. + :type endpoint_update_properties: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns AFDEndpoint. The AFDEndpoint is compatible + with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.AFDEndpoint] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + endpoint_update_properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AFDEndpoint]: + """Updates an existing AzureFrontDoor endpoint with the specified endpoint name under the + specified subscription, resource group and profile. Only tags can be updated after creating an + endpoint. To update origins, use the Update Origin operation. To update origin groups, use the + Update Origin group operation. To update domains, use the Update Custom Domain operation. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param endpoint_update_properties: Endpoint update properties. Required. + :type endpoint_update_properties: IO[bytes] + :keyword content_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 AFDEndpoint. The AFDEndpoint is compatible + with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.AFDEndpoint] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + endpoint_update_properties: Union[_models.AFDEndpointUpdateParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.AFDEndpoint]: + """Updates an existing AzureFrontDoor endpoint with the specified endpoint name under the + specified subscription, resource group and profile. Only tags can be updated after creating an + endpoint. To update origins, use the Update Origin operation. To update origin groups, use the + Update Origin group operation. To update domains, use the Update Custom Domain operation. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param endpoint_update_properties: Endpoint update properties. Is one of the following types: + AFDEndpointUpdateParameters, JSON, IO[bytes] Required. + :type endpoint_update_properties: ~azure.mgmt.cdn.models.AFDEndpointUpdateParameters or JSON or + IO[bytes] + :return: An instance of AsyncLROPoller that returns AFDEndpoint. The AFDEndpoint is compatible + with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.AFDEndpoint] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AFDEndpoint] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._update_initial( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + endpoint_update_properties=endpoint_update_properties, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.AFDEndpoint, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.AFDEndpoint].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.AFDEndpoint]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _delete_initial( + self, resource_group_name: str, profile_name: str, endpoint_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_afd_endpoints_delete_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, profile_name: str, endpoint_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes an existing AzureFrontDoor endpoint with the specified endpoint name under the + specified subscription, resource group and 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 or CDN + profile 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. + :type endpoint_name: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_profile( + self, resource_group_name: str, profile_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.AFDEndpoint"]: + """Lists existing AzureFrontDoor endpoints. + + :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 or CDN + profile which is unique within the resource group. Required. + :type profile_name: str + :return: An iterator like instance of AFDEndpoint + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cdn.models.AFDEndpoint] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.AFDEndpoint]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_afd_endpoints_list_by_profile_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.AFDEndpoint], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + async def _purge_content_initial( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + contents: Union[_models.AfdPurgeParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(contents, (IOBase, bytes)): + _content = contents + else: + _content = json.dumps(contents, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_afd_endpoints_purge_content_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_purge_content( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + contents: _models.AfdPurgeParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Removes a content from AzureFrontDoor. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param contents: The list of paths to the content and the list of linked domains to be purged. + Path can be a full URL, e.g. '/pictures/city.png' which removes a single file, or a directory + with a wildcard, e.g. '/pictures/*' which removes all folders and files in the directory. + Required. + :type contents: ~azure.mgmt.cdn.models.AfdPurgeParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_purge_content( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + contents: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Removes a content from AzureFrontDoor. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param contents: The list of paths to the content and the list of linked domains to be purged. + Path can be a full URL, e.g. '/pictures/city.png' which removes a single file, or a directory + with a wildcard, e.g. '/pictures/*' which removes all folders and files in the directory. + Required. + :type contents: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_purge_content( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + contents: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Removes a content from AzureFrontDoor. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param contents: The list of paths to the content and the list of linked domains to be purged. + Path can be a full URL, e.g. '/pictures/city.png' which removes a single file, or a directory + with a wildcard, e.g. '/pictures/*' which removes all folders and files in the directory. + Required. + :type contents: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_purge_content( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + contents: Union[_models.AfdPurgeParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Removes a content from AzureFrontDoor. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param contents: The list of paths to the content and the list of linked domains to be purged. + Path can be a full URL, e.g. '/pictures/city.png' which removes a single file, or a directory + with a wildcard, e.g. '/pictures/*' which removes all folders and files in the directory. Is + one of the following types: AfdPurgeParameters, JSON, IO[bytes] Required. + :type contents: ~azure.mgmt.cdn.models.AfdPurgeParameters or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._purge_content_initial( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + contents=contents, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_resource_usage( + self, resource_group_name: str, profile_name: str, endpoint_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.Usage"]: + """Checks the quota and actual usage of endpoints under the given Azure Front Door 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 or CDN + profile 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. + :type endpoint_name: str + :return: An iterator like instance of Usage + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cdn.models.Usage] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Usage]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_afd_endpoints_list_resource_usage_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.Usage], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @overload + async def validate_custom_domain( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + custom_domain_properties: _models.ValidateCustomDomainInput, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ValidateCustomDomainOutput: + """Validates the custom domain mapping to ensure it maps to the correct Azure Front Door endpoint + in DNS. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param custom_domain_properties: Custom domain to be validated. Required. + :type custom_domain_properties: ~azure.mgmt.cdn.models.ValidateCustomDomainInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ValidateCustomDomainOutput. The ValidateCustomDomainOutput is compatible with + MutableMapping + :rtype: ~azure.mgmt.cdn.models.ValidateCustomDomainOutput + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def validate_custom_domain( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + custom_domain_properties: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ValidateCustomDomainOutput: + """Validates the custom domain mapping to ensure it maps to the correct Azure Front Door endpoint + in DNS. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param custom_domain_properties: Custom domain to be validated. Required. + :type custom_domain_properties: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ValidateCustomDomainOutput. The ValidateCustomDomainOutput is compatible with + MutableMapping + :rtype: ~azure.mgmt.cdn.models.ValidateCustomDomainOutput + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def validate_custom_domain( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + custom_domain_properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ValidateCustomDomainOutput: + """Validates the custom domain mapping to ensure it maps to the correct Azure Front Door endpoint + in DNS. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param custom_domain_properties: Custom domain to be validated. Required. + :type custom_domain_properties: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ValidateCustomDomainOutput. The ValidateCustomDomainOutput is compatible with + MutableMapping + :rtype: ~azure.mgmt.cdn.models.ValidateCustomDomainOutput + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def validate_custom_domain( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + custom_domain_properties: Union[_models.ValidateCustomDomainInput, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.ValidateCustomDomainOutput: + """Validates the custom domain mapping to ensure it maps to the correct Azure Front Door endpoint + in DNS. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param custom_domain_properties: Custom domain to be validated. Is one of the following types: + ValidateCustomDomainInput, JSON, IO[bytes] Required. + :type custom_domain_properties: ~azure.mgmt.cdn.models.ValidateCustomDomainInput or JSON or + IO[bytes] + :return: ValidateCustomDomainOutput. The ValidateCustomDomainOutput is compatible with + MutableMapping + :rtype: ~azure.mgmt.cdn.models.ValidateCustomDomainOutput + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ValidateCustomDomainOutput] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(custom_domain_properties, (IOBase, bytes)): + _content = custom_domain_properties + else: + _content = json.dumps(custom_domain_properties, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_afd_endpoints_validate_custom_domain_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ValidateCustomDomainOutput, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class AFDOriginGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cdn.aio.CdnManagementClient`'s + :attr:`afd_origin_groups` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: 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( + self, resource_group_name: str, profile_name: str, origin_group_name: str, **kwargs: Any + ) -> _models.AFDOriginGroup: + """Gets an existing origin group within a 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 or CDN + profile 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. + :type origin_group_name: str + :return: AFDOriginGroup. The AFDOriginGroup is compatible with MutableMapping + :rtype: ~azure.mgmt.cdn.models.AFDOriginGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.AFDOriginGroup] = kwargs.pop("cls", None) + + _request = build_afd_origin_groups_get_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + origin_group_name=origin_group_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.AFDOriginGroup, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_initial( + self, + resource_group_name: str, + profile_name: str, + origin_group_name: str, + origin_group: Union[_models.AFDOriginGroup, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(origin_group, (IOBase, bytes)): + _content = origin_group + else: + _content = json.dumps(origin_group, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_afd_origin_groups_create_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + origin_group_name=origin_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create( + self, + resource_group_name: str, + profile_name: str, + origin_group_name: str, + origin_group: _models.AFDOriginGroup, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AFDOriginGroup]: + """Creates a new origin group within the specified 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 or CDN + profile 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. + :type origin_group_name: str + :param origin_group: Origin group properties. Required. + :type origin_group: ~azure.mgmt.cdn.models.AFDOriginGroup + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns AFDOriginGroup. The AFDOriginGroup is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.AFDOriginGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + profile_name: str, + origin_group_name: str, + origin_group: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AFDOriginGroup]: + """Creates a new origin group within the specified 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 or CDN + profile 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. + :type origin_group_name: str + :param origin_group: Origin group properties. Required. + :type origin_group: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns AFDOriginGroup. The AFDOriginGroup is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.AFDOriginGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + profile_name: str, + origin_group_name: str, + origin_group: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AFDOriginGroup]: + """Creates a new origin group within the specified 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 or CDN + profile 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. + :type origin_group_name: str + :param origin_group: Origin group properties. Required. + :type origin_group: IO[bytes] + :keyword content_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 AFDOriginGroup. The AFDOriginGroup is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.AFDOriginGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + profile_name: str, + origin_group_name: str, + origin_group: Union[_models.AFDOriginGroup, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.AFDOriginGroup]: + """Creates a new origin group within the specified 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 or CDN + profile 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. + :type origin_group_name: str + :param origin_group: Origin group properties. Is one of the following types: AFDOriginGroup, + JSON, IO[bytes] Required. + :type origin_group: ~azure.mgmt.cdn.models.AFDOriginGroup or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns AFDOriginGroup. The AFDOriginGroup is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.AFDOriginGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AFDOriginGroup] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_initial( + resource_group_name=resource_group_name, + profile_name=profile_name, + origin_group_name=origin_group_name, + origin_group=origin_group, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.AFDOriginGroup, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.AFDOriginGroup].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.AFDOriginGroup]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _update_initial( + self, + resource_group_name: str, + profile_name: str, + origin_group_name: str, + origin_group_update_properties: Union[_models.AFDOriginGroupUpdateParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(origin_group_update_properties, (IOBase, bytes)): + _content = origin_group_update_properties + else: + _content = json.dumps(origin_group_update_properties, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_afd_origin_groups_update_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + origin_group_name=origin_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_update( + self, + resource_group_name: str, + profile_name: str, + origin_group_name: str, + origin_group_update_properties: _models.AFDOriginGroupUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AFDOriginGroup]: + """Updates an existing origin group within a 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 or CDN + profile 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. + :type origin_group_name: str + :param origin_group_update_properties: Origin group properties. Required. + :type origin_group_update_properties: ~azure.mgmt.cdn.models.AFDOriginGroupUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns AFDOriginGroup. The AFDOriginGroup is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.AFDOriginGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + profile_name: str, + origin_group_name: str, + origin_group_update_properties: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AFDOriginGroup]: + """Updates an existing origin group within a 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 or CDN + profile 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. + :type origin_group_name: str + :param origin_group_update_properties: Origin group properties. Required. + :type origin_group_update_properties: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns AFDOriginGroup. The AFDOriginGroup is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.AFDOriginGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + profile_name: str, + origin_group_name: str, + origin_group_update_properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AFDOriginGroup]: + """Updates an existing origin group within a 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 or CDN + profile 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. + :type origin_group_name: str + :param origin_group_update_properties: Origin group properties. Required. + :type origin_group_update_properties: IO[bytes] + :keyword content_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 AFDOriginGroup. The AFDOriginGroup is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.AFDOriginGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + profile_name: str, + origin_group_name: str, + origin_group_update_properties: Union[_models.AFDOriginGroupUpdateParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.AFDOriginGroup]: + """Updates an existing origin group within a 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 or CDN + profile 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. + :type origin_group_name: str + :param origin_group_update_properties: Origin group properties. Is one of the following types: + AFDOriginGroupUpdateParameters, JSON, IO[bytes] Required. + :type origin_group_update_properties: ~azure.mgmt.cdn.models.AFDOriginGroupUpdateParameters or + JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns AFDOriginGroup. The AFDOriginGroup is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.AFDOriginGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AFDOriginGroup] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._update_initial( + resource_group_name=resource_group_name, + profile_name=profile_name, + origin_group_name=origin_group_name, + origin_group_update_properties=origin_group_update_properties, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.AFDOriginGroup, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.AFDOriginGroup].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.AFDOriginGroup]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _delete_initial( + self, resource_group_name: str, profile_name: str, origin_group_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_afd_origin_groups_delete_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + origin_group_name=origin_group_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, profile_name: str, origin_group_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes an existing origin group within a 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 or CDN + profile 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. + :type origin_group_name: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + profile_name=profile_name, + origin_group_name=origin_group_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_profile( + self, resource_group_name: str, profile_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.AFDOriginGroup"]: + """Lists all of the existing origin groups within a 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 or CDN + profile which is unique within the resource group. Required. + :type profile_name: str + :return: An iterator like instance of AFDOriginGroup + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cdn.models.AFDOriginGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.AFDOriginGroup]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_afd_origin_groups_list_by_profile_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.AFDOriginGroup], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list_resource_usage( + self, resource_group_name: str, profile_name: str, origin_group_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.Usage"]: + """Checks the quota and actual usage of endpoints under the given Azure Front Door 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 or CDN + profile 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. + :type origin_group_name: str + :return: An iterator like instance of Usage + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cdn.models.Usage] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Usage]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_afd_origin_groups_list_resource_usage_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + origin_group_name=origin_group_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.Usage], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class AFDOriginsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cdn.aio.CdnManagementClient`'s + :attr:`afd_origins` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: 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( + self, resource_group_name: str, profile_name: str, origin_group_name: str, origin_name: str, **kwargs: Any + ) -> _models.AFDOrigin: + """Gets an existing origin within an origin group. + + :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 or CDN + profile 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. + :type origin_group_name: str + :param origin_name: Name of the origin which is unique within the profile. Required. + :type origin_name: str + :return: AFDOrigin. The AFDOrigin is compatible with MutableMapping + :rtype: ~azure.mgmt.cdn.models.AFDOrigin + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.AFDOrigin] = kwargs.pop("cls", None) + + _request = build_afd_origins_get_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + origin_group_name=origin_group_name, + origin_name=origin_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.AFDOrigin, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_initial( + self, + resource_group_name: str, + profile_name: str, + origin_group_name: str, + origin_name: str, + origin: Union[_models.AFDOrigin, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(origin, (IOBase, bytes)): + _content = origin + else: + _content = json.dumps(origin, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_afd_origins_create_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + origin_group_name=origin_group_name, + origin_name=origin_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create( + self, + resource_group_name: str, + profile_name: str, + origin_group_name: str, + origin_name: str, + origin: _models.AFDOrigin, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AFDOrigin]: + """Creates a new origin within the specified origin group. + + :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 or CDN + profile 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. + :type origin_group_name: str + :param origin_name: Name of the origin which is unique within the profile. Required. + :type origin_name: str + :param origin: Origin properties. Required. + :type origin: ~azure.mgmt.cdn.models.AFDOrigin + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns AFDOrigin. The AFDOrigin is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.AFDOrigin] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + profile_name: str, + origin_group_name: str, + origin_name: str, + origin: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AFDOrigin]: + """Creates a new origin within the specified origin group. + + :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 or CDN + profile 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. + :type origin_group_name: str + :param origin_name: Name of the origin which is unique within the profile. Required. + :type origin_name: str + :param origin: Origin properties. Required. + :type origin: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns AFDOrigin. The AFDOrigin is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.AFDOrigin] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + profile_name: str, + origin_group_name: str, + origin_name: str, + origin: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AFDOrigin]: + """Creates a new origin within the specified origin group. + + :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 or CDN + profile 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. + :type origin_group_name: str + :param origin_name: Name of the origin which is unique within the profile. Required. + :type origin_name: str + :param origin: Origin properties. Required. + :type origin: IO[bytes] + :keyword content_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 AFDOrigin. The AFDOrigin is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.AFDOrigin] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + profile_name: str, + origin_group_name: str, + origin_name: str, + origin: Union[_models.AFDOrigin, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.AFDOrigin]: + """Creates a new origin within the specified origin group. + + :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 or CDN + profile 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. + :type origin_group_name: str + :param origin_name: Name of the origin which is unique within the profile. Required. + :type origin_name: str + :param origin: Origin properties. Is one of the following types: AFDOrigin, JSON, IO[bytes] + Required. + :type origin: ~azure.mgmt.cdn.models.AFDOrigin or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns AFDOrigin. The AFDOrigin is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.AFDOrigin] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AFDOrigin] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_initial( + resource_group_name=resource_group_name, + profile_name=profile_name, + origin_group_name=origin_group_name, + origin_name=origin_name, + origin=origin, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.AFDOrigin, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.AFDOrigin].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.AFDOrigin]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _update_initial( + self, + resource_group_name: str, + profile_name: str, + origin_group_name: str, + origin_name: str, + origin_update_properties: Union[_models.AFDOriginUpdateParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(origin_update_properties, (IOBase, bytes)): + _content = origin_update_properties + else: + _content = json.dumps(origin_update_properties, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_afd_origins_update_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + origin_group_name=origin_group_name, + origin_name=origin_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_update( + self, + resource_group_name: str, + profile_name: str, + origin_group_name: str, + origin_name: str, + origin_update_properties: _models.AFDOriginUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AFDOrigin]: + """Updates an existing origin within an origin group. + + :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 or CDN + profile 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. + :type origin_group_name: str + :param origin_name: Name of the origin which is unique within the profile. Required. + :type origin_name: str + :param origin_update_properties: Origin properties. Required. + :type origin_update_properties: ~azure.mgmt.cdn.models.AFDOriginUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns AFDOrigin. The AFDOrigin is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.AFDOrigin] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + profile_name: str, + origin_group_name: str, + origin_name: str, + origin_update_properties: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AFDOrigin]: + """Updates an existing origin within an origin group. + + :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 or CDN + profile 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. + :type origin_group_name: str + :param origin_name: Name of the origin which is unique within the profile. Required. + :type origin_name: str + :param origin_update_properties: Origin properties. Required. + :type origin_update_properties: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns AFDOrigin. The AFDOrigin is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.AFDOrigin] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + profile_name: str, + origin_group_name: str, + origin_name: str, + origin_update_properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AFDOrigin]: + """Updates an existing origin within an origin group. + + :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 or CDN + profile 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. + :type origin_group_name: str + :param origin_name: Name of the origin which is unique within the profile. Required. + :type origin_name: str + :param origin_update_properties: Origin properties. Required. + :type origin_update_properties: IO[bytes] + :keyword content_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 AFDOrigin. The AFDOrigin is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.AFDOrigin] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + profile_name: str, + origin_group_name: str, + origin_name: str, + origin_update_properties: Union[_models.AFDOriginUpdateParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.AFDOrigin]: + """Updates an existing origin within an origin group. + + :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 or CDN + profile 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. + :type origin_group_name: str + :param origin_name: Name of the origin which is unique within the profile. Required. + :type origin_name: str + :param origin_update_properties: Origin properties. Is one of the following types: + AFDOriginUpdateParameters, JSON, IO[bytes] Required. + :type origin_update_properties: ~azure.mgmt.cdn.models.AFDOriginUpdateParameters or JSON or + IO[bytes] + :return: An instance of AsyncLROPoller that returns AFDOrigin. The AFDOrigin is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.AFDOrigin] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AFDOrigin] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._update_initial( + resource_group_name=resource_group_name, + profile_name=profile_name, + origin_group_name=origin_group_name, + origin_name=origin_name, + origin_update_properties=origin_update_properties, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.AFDOrigin, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.AFDOrigin].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.AFDOrigin]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _delete_initial( + self, resource_group_name: str, profile_name: str, origin_group_name: str, origin_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_afd_origins_delete_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + origin_group_name=origin_group_name, + origin_name=origin_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, profile_name: str, origin_group_name: str, origin_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes an existing origin within an origin group. + + :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 or CDN + profile 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. + :type origin_group_name: str + :param origin_name: Name of the origin which is unique within the profile. Required. + :type origin_name: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + profile_name=profile_name, + origin_group_name=origin_group_name, + origin_name=origin_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_origin_group( + self, resource_group_name: str, profile_name: str, origin_group_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.AFDOrigin"]: + """Lists all of the existing origins within an origin group. + + :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 or CDN + profile 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. + :type origin_group_name: str + :return: An iterator like instance of AFDOrigin + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cdn.models.AFDOrigin] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.AFDOrigin]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_afd_origins_list_by_origin_group_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + origin_group_name=origin_group_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.AFDOrigin], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class RoutesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cdn.aio.CdnManagementClient`'s + :attr:`routes` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: 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( + self, resource_group_name: str, profile_name: str, endpoint_name: str, route_name: str, **kwargs: Any + ) -> _models.Route: + """Gets an existing route with the specified route name under the specified subscription, resource + group, profile, and AzureFrontDoor endpoint. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param route_name: Name of the routing rule. Required. + :type route_name: str + :return: Route. The Route is compatible with MutableMapping + :rtype: ~azure.mgmt.cdn.models.Route + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.Route] = kwargs.pop("cls", None) + + _request = build_routes_get_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + route_name=route_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Route, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_initial( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + route_name: str, + route: Union[_models.Route, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(route, (IOBase, bytes)): + _content = route + else: + _content = json.dumps(route, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_routes_create_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + route_name=route_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + route_name: str, + route: _models.Route, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Route]: + """Creates a new route with the specified route name under the specified subscription, resource + group, profile, and AzureFrontDoor endpoint. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param route_name: Name of the routing rule. Required. + :type route_name: str + :param route: Route properties. Required. + :type route: ~azure.mgmt.cdn.models.Route + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns Route. The Route is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Route] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + route_name: str, + route: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Route]: + """Creates a new route with the specified route name under the specified subscription, resource + group, profile, and AzureFrontDoor endpoint. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param route_name: Name of the routing rule. Required. + :type route_name: str + :param route: Route properties. Required. + :type route: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns Route. The Route is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Route] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + route_name: str, + route: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Route]: + """Creates a new route with the specified route name under the specified subscription, resource + group, profile, and AzureFrontDoor endpoint. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param route_name: Name of the routing rule. Required. + :type route_name: str + :param route: Route properties. Required. + :type route: IO[bytes] + :keyword content_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 Route. The Route is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Route] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + route_name: str, + route: Union[_models.Route, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.Route]: + """Creates a new route with the specified route name under the specified subscription, resource + group, profile, and AzureFrontDoor endpoint. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param route_name: Name of the routing rule. Required. + :type route_name: str + :param route: Route properties. Is one of the following types: Route, JSON, IO[bytes] Required. + :type route: ~azure.mgmt.cdn.models.Route or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns Route. The Route is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Route] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Route] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_initial( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + route_name=route_name, + route=route, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.Route, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.Route].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.Route]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _update_initial( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + route_name: str, + route_update_properties: Union[_models.RouteUpdateParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(route_update_properties, (IOBase, bytes)): + _content = route_update_properties + else: + _content = json.dumps(route_update_properties, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_routes_update_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + route_name=route_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_update( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + route_name: str, + route_update_properties: _models.RouteUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Route]: + """Updates an existing route with the specified route name under the specified subscription, + resource group, profile, and AzureFrontDoor endpoint. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param route_name: Name of the routing rule. Required. + :type route_name: str + :param route_update_properties: Route update properties. Required. + :type route_update_properties: ~azure.mgmt.cdn.models.RouteUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns Route. The Route is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Route] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + route_name: str, + route_update_properties: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Route]: + """Updates an existing route with the specified route name under the specified subscription, + resource group, profile, and AzureFrontDoor endpoint. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param route_name: Name of the routing rule. Required. + :type route_name: str + :param route_update_properties: Route update properties. Required. + :type route_update_properties: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns Route. The Route is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Route] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + route_name: str, + route_update_properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Route]: + """Updates an existing route with the specified route name under the specified subscription, + resource group, profile, and AzureFrontDoor endpoint. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param route_name: Name of the routing rule. Required. + :type route_name: str + :param route_update_properties: Route update properties. Required. + :type route_update_properties: IO[bytes] + :keyword content_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 Route. The Route is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Route] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + route_name: str, + route_update_properties: Union[_models.RouteUpdateParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.Route]: + """Updates an existing route with the specified route name under the specified subscription, + resource group, profile, and AzureFrontDoor endpoint. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param route_name: Name of the routing rule. Required. + :type route_name: str + :param route_update_properties: Route update properties. Is one of the following types: + RouteUpdateParameters, JSON, IO[bytes] Required. + :type route_update_properties: ~azure.mgmt.cdn.models.RouteUpdateParameters or JSON or + IO[bytes] + :return: An instance of AsyncLROPoller that returns Route. The Route is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Route] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Route] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._update_initial( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + route_name=route_name, + route_update_properties=route_update_properties, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.Route, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.Route].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.Route]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _delete_initial( + self, resource_group_name: str, profile_name: str, endpoint_name: str, route_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_routes_delete_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + route_name=route_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, profile_name: str, endpoint_name: str, route_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes an existing route with the specified route name under the specified subscription, + resource group, profile, and AzureFrontDoor endpoint. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param route_name: Name of the routing rule. Required. + :type route_name: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + route_name=route_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_endpoint( + self, resource_group_name: str, profile_name: str, endpoint_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.Route"]: + """Lists all of the existing origins within a 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 or CDN + profile 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. + :type endpoint_name: str + :return: An iterator like instance of Route + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cdn.models.Route] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Route]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_routes_list_by_endpoint_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.Route], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class RuleSetsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cdn.aio.CdnManagementClient`'s + :attr:`rule_sets` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: 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( + self, resource_group_name: str, profile_name: str, rule_set_name: str, **kwargs: Any + ) -> _models.RuleSet: + """Gets an existing AzureFrontDoor rule set with the specified rule set name under the specified + subscription, resource group and 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 or CDN + profile 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. + :type rule_set_name: str + :return: RuleSet. The RuleSet is compatible with MutableMapping + :rtype: ~azure.mgmt.cdn.models.RuleSet + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.RuleSet] = kwargs.pop("cls", None) + + _request = build_rule_sets_get_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + rule_set_name=rule_set_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.RuleSet, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @api_version_validation( + method_added_on="2025-12-01", + params_added_on={ + "2025-12-01": [ + "api_version", + "subscription_id", + "resource_group_name", + "profile_name", + "rule_set_name", + "content_type", + "accept", + ] + }, + api_versions_list=["2025-12-01"], + ) + async def _create_initial( + self, + resource_group_name: str, + profile_name: str, + rule_set_name: str, + resource: Optional[Union[_models.RuleSet, JSON, IO[bytes]]] = None, + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + content_type = content_type if resource else None + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" if resource else None + _content = None + if isinstance(resource, (IOBase, bytes)): + _content = resource + else: + if resource is not None: + _content = json.dumps(resource, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + else: + _content = None + + _request = build_rule_sets_create_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + rule_set_name=rule_set_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create( + self, + resource_group_name: str, + profile_name: str, + rule_set_name: str, + resource: Optional[_models.RuleSet] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.RuleSet]: + """Creates or update a batch rule set within the specified profile along with the rules associate + to it. + + :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 or CDN + profile 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. + :type rule_set_name: str + :param resource: Resource create parameters. Default value is None. + :type resource: ~azure.mgmt.cdn.models.RuleSet + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns RuleSet. The RuleSet is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.RuleSet] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + profile_name: str, + rule_set_name: str, + resource: Optional[JSON] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.RuleSet]: + """Creates or update a batch rule set within the specified profile along with the rules associate + to it. + + :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 or CDN + profile 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. + :type rule_set_name: str + :param resource: Resource create parameters. Default value is None. + :type resource: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns RuleSet. The RuleSet is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.RuleSet] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + profile_name: str, + rule_set_name: str, + resource: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.RuleSet]: + """Creates or update a batch rule set within the specified profile along with the rules associate + to it. + + :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 or CDN + profile 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. + :type rule_set_name: str + :param resource: Resource create parameters. Default value is None. + :type resource: IO[bytes] + :keyword content_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 RuleSet. The RuleSet is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.RuleSet] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + @api_version_validation( + method_added_on="2025-12-01", + params_added_on={ + "2025-12-01": [ + "api_version", + "subscription_id", + "resource_group_name", + "profile_name", + "rule_set_name", + "content_type", + "accept", + ] + }, + api_versions_list=["2025-12-01"], + ) + async def begin_create( + self, + resource_group_name: str, + profile_name: str, + rule_set_name: str, + resource: Optional[Union[_models.RuleSet, JSON, IO[bytes]]] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.RuleSet]: + """Creates or update a batch rule set within the specified profile along with the rules associate + to it. + + :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 or CDN + profile 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. + :type rule_set_name: str + :param resource: Resource create parameters. Is one of the following types: RuleSet, JSON, + IO[bytes] Default value is None. + :type resource: ~azure.mgmt.cdn.models.RuleSet or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns RuleSet. The RuleSet is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.RuleSet] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + content_type = content_type if resource else None + cls: ClsType[_models.RuleSet] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_initial( + resource_group_name=resource_group_name, + profile_name=profile_name, + rule_set_name=rule_set_name, + resource=resource, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.RuleSet, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.RuleSet].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.RuleSet]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _delete_initial( + self, resource_group_name: str, profile_name: str, rule_set_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_rule_sets_delete_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + rule_set_name=rule_set_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, profile_name: str, rule_set_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes an existing AzureFrontDoor rule set with the specified rule set name under the + specified subscription, resource group and 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 or CDN + profile 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. + :type rule_set_name: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + profile_name=profile_name, + rule_set_name=rule_set_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_profile( + self, resource_group_name: str, profile_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.RuleSet"]: + """Lists existing AzureFrontDoor rule sets within a 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 or CDN + profile which is unique within the resource group. Required. + :type profile_name: str + :return: An iterator like instance of RuleSet + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cdn.models.RuleSet] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.RuleSet]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_rule_sets_list_by_profile_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.RuleSet], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list_resource_usage( + self, resource_group_name: str, profile_name: str, rule_set_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.Usage"]: + """Checks the quota and actual usage of endpoints under the given Azure Front Door 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 or CDN + profile 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. + :type rule_set_name: str + :return: An iterator like instance of Usage + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cdn.models.Usage] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Usage]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_rule_sets_list_resource_usage_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + rule_set_name=rule_set_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.Usage], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class RulesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cdn.aio.CdnManagementClient`'s + :attr:`rules` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: 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( + self, resource_group_name: str, profile_name: str, rule_set_name: str, rule_name: str, **kwargs: Any + ) -> _models.Rule: + """Gets an existing delivery rule within a rule set. + + :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 or CDN + profile 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. + :type rule_set_name: str + :param rule_name: Name of the delivery rule which is unique within the endpoint. Required. + :type rule_name: str + :return: Rule. The Rule is compatible with MutableMapping + :rtype: ~azure.mgmt.cdn.models.Rule + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.Rule] = kwargs.pop("cls", None) + + _request = build_rules_get_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + rule_set_name=rule_set_name, + rule_name=rule_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Rule, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_initial( + self, + resource_group_name: str, + profile_name: str, + rule_set_name: str, + rule_name: str, + rule: Union[_models.Rule, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(rule, (IOBase, bytes)): + _content = rule + else: + _content = json.dumps(rule, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_rules_create_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + rule_set_name=rule_set_name, + rule_name=rule_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create( + self, + resource_group_name: str, + profile_name: str, + rule_set_name: str, + rule_name: str, + rule: _models.Rule, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Rule]: + """Creates a new delivery rule within the specified rule set. + + :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 or CDN + profile 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. + :type rule_set_name: str + :param rule_name: Name of the delivery rule which is unique within the endpoint. Required. + :type rule_name: str + :param rule: The delivery rule properties. Required. + :type rule: ~azure.mgmt.cdn.models.Rule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns Rule. The Rule is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Rule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + profile_name: str, + rule_set_name: str, + rule_name: str, + rule: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Rule]: + """Creates a new delivery rule within the specified rule set. + + :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 or CDN + profile 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. + :type rule_set_name: str + :param rule_name: Name of the delivery rule which is unique within the endpoint. Required. + :type rule_name: str + :param rule: The delivery rule properties. Required. + :type rule: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns Rule. The Rule is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Rule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + profile_name: str, + rule_set_name: str, + rule_name: str, + rule: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Rule]: + """Creates a new delivery rule within the specified rule set. + + :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 or CDN + profile 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. + :type rule_set_name: str + :param rule_name: Name of the delivery rule which is unique within the endpoint. Required. + :type rule_name: str + :param rule: The delivery rule properties. Required. + :type rule: IO[bytes] + :keyword content_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 Rule. The Rule is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Rule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + profile_name: str, + rule_set_name: str, + rule_name: str, + rule: Union[_models.Rule, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.Rule]: + """Creates a new delivery rule within the specified rule set. + + :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 or CDN + profile 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. + :type rule_set_name: str + :param rule_name: Name of the delivery rule which is unique within the endpoint. Required. + :type rule_name: str + :param rule: The delivery rule properties. Is one of the following types: Rule, JSON, IO[bytes] + Required. + :type rule: ~azure.mgmt.cdn.models.Rule or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns Rule. The Rule is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Rule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Rule] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_initial( + resource_group_name=resource_group_name, + profile_name=profile_name, + rule_set_name=rule_set_name, + rule_name=rule_name, + rule=rule, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.Rule, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.Rule].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.Rule]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _update_initial( + self, + resource_group_name: str, + profile_name: str, + rule_set_name: str, + rule_name: str, + rule_update_properties: Union[_models.RuleUpdateParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(rule_update_properties, (IOBase, bytes)): + _content = rule_update_properties + else: + _content = json.dumps(rule_update_properties, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_rules_update_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + rule_set_name=rule_set_name, + rule_name=rule_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_update( + self, + resource_group_name: str, + profile_name: str, + rule_set_name: str, + rule_name: str, + rule_update_properties: _models.RuleUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Rule]: + """Updates an existing delivery rule within a rule set. + + :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 or CDN + profile 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. + :type rule_set_name: str + :param rule_name: Name of the delivery rule which is unique within the endpoint. Required. + :type rule_name: str + :param rule_update_properties: Delivery rule properties. Required. + :type rule_update_properties: ~azure.mgmt.cdn.models.RuleUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns Rule. The Rule is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Rule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + profile_name: str, + rule_set_name: str, + rule_name: str, + rule_update_properties: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Rule]: + """Updates an existing delivery rule within a rule set. + + :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 or CDN + profile 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. + :type rule_set_name: str + :param rule_name: Name of the delivery rule which is unique within the endpoint. Required. + :type rule_name: str + :param rule_update_properties: Delivery rule properties. Required. + :type rule_update_properties: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns Rule. The Rule is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Rule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + profile_name: str, + rule_set_name: str, + rule_name: str, + rule_update_properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Rule]: + """Updates an existing delivery rule within a rule set. + + :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 or CDN + profile 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. + :type rule_set_name: str + :param rule_name: Name of the delivery rule which is unique within the endpoint. Required. + :type rule_name: str + :param rule_update_properties: Delivery rule properties. Required. + :type rule_update_properties: IO[bytes] + :keyword content_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 Rule. The Rule is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Rule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + profile_name: str, + rule_set_name: str, + rule_name: str, + rule_update_properties: Union[_models.RuleUpdateParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.Rule]: + """Updates an existing delivery rule within a rule set. + + :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 or CDN + profile 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. + :type rule_set_name: str + :param rule_name: Name of the delivery rule which is unique within the endpoint. Required. + :type rule_name: str + :param rule_update_properties: Delivery rule properties. Is one of the following types: + RuleUpdateParameters, JSON, IO[bytes] Required. + :type rule_update_properties: ~azure.mgmt.cdn.models.RuleUpdateParameters or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns Rule. The Rule is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Rule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Rule] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._update_initial( + resource_group_name=resource_group_name, + profile_name=profile_name, + rule_set_name=rule_set_name, + rule_name=rule_name, + rule_update_properties=rule_update_properties, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.Rule, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.Rule].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.Rule]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _delete_initial( + self, resource_group_name: str, profile_name: str, rule_set_name: str, rule_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_rules_delete_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + rule_set_name=rule_set_name, + rule_name=rule_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, profile_name: str, rule_set_name: str, rule_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes an existing delivery rule within a rule set. + + :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 or CDN + profile 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. + :type rule_set_name: str + :param rule_name: Name of the delivery rule which is unique within the endpoint. Required. + :type rule_name: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + profile_name=profile_name, + rule_set_name=rule_set_name, + rule_name=rule_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_rule_set( + self, resource_group_name: str, profile_name: str, rule_set_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.Rule"]: + """Lists all of the existing delivery rules within a rule set. + + :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 or CDN + profile 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. + :type rule_set_name: str + :return: An iterator like instance of Rule + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cdn.models.Rule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Rule]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_rules_list_by_rule_set_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + rule_set_name=rule_set_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.Rule], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class SecurityPoliciesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cdn.aio.CdnManagementClient`'s + :attr:`security_policies` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: 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( + self, resource_group_name: str, profile_name: str, security_policy_name: str, **kwargs: Any + ) -> _models.SecurityPolicy: + """Gets an existing security policy within a 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 or CDN + profile 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 + :return: SecurityPolicy. The SecurityPolicy is compatible with MutableMapping + :rtype: ~azure.mgmt.cdn.models.SecurityPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.SecurityPolicy] = kwargs.pop("cls", None) + + _request = build_security_policies_get_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + security_policy_name=security_policy_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.SecurityPolicy, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_initial( + self, + resource_group_name: str, + profile_name: str, + security_policy_name: str, + security_policy: Union[_models.SecurityPolicy, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(security_policy, (IOBase, bytes)): + _content = security_policy + else: + _content = json.dumps(security_policy, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_security_policies_create_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + security_policy_name=security_policy_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create( + self, + resource_group_name: str, + profile_name: str, + security_policy_name: str, + security_policy: _models.SecurityPolicy, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.SecurityPolicy]: + """Creates a new security policy within the specified 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 or CDN + profile 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 + :param security_policy: The security policy properties. Required. + :type security_policy: ~azure.mgmt.cdn.models.SecurityPolicy + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns SecurityPolicy. The SecurityPolicy is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.SecurityPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + profile_name: str, + security_policy_name: str, + security_policy: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.SecurityPolicy]: + """Creates a new security policy within the specified 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 or CDN + profile 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 + :param security_policy: The security policy properties. Required. + :type security_policy: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns SecurityPolicy. The SecurityPolicy is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.SecurityPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + profile_name: str, + security_policy_name: str, + security_policy: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.SecurityPolicy]: + """Creates a new security policy within the specified 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 or CDN + profile 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 + :param security_policy: The security policy properties. Required. + :type security_policy: IO[bytes] + :keyword content_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 SecurityPolicy. The SecurityPolicy is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.SecurityPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + profile_name: str, + security_policy_name: str, + security_policy: Union[_models.SecurityPolicy, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.SecurityPolicy]: + """Creates a new security policy within the specified 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 or CDN + profile 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 + :param security_policy: The security policy properties. Is one of the following types: + SecurityPolicy, JSON, IO[bytes] Required. + :type security_policy: ~azure.mgmt.cdn.models.SecurityPolicy or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns SecurityPolicy. The SecurityPolicy is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.SecurityPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SecurityPolicy] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_initial( + resource_group_name=resource_group_name, + profile_name=profile_name, + security_policy_name=security_policy_name, + security_policy=security_policy, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.SecurityPolicy, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.SecurityPolicy].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.SecurityPolicy]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _patch_initial( + self, + resource_group_name: str, + profile_name: str, + security_policy_name: str, + security_policy_update_properties: Union[_models.SecurityPolicyUpdateParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(security_policy_update_properties, (IOBase, bytes)): + _content = security_policy_update_properties + else: + _content = json.dumps(security_policy_update_properties, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_security_policies_patch_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + security_policy_name=security_policy_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_patch( + self, + resource_group_name: str, + profile_name: str, + security_policy_name: str, + security_policy_update_properties: _models.SecurityPolicyUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.SecurityPolicy]: + """Updates an existing security policy within a 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 or CDN + profile 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 + :param security_policy_update_properties: Security policy update properties. Required. + :type security_policy_update_properties: ~azure.mgmt.cdn.models.SecurityPolicyUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns SecurityPolicy. The SecurityPolicy is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.SecurityPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_patch( + self, + resource_group_name: str, + profile_name: str, + security_policy_name: str, + security_policy_update_properties: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.SecurityPolicy]: + """Updates an existing security policy within a 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 or CDN + profile 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 + :param security_policy_update_properties: Security policy update properties. Required. + :type security_policy_update_properties: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns SecurityPolicy. The SecurityPolicy is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.SecurityPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_patch( + self, + resource_group_name: str, + profile_name: str, + security_policy_name: str, + security_policy_update_properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.SecurityPolicy]: + """Updates an existing security policy within a 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 or CDN + profile 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 + :param security_policy_update_properties: Security policy update properties. Required. + :type security_policy_update_properties: IO[bytes] + :keyword content_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 SecurityPolicy. The SecurityPolicy is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.SecurityPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_patch( + self, + resource_group_name: str, + profile_name: str, + security_policy_name: str, + security_policy_update_properties: Union[_models.SecurityPolicyUpdateParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.SecurityPolicy]: + """Updates an existing security policy within a 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 or CDN + profile 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 + :param security_policy_update_properties: Security policy update properties. Is one of the + following types: SecurityPolicyUpdateParameters, JSON, IO[bytes] Required. + :type security_policy_update_properties: ~azure.mgmt.cdn.models.SecurityPolicyUpdateParameters + or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns SecurityPolicy. The SecurityPolicy is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.SecurityPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SecurityPolicy] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._patch_initial( + resource_group_name=resource_group_name, + profile_name=profile_name, + security_policy_name=security_policy_name, + security_policy_update_properties=security_policy_update_properties, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.SecurityPolicy, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.SecurityPolicy].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.SecurityPolicy]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _delete_initial( + self, resource_group_name: str, profile_name: str, security_policy_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_security_policies_delete_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + security_policy_name=security_policy_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, profile_name: str, security_policy_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes an existing security policy within 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 or CDN + profile 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 + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + profile_name=profile_name, + security_policy_name=security_policy_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_profile( + self, resource_group_name: str, profile_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.SecurityPolicy"]: + """Lists security policies associated with the 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 or CDN + profile which is unique within the resource group. Required. + :type profile_name: str + :return: An iterator like instance of SecurityPolicy + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cdn.models.SecurityPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.SecurityPolicy]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_security_policies_list_by_profile_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.SecurityPolicy], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class SecretsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cdn.aio.CdnManagementClient`'s + :attr:`secrets` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: 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(self, resource_group_name: str, profile_name: str, secret_name: str, **kwargs: Any) -> _models.Secret: + """Gets an existing Secret within a 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 or CDN + profile 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 + :return: Secret. The Secret is compatible with MutableMapping + :rtype: ~azure.mgmt.cdn.models.Secret + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.Secret] = kwargs.pop("cls", None) + + _request = build_secrets_get_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + secret_name=secret_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Secret, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_initial( + self, + resource_group_name: str, + profile_name: str, + secret_name: str, + secret: Union[_models.Secret, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(secret, (IOBase, bytes)): + _content = secret + else: + _content = json.dumps(secret, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_secrets_create_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + secret_name=secret_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create( + self, + resource_group_name: str, + profile_name: str, + secret_name: str, + secret: _models.Secret, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Secret]: + """Creates a new Secret within the specified 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 or CDN + profile 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 + :param secret: The Secret properties. Required. + :type secret: ~azure.mgmt.cdn.models.Secret + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns Secret. The Secret is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Secret] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + profile_name: str, + secret_name: str, + secret: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Secret]: + """Creates a new Secret within the specified 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 or CDN + profile 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 + :param secret: The Secret properties. Required. + :type secret: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns Secret. The Secret is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Secret] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + profile_name: str, + secret_name: str, + secret: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Secret]: + """Creates a new Secret within the specified 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 or CDN + profile 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 + :param secret: The Secret properties. Required. + :type secret: IO[bytes] + :keyword content_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 Secret. The Secret is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Secret] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + profile_name: str, + secret_name: str, + secret: Union[_models.Secret, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.Secret]: + """Creates a new Secret within the specified 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 or CDN + profile 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 + :param secret: The Secret properties. Is one of the following types: Secret, JSON, IO[bytes] + Required. + :type secret: ~azure.mgmt.cdn.models.Secret or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns Secret. The Secret is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Secret] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Secret] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_initial( + resource_group_name=resource_group_name, + profile_name=profile_name, + secret_name=secret_name, + secret=secret, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.Secret, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.Secret].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.Secret]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _delete_initial( + self, resource_group_name: str, profile_name: str, secret_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_secrets_delete_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + secret_name=secret_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, profile_name: str, secret_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes an existing Secret within 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 or CDN + profile 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 + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + profile_name=profile_name, + secret_name=secret_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_profile( + self, resource_group_name: str, profile_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.Secret"]: + """Lists existing AzureFrontDoor secrets. + + :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 or CDN + profile which is unique within the resource group. Required. + :type profile_name: str + :return: An iterator like instance of Secret + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cdn.models.Secret] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Secret]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_secrets_list_by_profile_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.Secret], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class EndpointsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cdn.aio.CdnManagementClient`'s + :attr:`endpoints` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: 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( + self, resource_group_name: str, profile_name: str, endpoint_name: str, **kwargs: Any + ) -> _models.Endpoint: + """Gets an existing CDN endpoint with the specified endpoint name under the specified + subscription, resource group and 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 or CDN + profile 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. + :type endpoint_name: str + :return: Endpoint. The Endpoint is compatible with MutableMapping + :rtype: ~azure.mgmt.cdn.models.Endpoint + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.Endpoint] = kwargs.pop("cls", None) + + _request = build_endpoints_get_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Endpoint, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_initial( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + endpoint: Union[_models.Endpoint, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(endpoint, (IOBase, bytes)): + _content = endpoint + else: + _content = json.dumps(endpoint, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_endpoints_create_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + endpoint: _models.Endpoint, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Endpoint]: + """Creates a new CDN endpoint with the specified endpoint name under the specified subscription, + resource group and 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 or CDN + profile 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. + :type endpoint_name: str + :param endpoint: Endpoint properties. Required. + :type endpoint: ~azure.mgmt.cdn.models.Endpoint + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns Endpoint. The Endpoint is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Endpoint] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + endpoint: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Endpoint]: + """Creates a new CDN endpoint with the specified endpoint name under the specified subscription, + resource group and 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 or CDN + profile 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. + :type endpoint_name: str + :param endpoint: Endpoint properties. Required. + :type endpoint: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns Endpoint. The Endpoint is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Endpoint] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + endpoint: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Endpoint]: + """Creates a new CDN endpoint with the specified endpoint name under the specified subscription, + resource group and 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 or CDN + profile 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. + :type endpoint_name: str + :param endpoint: Endpoint properties. Required. + :type endpoint: IO[bytes] + :keyword content_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 Endpoint. The Endpoint is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Endpoint] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + endpoint: Union[_models.Endpoint, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.Endpoint]: + """Creates a new CDN endpoint with the specified endpoint name under the specified subscription, + resource group and 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 or CDN + profile 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. + :type endpoint_name: str + :param endpoint: Endpoint properties. Is one of the following types: Endpoint, JSON, IO[bytes] + Required. + :type endpoint: ~azure.mgmt.cdn.models.Endpoint or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns Endpoint. The Endpoint is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Endpoint] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Endpoint] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_initial( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + endpoint=endpoint, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.Endpoint, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.Endpoint].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.Endpoint]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _update_initial( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + endpoint_update_properties: Union[_models.EndpointUpdateParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(endpoint_update_properties, (IOBase, bytes)): + _content = endpoint_update_properties + else: + _content = json.dumps(endpoint_update_properties, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_endpoints_update_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_update( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + endpoint_update_properties: _models.EndpointUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Endpoint]: + """Updates an existing CDN endpoint with the specified endpoint name under the specified + subscription, resource group and profile. Only tags can be updated after creating an endpoint. + To update origins, use the Update Origin operation. To update origin groups, use the Update + Origin group operation. To update custom domains, use the Update Custom Domain operation. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param endpoint_update_properties: Endpoint update properties. Required. + :type endpoint_update_properties: ~azure.mgmt.cdn.models.EndpointUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns Endpoint. The Endpoint is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Endpoint] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + endpoint_update_properties: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Endpoint]: + """Updates an existing CDN endpoint with the specified endpoint name under the specified + subscription, resource group and profile. Only tags can be updated after creating an endpoint. + To update origins, use the Update Origin operation. To update origin groups, use the Update + Origin group operation. To update custom domains, use the Update Custom Domain operation. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param endpoint_update_properties: Endpoint update properties. Required. + :type endpoint_update_properties: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns Endpoint. The Endpoint is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Endpoint] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + endpoint_update_properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Endpoint]: + """Updates an existing CDN endpoint with the specified endpoint name under the specified + subscription, resource group and profile. Only tags can be updated after creating an endpoint. + To update origins, use the Update Origin operation. To update origin groups, use the Update + Origin group operation. To update custom domains, use the Update Custom Domain operation. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param endpoint_update_properties: Endpoint update properties. Required. + :type endpoint_update_properties: IO[bytes] + :keyword content_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 Endpoint. The Endpoint is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Endpoint] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + endpoint_update_properties: Union[_models.EndpointUpdateParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.Endpoint]: + """Updates an existing CDN endpoint with the specified endpoint name under the specified + subscription, resource group and profile. Only tags can be updated after creating an endpoint. + To update origins, use the Update Origin operation. To update origin groups, use the Update + Origin group operation. To update custom domains, use the Update Custom Domain operation. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param endpoint_update_properties: Endpoint update properties. Is one of the following types: + EndpointUpdateParameters, JSON, IO[bytes] Required. + :type endpoint_update_properties: ~azure.mgmt.cdn.models.EndpointUpdateParameters or JSON or + IO[bytes] + :return: An instance of AsyncLROPoller that returns Endpoint. The Endpoint is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Endpoint] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Endpoint] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._update_initial( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + endpoint_update_properties=endpoint_update_properties, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.Endpoint, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.Endpoint].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.Endpoint]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _delete_initial( + self, resource_group_name: str, profile_name: str, endpoint_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_endpoints_delete_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, profile_name: str, endpoint_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes an existing CDN endpoint with the specified endpoint name under the specified + subscription, resource group and 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 or CDN + profile 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. + :type endpoint_name: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_profile( + self, resource_group_name: str, profile_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.Endpoint"]: + """Lists existing CDN endpoints. + + :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 or CDN + profile which is unique within the resource group. Required. + :type profile_name: str + :return: An iterator like instance of Endpoint + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cdn.models.Endpoint] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Endpoint]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_endpoints_list_by_profile_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.Endpoint], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + async def _start_initial( + self, resource_group_name: str, profile_name: str, endpoint_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_endpoints_start_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_start( + self, resource_group_name: str, profile_name: str, endpoint_name: str, **kwargs: Any + ) -> AsyncLROPoller[_models.Endpoint]: + """Starts an existing CDN endpoint that is on a stopped state. + + :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 or CDN + profile 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. + :type endpoint_name: str + :return: An instance of AsyncLROPoller that returns Endpoint. The Endpoint is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Endpoint] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.Endpoint] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._start_initial( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = _deserialize(_models.Endpoint, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.Endpoint].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.Endpoint]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _stop_initial( + self, resource_group_name: str, profile_name: str, endpoint_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_endpoints_stop_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_stop( + self, resource_group_name: str, profile_name: str, endpoint_name: str, **kwargs: Any + ) -> AsyncLROPoller[_models.Endpoint]: + """Stops an existing running CDN endpoint. + + :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 or CDN + profile 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. + :type endpoint_name: str + :return: An instance of AsyncLROPoller that returns Endpoint. The Endpoint is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Endpoint] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.Endpoint] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._stop_initial( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = _deserialize(_models.Endpoint, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.Endpoint].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.Endpoint]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _purge_content_initial( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + content_file_paths: Union[_models.PurgeParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(content_file_paths, (IOBase, bytes)): + _content = content_file_paths + else: + _content = json.dumps(content_file_paths, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_endpoints_purge_content_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_purge_content( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + content_file_paths: _models.PurgeParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Removes a content from CDN. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param content_file_paths: The path to the content to be purged. Path can be a full URL, e.g. + '/pictures/city.png' which removes a single file, or a directory with a wildcard, e.g. + '/pictures/*' which removes all folders and files in the directory. Required. + :type content_file_paths: ~azure.mgmt.cdn.models.PurgeParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_purge_content( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + content_file_paths: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Removes a content from CDN. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param content_file_paths: The path to the content to be purged. Path can be a full URL, e.g. + '/pictures/city.png' which removes a single file, or a directory with a wildcard, e.g. + '/pictures/*' which removes all folders and files in the directory. Required. + :type content_file_paths: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_purge_content( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + content_file_paths: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Removes a content from CDN. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param content_file_paths: The path to the content to be purged. Path can be a full URL, e.g. + '/pictures/city.png' which removes a single file, or a directory with a wildcard, e.g. + '/pictures/*' which removes all folders and files in the directory. Required. + :type content_file_paths: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_purge_content( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + content_file_paths: Union[_models.PurgeParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Removes a content from CDN. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param content_file_paths: The path to the content to be purged. Path can be a full URL, e.g. + '/pictures/city.png' which removes a single file, or a directory with a wildcard, e.g. + '/pictures/*' which removes all folders and files in the directory. Is one of the following + types: PurgeParameters, JSON, IO[bytes] Required. + :type content_file_paths: ~azure.mgmt.cdn.models.PurgeParameters or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._purge_content_initial( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + content_file_paths=content_file_paths, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + async def _load_content_initial( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + content_file_paths: Union[_models.LoadParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(content_file_paths, (IOBase, bytes)): + _content = content_file_paths + else: + _content = json.dumps(content_file_paths, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_endpoints_load_content_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_load_content( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + content_file_paths: _models.LoadParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Pre-loads a content to CDN. Available for Verizon Profiles. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param content_file_paths: The path to the content to be loaded. Path should be a full URL, + e.g. ‘/pictures/city.png' which loads a single file. Required. + :type content_file_paths: ~azure.mgmt.cdn.models.LoadParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_load_content( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + content_file_paths: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Pre-loads a content to CDN. Available for Verizon Profiles. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param content_file_paths: The path to the content to be loaded. Path should be a full URL, + e.g. ‘/pictures/city.png' which loads a single file. Required. + :type content_file_paths: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_load_content( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + content_file_paths: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Pre-loads a content to CDN. Available for Verizon Profiles. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param content_file_paths: The path to the content to be loaded. Path should be a full URL, + e.g. ‘/pictures/city.png' which loads a single file. Required. + :type content_file_paths: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_load_content( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + content_file_paths: Union[_models.LoadParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Pre-loads a content to CDN. Available for Verizon Profiles. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param content_file_paths: The path to the content to be loaded. Path should be a full URL, + e.g. ‘/pictures/city.png' which loads a single file. Is one of the following types: + LoadParameters, JSON, IO[bytes] Required. + :type content_file_paths: ~azure.mgmt.cdn.models.LoadParameters or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._load_content_initial( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + content_file_paths=content_file_paths, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @overload + async def validate_custom_domain( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + custom_domain_properties: _models.ValidateCustomDomainInput, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ValidateCustomDomainOutput: + """Validates the custom domain mapping to ensure it maps to the correct CDN endpoint in DNS. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param custom_domain_properties: Custom domain to be validated. Required. + :type custom_domain_properties: ~azure.mgmt.cdn.models.ValidateCustomDomainInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ValidateCustomDomainOutput. The ValidateCustomDomainOutput is compatible with + MutableMapping + :rtype: ~azure.mgmt.cdn.models.ValidateCustomDomainOutput + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def validate_custom_domain( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + custom_domain_properties: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ValidateCustomDomainOutput: + """Validates the custom domain mapping to ensure it maps to the correct CDN endpoint in DNS. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param custom_domain_properties: Custom domain to be validated. Required. + :type custom_domain_properties: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ValidateCustomDomainOutput. The ValidateCustomDomainOutput is compatible with + MutableMapping + :rtype: ~azure.mgmt.cdn.models.ValidateCustomDomainOutput + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def validate_custom_domain( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + custom_domain_properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ValidateCustomDomainOutput: + """Validates the custom domain mapping to ensure it maps to the correct CDN endpoint in DNS. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param custom_domain_properties: Custom domain to be validated. Required. + :type custom_domain_properties: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ValidateCustomDomainOutput. The ValidateCustomDomainOutput is compatible with + MutableMapping + :rtype: ~azure.mgmt.cdn.models.ValidateCustomDomainOutput + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def validate_custom_domain( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + custom_domain_properties: Union[_models.ValidateCustomDomainInput, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.ValidateCustomDomainOutput: + """Validates the custom domain mapping to ensure it maps to the correct CDN endpoint in DNS. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param custom_domain_properties: Custom domain to be validated. Is one of the following types: + ValidateCustomDomainInput, JSON, IO[bytes] Required. + :type custom_domain_properties: ~azure.mgmt.cdn.models.ValidateCustomDomainInput or JSON or + IO[bytes] + :return: ValidateCustomDomainOutput. The ValidateCustomDomainOutput is compatible with + MutableMapping + :rtype: ~azure.mgmt.cdn.models.ValidateCustomDomainOutput + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ValidateCustomDomainOutput] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(custom_domain_properties, (IOBase, bytes)): + _content = custom_domain_properties + else: + _content = json.dumps(custom_domain_properties, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_endpoints_validate_custom_domain_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ValidateCustomDomainOutput, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_resource_usage( + self, resource_group_name: str, profile_name: str, endpoint_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.ResourceUsage"]: + """Checks the quota and usage of geo filters and custom domains under the given endpoint. + + :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 or CDN + profile 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. + :type endpoint_name: str + :return: An iterator like instance of ResourceUsage + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cdn.models.ResourceUsage] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ResourceUsage]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_endpoints_list_resource_usage_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ResourceUsage], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class OriginsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cdn.aio.CdnManagementClient`'s + :attr:`origins` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: 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( + self, resource_group_name: str, profile_name: str, endpoint_name: str, origin_name: str, **kwargs: Any + ) -> _models.Origin: + """Gets an existing origin within an endpoint. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param origin_name: Name of the origin which is unique within the endpoint. Required. + :type origin_name: str + :return: Origin. The Origin is compatible with MutableMapping + :rtype: ~azure.mgmt.cdn.models.Origin + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.Origin] = kwargs.pop("cls", None) + + _request = build_origins_get_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + origin_name=origin_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Origin, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_initial( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + origin_name: str, + origin: Union[_models.Origin, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(origin, (IOBase, bytes)): + _content = origin + else: + _content = json.dumps(origin, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_origins_create_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + origin_name=origin_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + origin_name: str, + origin: _models.Origin, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Origin]: + """Creates a new origin within the specified endpoint. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param origin_name: Name of the origin which is unique within the endpoint. Required. + :type origin_name: str + :param origin: Origin properties. Required. + :type origin: ~azure.mgmt.cdn.models.Origin + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns Origin. The Origin is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Origin] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + origin_name: str, + origin: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Origin]: + """Creates a new origin within the specified endpoint. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param origin_name: Name of the origin which is unique within the endpoint. Required. + :type origin_name: str + :param origin: Origin properties. Required. + :type origin: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns Origin. The Origin is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Origin] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + origin_name: str, + origin: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Origin]: + """Creates a new origin within the specified endpoint. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param origin_name: Name of the origin which is unique within the endpoint. Required. + :type origin_name: str + :param origin: Origin properties. Required. + :type origin: IO[bytes] + :keyword content_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 Origin. The Origin is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Origin] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + origin_name: str, + origin: Union[_models.Origin, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.Origin]: + """Creates a new origin within the specified endpoint. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param origin_name: Name of the origin which is unique within the endpoint. Required. + :type origin_name: str + :param origin: Origin properties. Is one of the following types: Origin, JSON, IO[bytes] + Required. + :type origin: ~azure.mgmt.cdn.models.Origin or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns Origin. The Origin is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Origin] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Origin] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_initial( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + origin_name=origin_name, + origin=origin, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.Origin, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.Origin].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.Origin]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _update_initial( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + origin_name: str, + origin_update_properties: Union[_models.OriginUpdateParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(origin_update_properties, (IOBase, bytes)): + _content = origin_update_properties + else: + _content = json.dumps(origin_update_properties, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_origins_update_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + origin_name=origin_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_update( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + origin_name: str, + origin_update_properties: _models.OriginUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Origin]: + """Updates an existing origin within an endpoint. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param origin_name: Name of the origin which is unique within the endpoint. Required. + :type origin_name: str + :param origin_update_properties: Origin properties. Required. + :type origin_update_properties: ~azure.mgmt.cdn.models.OriginUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns Origin. The Origin is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Origin] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + origin_name: str, + origin_update_properties: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Origin]: + """Updates an existing origin within an endpoint. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param origin_name: Name of the origin which is unique within the endpoint. Required. + :type origin_name: str + :param origin_update_properties: Origin properties. Required. + :type origin_update_properties: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns Origin. The Origin is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Origin] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + origin_name: str, + origin_update_properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Origin]: + """Updates an existing origin within an endpoint. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param origin_name: Name of the origin which is unique within the endpoint. Required. + :type origin_name: str + :param origin_update_properties: Origin properties. Required. + :type origin_update_properties: IO[bytes] + :keyword content_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 Origin. The Origin is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Origin] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + origin_name: str, + origin_update_properties: Union[_models.OriginUpdateParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.Origin]: + """Updates an existing origin within an endpoint. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param origin_name: Name of the origin which is unique within the endpoint. Required. + :type origin_name: str + :param origin_update_properties: Origin properties. Is one of the following types: + OriginUpdateParameters, JSON, IO[bytes] Required. + :type origin_update_properties: ~azure.mgmt.cdn.models.OriginUpdateParameters or JSON or + IO[bytes] + :return: An instance of AsyncLROPoller that returns Origin. The Origin is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Origin] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Origin] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._update_initial( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + origin_name=origin_name, + origin_update_properties=origin_update_properties, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.Origin, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.Origin].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.Origin]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _delete_initial( + self, resource_group_name: str, profile_name: str, endpoint_name: str, origin_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_origins_delete_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + origin_name=origin_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, profile_name: str, endpoint_name: str, origin_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes an existing origin within an endpoint. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param origin_name: Name of the origin which is unique within the endpoint. Required. + :type origin_name: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + origin_name=origin_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_endpoint( + self, resource_group_name: str, profile_name: str, endpoint_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.Origin"]: + """Lists all of the existing origins within an endpoint. + + :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 or CDN + profile 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. + :type endpoint_name: str + :return: An iterator like instance of Origin + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cdn.models.Origin] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Origin]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_origins_list_by_endpoint_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.Origin], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class OriginGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cdn.aio.CdnManagementClient`'s + :attr:`origin_groups` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: 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( + self, resource_group_name: str, profile_name: str, endpoint_name: str, origin_group_name: str, **kwargs: Any + ) -> _models.OriginGroup: + """Gets an existing origin group within an endpoint. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param origin_group_name: Name of the origin group which is unique within the endpoint. + Required. + :type origin_group_name: str + :return: OriginGroup. The OriginGroup is compatible with MutableMapping + :rtype: ~azure.mgmt.cdn.models.OriginGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.OriginGroup] = kwargs.pop("cls", None) + + _request = build_origin_groups_get_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + origin_group_name=origin_group_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.OriginGroup, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_initial( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + origin_group_name: str, + origin_group: Union[_models.OriginGroup, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(origin_group, (IOBase, bytes)): + _content = origin_group + else: + _content = json.dumps(origin_group, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_origin_groups_create_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + origin_group_name=origin_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + origin_group_name: str, + origin_group: _models.OriginGroup, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.OriginGroup]: + """Creates a new origin group within the specified endpoint. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param origin_group_name: Name of the origin group which is unique within the endpoint. + Required. + :type origin_group_name: str + :param origin_group: Origin group properties. Required. + :type origin_group: ~azure.mgmt.cdn.models.OriginGroup + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns OriginGroup. The OriginGroup is compatible + with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.OriginGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + origin_group_name: str, + origin_group: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.OriginGroup]: + """Creates a new origin group within the specified endpoint. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param origin_group_name: Name of the origin group which is unique within the endpoint. + Required. + :type origin_group_name: str + :param origin_group: Origin group properties. Required. + :type origin_group: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns OriginGroup. The OriginGroup is compatible + with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.OriginGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + origin_group_name: str, + origin_group: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.OriginGroup]: + """Creates a new origin group within the specified endpoint. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param origin_group_name: Name of the origin group which is unique within the endpoint. + Required. + :type origin_group_name: str + :param origin_group: Origin group properties. Required. + :type origin_group: IO[bytes] + :keyword content_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 OriginGroup. The OriginGroup is compatible + with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.OriginGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + origin_group_name: str, + origin_group: Union[_models.OriginGroup, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.OriginGroup]: + """Creates a new origin group within the specified endpoint. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param origin_group_name: Name of the origin group which is unique within the endpoint. + Required. + :type origin_group_name: str + :param origin_group: Origin group properties. Is one of the following types: OriginGroup, JSON, + IO[bytes] Required. + :type origin_group: ~azure.mgmt.cdn.models.OriginGroup or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns OriginGroup. The OriginGroup is compatible + with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.OriginGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.OriginGroup] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_initial( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + origin_group_name=origin_group_name, + origin_group=origin_group, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.OriginGroup, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.OriginGroup].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.OriginGroup]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _update_initial( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + origin_group_name: str, + origin_group_update_properties: Union[_models.OriginGroupUpdateParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(origin_group_update_properties, (IOBase, bytes)): + _content = origin_group_update_properties + else: + _content = json.dumps(origin_group_update_properties, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_origin_groups_update_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + origin_group_name=origin_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_update( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + origin_group_name: str, + origin_group_update_properties: _models.OriginGroupUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.OriginGroup]: + """Updates an existing origin group within an endpoint. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param origin_group_name: Name of the origin group which is unique within the endpoint. + Required. + :type origin_group_name: str + :param origin_group_update_properties: Origin group properties. Required. + :type origin_group_update_properties: ~azure.mgmt.cdn.models.OriginGroupUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns OriginGroup. The OriginGroup is compatible + with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.OriginGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + origin_group_name: str, + origin_group_update_properties: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.OriginGroup]: + """Updates an existing origin group within an endpoint. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param origin_group_name: Name of the origin group which is unique within the endpoint. + Required. + :type origin_group_name: str + :param origin_group_update_properties: Origin group properties. Required. + :type origin_group_update_properties: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns OriginGroup. The OriginGroup is compatible + with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.OriginGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + origin_group_name: str, + origin_group_update_properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.OriginGroup]: + """Updates an existing origin group within an endpoint. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param origin_group_name: Name of the origin group which is unique within the endpoint. + Required. + :type origin_group_name: str + :param origin_group_update_properties: Origin group properties. Required. + :type origin_group_update_properties: IO[bytes] + :keyword content_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 OriginGroup. The OriginGroup is compatible + with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.OriginGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + origin_group_name: str, + origin_group_update_properties: Union[_models.OriginGroupUpdateParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.OriginGroup]: + """Updates an existing origin group within an endpoint. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param origin_group_name: Name of the origin group which is unique within the endpoint. + Required. + :type origin_group_name: str + :param origin_group_update_properties: Origin group properties. Is one of the following types: + OriginGroupUpdateParameters, JSON, IO[bytes] Required. + :type origin_group_update_properties: ~azure.mgmt.cdn.models.OriginGroupUpdateParameters or + JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns OriginGroup. The OriginGroup is compatible + with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.OriginGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.OriginGroup] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._update_initial( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + origin_group_name=origin_group_name, + origin_group_update_properties=origin_group_update_properties, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.OriginGroup, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.OriginGroup].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.OriginGroup]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _delete_initial( + self, resource_group_name: str, profile_name: str, endpoint_name: str, origin_group_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_origin_groups_delete_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + origin_group_name=origin_group_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, profile_name: str, endpoint_name: str, origin_group_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes an existing origin group within an endpoint. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param origin_group_name: Name of the origin group which is unique within the endpoint. + Required. + :type origin_group_name: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + origin_group_name=origin_group_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_endpoint( + self, resource_group_name: str, profile_name: str, endpoint_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.OriginGroup"]: + """Lists all of the existing origin groups within an endpoint. + + :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 or CDN + profile 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. + :type endpoint_name: str + :return: An iterator like instance of OriginGroup + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cdn.models.OriginGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.OriginGroup]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_origin_groups_list_by_endpoint_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.OriginGroup], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class CustomDomainsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cdn.aio.CdnManagementClient`'s + :attr:`custom_domains` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: 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( + self, resource_group_name: str, profile_name: str, endpoint_name: str, custom_domain_name: str, **kwargs: Any + ) -> _models.CustomDomain: + """Gets an existing custom domain within an endpoint. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param custom_domain_name: Name of the custom domain within an endpoint. Required. + :type custom_domain_name: str + :return: CustomDomain. The CustomDomain is compatible with MutableMapping + :rtype: ~azure.mgmt.cdn.models.CustomDomain + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.CustomDomain] = kwargs.pop("cls", None) + + _request = build_custom_domains_get_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + custom_domain_name=custom_domain_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.CustomDomain, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_initial( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + custom_domain_name: str, + custom_domain_properties: Union[_models.CustomDomainParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(custom_domain_properties, (IOBase, bytes)): + _content = custom_domain_properties + else: + _content = json.dumps(custom_domain_properties, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_custom_domains_create_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + custom_domain_name=custom_domain_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + custom_domain_name: str, + custom_domain_properties: _models.CustomDomainParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CustomDomain]: + """Creates a new custom domain within an endpoint. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param custom_domain_name: Name of the custom domain within an endpoint. Required. + :type custom_domain_name: str + :param custom_domain_properties: Properties required to create a new custom domain. Required. + :type custom_domain_properties: ~azure.mgmt.cdn.models.CustomDomainParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns CustomDomain. The CustomDomain is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.CustomDomain] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + custom_domain_name: str, + custom_domain_properties: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CustomDomain]: + """Creates a new custom domain within an endpoint. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param custom_domain_name: Name of the custom domain within an endpoint. Required. + :type custom_domain_name: str + :param custom_domain_properties: Properties required to create a new custom domain. Required. + :type custom_domain_properties: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns CustomDomain. The CustomDomain is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.CustomDomain] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + custom_domain_name: str, + custom_domain_properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CustomDomain]: + """Creates a new custom domain within an endpoint. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param custom_domain_name: Name of the custom domain within an endpoint. Required. + :type custom_domain_name: str + :param custom_domain_properties: Properties required to create a new custom domain. Required. + :type custom_domain_properties: IO[bytes] + :keyword content_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 CustomDomain. The CustomDomain is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.CustomDomain] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + custom_domain_name: str, + custom_domain_properties: Union[_models.CustomDomainParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.CustomDomain]: + """Creates a new custom domain within an endpoint. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param custom_domain_name: Name of the custom domain within an endpoint. Required. + :type custom_domain_name: str + :param custom_domain_properties: Properties required to create a new custom domain. Is one of + the following types: CustomDomainParameters, JSON, IO[bytes] Required. + :type custom_domain_properties: ~azure.mgmt.cdn.models.CustomDomainParameters or JSON or + IO[bytes] + :return: An instance of AsyncLROPoller that returns CustomDomain. The CustomDomain is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.CustomDomain] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CustomDomain] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_initial( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + custom_domain_name=custom_domain_name, + custom_domain_properties=custom_domain_properties, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.CustomDomain, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.CustomDomain].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.CustomDomain]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _delete_initial( + self, resource_group_name: str, profile_name: str, endpoint_name: str, custom_domain_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_custom_domains_delete_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + custom_domain_name=custom_domain_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, profile_name: str, endpoint_name: str, custom_domain_name: str, **kwargs: Any + ) -> AsyncLROPoller[_models.CustomDomain]: + """Deletes an existing custom domain within an endpoint. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param custom_domain_name: Name of the custom domain within an endpoint. Required. + :type custom_domain_name: str + :return: An instance of AsyncLROPoller that returns CustomDomain. The CustomDomain is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.CustomDomain] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.CustomDomain] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + custom_domain_name=custom_domain_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.CustomDomain, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.CustomDomain].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.CustomDomain]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace + def list_by_endpoint( + self, resource_group_name: str, profile_name: str, endpoint_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.CustomDomain"]: + """Lists all of the existing custom domains within an endpoint. + + :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 or CDN + profile 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. + :type endpoint_name: str + :return: An iterator like instance of CustomDomain + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cdn.models.CustomDomain] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.CustomDomain]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_custom_domains_list_by_endpoint_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.CustomDomain], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + async def _disable_custom_https_initial( + self, resource_group_name: str, profile_name: str, endpoint_name: str, custom_domain_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_custom_domains_disable_custom_https_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + custom_domain_name=custom_domain_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_disable_custom_https( + self, resource_group_name: str, profile_name: str, endpoint_name: str, custom_domain_name: str, **kwargs: Any + ) -> AsyncLROPoller[_models.CustomDomain]: + """Disable https delivery of the custom domain. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param custom_domain_name: Name of the custom domain within an endpoint. Required. + :type custom_domain_name: str + :return: An instance of AsyncLROPoller that returns CustomDomain. The CustomDomain is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.CustomDomain] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.CustomDomain] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._disable_custom_https_initial( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + custom_domain_name=custom_domain_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.CustomDomain, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.CustomDomain].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.CustomDomain]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _enable_custom_https_initial( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + custom_domain_name: str, + custom_domain_https_parameters: Optional[Union[_models.CustomDomainHttpsParameters, JSON, IO[bytes]]] = None, + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + content_type = content_type if custom_domain_https_parameters else None + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" if custom_domain_https_parameters else None + _content = None + if isinstance(custom_domain_https_parameters, (IOBase, bytes)): + _content = custom_domain_https_parameters + else: + if custom_domain_https_parameters is not None: + _content = json.dumps(custom_domain_https_parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + else: + _content = None + + _request = build_custom_domains_enable_custom_https_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + custom_domain_name=custom_domain_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_enable_custom_https( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + custom_domain_name: str, + custom_domain_https_parameters: Optional[_models.CustomDomainHttpsParameters] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CustomDomain]: + """Enable https delivery of the custom domain. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param custom_domain_name: Name of the custom domain within an endpoint. Required. + :type custom_domain_name: str + :param custom_domain_https_parameters: The configuration specifying how to enable HTTPS for the + custom domain - using CDN managed certificate or user's own certificate. If not specified, + enabling ssl uses CDN managed certificate by default. Default value is None. + :type custom_domain_https_parameters: ~azure.mgmt.cdn.models.CustomDomainHttpsParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns CustomDomain. The CustomDomain is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.CustomDomain] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_enable_custom_https( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + custom_domain_name: str, + custom_domain_https_parameters: Optional[JSON] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CustomDomain]: + """Enable https delivery of the custom domain. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param custom_domain_name: Name of the custom domain within an endpoint. Required. + :type custom_domain_name: str + :param custom_domain_https_parameters: The configuration specifying how to enable HTTPS for the + custom domain - using CDN managed certificate or user's own certificate. If not specified, + enabling ssl uses CDN managed certificate by default. Default value is None. + :type custom_domain_https_parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns CustomDomain. The CustomDomain is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.CustomDomain] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_enable_custom_https( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + custom_domain_name: str, + custom_domain_https_parameters: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CustomDomain]: + """Enable https delivery of the custom domain. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param custom_domain_name: Name of the custom domain within an endpoint. Required. + :type custom_domain_name: str + :param custom_domain_https_parameters: The configuration specifying how to enable HTTPS for the + custom domain - using CDN managed certificate or user's own certificate. If not specified, + enabling ssl uses CDN managed certificate by default. Default value is None. + :type custom_domain_https_parameters: IO[bytes] + :keyword content_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 CustomDomain. The CustomDomain is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.CustomDomain] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_enable_custom_https( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + custom_domain_name: str, + custom_domain_https_parameters: Optional[Union[_models.CustomDomainHttpsParameters, JSON, IO[bytes]]] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.CustomDomain]: + """Enable https delivery of the custom domain. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param custom_domain_name: Name of the custom domain within an endpoint. Required. + :type custom_domain_name: str + :param custom_domain_https_parameters: The configuration specifying how to enable HTTPS for the + custom domain - using CDN managed certificate or user's own certificate. If not specified, + enabling ssl uses CDN managed certificate by default. Is one of the following types: + CustomDomainHttpsParameters, JSON, IO[bytes] Default value is None. + :type custom_domain_https_parameters: ~azure.mgmt.cdn.models.CustomDomainHttpsParameters or + JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns CustomDomain. The CustomDomain is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.CustomDomain] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + content_type = content_type if custom_domain_https_parameters else None + cls: ClsType[_models.CustomDomain] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._enable_custom_https_initial( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + custom_domain_name=custom_domain_name, + custom_domain_https_parameters=custom_domain_https_parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.CustomDomain, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.CustomDomain].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.CustomDomain]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + +class AFDCustomDomainsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cdn.aio.CdnManagementClient`'s + :attr:`afd_custom_domains` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: 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( + self, resource_group_name: str, profile_name: str, custom_domain_name: str, **kwargs: Any + ) -> _models.AFDDomain: + """Gets an existing AzureFrontDoor domain with the specified domain name under the specified + subscription, resource group and 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 or CDN + profile 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. + :type custom_domain_name: str + :return: AFDDomain. The AFDDomain is compatible with MutableMapping + :rtype: ~azure.mgmt.cdn.models.AFDDomain + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.AFDDomain] = kwargs.pop("cls", None) + + _request = build_afd_custom_domains_get_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + custom_domain_name=custom_domain_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.AFDDomain, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_initial( + self, + resource_group_name: str, + profile_name: str, + custom_domain_name: str, + custom_domain: Union[_models.AFDDomain, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(custom_domain, (IOBase, bytes)): + _content = custom_domain + else: + _content = json.dumps(custom_domain, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_afd_custom_domains_create_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + custom_domain_name=custom_domain_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create( + self, + resource_group_name: str, + profile_name: str, + custom_domain_name: str, + custom_domain: _models.AFDDomain, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AFDDomain]: + """Creates a new domain within the specified 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 or CDN + profile 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. + :type custom_domain_name: str + :param custom_domain: Domain properties. Required. + :type custom_domain: ~azure.mgmt.cdn.models.AFDDomain + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns AFDDomain. The AFDDomain is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.AFDDomain] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + profile_name: str, + custom_domain_name: str, + custom_domain: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AFDDomain]: + """Creates a new domain within the specified 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 or CDN + profile 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. + :type custom_domain_name: str + :param custom_domain: Domain properties. Required. + :type custom_domain: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns AFDDomain. The AFDDomain is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.AFDDomain] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + profile_name: str, + custom_domain_name: str, + custom_domain: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AFDDomain]: + """Creates a new domain within the specified 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 or CDN + profile 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. + :type custom_domain_name: str + :param custom_domain: Domain properties. Required. + :type custom_domain: IO[bytes] + :keyword content_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 AFDDomain. The AFDDomain is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.AFDDomain] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + profile_name: str, + custom_domain_name: str, + custom_domain: Union[_models.AFDDomain, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.AFDDomain]: + """Creates a new domain within the specified 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 or CDN + profile 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. + :type custom_domain_name: str + :param custom_domain: Domain properties. Is one of the following types: AFDDomain, JSON, + IO[bytes] Required. + :type custom_domain: ~azure.mgmt.cdn.models.AFDDomain or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns AFDDomain. The AFDDomain is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.AFDDomain] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AFDDomain] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_initial( + resource_group_name=resource_group_name, + profile_name=profile_name, + custom_domain_name=custom_domain_name, + custom_domain=custom_domain, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.AFDDomain, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.AFDDomain].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.AFDDomain]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _update_initial( + self, + resource_group_name: str, + profile_name: str, + custom_domain_name: str, + custom_domain_update_properties: Union[_models.AFDDomainUpdateParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(custom_domain_update_properties, (IOBase, bytes)): + _content = custom_domain_update_properties + else: + _content = json.dumps(custom_domain_update_properties, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_afd_custom_domains_update_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + custom_domain_name=custom_domain_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_update( + self, + resource_group_name: str, + profile_name: str, + custom_domain_name: str, + custom_domain_update_properties: _models.AFDDomainUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AFDDomain]: + """Updates an existing domain within a 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 or CDN + profile 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. + :type custom_domain_name: str + :param custom_domain_update_properties: Domain properties. Required. + :type custom_domain_update_properties: ~azure.mgmt.cdn.models.AFDDomainUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns AFDDomain. The AFDDomain is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.AFDDomain] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + profile_name: str, + custom_domain_name: str, + custom_domain_update_properties: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AFDDomain]: + """Updates an existing domain within a 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 or CDN + profile 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. + :type custom_domain_name: str + :param custom_domain_update_properties: Domain properties. Required. + :type custom_domain_update_properties: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns AFDDomain. The AFDDomain is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.AFDDomain] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + profile_name: str, + custom_domain_name: str, + custom_domain_update_properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AFDDomain]: + """Updates an existing domain within a 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 or CDN + profile 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. + :type custom_domain_name: str + :param custom_domain_update_properties: Domain properties. Required. + :type custom_domain_update_properties: IO[bytes] + :keyword content_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 AFDDomain. The AFDDomain is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.AFDDomain] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + profile_name: str, + custom_domain_name: str, + custom_domain_update_properties: Union[_models.AFDDomainUpdateParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.AFDDomain]: + """Updates an existing domain within a 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 or CDN + profile 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. + :type custom_domain_name: str + :param custom_domain_update_properties: Domain properties. Is one of the following types: + AFDDomainUpdateParameters, JSON, IO[bytes] Required. + :type custom_domain_update_properties: ~azure.mgmt.cdn.models.AFDDomainUpdateParameters or JSON + or IO[bytes] + :return: An instance of AsyncLROPoller that returns AFDDomain. The AFDDomain is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.AFDDomain] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AFDDomain] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._update_initial( + resource_group_name=resource_group_name, + profile_name=profile_name, + custom_domain_name=custom_domain_name, + custom_domain_update_properties=custom_domain_update_properties, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.AFDDomain, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.AFDDomain].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.AFDDomain]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _delete_initial( + self, resource_group_name: str, profile_name: str, custom_domain_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_afd_custom_domains_delete_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + custom_domain_name=custom_domain_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, profile_name: str, custom_domain_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes an existing AzureFrontDoor domain with the specified domain name under the specified + subscription, resource group and 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 or CDN + profile 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. + :type custom_domain_name: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + profile_name=profile_name, + custom_domain_name=custom_domain_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_profile( + self, resource_group_name: str, profile_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.AFDDomain"]: + """Lists existing AzureFrontDoor domains. + + :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 or CDN + profile which is unique within the resource group. Required. + :type profile_name: str + :return: An iterator like instance of AFDDomain + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cdn.models.AFDDomain] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.AFDDomain]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_afd_custom_domains_list_by_profile_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.AFDDomain], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + async def _refresh_validation_token_initial( + self, resource_group_name: str, profile_name: str, custom_domain_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_afd_custom_domains_refresh_validation_token_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + custom_domain_name=custom_domain_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_refresh_validation_token( + self, resource_group_name: str, profile_name: str, custom_domain_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Updates the domain validation token. + + :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 or CDN + profile 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. + :type custom_domain_name: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._refresh_validation_token_initial( + resource_group_name=resource_group_name, + profile_name=profile_name, + custom_domain_name=custom_domain_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + +class AFDProfilesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cdn.aio.CdnManagementClient`'s + :attr:`afd_profiles` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: 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( + self, + resource_group_name: str, + profile_name: str, + check_endpoint_name_availability_input: _models.CheckEndpointNameAvailabilityInput, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CheckEndpointNameAvailabilityOutput: + """Check the availability of an afdx endpoint name, and return the globally unique endpoint host + name. + + :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 or CDN + profile which is unique within the resource group. Required. + :type profile_name: str + :param check_endpoint_name_availability_input: Input to check. Required. + :type check_endpoint_name_availability_input: + ~azure.mgmt.cdn.models.CheckEndpointNameAvailabilityInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: CheckEndpointNameAvailabilityOutput. The CheckEndpointNameAvailabilityOutput is + compatible with MutableMapping + :rtype: ~azure.mgmt.cdn.models.CheckEndpointNameAvailabilityOutput + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_endpoint_name_availability( + self, + resource_group_name: str, + profile_name: str, + check_endpoint_name_availability_input: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CheckEndpointNameAvailabilityOutput: + """Check the availability of an afdx endpoint name, and return the globally unique endpoint host + name. + + :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 or CDN + profile which is unique within the resource group. Required. + :type profile_name: str + :param check_endpoint_name_availability_input: Input to check. Required. + :type check_endpoint_name_availability_input: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: CheckEndpointNameAvailabilityOutput. The CheckEndpointNameAvailabilityOutput is + compatible with MutableMapping + :rtype: ~azure.mgmt.cdn.models.CheckEndpointNameAvailabilityOutput + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_endpoint_name_availability( + self, + resource_group_name: str, + profile_name: str, + check_endpoint_name_availability_input: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CheckEndpointNameAvailabilityOutput: + """Check the availability of an afdx endpoint name, and return the globally unique endpoint host + name. + + :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 or CDN + profile which is unique within the resource group. Required. + :type profile_name: str + :param check_endpoint_name_availability_input: Input to check. Required. + :type check_endpoint_name_availability_input: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: CheckEndpointNameAvailabilityOutput. The CheckEndpointNameAvailabilityOutput is + compatible with MutableMapping + :rtype: ~azure.mgmt.cdn.models.CheckEndpointNameAvailabilityOutput + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_endpoint_name_availability( + self, + resource_group_name: str, + profile_name: str, + check_endpoint_name_availability_input: Union[_models.CheckEndpointNameAvailabilityInput, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.CheckEndpointNameAvailabilityOutput: + """Check the availability of an afdx endpoint name, and return the globally unique endpoint host + name. + + :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 or CDN + profile which is unique within the resource group. Required. + :type profile_name: str + :param check_endpoint_name_availability_input: Input to check. Is one of the following types: + CheckEndpointNameAvailabilityInput, JSON, IO[bytes] Required. + :type check_endpoint_name_availability_input: + ~azure.mgmt.cdn.models.CheckEndpointNameAvailabilityInput or JSON or IO[bytes] + :return: CheckEndpointNameAvailabilityOutput. The CheckEndpointNameAvailabilityOutput is + compatible with MutableMapping + :rtype: ~azure.mgmt.cdn.models.CheckEndpointNameAvailabilityOutput + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CheckEndpointNameAvailabilityOutput] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(check_endpoint_name_availability_input, (IOBase, bytes)): + _content = check_endpoint_name_availability_input + else: + _content = json.dumps(check_endpoint_name_availability_input, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_afd_profiles_check_endpoint_name_availability_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.CheckEndpointNameAvailabilityOutput, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_resource_usage( + self, resource_group_name: str, profile_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.Usage"]: + """Checks the quota and actual usage of endpoints under the given Azure Front Door 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 or CDN + profile which is unique within the resource group. Required. + :type profile_name: str + :return: An iterator like instance of Usage + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cdn.models.Usage] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Usage]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_afd_profiles_list_resource_usage_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.Usage], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @overload + async def check_host_name_availability( + self, + resource_group_name: str, + profile_name: str, + check_host_name_availability_input: _models.CheckHostNameAvailabilityInput, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CheckNameAvailabilityOutput: + """Validates the custom domain mapping to ensure it maps to the correct Azure Front Door endpoint + in DNS. + + :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 or CDN + profile 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 + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: CheckNameAvailabilityOutput. The CheckNameAvailabilityOutput is compatible with + MutableMapping + :rtype: ~azure.mgmt.cdn.models.CheckNameAvailabilityOutput + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_host_name_availability( + self, + resource_group_name: str, + profile_name: str, + check_host_name_availability_input: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CheckNameAvailabilityOutput: + """Validates the custom domain mapping to ensure it maps to the correct Azure Front Door endpoint + in DNS. + + :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 or CDN + profile 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: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: CheckNameAvailabilityOutput. The CheckNameAvailabilityOutput is compatible with + MutableMapping + :rtype: ~azure.mgmt.cdn.models.CheckNameAvailabilityOutput + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_host_name_availability( + self, + resource_group_name: str, + profile_name: str, + check_host_name_availability_input: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CheckNameAvailabilityOutput: + """Validates the custom domain mapping to ensure it maps to the correct Azure Front Door endpoint + in DNS. + + :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 or CDN + profile 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] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: CheckNameAvailabilityOutput. The CheckNameAvailabilityOutput is compatible with + MutableMapping + :rtype: ~azure.mgmt.cdn.models.CheckNameAvailabilityOutput + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_host_name_availability( + self, + resource_group_name: str, + profile_name: str, + check_host_name_availability_input: Union[_models.CheckHostNameAvailabilityInput, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.CheckNameAvailabilityOutput: + """Validates the custom domain mapping to ensure it maps to the correct Azure Front Door endpoint + in DNS. + + :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 or CDN + profile which is unique within the resource group. Required. + :type profile_name: str + :param check_host_name_availability_input: Custom domain to be validated. Is one of the + following types: CheckHostNameAvailabilityInput, JSON, IO[bytes] Required. + :type check_host_name_availability_input: ~azure.mgmt.cdn.models.CheckHostNameAvailabilityInput + or JSON or IO[bytes] + :return: CheckNameAvailabilityOutput. The CheckNameAvailabilityOutput is compatible with + MutableMapping + :rtype: ~azure.mgmt.cdn.models.CheckNameAvailabilityOutput + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CheckNameAvailabilityOutput] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(check_host_name_availability_input, (IOBase, bytes)): + _content = check_host_name_availability_input + else: + _content = json.dumps(check_host_name_availability_input, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_afd_profiles_check_host_name_availability_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.CheckNameAvailabilityOutput, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def validate_secret( + self, + resource_group_name: str, + profile_name: str, + validate_secret_input: _models.ValidateSecretInput, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ValidateSecretOutput: + """Validate a Secret in the 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 or CDN + profile which is unique within the resource group. Required. + :type profile_name: str + :param validate_secret_input: The Secret source. Required. + :type validate_secret_input: ~azure.mgmt.cdn.models.ValidateSecretInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ValidateSecretOutput. The ValidateSecretOutput is compatible with MutableMapping + :rtype: ~azure.mgmt.cdn.models.ValidateSecretOutput + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def validate_secret( + self, + resource_group_name: str, + profile_name: str, + validate_secret_input: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ValidateSecretOutput: + """Validate a Secret in the 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 or CDN + profile which is unique within the resource group. Required. + :type profile_name: str + :param validate_secret_input: The Secret source. Required. + :type validate_secret_input: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ValidateSecretOutput. The ValidateSecretOutput is compatible with MutableMapping + :rtype: ~azure.mgmt.cdn.models.ValidateSecretOutput + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def validate_secret( + self, + resource_group_name: str, + profile_name: str, + validate_secret_input: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ValidateSecretOutput: + """Validate a Secret in the 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 or CDN + profile which is unique within the resource group. Required. + :type profile_name: str + :param validate_secret_input: The Secret source. Required. + :type validate_secret_input: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ValidateSecretOutput. The ValidateSecretOutput is compatible with MutableMapping + :rtype: ~azure.mgmt.cdn.models.ValidateSecretOutput + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def validate_secret( + self, + resource_group_name: str, + profile_name: str, + validate_secret_input: Union[_models.ValidateSecretInput, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.ValidateSecretOutput: + """Validate a Secret in the 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 or CDN + profile which is unique within the resource group. Required. + :type profile_name: str + :param validate_secret_input: The Secret source. Is one of the following types: + ValidateSecretInput, JSON, IO[bytes] Required. + :type validate_secret_input: ~azure.mgmt.cdn.models.ValidateSecretInput or JSON or IO[bytes] + :return: ValidateSecretOutput. The ValidateSecretOutput is compatible with MutableMapping + :rtype: ~azure.mgmt.cdn.models.ValidateSecretOutput + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ValidateSecretOutput] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(validate_secret_input, (IOBase, bytes)): + _content = validate_secret_input + else: + _content = json.dumps(validate_secret_input, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_afd_profiles_validate_secret_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ValidateSecretOutput, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _upgrade_initial( + self, + resource_group_name: str, + profile_name: str, + profile_upgrade_parameters: Union[_models.ProfileUpgradeParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(profile_upgrade_parameters, (IOBase, bytes)): + _content = profile_upgrade_parameters + else: + _content = json.dumps(profile_upgrade_parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_afd_profiles_upgrade_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_upgrade( + self, + resource_group_name: str, + profile_name: str, + profile_upgrade_parameters: _models.ProfileUpgradeParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Profile]: + """Upgrade a profile from Standard_AzureFrontDoor to Premium_AzureFrontDoor. + + :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 or CDN + profile which is unique within the resource group. Required. + :type profile_name: str + :param profile_upgrade_parameters: Profile upgrade input parameter. Required. + :type profile_upgrade_parameters: ~azure.mgmt.cdn.models.ProfileUpgradeParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns Profile. The Profile is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Profile] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_upgrade( + self, + resource_group_name: str, + profile_name: str, + profile_upgrade_parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Profile]: + """Upgrade a profile from Standard_AzureFrontDoor to Premium_AzureFrontDoor. + + :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 or CDN + profile which is unique within the resource group. Required. + :type profile_name: str + :param profile_upgrade_parameters: Profile upgrade input parameter. Required. + :type profile_upgrade_parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns Profile. The Profile is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Profile] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_upgrade( + self, + resource_group_name: str, + profile_name: str, + profile_upgrade_parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Profile]: + """Upgrade a profile from Standard_AzureFrontDoor to Premium_AzureFrontDoor. + + :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 or CDN + profile which is unique within the resource group. Required. + :type profile_name: str + :param profile_upgrade_parameters: Profile upgrade input parameter. Required. + :type profile_upgrade_parameters: IO[bytes] + :keyword content_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 Profile. The Profile is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Profile] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_upgrade( + self, + resource_group_name: str, + profile_name: str, + profile_upgrade_parameters: Union[_models.ProfileUpgradeParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.Profile]: + """Upgrade a profile from Standard_AzureFrontDoor to Premium_AzureFrontDoor. + + :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 or CDN + profile which is unique within the resource group. Required. + :type profile_name: str + :param profile_upgrade_parameters: Profile upgrade input parameter. Is one of the following + types: ProfileUpgradeParameters, JSON, IO[bytes] Required. + :type profile_upgrade_parameters: ~azure.mgmt.cdn.models.ProfileUpgradeParameters or JSON or + IO[bytes] + :return: An instance of AsyncLROPoller that returns Profile. The Profile is compatible with + MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Profile] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Profile] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._upgrade_initial( + resource_group_name=resource_group_name, + profile_name=profile_name, + profile_upgrade_parameters=profile_upgrade_parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.Profile, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.Profile].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.Profile]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + +class LogAnalyticsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cdn.aio.CdnManagementClient`'s + :attr:`log_analytics` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: 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( + self, + resource_group_name: str, + profile_name: str, + *, + metrics: List[Union[str, _models.LogMetric]], + date_time_begin: datetime.datetime, + date_time_end: datetime.datetime, + granularity: Union[str, _models.LogMetricsGranularity], + custom_domains: List[str], + protocols: List[str], + group_by: Optional[List[Union[str, _models.LogMetricsGroupBy]]] = None, + continents: Optional[List[str]] = None, + country_or_regions: Optional[List[str]] = None, + **kwargs: Any + ) -> _models.MetricsResponse: + """Get log report for AFD 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 or CDN + profile which is unique within the resource group. Required. + :type profile_name: str + :keyword metrics: Required. + :paramtype metrics: list[str or ~azure.mgmt.cdn.models.LogMetric] + :keyword date_time_begin: Required. + :paramtype date_time_begin: ~datetime.datetime + :keyword date_time_end: Required. + :paramtype date_time_end: ~datetime.datetime + :keyword granularity: Known values are: "PT5M", "PT1H", and "P1D". Required. + :paramtype granularity: str or ~azure.mgmt.cdn.models.LogMetricsGranularity + :keyword custom_domains: Required. + :paramtype custom_domains: list[str] + :keyword protocols: Required. + :paramtype protocols: list[str] + :keyword group_by: Default value is None. + :paramtype group_by: list[str or ~azure.mgmt.cdn.models.LogMetricsGroupBy] + :keyword continents: Default value is None. + :paramtype continents: list[str] + :keyword country_or_regions: Default value is None. + :paramtype country_or_regions: list[str] + :return: MetricsResponse. The MetricsResponse is compatible with MutableMapping + :rtype: ~azure.mgmt.cdn.models.MetricsResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.MetricsResponse] = kwargs.pop("cls", None) + + _request = build_log_analytics_get_log_analytics_metrics_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + subscription_id=self._config.subscription_id, + metrics=metrics, + date_time_begin=date_time_begin, + date_time_end=date_time_end, + granularity=granularity, + custom_domains=custom_domains, + protocols=protocols, + group_by=group_by, + continents=continents, + country_or_regions=country_or_regions, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.MetricsResponse, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get_log_analytics_rankings( + self, + resource_group_name: str, + profile_name: str, + *, + rankings: List[Union[str, _models.LogRanking]], + metrics: List[Union[str, _models.LogRankingMetric]], + max_ranking: int, + date_time_begin: datetime.datetime, + date_time_end: datetime.datetime, + custom_domains: Optional[List[str]] = None, + **kwargs: Any + ) -> _models.RankingsResponse: + """Get log analytics ranking report for AFD 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 or CDN + profile which is unique within the resource group. Required. + :type profile_name: str + :keyword rankings: Required. + :paramtype rankings: list[str or ~azure.mgmt.cdn.models.LogRanking] + :keyword metrics: Required. + :paramtype metrics: list[str or ~azure.mgmt.cdn.models.LogRankingMetric] + :keyword max_ranking: Required. + :paramtype max_ranking: int + :keyword date_time_begin: Required. + :paramtype date_time_begin: ~datetime.datetime + :keyword date_time_end: Required. + :paramtype date_time_end: ~datetime.datetime + :keyword custom_domains: Default value is None. + :paramtype custom_domains: list[str] + :return: RankingsResponse. The RankingsResponse is compatible with MutableMapping + :rtype: ~azure.mgmt.cdn.models.RankingsResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.RankingsResponse] = kwargs.pop("cls", None) + + _request = build_log_analytics_get_log_analytics_rankings_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + subscription_id=self._config.subscription_id, + rankings=rankings, + metrics=metrics, + max_ranking=max_ranking, + date_time_begin=date_time_begin, + date_time_end=date_time_end, + custom_domains=custom_domains, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.RankingsResponse, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get_log_analytics_locations( + self, resource_group_name: str, profile_name: str, **kwargs: Any + ) -> _models.ContinentsResponse: + """Get all available location names for AFD log analytics report. + + :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 or CDN + profile which is unique within the resource group. Required. + :type profile_name: str + :return: ContinentsResponse. The ContinentsResponse is compatible with MutableMapping + :rtype: ~azure.mgmt.cdn.models.ContinentsResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ContinentsResponse] = kwargs.pop("cls", None) + + _request = build_log_analytics_get_log_analytics_locations_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ContinentsResponse, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get_log_analytics_resources( + self, resource_group_name: str, profile_name: str, **kwargs: Any + ) -> _models.ResourcesResponse: + """Get all endpoints and custom domains available for AFD log report. + + :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 or CDN + profile which is unique within the resource group. Required. + :type profile_name: str + :return: ResourcesResponse. The ResourcesResponse is compatible with MutableMapping + :rtype: ~azure.mgmt.cdn.models.ResourcesResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ResourcesResponse] = kwargs.pop("cls", None) + + _request = build_log_analytics_get_log_analytics_resources_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ResourcesResponse, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get_waf_log_analytics_metrics( + self, + resource_group_name: str, + profile_name: str, + *, + metrics: List[Union[str, _models.WafMetric]], + date_time_begin: datetime.datetime, + date_time_end: datetime.datetime, + granularity: Union[str, _models.WafGranularity], + actions: Optional[List[Union[str, _models.WafAction]]] = None, + group_by: Optional[List[Union[str, _models.WafRankingGroupBy]]] = None, + rule_types: Optional[List[Union[str, _models.WafRuleType]]] = None, + **kwargs: Any + ) -> _models.WafMetricsResponse: + """Get Waf related log analytics report for AFD 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 or CDN + profile which is unique within the resource group. Required. + :type profile_name: str + :keyword metrics: Required. + :paramtype metrics: list[str or ~azure.mgmt.cdn.models.WafMetric] + :keyword date_time_begin: Required. + :paramtype date_time_begin: ~datetime.datetime + :keyword date_time_end: Required. + :paramtype date_time_end: ~datetime.datetime + :keyword granularity: Known values are: "PT5M", "PT1H", and "P1D". Required. + :paramtype granularity: str or ~azure.mgmt.cdn.models.WafGranularity + :keyword actions: Default value is None. + :paramtype actions: list[str or ~azure.mgmt.cdn.models.WafAction] + :keyword group_by: Default value is None. + :paramtype group_by: list[str or ~azure.mgmt.cdn.models.WafRankingGroupBy] + :keyword rule_types: Default value is None. + :paramtype rule_types: list[str or ~azure.mgmt.cdn.models.WafRuleType] + :return: WafMetricsResponse. The WafMetricsResponse is compatible with MutableMapping + :rtype: ~azure.mgmt.cdn.models.WafMetricsResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.WafMetricsResponse] = kwargs.pop("cls", None) + + _request = build_log_analytics_get_waf_log_analytics_metrics_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + subscription_id=self._config.subscription_id, + metrics=metrics, + date_time_begin=date_time_begin, + date_time_end=date_time_end, + granularity=granularity, + actions=actions, + group_by=group_by, + rule_types=rule_types, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.WafMetricsResponse, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get_waf_log_analytics_rankings( + self, + resource_group_name: str, + profile_name: str, + *, + metrics: List[Union[str, _models.WafMetric]], + date_time_begin: datetime.datetime, + date_time_end: datetime.datetime, + max_ranking: int, + rankings: List[Union[str, _models.WafRankingType]], + actions: Optional[List[Union[str, _models.WafAction]]] = None, + rule_types: Optional[List[Union[str, _models.WafRuleType]]] = None, + **kwargs: Any + ) -> _models.WafRankingsResponse: + """Get WAF log analytics charts for AFD 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 or CDN + profile which is unique within the resource group. Required. + :type profile_name: str + :keyword metrics: Required. + :paramtype metrics: list[str or ~azure.mgmt.cdn.models.WafMetric] + :keyword date_time_begin: Required. + :paramtype date_time_begin: ~datetime.datetime + :keyword date_time_end: Required. + :paramtype date_time_end: ~datetime.datetime + :keyword max_ranking: Required. + :paramtype max_ranking: int + :keyword rankings: Required. + :paramtype rankings: list[str or ~azure.mgmt.cdn.models.WafRankingType] + :keyword actions: Default value is None. + :paramtype actions: list[str or ~azure.mgmt.cdn.models.WafAction] + :keyword rule_types: Default value is None. + :paramtype rule_types: list[str or ~azure.mgmt.cdn.models.WafRuleType] + :return: WafRankingsResponse. The WafRankingsResponse is compatible with MutableMapping + :rtype: ~azure.mgmt.cdn.models.WafRankingsResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.WafRankingsResponse] = kwargs.pop("cls", None) + + _request = build_log_analytics_get_waf_log_analytics_rankings_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + subscription_id=self._config.subscription_id, + metrics=metrics, + date_time_begin=date_time_begin, + date_time_end=date_time_end, + max_ranking=max_ranking, + rankings=rankings, + actions=actions, + rule_types=rule_types, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.WafRankingsResponse, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class PoliciesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cdn.aio.CdnManagementClient`'s + :attr:`policies` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: 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( + self, resource_group_name: str, policy_name: str, **kwargs: Any + ) -> _models.CdnWebApplicationFirewallPolicy: + """Retrieve protection policy with specified name within a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param policy_name: The name of the CdnWebApplicationFirewallPolicy. Required. + :type policy_name: str + :return: CdnWebApplicationFirewallPolicy. The CdnWebApplicationFirewallPolicy is compatible + with MutableMapping + :rtype: ~azure.mgmt.cdn.models.CdnWebApplicationFirewallPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.CdnWebApplicationFirewallPolicy] = kwargs.pop("cls", None) + + _request = build_policies_get_request( + resource_group_name=resource_group_name, + policy_name=policy_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.CdnWebApplicationFirewallPolicy, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + policy_name: str, + cdn_web_application_firewall_policy: Union[_models.CdnWebApplicationFirewallPolicy, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(cdn_web_application_firewall_policy, (IOBase, bytes)): + _content = cdn_web_application_firewall_policy + else: + _content = json.dumps(cdn_web_application_firewall_policy, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_policies_create_or_update_request( + resource_group_name=resource_group_name, + policy_name=policy_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + policy_name: str, + cdn_web_application_firewall_policy: _models.CdnWebApplicationFirewallPolicy, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CdnWebApplicationFirewallPolicy]: + """Create or update policy with specified rule set name within a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param policy_name: The name of the CdnWebApplicationFirewallPolicy. Required. + :type policy_name: str + :param cdn_web_application_firewall_policy: Policy to be created. Required. + :type cdn_web_application_firewall_policy: + ~azure.mgmt.cdn.models.CdnWebApplicationFirewallPolicy + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns CdnWebApplicationFirewallPolicy. The + CdnWebApplicationFirewallPolicy is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.CdnWebApplicationFirewallPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + policy_name: str, + cdn_web_application_firewall_policy: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CdnWebApplicationFirewallPolicy]: + """Create or update policy with specified rule set name within a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param policy_name: The name of the CdnWebApplicationFirewallPolicy. Required. + :type policy_name: str + :param cdn_web_application_firewall_policy: Policy to be created. Required. + :type cdn_web_application_firewall_policy: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns CdnWebApplicationFirewallPolicy. The + CdnWebApplicationFirewallPolicy is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.CdnWebApplicationFirewallPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + policy_name: str, + cdn_web_application_firewall_policy: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CdnWebApplicationFirewallPolicy]: + """Create or update policy with specified rule set name within a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param policy_name: The name of the CdnWebApplicationFirewallPolicy. Required. + :type policy_name: str + :param cdn_web_application_firewall_policy: Policy to be created. Required. + :type cdn_web_application_firewall_policy: IO[bytes] + :keyword content_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 CdnWebApplicationFirewallPolicy. The + CdnWebApplicationFirewallPolicy is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.CdnWebApplicationFirewallPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + policy_name: str, + cdn_web_application_firewall_policy: Union[_models.CdnWebApplicationFirewallPolicy, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.CdnWebApplicationFirewallPolicy]: + """Create or update policy with specified rule set name within a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param policy_name: The name of the CdnWebApplicationFirewallPolicy. Required. + :type policy_name: str + :param cdn_web_application_firewall_policy: Policy to be created. Is one of the following + types: CdnWebApplicationFirewallPolicy, JSON, IO[bytes] Required. + :type cdn_web_application_firewall_policy: + ~azure.mgmt.cdn.models.CdnWebApplicationFirewallPolicy or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns CdnWebApplicationFirewallPolicy. The + CdnWebApplicationFirewallPolicy is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.CdnWebApplicationFirewallPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CdnWebApplicationFirewallPolicy] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + policy_name=policy_name, + cdn_web_application_firewall_policy=cdn_web_application_firewall_policy, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.CdnWebApplicationFirewallPolicy, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.CdnWebApplicationFirewallPolicy].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.CdnWebApplicationFirewallPolicy]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _update_initial( + self, + resource_group_name: str, + policy_name: str, + cdn_web_application_firewall_policy_patch_parameters: Union[ + _models.CdnWebApplicationFirewallPolicyPatchParameters, JSON, IO[bytes] + ], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(cdn_web_application_firewall_policy_patch_parameters, (IOBase, bytes)): + _content = cdn_web_application_firewall_policy_patch_parameters + else: + _content = json.dumps(cdn_web_application_firewall_policy_patch_parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_policies_update_request( + resource_group_name=resource_group_name, + policy_name=policy_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_update( + self, + resource_group_name: str, + policy_name: str, + cdn_web_application_firewall_policy_patch_parameters: _models.CdnWebApplicationFirewallPolicyPatchParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CdnWebApplicationFirewallPolicy]: + """Update an existing CdnWebApplicationFirewallPolicy with the specified policy name under the + specified subscription and resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param policy_name: The name of the CdnWebApplicationFirewallPolicy. Required. + :type policy_name: str + :param cdn_web_application_firewall_policy_patch_parameters: CdnWebApplicationFirewallPolicy + parameters to be patched. Required. + :type cdn_web_application_firewall_policy_patch_parameters: + ~azure.mgmt.cdn.models.CdnWebApplicationFirewallPolicyPatchParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns CdnWebApplicationFirewallPolicy. The + CdnWebApplicationFirewallPolicy is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.CdnWebApplicationFirewallPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + policy_name: str, + cdn_web_application_firewall_policy_patch_parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CdnWebApplicationFirewallPolicy]: + """Update an existing CdnWebApplicationFirewallPolicy with the specified policy name under the + specified subscription and resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param policy_name: The name of the CdnWebApplicationFirewallPolicy. Required. + :type policy_name: str + :param cdn_web_application_firewall_policy_patch_parameters: CdnWebApplicationFirewallPolicy + parameters to be patched. Required. + :type cdn_web_application_firewall_policy_patch_parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns CdnWebApplicationFirewallPolicy. The + CdnWebApplicationFirewallPolicy is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.CdnWebApplicationFirewallPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + policy_name: str, + cdn_web_application_firewall_policy_patch_parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CdnWebApplicationFirewallPolicy]: + """Update an existing CdnWebApplicationFirewallPolicy with the specified policy name under the + specified subscription and resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param policy_name: The name of the CdnWebApplicationFirewallPolicy. Required. + :type policy_name: str + :param cdn_web_application_firewall_policy_patch_parameters: CdnWebApplicationFirewallPolicy + parameters to be patched. Required. + :type cdn_web_application_firewall_policy_patch_parameters: IO[bytes] + :keyword content_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 CdnWebApplicationFirewallPolicy. The + CdnWebApplicationFirewallPolicy is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.CdnWebApplicationFirewallPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + policy_name: str, + cdn_web_application_firewall_policy_patch_parameters: Union[ + _models.CdnWebApplicationFirewallPolicyPatchParameters, JSON, IO[bytes] + ], + **kwargs: Any + ) -> AsyncLROPoller[_models.CdnWebApplicationFirewallPolicy]: + """Update an existing CdnWebApplicationFirewallPolicy with the specified policy name under the + specified subscription and resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param policy_name: The name of the CdnWebApplicationFirewallPolicy. Required. + :type policy_name: str + :param cdn_web_application_firewall_policy_patch_parameters: CdnWebApplicationFirewallPolicy + parameters to be patched. Is one of the following types: + CdnWebApplicationFirewallPolicyPatchParameters, JSON, IO[bytes] Required. + :type cdn_web_application_firewall_policy_patch_parameters: + ~azure.mgmt.cdn.models.CdnWebApplicationFirewallPolicyPatchParameters or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns CdnWebApplicationFirewallPolicy. The + CdnWebApplicationFirewallPolicy is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.CdnWebApplicationFirewallPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CdnWebApplicationFirewallPolicy] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._update_initial( + resource_group_name=resource_group_name, + policy_name=policy_name, + cdn_web_application_firewall_policy_patch_parameters=cdn_web_application_firewall_policy_patch_parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.CdnWebApplicationFirewallPolicy, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.CdnWebApplicationFirewallPolicy].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.CdnWebApplicationFirewallPolicy]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace_async + async def delete(self, resource_group_name: str, policy_name: str, **kwargs: Any) -> None: + """Deletes Policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param policy_name: The name of the CdnWebApplicationFirewallPolicy. Required. + :type policy_name: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_policies_delete_request( + resource_group_name=resource_group_name, + policy_name=policy_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list( + self, resource_group_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.CdnWebApplicationFirewallPolicy"]: + """Lists all of the protection policies within a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :return: An iterator like instance of CdnWebApplicationFirewallPolicy + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cdn.models.CdnWebApplicationFirewallPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.CdnWebApplicationFirewallPolicy]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_policies_list_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.CdnWebApplicationFirewallPolicy], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class ResourceUsageOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cdn.aio.CdnManagementClient`'s + :attr:`resource_usage` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: 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) -> AsyncItemPaged["_models.ResourceUsage"]: + """Check the quota and actual usage of the CDN profiles under the given subscription. + + :return: An iterator like instance of ResourceUsage + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cdn.models.ResourceUsage] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ResourceUsage]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_resource_usage_list_request( + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ResourceUsage], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class EdgeNodesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cdn.aio.CdnManagementClient`'s + :attr:`edge_nodes` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: 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) -> AsyncItemPaged["_models.EdgeNode"]: + """Edgenodes are the global Point of Presence (POP) locations used to deliver CDN content to end + users. + + :return: An iterator like instance of EdgeNode + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cdn.models.EdgeNode] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.EdgeNode]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_edge_nodes_list_request( + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.EdgeNode], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class ManagedRuleSetsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cdn.aio.CdnManagementClient`'s + :attr:`managed_rule_sets` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: 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) -> AsyncItemPaged["_models.ManagedRuleSetDefinition"]: + """Lists all available managed rule sets. + + :return: An iterator like instance of ManagedRuleSetDefinition + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cdn.models.ManagedRuleSetDefinition] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ManagedRuleSetDefinition]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_managed_rule_sets_list_request( + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ManagedRuleSetDefinition], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class _CdnManagementClientOperationsMixin( + ClientMixinABC[AsyncPipelineClient[HttpRequest, AsyncHttpResponse], CdnManagementClientConfiguration] +): + + @overload + async def check_endpoint_name_availability( + self, + resource_group_name: str, + check_endpoint_name_availability_input: _models.CheckEndpointNameAvailabilityInput, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CheckEndpointNameAvailabilityOutput: + """Check the availability of a resource name. This is needed for resources where name is globally + unique, such as a afdx endpoint. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param check_endpoint_name_availability_input: Input to check. Required. + :type check_endpoint_name_availability_input: + ~azure.mgmt.cdn.models.CheckEndpointNameAvailabilityInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: CheckEndpointNameAvailabilityOutput. The CheckEndpointNameAvailabilityOutput is + compatible with MutableMapping + :rtype: ~azure.mgmt.cdn.models.CheckEndpointNameAvailabilityOutput + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_endpoint_name_availability( + self, + resource_group_name: str, + check_endpoint_name_availability_input: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CheckEndpointNameAvailabilityOutput: + """Check the availability of a resource name. This is needed for resources where name is globally + unique, such as a afdx endpoint. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param check_endpoint_name_availability_input: Input to check. Required. + :type check_endpoint_name_availability_input: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: CheckEndpointNameAvailabilityOutput. The CheckEndpointNameAvailabilityOutput is + compatible with MutableMapping + :rtype: ~azure.mgmt.cdn.models.CheckEndpointNameAvailabilityOutput + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_endpoint_name_availability( + self, + resource_group_name: str, + check_endpoint_name_availability_input: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CheckEndpointNameAvailabilityOutput: + """Check the availability of a resource name. This is needed for resources where name is globally + unique, such as a afdx endpoint. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param check_endpoint_name_availability_input: Input to check. Required. + :type check_endpoint_name_availability_input: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: CheckEndpointNameAvailabilityOutput. The CheckEndpointNameAvailabilityOutput is + compatible with MutableMapping + :rtype: ~azure.mgmt.cdn.models.CheckEndpointNameAvailabilityOutput + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_endpoint_name_availability( + self, + resource_group_name: str, + check_endpoint_name_availability_input: Union[_models.CheckEndpointNameAvailabilityInput, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.CheckEndpointNameAvailabilityOutput: + """Check the availability of a resource name. This is needed for resources where name is globally + unique, such as a afdx endpoint. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param check_endpoint_name_availability_input: Input to check. Is one of the following types: + CheckEndpointNameAvailabilityInput, JSON, IO[bytes] Required. + :type check_endpoint_name_availability_input: + ~azure.mgmt.cdn.models.CheckEndpointNameAvailabilityInput or JSON or IO[bytes] + :return: CheckEndpointNameAvailabilityOutput. The CheckEndpointNameAvailabilityOutput is + compatible with MutableMapping + :rtype: ~azure.mgmt.cdn.models.CheckEndpointNameAvailabilityOutput + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CheckEndpointNameAvailabilityOutput] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(check_endpoint_name_availability_input, (IOBase, bytes)): + _content = check_endpoint_name_availability_input + else: + _content = json.dumps(check_endpoint_name_availability_input, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_cdn_management_check_endpoint_name_availability_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.CheckEndpointNameAvailabilityOutput, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def check_name_availability( + self, + check_name_availability_input: _models.CheckNameAvailabilityInput, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CheckNameAvailabilityOutput: + """Check the availability of a resource name. This is needed for resources where name is globally + unique, such as a CDN endpoint. + + :param check_name_availability_input: The request body. Required. + :type check_name_availability_input: ~azure.mgmt.cdn.models.CheckNameAvailabilityInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: CheckNameAvailabilityOutput. The CheckNameAvailabilityOutput is compatible with + MutableMapping + :rtype: ~azure.mgmt.cdn.models.CheckNameAvailabilityOutput + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_name_availability( + self, check_name_availability_input: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityOutput: + """Check the availability of a resource name. This is needed for resources where name is globally + unique, such as a CDN endpoint. + + :param check_name_availability_input: The request body. Required. + :type check_name_availability_input: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: CheckNameAvailabilityOutput. The CheckNameAvailabilityOutput is compatible with + MutableMapping + :rtype: ~azure.mgmt.cdn.models.CheckNameAvailabilityOutput + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_name_availability( + self, check_name_availability_input: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityOutput: + """Check the availability of a resource name. This is needed for resources where name is globally + unique, such as a CDN endpoint. + + :param check_name_availability_input: The request body. Required. + :type check_name_availability_input: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: CheckNameAvailabilityOutput. The CheckNameAvailabilityOutput is compatible with + MutableMapping + :rtype: ~azure.mgmt.cdn.models.CheckNameAvailabilityOutput + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_name_availability( + self, check_name_availability_input: Union[_models.CheckNameAvailabilityInput, JSON, IO[bytes]], **kwargs: Any + ) -> _models.CheckNameAvailabilityOutput: + """Check the availability of a resource name. This is needed for resources where name is globally + unique, such as a CDN endpoint. + + :param check_name_availability_input: The request body. Is one of the following types: + CheckNameAvailabilityInput, JSON, IO[bytes] Required. + :type check_name_availability_input: ~azure.mgmt.cdn.models.CheckNameAvailabilityInput or JSON + or IO[bytes] + :return: CheckNameAvailabilityOutput. The CheckNameAvailabilityOutput is compatible with + MutableMapping + :rtype: ~azure.mgmt.cdn.models.CheckNameAvailabilityOutput + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CheckNameAvailabilityOutput] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(check_name_availability_input, (IOBase, bytes)): + _content = check_name_availability_input + else: + _content = json.dumps(check_name_availability_input, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_cdn_management_check_name_availability_request( + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.CheckNameAvailabilityOutput, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def check_name_availability_with_subscription( # pylint: disable=name-too-long + self, + check_name_availability_input: _models.CheckNameAvailabilityInput, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CheckNameAvailabilityOutput: + """Check the availability of a resource name. This is needed for resources where name is globally + unique, such as a CDN endpoint. + + :param check_name_availability_input: The request body. Required. + :type check_name_availability_input: ~azure.mgmt.cdn.models.CheckNameAvailabilityInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: CheckNameAvailabilityOutput. The CheckNameAvailabilityOutput is compatible with + MutableMapping + :rtype: ~azure.mgmt.cdn.models.CheckNameAvailabilityOutput + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_name_availability_with_subscription( # pylint: disable=name-too-long + self, check_name_availability_input: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityOutput: + """Check the availability of a resource name. This is needed for resources where name is globally + unique, such as a CDN endpoint. + + :param check_name_availability_input: The request body. Required. + :type check_name_availability_input: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: CheckNameAvailabilityOutput. The CheckNameAvailabilityOutput is compatible with + MutableMapping + :rtype: ~azure.mgmt.cdn.models.CheckNameAvailabilityOutput + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_name_availability_with_subscription( # pylint: disable=name-too-long + self, check_name_availability_input: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityOutput: + """Check the availability of a resource name. This is needed for resources where name is globally + unique, such as a CDN endpoint. + + :param check_name_availability_input: The request body. Required. + :type check_name_availability_input: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: CheckNameAvailabilityOutput. The CheckNameAvailabilityOutput is compatible with + MutableMapping + :rtype: ~azure.mgmt.cdn.models.CheckNameAvailabilityOutput + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_name_availability_with_subscription( # pylint: disable=name-too-long + self, check_name_availability_input: Union[_models.CheckNameAvailabilityInput, JSON, IO[bytes]], **kwargs: Any + ) -> _models.CheckNameAvailabilityOutput: + """Check the availability of a resource name. This is needed for resources where name is globally + unique, such as a CDN endpoint. + + :param check_name_availability_input: The request body. Is one of the following types: + CheckNameAvailabilityInput, JSON, IO[bytes] Required. + :type check_name_availability_input: ~azure.mgmt.cdn.models.CheckNameAvailabilityInput or JSON + or IO[bytes] + :return: CheckNameAvailabilityOutput. The CheckNameAvailabilityOutput is compatible with + MutableMapping + :rtype: ~azure.mgmt.cdn.models.CheckNameAvailabilityOutput + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CheckNameAvailabilityOutput] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(check_name_availability_input, (IOBase, bytes)): + _content = check_name_availability_input + else: + _content = json.dumps(check_name_availability_input, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_cdn_management_check_name_availability_with_subscription_request( + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.CheckNameAvailabilityOutput, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def validate_probe( + self, validate_probe_input: _models.ValidateProbeInput, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ValidateProbeOutput: + """Check if the probe path is a valid path and the file can be accessed. Probe path is the path to + a file hosted on the origin server to help accelerate the delivery of dynamic content via the + CDN endpoint. This path is relative to the origin path specified in the endpoint configuration. + + :param validate_probe_input: The request body. Required. + :type validate_probe_input: ~azure.mgmt.cdn.models.ValidateProbeInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ValidateProbeOutput. The ValidateProbeOutput is compatible with MutableMapping + :rtype: ~azure.mgmt.cdn.models.ValidateProbeOutput + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def validate_probe( + self, validate_probe_input: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ValidateProbeOutput: + """Check if the probe path is a valid path and the file can be accessed. Probe path is the path to + a file hosted on the origin server to help accelerate the delivery of dynamic content via the + CDN endpoint. This path is relative to the origin path specified in the endpoint configuration. + + :param validate_probe_input: The request body. Required. + :type validate_probe_input: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ValidateProbeOutput. The ValidateProbeOutput is compatible with MutableMapping + :rtype: ~azure.mgmt.cdn.models.ValidateProbeOutput + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def validate_probe( + self, validate_probe_input: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ValidateProbeOutput: + """Check if the probe path is a valid path and the file can be accessed. Probe path is the path to + a file hosted on the origin server to help accelerate the delivery of dynamic content via the + CDN endpoint. This path is relative to the origin path specified in the endpoint configuration. + + :param validate_probe_input: The request body. Required. + :type validate_probe_input: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ValidateProbeOutput. The ValidateProbeOutput is compatible with MutableMapping + :rtype: ~azure.mgmt.cdn.models.ValidateProbeOutput + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def validate_probe( + self, validate_probe_input: Union[_models.ValidateProbeInput, JSON, IO[bytes]], **kwargs: Any + ) -> _models.ValidateProbeOutput: + """Check if the probe path is a valid path and the file can be accessed. Probe path is the path to + a file hosted on the origin server to help accelerate the delivery of dynamic content via the + CDN endpoint. This path is relative to the origin path specified in the endpoint configuration. + + :param validate_probe_input: The request body. Is one of the following types: + ValidateProbeInput, JSON, IO[bytes] Required. + :type validate_probe_input: ~azure.mgmt.cdn.models.ValidateProbeInput or JSON or IO[bytes] + :return: ValidateProbeOutput. The ValidateProbeOutput is compatible with MutableMapping + :rtype: ~azure.mgmt.cdn.models.ValidateProbeOutput + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ValidateProbeOutput] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(validate_probe_input, (IOBase, bytes)): + _content = validate_probe_input + else: + _content = json.dumps(validate_probe_input, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_cdn_management_validate_probe_request( + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ValidateProbeOutput, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore 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 deleted file mode 100644 index 3512194ddb18..000000000000 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_origin_groups_operations.py +++ /dev/null @@ -1,791 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._origin_groups_operations import ( - build_create_request, - build_delete_request, - build_get_request, - build_list_by_endpoint_request, - build_update_request, -) -from .._vendor import CdnManagementClientMixinABC - -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 OriginGroupsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.cdn.aio.CdnManagementClient`'s - :attr:`origin_groups` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_endpoint( - self, resource_group_name: str, profile_name: str, endpoint_name: str, **kwargs: Any - ) -> AsyncIterable["_models.OriginGroup"]: - """Lists all of the existing origin groups within an 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 CDN profile 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. - :type endpoint_name: str - :return: An iterator like instance of either OriginGroup or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cdn.models.OriginGroup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - 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]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_endpoint_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("OriginGroupListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, resource_group_name: str, profile_name: str, endpoint_name: str, origin_group_name: str, **kwargs: Any - ) -> _models.OriginGroup: - """Gets an existing origin group within an 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 CDN profile 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. - :type endpoint_name: str - :param origin_group_name: Name of the origin group which is unique within the endpoint. - Required. - :type origin_group_name: str - :return: OriginGroup or the result of cls(response) - :rtype: ~azure.mgmt.cdn.models.OriginGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.OriginGroup] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - origin_group_name=origin_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("OriginGroup", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_initial( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - origin_group_name: str, - origin_group: Union[_models.OriginGroup, IO[bytes]], - **kwargs: Any - ) -> _models.OriginGroup: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_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.OriginGroup] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(origin_group, (IOBase, bytes)): - _content = origin_group - else: - _json = self._serialize.body(origin_group, "OriginGroup") - - _request = build_create_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - origin_group_name=origin_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - 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) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - origin_group_name: str, - origin_group: _models.OriginGroup, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.OriginGroup]: - """Creates a new origin group within the specified 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 CDN profile 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. - :type endpoint_name: str - :param origin_group_name: Name of the origin group which is unique within the endpoint. - Required. - :type origin_group_name: str - :param origin_group: Origin group properties. Required. - :type origin_group: ~azure.mgmt.cdn.models.OriginGroup - :keyword content_type: Body Parameter 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 OriginGroup or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.OriginGroup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - origin_group_name: str, - origin_group: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.OriginGroup]: - """Creates a new origin group within the specified 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 CDN profile 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. - :type endpoint_name: str - :param origin_group_name: Name of the origin group which is unique within the endpoint. - Required. - :type origin_group_name: str - :param origin_group: Origin group properties. Required. - :type origin_group: IO[bytes] - :keyword content_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 OriginGroup or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.OriginGroup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - origin_group_name: str, - origin_group: Union[_models.OriginGroup, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.OriginGroup]: - """Creates a new origin group within the specified 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 CDN profile 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. - :type endpoint_name: str - :param origin_group_name: Name of the origin group which is unique within the endpoint. - Required. - :type origin_group_name: str - :param origin_group: Origin group properties. Is either a OriginGroup type or a IO[bytes] type. - Required. - :type origin_group: ~azure.mgmt.cdn.models.OriginGroup or IO[bytes] - :return: An instance of AsyncLROPoller that returns either OriginGroup or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.OriginGroup] - :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.OriginGroup] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._create_initial( - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - origin_group_name=origin_group_name, - origin_group=origin_group, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("OriginGroup", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.OriginGroup].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.OriginGroup]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _update_initial( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - origin_group_name: str, - origin_group_update_properties: Union[_models.OriginGroupUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> _models.OriginGroup: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_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.OriginGroup] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(origin_group_update_properties, (IOBase, bytes)): - _content = origin_group_update_properties - else: - _json = self._serialize.body(origin_group_update_properties, "OriginGroupUpdateParameters") - - _request = build_update_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - origin_group_name=origin_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - 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) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_update( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - origin_group_name: str, - origin_group_update_properties: _models.OriginGroupUpdateParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.OriginGroup]: - """Updates an existing origin group within an 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 CDN profile 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. - :type endpoint_name: str - :param origin_group_name: Name of the origin group which is unique within the endpoint. - Required. - :type origin_group_name: str - :param origin_group_update_properties: Origin group properties. Required. - :type origin_group_update_properties: ~azure.mgmt.cdn.models.OriginGroupUpdateParameters - :keyword content_type: Body Parameter 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 OriginGroup or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.OriginGroup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - origin_group_name: str, - origin_group_update_properties: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.OriginGroup]: - """Updates an existing origin group within an 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 CDN profile 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. - :type endpoint_name: str - :param origin_group_name: Name of the origin group which is unique within the endpoint. - Required. - :type origin_group_name: str - :param origin_group_update_properties: Origin group properties. Required. - :type origin_group_update_properties: IO[bytes] - :keyword content_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 OriginGroup or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.OriginGroup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - origin_group_name: str, - origin_group_update_properties: Union[_models.OriginGroupUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.OriginGroup]: - """Updates an existing origin group within an 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 CDN profile 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. - :type endpoint_name: str - :param origin_group_name: Name of the origin group which is unique within the endpoint. - Required. - :type origin_group_name: str - :param origin_group_update_properties: Origin group properties. Is either a - OriginGroupUpdateParameters type or a IO[bytes] type. Required. - :type origin_group_update_properties: ~azure.mgmt.cdn.models.OriginGroupUpdateParameters or - IO[bytes] - :return: An instance of AsyncLROPoller that returns either OriginGroup or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.OriginGroup] - :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.OriginGroup] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._update_initial( - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - origin_group_name=origin_group_name, - origin_group_update_properties=origin_group_update_properties, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("OriginGroup", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.OriginGroup].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.OriginGroup]( - 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, endpoint_name: str, origin_group_name: str, **kwargs: Any - ) -> None: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - origin_group_name=origin_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["location"] = self._deserialize("str", response.headers.get("location")) - - if cls: - return cls(pipeline_response, None, response_headers) # type: ignore - - @distributed_trace_async - async def begin_delete( - self, resource_group_name: str, profile_name: str, endpoint_name: str, origin_group_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes an existing origin group within an 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 CDN profile 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. - :type endpoint_name: str - :param origin_group_name: Name of the origin group which is unique within the endpoint. - Required. - :type origin_group_name: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_initial( # type: ignore - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - origin_group_name=origin_group_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/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 deleted file mode 100644 index 21192a6e9ad0..000000000000 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_origins_operations.py +++ /dev/null @@ -1,781 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._origins_operations import ( - build_create_request, - build_delete_request, - build_get_request, - build_list_by_endpoint_request, - build_update_request, -) -from .._vendor import CdnManagementClientMixinABC - -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 OriginsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.cdn.aio.CdnManagementClient`'s - :attr:`origins` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_endpoint( - self, resource_group_name: str, profile_name: str, endpoint_name: str, **kwargs: Any - ) -> AsyncIterable["_models.Origin"]: - """Lists all of the existing origins within an 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 CDN profile 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. - :type endpoint_name: str - :return: An iterator like instance of either Origin or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cdn.models.Origin] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - 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]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_endpoint_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("OriginListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, resource_group_name: str, profile_name: str, endpoint_name: str, origin_name: str, **kwargs: Any - ) -> _models.Origin: - """Gets an existing origin within an 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 CDN profile 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. - :type endpoint_name: str - :param origin_name: Name of the origin which is unique within the endpoint. Required. - :type origin_name: str - :return: Origin or the result of cls(response) - :rtype: ~azure.mgmt.cdn.models.Origin - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.Origin] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - origin_name=origin_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Origin", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_initial( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - origin_name: str, - origin: Union[_models.Origin, IO[bytes]], - **kwargs: Any - ) -> _models.Origin: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_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.Origin] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(origin, (IOBase, bytes)): - _content = origin - else: - _json = self._serialize.body(origin, "Origin") - - _request = build_create_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - origin_name=origin_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - 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) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - origin_name: str, - origin: _models.Origin, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Origin]: - """Creates a new origin within the specified 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 CDN profile 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. - :type endpoint_name: str - :param origin_name: Name of the origin that is unique within the endpoint. Required. - :type origin_name: str - :param origin: Origin properties. Required. - :type origin: ~azure.mgmt.cdn.models.Origin - :keyword content_type: Body Parameter 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 Origin or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Origin] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - origin_name: str, - origin: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Origin]: - """Creates a new origin within the specified 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 CDN profile 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. - :type endpoint_name: str - :param origin_name: Name of the origin that is unique within the endpoint. Required. - :type origin_name: str - :param origin: Origin properties. Required. - :type origin: IO[bytes] - :keyword content_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 Origin or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Origin] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - origin_name: str, - origin: Union[_models.Origin, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.Origin]: - """Creates a new origin within the specified 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 CDN profile 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. - :type endpoint_name: str - :param origin_name: Name of the origin that is unique within the endpoint. Required. - :type origin_name: str - :param origin: Origin properties. Is either a Origin type or a IO[bytes] type. Required. - :type origin: ~azure.mgmt.cdn.models.Origin or IO[bytes] - :return: An instance of AsyncLROPoller that returns either Origin or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Origin] - :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.Origin] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._create_initial( - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - origin_name=origin_name, - origin=origin, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Origin", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.Origin].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Origin]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _update_initial( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - origin_name: str, - origin_update_properties: Union[_models.OriginUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> _models.Origin: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_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.Origin] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(origin_update_properties, (IOBase, bytes)): - _content = origin_update_properties - else: - _json = self._serialize.body(origin_update_properties, "OriginUpdateParameters") - - _request = build_update_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - origin_name=origin_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - 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) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_update( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - origin_name: str, - origin_update_properties: _models.OriginUpdateParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Origin]: - """Updates an existing origin within an 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 CDN profile 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. - :type endpoint_name: str - :param origin_name: Name of the origin which is unique within the endpoint. Required. - :type origin_name: str - :param origin_update_properties: Origin properties. Required. - :type origin_update_properties: ~azure.mgmt.cdn.models.OriginUpdateParameters - :keyword content_type: Body Parameter 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 Origin or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Origin] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - origin_name: str, - origin_update_properties: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Origin]: - """Updates an existing origin within an 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 CDN profile 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. - :type endpoint_name: str - :param origin_name: Name of the origin which is unique within the endpoint. Required. - :type origin_name: str - :param origin_update_properties: Origin properties. Required. - :type origin_update_properties: IO[bytes] - :keyword content_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 Origin or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Origin] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - origin_name: str, - origin_update_properties: Union[_models.OriginUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.Origin]: - """Updates an existing origin within an 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 CDN profile 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. - :type endpoint_name: str - :param origin_name: Name of the origin which is unique within the endpoint. Required. - :type origin_name: str - :param origin_update_properties: Origin properties. Is either a OriginUpdateParameters type or - a IO[bytes] type. Required. - :type origin_update_properties: ~azure.mgmt.cdn.models.OriginUpdateParameters or IO[bytes] - :return: An instance of AsyncLROPoller that returns either Origin or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Origin] - :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.Origin] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._update_initial( - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - origin_name=origin_name, - origin_update_properties=origin_update_properties, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Origin", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.Origin].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Origin]( - 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, endpoint_name: str, origin_name: str, **kwargs: Any - ) -> None: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - origin_name=origin_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["location"] = self._deserialize("str", response.headers.get("location")) - - if cls: - return cls(pipeline_response, None, response_headers) # type: ignore - - @distributed_trace_async - async def begin_delete( - self, resource_group_name: str, profile_name: str, endpoint_name: str, origin_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes an existing origin within an 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 CDN profile 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. - :type endpoint_name: str - :param origin_name: Name of the origin which is unique within the endpoint. Required. - :type origin_name: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_initial( # type: ignore - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - origin_name=origin_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_patch.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_patch.py index f7dd32510333..ea765788358a 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_patch.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_patch.py @@ -1,14 +1,14 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------- """Customize generated code here. Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize """ -from typing import List -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level +__all__: list[str] = [] # Add all objects you want publicly available to users at this package level def patch_sdk(): diff --git a/sdk/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 deleted file mode 100644 index 7e6760ff2bf3..000000000000 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_policies_operations.py +++ /dev/null @@ -1,672 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._policies_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_request, - build_update_request, -) -from .._vendor import CdnManagementClientMixinABC - -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 PoliciesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.cdn.aio.CdnManagementClient`'s - :attr:`policies` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.CdnWebApplicationFirewallPolicy"]: - """Lists all of the protection policies within a resource group. - - :param resource_group_name: Name of the Resource group within the Azure subscription. Required. - :type resource_group_name: str - :return: An iterator like instance of either CdnWebApplicationFirewallPolicy or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cdn.models.CdnWebApplicationFirewallPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - 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]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("CdnWebApplicationFirewallPolicyList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, resource_group_name: str, policy_name: str, **kwargs: Any - ) -> _models.CdnWebApplicationFirewallPolicy: - """Retrieve protection policy with specified name within a resource group. - - :param resource_group_name: Name of the Resource group within the Azure subscription. Required. - :type resource_group_name: str - :param policy_name: The name of the CdnWebApplicationFirewallPolicy. Required. - :type policy_name: str - :return: CdnWebApplicationFirewallPolicy or the result of cls(response) - :rtype: ~azure.mgmt.cdn.models.CdnWebApplicationFirewallPolicy - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.CdnWebApplicationFirewallPolicy] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - policy_name=policy_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("CdnWebApplicationFirewallPolicy", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_or_update_initial( - self, - resource_group_name: str, - policy_name: str, - cdn_web_application_firewall_policy: Union[_models.CdnWebApplicationFirewallPolicy, IO[bytes]], - **kwargs: Any - ) -> _models.CdnWebApplicationFirewallPolicy: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_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.CdnWebApplicationFirewallPolicy] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(cdn_web_application_firewall_policy, (IOBase, bytes)): - _content = cdn_web_application_firewall_policy - else: - _json = self._serialize.body(cdn_web_application_firewall_policy, "CdnWebApplicationFirewallPolicy") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - policy_name=policy_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - 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) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - policy_name: str, - cdn_web_application_firewall_policy: _models.CdnWebApplicationFirewallPolicy, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.CdnWebApplicationFirewallPolicy]: - """Create or update policy with specified rule set name within a resource group. - - :param resource_group_name: Name of the Resource group within the Azure subscription. Required. - :type resource_group_name: str - :param policy_name: The name of the CdnWebApplicationFirewallPolicy. Required. - :type policy_name: str - :param cdn_web_application_firewall_policy: Policy to be created. Required. - :type cdn_web_application_firewall_policy: - ~azure.mgmt.cdn.models.CdnWebApplicationFirewallPolicy - :keyword content_type: Body Parameter 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 CdnWebApplicationFirewallPolicy or - the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.CdnWebApplicationFirewallPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - policy_name: str, - cdn_web_application_firewall_policy: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.CdnWebApplicationFirewallPolicy]: - """Create or update policy with specified rule set name within a resource group. - - :param resource_group_name: Name of the Resource group within the Azure subscription. Required. - :type resource_group_name: str - :param policy_name: The name of the CdnWebApplicationFirewallPolicy. Required. - :type policy_name: str - :param cdn_web_application_firewall_policy: Policy to be created. Required. - :type cdn_web_application_firewall_policy: IO[bytes] - :keyword content_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 CdnWebApplicationFirewallPolicy or - the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.CdnWebApplicationFirewallPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - policy_name: str, - cdn_web_application_firewall_policy: Union[_models.CdnWebApplicationFirewallPolicy, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.CdnWebApplicationFirewallPolicy]: - """Create or update policy with specified rule set name within a resource group. - - :param resource_group_name: Name of the Resource group within the Azure subscription. Required. - :type resource_group_name: str - :param policy_name: The name of the CdnWebApplicationFirewallPolicy. Required. - :type policy_name: str - :param cdn_web_application_firewall_policy: Policy to be created. Is either a - CdnWebApplicationFirewallPolicy type or a IO[bytes] type. Required. - :type cdn_web_application_firewall_policy: - ~azure.mgmt.cdn.models.CdnWebApplicationFirewallPolicy or IO[bytes] - :return: An instance of AsyncLROPoller that returns either CdnWebApplicationFirewallPolicy or - the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.CdnWebApplicationFirewallPolicy] - :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.CdnWebApplicationFirewallPolicy] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._create_or_update_initial( - resource_group_name=resource_group_name, - policy_name=policy_name, - cdn_web_application_firewall_policy=cdn_web_application_firewall_policy, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("CdnWebApplicationFirewallPolicy", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.CdnWebApplicationFirewallPolicy].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.CdnWebApplicationFirewallPolicy]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _update_initial( - self, - resource_group_name: str, - policy_name: str, - cdn_web_application_firewall_policy_patch_parameters: Union[ - _models.CdnWebApplicationFirewallPolicyPatchParameters, IO[bytes] - ], - **kwargs: Any - ) -> _models.CdnWebApplicationFirewallPolicy: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_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.CdnWebApplicationFirewallPolicy] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(cdn_web_application_firewall_policy_patch_parameters, (IOBase, bytes)): - _content = cdn_web_application_firewall_policy_patch_parameters - else: - _json = self._serialize.body( - cdn_web_application_firewall_policy_patch_parameters, "CdnWebApplicationFirewallPolicyPatchParameters" - ) - - _request = build_update_request( - resource_group_name=resource_group_name, - policy_name=policy_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - 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) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_update( - self, - resource_group_name: str, - policy_name: str, - cdn_web_application_firewall_policy_patch_parameters: _models.CdnWebApplicationFirewallPolicyPatchParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.CdnWebApplicationFirewallPolicy]: - """Update an existing CdnWebApplicationFirewallPolicy with the specified policy name under the - specified subscription and resource group. - - :param resource_group_name: Name of the Resource group within the Azure subscription. Required. - :type resource_group_name: str - :param policy_name: The name of the CdnWebApplicationFirewallPolicy. Required. - :type policy_name: str - :param cdn_web_application_firewall_policy_patch_parameters: CdnWebApplicationFirewallPolicy - parameters to be patched. Required. - :type cdn_web_application_firewall_policy_patch_parameters: - ~azure.mgmt.cdn.models.CdnWebApplicationFirewallPolicyPatchParameters - :keyword content_type: Body Parameter 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 CdnWebApplicationFirewallPolicy or - the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.CdnWebApplicationFirewallPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - policy_name: str, - cdn_web_application_firewall_policy_patch_parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.CdnWebApplicationFirewallPolicy]: - """Update an existing CdnWebApplicationFirewallPolicy with the specified policy name under the - specified subscription and resource group. - - :param resource_group_name: Name of the Resource group within the Azure subscription. Required. - :type resource_group_name: str - :param policy_name: The name of the CdnWebApplicationFirewallPolicy. Required. - :type policy_name: str - :param cdn_web_application_firewall_policy_patch_parameters: CdnWebApplicationFirewallPolicy - parameters to be patched. Required. - :type cdn_web_application_firewall_policy_patch_parameters: IO[bytes] - :keyword content_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 CdnWebApplicationFirewallPolicy or - the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.CdnWebApplicationFirewallPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - policy_name: str, - cdn_web_application_firewall_policy_patch_parameters: Union[ - _models.CdnWebApplicationFirewallPolicyPatchParameters, IO[bytes] - ], - **kwargs: Any - ) -> AsyncLROPoller[_models.CdnWebApplicationFirewallPolicy]: - """Update an existing CdnWebApplicationFirewallPolicy with the specified policy name under the - specified subscription and resource group. - - :param resource_group_name: Name of the Resource group within the Azure subscription. Required. - :type resource_group_name: str - :param policy_name: The name of the CdnWebApplicationFirewallPolicy. Required. - :type policy_name: str - :param cdn_web_application_firewall_policy_patch_parameters: CdnWebApplicationFirewallPolicy - parameters to be patched. Is either a CdnWebApplicationFirewallPolicyPatchParameters type or a - IO[bytes] type. Required. - :type cdn_web_application_firewall_policy_patch_parameters: - ~azure.mgmt.cdn.models.CdnWebApplicationFirewallPolicyPatchParameters or IO[bytes] - :return: An instance of AsyncLROPoller that returns either CdnWebApplicationFirewallPolicy or - the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.CdnWebApplicationFirewallPolicy] - :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.CdnWebApplicationFirewallPolicy] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._update_initial( - resource_group_name=resource_group_name, - policy_name=policy_name, - cdn_web_application_firewall_policy_patch_parameters=cdn_web_application_firewall_policy_patch_parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("CdnWebApplicationFirewallPolicy", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.CdnWebApplicationFirewallPolicy].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.CdnWebApplicationFirewallPolicy]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - 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. - :type resource_group_name: str - :param policy_name: The name of the CdnWebApplicationFirewallPolicy. Required. - :type policy_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - policy_name=policy_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/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 deleted file mode 100644 index 83eebbe330db..000000000000 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_profiles_operations.py +++ /dev/null @@ -1,1467 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._profiles_operations import ( - build_can_migrate_request, - build_create_request, - build_delete_request, - build_generate_sso_uri_request, - build_get_request, - build_list_by_resource_group_request, - build_list_request, - build_list_resource_usage_request, - build_list_supported_optimization_types_request, - build_migrate_request, - build_migration_commit_request, - build_update_request, -) -from .._vendor import CdnManagementClientMixinABC - -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: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.cdn.aio.CdnManagementClient`'s - :attr:`profiles` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list(self, **kwargs: Any) -> AsyncIterable["_models.Profile"]: - """Lists all of the Azure Front Door Standard, Azure Front Door Premium, and CDN profiles within - an Azure subscription. - - :return: An iterator like instance of either Profile or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cdn.models.Profile] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - 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]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ProfileListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace - def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.Profile"]: - """Lists all of the Azure Front Door Standard, Azure Front Door Premium, and CDN profiles within a - resource group. - - :param resource_group_name: Name of the Resource group within the Azure subscription. Required. - :type resource_group_name: str - :return: An iterator like instance of either Profile or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cdn.models.Profile] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - 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]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ProfileListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get(self, resource_group_name: str, profile_name: str, **kwargs: Any) -> _models.Profile: - """Gets an Azure Front Door Standard or Azure Front Door Premium or CDN profile with the specified - profile name under the specified subscription and resource 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 or CDN - profile which is unique within the resource group. Required. - :type profile_name: str - :return: Profile or the result of cls(response) - :rtype: ~azure.mgmt.cdn.models.Profile - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.Profile] = kwargs.pop("cls", None) - - _request = build_get_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 = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Profile", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - 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]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_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.Profile] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(profile, (IOBase, bytes)): - _content = profile - else: - _json = self._serialize.body(profile, "Profile") - - _request = build_create_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 = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - 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) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create( - self, - resource_group_name: str, - profile_name: str, - profile: _models.Profile, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Profile]: - """Creates a new Azure Front Door Standard or Azure Front Door Premium or CDN profile with a - profile name under the specified subscription and resource 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 or CDN - profile which is unique within the resource group. Required. - :type profile_name: str - :param profile: Profile properties needed to create a new profile. Required. - :type profile: ~azure.mgmt.cdn.models.Profile - :keyword content_type: Body Parameter 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 Profile or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Profile] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create( - self, - resource_group_name: str, - profile_name: str, - profile: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Profile]: - """Creates a new Azure Front Door Standard or Azure Front Door Premium or CDN profile with a - profile name under the specified subscription and resource 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 or CDN - profile which is unique within the resource group. Required. - :type profile_name: str - :param profile: Profile properties needed to create a new profile. Required. - :type profile: IO[bytes] - :keyword content_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 Profile or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Profile] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create( - self, resource_group_name: str, profile_name: str, profile: Union[_models.Profile, IO[bytes]], **kwargs: Any - ) -> AsyncLROPoller[_models.Profile]: - """Creates a new Azure Front Door Standard or Azure Front Door Premium or CDN profile with a - profile name under the specified subscription and resource 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 or CDN - profile which is unique within the resource group. Required. - :type profile_name: str - :param profile: Profile properties needed to create a new profile. Is either a Profile type or - a IO[bytes] type. Required. - :type profile: ~azure.mgmt.cdn.models.Profile or IO[bytes] - :return: An instance of AsyncLROPoller that returns either Profile or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Profile] - :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.Profile] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._create_initial( - resource_group_name=resource_group_name, - profile_name=profile_name, - profile=profile, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Profile", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.Profile].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Profile]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _update_initial( - self, - resource_group_name: str, - profile_name: str, - profile_update_parameters: Union[_models.ProfileUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> _models.Profile: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_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.Profile] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(profile_update_parameters, (IOBase, bytes)): - _content = profile_update_parameters - else: - _json = self._serialize.body(profile_update_parameters, "ProfileUpdateParameters") - - _request = build_update_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 = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - 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) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_update( - self, - resource_group_name: str, - profile_name: str, - profile_update_parameters: _models.ProfileUpdateParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Profile]: - """Updates an existing Azure Front Door Standard or Azure Front Door Premium or CDN profile with - the specified profile name under the specified subscription and resource 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 or CDN - profile which is unique within the resource group. Required. - :type profile_name: str - :param profile_update_parameters: Profile properties needed to update an existing profile. - Required. - :type profile_update_parameters: ~azure.mgmt.cdn.models.ProfileUpdateParameters - :keyword content_type: Body Parameter 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 Profile or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Profile] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - profile_name: str, - profile_update_parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Profile]: - """Updates an existing Azure Front Door Standard or Azure Front Door Premium or CDN profile with - the specified profile name under the specified subscription and resource 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 or CDN - profile which is unique within the resource group. Required. - :type profile_name: str - :param profile_update_parameters: Profile properties needed to update an existing profile. - Required. - :type profile_update_parameters: IO[bytes] - :keyword content_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 Profile or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Profile] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - profile_name: str, - profile_update_parameters: Union[_models.ProfileUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.Profile]: - """Updates an existing Azure Front Door Standard or Azure Front Door Premium or CDN profile with - the specified profile name under the specified subscription and resource 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 or CDN - profile which is unique within the resource group. Required. - :type profile_name: str - :param profile_update_parameters: Profile properties needed to update an existing profile. Is - either a ProfileUpdateParameters type or a IO[bytes] type. Required. - :type profile_update_parameters: ~azure.mgmt.cdn.models.ProfileUpdateParameters or IO[bytes] - :return: An instance of AsyncLROPoller that returns either Profile or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Profile] - :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.Profile] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._update_initial( - resource_group_name=resource_group_name, - profile_name=profile_name, - profile_update_parameters=profile_update_parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Profile", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.Profile].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Profile]( - 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]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["location"] = self._deserialize("str", response.headers.get("location")) - - if cls: - return cls(pipeline_response, None, response_headers) # type: ignore - - @distributed_trace_async - async def begin_delete(self, resource_group_name: str, profile_name: str, **kwargs: Any) -> AsyncLROPoller[None]: - """Deletes an existing Azure Front Door Standard or Azure Front Door Premium or CDN profile with - the specified parameters. Deleting a profile will result in the deletion of all of the - sub-resources including endpoints, origins and custom domains. - - :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 or CDN - profile 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._delete_initial( # type: ignore - 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 - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _can_migrate_initial( - self, - resource_group_name: str, - can_migrate_parameters: Union[_models.CanMigrateParameters, IO[bytes]], - **kwargs: Any - ) -> Optional[_models.CanMigrateResult]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.CanMigrateResult]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(can_migrate_parameters, (IOBase, bytes)): - _content = can_migrate_parameters - else: - _json = self._serialize.body(can_migrate_parameters, "CanMigrateParameters") - - _request = build_can_migrate_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("CanMigrateResult", pipeline_response) - - if response.status_code == 202: - response_headers["location"] = self._deserialize("str", response.headers.get("location")) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_can_migrate( - self, - resource_group_name: str, - can_migrate_parameters: _models.CanMigrateParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.CanMigrateResult]: - """Checks if CDN profile can be migrated to Azure Frontdoor(Standard/Premium) profile. - - :param resource_group_name: Name of the Resource group within the Azure subscription. Required. - :type resource_group_name: str - :param can_migrate_parameters: Properties needed to check if cdn profile or classic frontdoor - can be migrated. Required. - :type can_migrate_parameters: ~azure.mgmt.cdn.models.CanMigrateParameters - :keyword content_type: Body Parameter 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 CanMigrateResult or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.CanMigrateResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_can_migrate( - self, - resource_group_name: str, - can_migrate_parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.CanMigrateResult]: - """Checks if CDN profile can be migrated to Azure Frontdoor(Standard/Premium) profile. - - :param resource_group_name: Name of the Resource group within the Azure subscription. Required. - :type resource_group_name: str - :param can_migrate_parameters: Properties needed to check if cdn profile or classic frontdoor - can be migrated. Required. - :type can_migrate_parameters: IO[bytes] - :keyword content_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 CanMigrateResult or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.CanMigrateResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_can_migrate( - self, - resource_group_name: str, - can_migrate_parameters: Union[_models.CanMigrateParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.CanMigrateResult]: - """Checks if CDN profile can be migrated to Azure Frontdoor(Standard/Premium) profile. - - :param resource_group_name: Name of the Resource group within the Azure subscription. Required. - :type resource_group_name: str - :param can_migrate_parameters: Properties needed to check if cdn profile or classic frontdoor - can be migrated. Is either a CanMigrateParameters type or a IO[bytes] type. Required. - :type can_migrate_parameters: ~azure.mgmt.cdn.models.CanMigrateParameters or IO[bytes] - :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 = case_insensitive_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.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._can_migrate_initial( - resource_group_name=resource_group_name, - can_migrate_parameters=can_migrate_parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("CanMigrateResult", pipeline_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 _migrate_initial( - self, - resource_group_name: str, - migration_parameters: Union[_models.MigrationParameters, IO[bytes]], - **kwargs: Any - ) -> _models.MigrateResult: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_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) - - 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, "MigrationParameters") - - _request = build_migrate_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - 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) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_migrate( - self, - resource_group_name: str, - migration_parameters: _models.MigrationParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.MigrateResult]: - """Migrate the CDN profile to Azure Frontdoor(Standard/Premium) profile. The change need to be - committed after this. - - :param resource_group_name: Name of the Resource group within the Azure subscription. Required. - :type resource_group_name: str - :param migration_parameters: Properties needed to migrate the profile. Required. - :type migration_parameters: ~azure.mgmt.cdn.models.MigrationParameters - :keyword content_type: Body Parameter 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_migrate( - self, - resource_group_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. The change need to be - committed after this. - - :param resource_group_name: Name of the Resource group within the Azure subscription. Required. - :type resource_group_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_migrate( - self, - resource_group_name: str, - migration_parameters: Union[_models.MigrationParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.MigrateResult]: - """Migrate the CDN profile to Azure Frontdoor(Standard/Premium) profile. The change need to be - committed after this. - - :param resource_group_name: Name of the Resource group within the Azure subscription. Required. - :type resource_group_name: str - :param migration_parameters: Properties needed to migrate the profile. Is either a - MigrationParameters type or a IO[bytes] type. Required. - :type migration_parameters: ~azure.mgmt.cdn.models.MigrationParameters 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._migrate_initial( - resource_group_name=resource_group_name, - migration_parameters=migration_parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("MigrateResult", pipeline_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_commit_initial( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, profile_name: str, **kwargs: Any - ) -> None: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_migration_commit_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 = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["location"] = self._deserialize("str", response.headers.get("location")) - - if cls: - return cls(pipeline_response, None, response_headers) # type: ignore - - @distributed_trace_async - async def begin_migration_commit( - self, resource_group_name: str, profile_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Commit the migrated Azure Frontdoor(Standard/Premium) 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 CDN profile 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_commit_initial( # type: ignore - 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 - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, - AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace_async - async def generate_sso_uri(self, resource_group_name: str, profile_name: str, **kwargs: Any) -> _models.SsoUri: - """Generates a dynamic SSO URI used to sign in to the CDN supplemental portal. Supplemental portal - is used to configure advanced feature capabilities that are not yet available in the Azure - portal, such as core reports in a standard profile; rules engine, advanced HTTP reports, and - real-time stats and alerts in a premium profile. The SSO URI changes approximately every 10 - minutes. - - :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 CDN profile which is unique within the resource group. - Required. - :type profile_name: str - :return: SsoUri or the result of cls(response) - :rtype: ~azure.mgmt.cdn.models.SsoUri - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.SsoUri] = kwargs.pop("cls", None) - - _request = build_generate_sso_uri_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 = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SsoUri", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def list_supported_optimization_types( - self, resource_group_name: str, profile_name: str, **kwargs: Any - ) -> _models.SupportedOptimizationTypesListResult: - """Gets the supported optimization types for the current profile. A user can create an endpoint - with an optimization type from the listed values. - - :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 or CDN - profile which is unique within the resource group. Required. - :type profile_name: str - :return: SupportedOptimizationTypesListResult or the result of cls(response) - :rtype: ~azure.mgmt.cdn.models.SupportedOptimizationTypesListResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.SupportedOptimizationTypesListResult] = kwargs.pop("cls", None) - - _request = build_list_supported_optimization_types_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 = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SupportedOptimizationTypesListResult", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_resource_usage( - self, resource_group_name: str, profile_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ResourceUsage"]: - """Checks the quota and actual usage of endpoints under the given Azure Front Door Standard or - Azure Front Door Premium or CDN 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 or CDN - profile which is unique within the resource group. Required. - :type profile_name: str - :return: An iterator like instance of either ResourceUsage or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cdn.models.ResourceUsage] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - 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]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_resource_usage_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 = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ResourceUsageListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) diff --git a/sdk/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 deleted file mode 100644 index 1c15d9080763..000000000000 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_resource_usage_operations.py +++ /dev/null @@ -1,136 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._resource_usage_operations import build_list_request -from .._vendor import CdnManagementClientMixinABC - -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 ResourceUsageOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.cdn.aio.CdnManagementClient`'s - :attr:`resource_usage` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list(self, **kwargs: Any) -> AsyncIterable["_models.ResourceUsage"]: - """Check the quota and actual usage of the CDN profiles under the given subscription. - - :return: An iterator like instance of either ResourceUsage or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cdn.models.ResourceUsage] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - 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]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ResourceUsageListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) diff --git a/sdk/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 deleted file mode 100644 index f75e5288b804..000000000000 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_routes_operations.py +++ /dev/null @@ -1,792 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._routes_operations import ( - build_create_request, - build_delete_request, - build_get_request, - build_list_by_endpoint_request, - build_update_request, -) -from .._vendor import CdnManagementClientMixinABC - -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 RoutesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.cdn.aio.CdnManagementClient`'s - :attr:`routes` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_endpoint( - self, resource_group_name: str, profile_name: str, endpoint_name: str, **kwargs: Any - ) -> AsyncIterable["_models.Route"]: - """Lists all of the existing origins within a 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. - :type profile_name: str - :param endpoint_name: Name of the endpoint under the profile which is unique globally. - Required. - :type endpoint_name: str - :return: An iterator like instance of either Route or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cdn.models.Route] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - 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]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_endpoint_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("RouteListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, resource_group_name: str, profile_name: str, endpoint_name: str, route_name: str, **kwargs: Any - ) -> _models.Route: - """Gets an existing route with the specified route name under the specified subscription, resource - group, profile, and AzureFrontDoor 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. - :type profile_name: str - :param endpoint_name: Name of the endpoint under the profile which is unique globally. - Required. - :type endpoint_name: str - :param route_name: Name of the routing rule. Required. - :type route_name: str - :return: Route or the result of cls(response) - :rtype: ~azure.mgmt.cdn.models.Route - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.Route] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - route_name=route_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Route", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_initial( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - route_name: str, - route: Union[_models.Route, IO[bytes]], - **kwargs: Any - ) -> _models.Route: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_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.Route] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(route, (IOBase, bytes)): - _content = route - else: - _json = self._serialize.body(route, "Route") - - _request = build_create_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - route_name=route_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201, 202]: - 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) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - route_name: str, - route: _models.Route, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Route]: - """Creates a new route with the specified route name under the specified subscription, resource - group, profile, and AzureFrontDoor 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. - :type profile_name: str - :param endpoint_name: Name of the endpoint under the profile which is unique globally. - Required. - :type endpoint_name: str - :param route_name: Name of the routing rule. Required. - :type route_name: str - :param route: Route properties. Required. - :type route: ~azure.mgmt.cdn.models.Route - :keyword content_type: Body Parameter 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 Route or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Route] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - route_name: str, - route: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Route]: - """Creates a new route with the specified route name under the specified subscription, resource - group, profile, and AzureFrontDoor 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. - :type profile_name: str - :param endpoint_name: Name of the endpoint under the profile which is unique globally. - Required. - :type endpoint_name: str - :param route_name: Name of the routing rule. Required. - :type route_name: str - :param route: Route properties. Required. - :type route: IO[bytes] - :keyword content_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 Route or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Route] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - route_name: str, - route: Union[_models.Route, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.Route]: - """Creates a new route with the specified route name under the specified subscription, resource - group, profile, and AzureFrontDoor 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. - :type profile_name: str - :param endpoint_name: Name of the endpoint under the profile which is unique globally. - Required. - :type endpoint_name: str - :param route_name: Name of the routing rule. Required. - :type route_name: str - :param route: Route properties. Is either a Route type or a IO[bytes] type. Required. - :type route: ~azure.mgmt.cdn.models.Route or IO[bytes] - :return: An instance of AsyncLROPoller that returns either Route or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Route] - :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.Route] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._create_initial( - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - route_name=route_name, - route=route, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Route", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, - AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.Route].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Route]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _update_initial( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - route_name: str, - route_update_properties: Union[_models.RouteUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> _models.Route: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_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.Route] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(route_update_properties, (IOBase, bytes)): - _content = route_update_properties - else: - _json = self._serialize.body(route_update_properties, "RouteUpdateParameters") - - _request = build_update_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - route_name=route_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.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) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_update( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - route_name: str, - route_update_properties: _models.RouteUpdateParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Route]: - """Updates an existing route with the specified route name under the specified subscription, - resource group, profile, and AzureFrontDoor 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. - :type profile_name: str - :param endpoint_name: Name of the endpoint under the profile which is unique globally. - Required. - :type endpoint_name: str - :param route_name: Name of the routing rule. Required. - :type route_name: str - :param route_update_properties: Route update properties. Required. - :type route_update_properties: ~azure.mgmt.cdn.models.RouteUpdateParameters - :keyword content_type: Body Parameter 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 Route or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Route] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - route_name: str, - route_update_properties: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Route]: - """Updates an existing route with the specified route name under the specified subscription, - resource group, profile, and AzureFrontDoor 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. - :type profile_name: str - :param endpoint_name: Name of the endpoint under the profile which is unique globally. - Required. - :type endpoint_name: str - :param route_name: Name of the routing rule. Required. - :type route_name: str - :param route_update_properties: Route update properties. Required. - :type route_update_properties: IO[bytes] - :keyword content_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 Route or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Route] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - route_name: str, - route_update_properties: Union[_models.RouteUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.Route]: - """Updates an existing route with the specified route name under the specified subscription, - resource group, profile, and AzureFrontDoor 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. - :type profile_name: str - :param endpoint_name: Name of the endpoint under the profile which is unique globally. - Required. - :type endpoint_name: str - :param route_name: Name of the routing rule. Required. - :type route_name: str - :param route_update_properties: Route update properties. Is either a RouteUpdateParameters type - or a IO[bytes] type. Required. - :type route_update_properties: ~azure.mgmt.cdn.models.RouteUpdateParameters or IO[bytes] - :return: An instance of AsyncLROPoller that returns either Route or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Route] - :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.Route] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._update_initial( - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - route_name=route_name, - route_update_properties=route_update_properties, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Route", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, - AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.Route].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Route]( - 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, endpoint_name: str, route_name: str, **kwargs: Any - ) -> None: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - route_name=route_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - 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 == 202: - response_headers["location"] = self._deserialize("str", response.headers.get("location")) - - if cls: - return cls(pipeline_response, None, response_headers) # type: ignore - - @distributed_trace_async - async def begin_delete( - self, resource_group_name: str, profile_name: str, endpoint_name: str, route_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes an existing route with the specified route name under the specified subscription, - resource group, profile, and AzureFrontDoor 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. - :type profile_name: str - :param endpoint_name: Name of the endpoint under the profile which is unique globally. - Required. - :type endpoint_name: str - :param route_name: Name of the routing rule. Required. - :type route_name: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_initial( # type: ignore - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - route_name=route_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, - AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore 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 deleted file mode 100644 index fc4b3e11a657..000000000000 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_rule_sets_operations.py +++ /dev/null @@ -1,485 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar, Union, cast -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._rule_sets_operations import ( - build_create_request, - build_delete_request, - build_get_request, - build_list_by_profile_request, - build_list_resource_usage_request, -) -from .._vendor import CdnManagementClientMixinABC - -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 RuleSetsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.cdn.aio.CdnManagementClient`'s - :attr:`rule_sets` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_profile( - self, resource_group_name: str, profile_name: str, **kwargs: Any - ) -> AsyncIterable["_models.RuleSet"]: - """Lists existing AzureFrontDoor rule sets within a 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. - :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] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - 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]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_profile_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 = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("RuleSetListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, resource_group_name: str, profile_name: str, rule_set_name: str, **kwargs: Any - ) -> _models.RuleSet: - """Gets an existing AzureFrontDoor rule set with the specified rule set name under the specified - subscription, resource group and 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. - :type profile_name: str - :param rule_set_name: Name of the rule set under the profile which is unique globally. - Required. - :type rule_set_name: str - :return: RuleSet or the result of cls(response) - :rtype: ~azure.mgmt.cdn.models.RuleSet - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.RuleSet] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - rule_set_name=rule_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RuleSet", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def create( - self, resource_group_name: str, profile_name: str, rule_set_name: str, **kwargs: Any - ) -> _models.RuleSet: - """Creates a new rule set within the specified 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. - :type profile_name: str - :param rule_set_name: Name of the rule set under the profile which is unique globally. - Required. - :type rule_set_name: str - :return: RuleSet or the result of cls(response) - :rtype: ~azure.mgmt.cdn.models.RuleSet - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.RuleSet] = kwargs.pop("cls", None) - - _request = build_create_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - rule_set_name=rule_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - 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) - - if response.status_code == 200: - deserialized = self._deserialize("RuleSet", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("RuleSet", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, profile_name: str, rule_set_name: str, **kwargs: Any - ) -> None: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - rule_set_name=rule_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - 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 == 202: - response_headers["location"] = self._deserialize("str", response.headers.get("location")) - - if cls: - return cls(pipeline_response, None, response_headers) # type: ignore - - @distributed_trace_async - async def begin_delete( - self, resource_group_name: str, profile_name: str, rule_set_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes an existing AzureFrontDoor rule set with the specified rule set name under the - specified subscription, resource group and 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. - :type profile_name: str - :param rule_set_name: Name of the rule set under the profile which is unique globally. - Required. - :type rule_set_name: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_initial( # type: ignore - resource_group_name=resource_group_name, - profile_name=profile_name, - rule_set_name=rule_set_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, - AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def list_resource_usage( - self, resource_group_name: str, profile_name: str, rule_set_name: str, **kwargs: Any - ) -> AsyncIterable["_models.Usage"]: - """Checks the quota and actual usage of endpoints under the given Azure Front Door 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. - :type profile_name: str - :param rule_set_name: Name of the rule set under the profile which is unique globally. - Required. - :type rule_set_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] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - 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]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_resource_usage_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - rule_set_name=rule_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("UsagesListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) 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 deleted file mode 100644 index 3461ad98d882..000000000000 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_rules_operations.py +++ /dev/null @@ -1,775 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._rules_operations import ( - build_create_request, - build_delete_request, - build_get_request, - build_list_by_rule_set_request, - build_update_request, -) -from .._vendor import CdnManagementClientMixinABC - -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 RulesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.cdn.aio.CdnManagementClient`'s - :attr:`rules` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_rule_set( - self, resource_group_name: str, profile_name: str, rule_set_name: str, **kwargs: Any - ) -> AsyncIterable["_models.Rule"]: - """Lists all of the existing delivery rules within a 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. - :type profile_name: str - :param rule_set_name: Name of the rule set under the profile. Required. - :type rule_set_name: str - :return: An iterator like instance of either Rule or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cdn.models.Rule] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - 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]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_rule_set_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - rule_set_name=rule_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("RuleListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, resource_group_name: str, profile_name: str, rule_set_name: str, rule_name: str, **kwargs: Any - ) -> _models.Rule: - """Gets an existing delivery rule within a 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. - :type profile_name: str - :param rule_set_name: Name of the rule set under the profile. Required. - :type rule_set_name: str - :param rule_name: Name of the delivery rule which is unique within the endpoint. Required. - :type rule_name: str - :return: Rule or the result of cls(response) - :rtype: ~azure.mgmt.cdn.models.Rule - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.Rule] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - rule_set_name=rule_set_name, - rule_name=rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Rule", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_initial( - self, - resource_group_name: str, - profile_name: str, - rule_set_name: str, - rule_name: str, - rule: Union[_models.Rule, IO[bytes]], - **kwargs: Any - ) -> _models.Rule: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_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.Rule] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(rule, (IOBase, bytes)): - _content = rule - else: - _json = self._serialize.body(rule, "Rule") - - _request = build_create_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - rule_set_name=rule_set_name, - rule_name=rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201, 202]: - 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) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create( - self, - resource_group_name: str, - profile_name: str, - rule_set_name: str, - rule_name: str, - rule: _models.Rule, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Rule]: - """Creates a new delivery rule within the specified 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. - :type profile_name: str - :param rule_set_name: Name of the rule set under the profile. Required. - :type rule_set_name: str - :param rule_name: Name of the delivery rule which is unique within the endpoint. Required. - :type rule_name: str - :param rule: The delivery rule properties. Required. - :type rule: ~azure.mgmt.cdn.models.Rule - :keyword content_type: Body Parameter 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 Rule or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Rule] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create( - self, - resource_group_name: str, - profile_name: str, - rule_set_name: str, - rule_name: str, - rule: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Rule]: - """Creates a new delivery rule within the specified 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. - :type profile_name: str - :param rule_set_name: Name of the rule set under the profile. Required. - :type rule_set_name: str - :param rule_name: Name of the delivery rule which is unique within the endpoint. Required. - :type rule_name: str - :param rule: The delivery rule properties. Required. - :type rule: IO[bytes] - :keyword content_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 Rule or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Rule] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create( - self, - resource_group_name: str, - profile_name: str, - rule_set_name: str, - rule_name: str, - rule: Union[_models.Rule, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.Rule]: - """Creates a new delivery rule within the specified 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. - :type profile_name: str - :param rule_set_name: Name of the rule set under the profile. Required. - :type rule_set_name: str - :param rule_name: Name of the delivery rule which is unique within the endpoint. Required. - :type rule_name: str - :param rule: The delivery rule properties. Is either a Rule type or a IO[bytes] type. Required. - :type rule: ~azure.mgmt.cdn.models.Rule or IO[bytes] - :return: An instance of AsyncLROPoller that returns either Rule or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Rule] - :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.Rule] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._create_initial( - resource_group_name=resource_group_name, - profile_name=profile_name, - rule_set_name=rule_set_name, - rule_name=rule_name, - rule=rule, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Rule", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, - AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.Rule].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Rule]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _update_initial( - self, - resource_group_name: str, - profile_name: str, - rule_set_name: str, - rule_name: str, - rule_update_properties: Union[_models.RuleUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> _models.Rule: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_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.Rule] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(rule_update_properties, (IOBase, bytes)): - _content = rule_update_properties - else: - _json = self._serialize.body(rule_update_properties, "RuleUpdateParameters") - - _request = build_update_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - rule_set_name=rule_set_name, - rule_name=rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.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) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_update( - self, - resource_group_name: str, - profile_name: str, - rule_set_name: str, - rule_name: str, - rule_update_properties: _models.RuleUpdateParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Rule]: - """Updates an existing delivery rule within a 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. - :type profile_name: str - :param rule_set_name: Name of the rule set under the profile. Required. - :type rule_set_name: str - :param rule_name: Name of the delivery rule which is unique within the endpoint. Required. - :type rule_name: str - :param rule_update_properties: Delivery rule properties. Required. - :type rule_update_properties: ~azure.mgmt.cdn.models.RuleUpdateParameters - :keyword content_type: Body Parameter 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 Rule or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Rule] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - profile_name: str, - rule_set_name: str, - rule_name: str, - rule_update_properties: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Rule]: - """Updates an existing delivery rule within a 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. - :type profile_name: str - :param rule_set_name: Name of the rule set under the profile. Required. - :type rule_set_name: str - :param rule_name: Name of the delivery rule which is unique within the endpoint. Required. - :type rule_name: str - :param rule_update_properties: Delivery rule properties. Required. - :type rule_update_properties: IO[bytes] - :keyword content_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 Rule or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Rule] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - profile_name: str, - rule_set_name: str, - rule_name: str, - rule_update_properties: Union[_models.RuleUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.Rule]: - """Updates an existing delivery rule within a 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. - :type profile_name: str - :param rule_set_name: Name of the rule set under the profile. Required. - :type rule_set_name: str - :param rule_name: Name of the delivery rule which is unique within the endpoint. Required. - :type rule_name: str - :param rule_update_properties: Delivery rule properties. Is either a RuleUpdateParameters type - or a IO[bytes] type. Required. - :type rule_update_properties: ~azure.mgmt.cdn.models.RuleUpdateParameters or IO[bytes] - :return: An instance of AsyncLROPoller that returns either Rule or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Rule] - :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.Rule] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._update_initial( - resource_group_name=resource_group_name, - profile_name=profile_name, - rule_set_name=rule_set_name, - rule_name=rule_name, - rule_update_properties=rule_update_properties, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Rule", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, - AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.Rule].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Rule]( - 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, rule_set_name: str, rule_name: str, **kwargs: Any - ) -> None: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - rule_set_name=rule_set_name, - rule_name=rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - 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 == 202: - response_headers["location"] = self._deserialize("str", response.headers.get("location")) - - if cls: - return cls(pipeline_response, None, response_headers) # type: ignore - - @distributed_trace_async - async def begin_delete( - self, resource_group_name: str, profile_name: str, rule_set_name: str, rule_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes an existing delivery rule within a 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. - :type profile_name: str - :param rule_set_name: Name of the rule set under the profile. Required. - :type rule_set_name: str - :param rule_name: Name of the delivery rule which is unique within the endpoint. Required. - :type rule_name: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_initial( # type: ignore - resource_group_name=resource_group_name, - profile_name=profile_name, - rule_set_name=rule_set_name, - rule_name=rule_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, - AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore 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 deleted file mode 100644 index 181fb64700c9..000000000000 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_secrets_operations.py +++ /dev/null @@ -1,534 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._secrets_operations import ( - build_create_request, - build_delete_request, - build_get_request, - build_list_by_profile_request, -) -from .._vendor import CdnManagementClientMixinABC - -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 SecretsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.cdn.aio.CdnManagementClient`'s - :attr:`secrets` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_profile( - self, resource_group_name: str, profile_name: str, **kwargs: Any - ) -> AsyncIterable["_models.Secret"]: - """Lists existing AzureFrontDoor secrets. - - :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. - :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] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - 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]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_profile_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 = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("SecretListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get(self, resource_group_name: str, profile_name: str, secret_name: str, **kwargs: Any) -> _models.Secret: - """Gets an existing Secret within a 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. - :type profile_name: str - :param secret_name: Name of the Secret under the profile. Required. - :type secret_name: str - :return: Secret or the result of cls(response) - :rtype: ~azure.mgmt.cdn.models.Secret - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.Secret] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - secret_name=secret_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Secret", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_initial( - self, - resource_group_name: str, - profile_name: str, - secret_name: str, - secret: Union[_models.Secret, IO[bytes]], - **kwargs: Any - ) -> _models.Secret: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_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.Secret] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(secret, (IOBase, bytes)): - _content = secret - else: - _json = self._serialize.body(secret, "Secret") - - _request = build_create_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - secret_name=secret_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201, 202]: - 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) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create( - self, - resource_group_name: str, - profile_name: str, - secret_name: str, - secret: _models.Secret, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Secret]: - """Creates a new Secret within the specified 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. - :type profile_name: str - :param secret_name: Name of the Secret under the profile. Required. - :type secret_name: str - :param secret: The Secret properties. Required. - :type secret: ~azure.mgmt.cdn.models.Secret - :keyword content_type: Body Parameter 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 Secret or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Secret] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create( - self, - resource_group_name: str, - profile_name: str, - secret_name: str, - secret: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Secret]: - """Creates a new Secret within the specified 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. - :type profile_name: str - :param secret_name: Name of the Secret under the profile. Required. - :type secret_name: str - :param secret: The Secret properties. Required. - :type secret: IO[bytes] - :keyword content_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 Secret or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Secret] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create( - self, - resource_group_name: str, - profile_name: str, - secret_name: str, - secret: Union[_models.Secret, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.Secret]: - """Creates a new Secret within the specified 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. - :type profile_name: str - :param secret_name: Name of the Secret under the profile. Required. - :type secret_name: str - :param secret: The Secret properties. Is either a Secret type or a IO[bytes] type. Required. - :type secret: ~azure.mgmt.cdn.models.Secret or IO[bytes] - :return: An instance of AsyncLROPoller that returns either Secret or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Secret] - :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.Secret] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._create_initial( - resource_group_name=resource_group_name, - profile_name=profile_name, - secret_name=secret_name, - secret=secret, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Secret", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, - AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.Secret].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Secret]( - 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, secret_name: str, **kwargs: Any - ) -> None: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - secret_name=secret_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - 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 == 202: - response_headers["location"] = self._deserialize("str", response.headers.get("location")) - - if cls: - return cls(pipeline_response, None, response_headers) # type: ignore - - @distributed_trace_async - async def begin_delete( - self, resource_group_name: str, profile_name: str, secret_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes an existing Secret within 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. - :type profile_name: str - :param secret_name: Name of the Secret under the profile. Required. - :type secret_name: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_initial( # type: ignore - resource_group_name=resource_group_name, - profile_name=profile_name, - secret_name=secret_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, - AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore 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 deleted file mode 100644 index 5a81547b0bc7..000000000000 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_security_policies_operations.py +++ /dev/null @@ -1,749 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._security_policies_operations import ( - build_create_request, - build_delete_request, - build_get_request, - build_list_by_profile_request, - build_patch_request, -) -from .._vendor import CdnManagementClientMixinABC - -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 SecurityPoliciesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.cdn.aio.CdnManagementClient`'s - :attr:`security_policies` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_profile( - self, resource_group_name: str, profile_name: str, **kwargs: Any - ) -> AsyncIterable["_models.SecurityPolicy"]: - """Lists security policies associated with the 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. - :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] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - 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]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_profile_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 = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("SecurityPolicyListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get( - self, resource_group_name: str, profile_name: str, security_policy_name: str, **kwargs: Any - ) -> _models.SecurityPolicy: - """Gets an existing security policy within a 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. - :type profile_name: str - :param security_policy_name: Name of the security policy under the profile. Required. - :type security_policy_name: str - :return: SecurityPolicy or the result of cls(response) - :rtype: ~azure.mgmt.cdn.models.SecurityPolicy - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.SecurityPolicy] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - security_policy_name=security_policy_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SecurityPolicy", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_initial( - self, - resource_group_name: str, - profile_name: str, - security_policy_name: str, - security_policy: Union[_models.SecurityPolicy, IO[bytes]], - **kwargs: Any - ) -> _models.SecurityPolicy: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_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.SecurityPolicy] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(security_policy, (IOBase, bytes)): - _content = security_policy - else: - _json = self._serialize.body(security_policy, "SecurityPolicy") - - _request = build_create_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - security_policy_name=security_policy_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201, 202]: - 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) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create( - self, - resource_group_name: str, - profile_name: str, - security_policy_name: str, - security_policy: _models.SecurityPolicy, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.SecurityPolicy]: - """Creates a new security policy within the specified 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. - :type profile_name: str - :param security_policy_name: Name of the security policy under the profile. Required. - :type security_policy_name: str - :param security_policy: The security policy properties. Required. - :type security_policy: ~azure.mgmt.cdn.models.SecurityPolicy - :keyword content_type: Body Parameter 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 SecurityPolicy or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.SecurityPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create( - self, - resource_group_name: str, - profile_name: str, - security_policy_name: str, - security_policy: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.SecurityPolicy]: - """Creates a new security policy within the specified 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. - :type profile_name: str - :param security_policy_name: Name of the security policy under the profile. Required. - :type security_policy_name: str - :param security_policy: The security policy properties. Required. - :type security_policy: IO[bytes] - :keyword content_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 SecurityPolicy or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.SecurityPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create( - self, - resource_group_name: str, - profile_name: str, - security_policy_name: str, - security_policy: Union[_models.SecurityPolicy, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.SecurityPolicy]: - """Creates a new security policy within the specified 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. - :type profile_name: str - :param security_policy_name: Name of the security policy under the profile. Required. - :type security_policy_name: str - :param security_policy: The security policy properties. Is either a SecurityPolicy type or a - IO[bytes] type. Required. - :type security_policy: ~azure.mgmt.cdn.models.SecurityPolicy or IO[bytes] - :return: An instance of AsyncLROPoller that returns either SecurityPolicy or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.SecurityPolicy] - :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.SecurityPolicy] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._create_initial( - resource_group_name=resource_group_name, - profile_name=profile_name, - security_policy_name=security_policy_name, - security_policy=security_policy, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("SecurityPolicy", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, - AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.SecurityPolicy].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.SecurityPolicy]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _patch_initial( - self, - resource_group_name: str, - profile_name: str, - security_policy_name: str, - security_policy_update_properties: Union[_models.SecurityPolicyUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> _models.SecurityPolicy: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_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.SecurityPolicy] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(security_policy_update_properties, (IOBase, bytes)): - _content = security_policy_update_properties - else: - _json = self._serialize.body(security_policy_update_properties, "SecurityPolicyUpdateParameters") - - _request = build_patch_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - security_policy_name=security_policy_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.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) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_patch( - self, - resource_group_name: str, - profile_name: str, - security_policy_name: str, - security_policy_update_properties: _models.SecurityPolicyUpdateParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.SecurityPolicy]: - """Updates an existing security policy within a 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. - :type profile_name: str - :param security_policy_name: Name of the security policy under the profile. Required. - :type security_policy_name: str - :param security_policy_update_properties: Security policy update properties. Required. - :type security_policy_update_properties: ~azure.mgmt.cdn.models.SecurityPolicyUpdateParameters - :keyword content_type: Body Parameter 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 SecurityPolicy or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.SecurityPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_patch( - self, - resource_group_name: str, - profile_name: str, - security_policy_name: str, - security_policy_update_properties: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.SecurityPolicy]: - """Updates an existing security policy within a 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. - :type profile_name: str - :param security_policy_name: Name of the security policy under the profile. Required. - :type security_policy_name: str - :param security_policy_update_properties: Security policy update properties. Required. - :type security_policy_update_properties: IO[bytes] - :keyword content_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 SecurityPolicy or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.SecurityPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_patch( - self, - resource_group_name: str, - profile_name: str, - security_policy_name: str, - security_policy_update_properties: Union[_models.SecurityPolicyUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.SecurityPolicy]: - """Updates an existing security policy within a 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. - :type profile_name: str - :param security_policy_name: Name of the security policy under the profile. Required. - :type security_policy_name: str - :param security_policy_update_properties: Security policy update properties. Is either a - SecurityPolicyUpdateParameters type or a IO[bytes] type. Required. - :type security_policy_update_properties: ~azure.mgmt.cdn.models.SecurityPolicyUpdateParameters - or IO[bytes] - :return: An instance of AsyncLROPoller that returns either SecurityPolicy or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.SecurityPolicy] - :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.SecurityPolicy] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._patch_initial( - resource_group_name=resource_group_name, - profile_name=profile_name, - security_policy_name=security_policy_name, - security_policy_update_properties=security_policy_update_properties, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("SecurityPolicy", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, - AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.SecurityPolicy].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.SecurityPolicy]( - 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, security_policy_name: str, **kwargs: Any - ) -> None: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - security_policy_name=security_policy_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - 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 == 202: - response_headers["location"] = self._deserialize("str", response.headers.get("location")) - - if cls: - return cls(pipeline_response, None, response_headers) # type: ignore - - @distributed_trace_async - async def begin_delete( - self, resource_group_name: str, profile_name: str, security_policy_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes an existing security policy within 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. - :type profile_name: str - :param security_policy_name: Name of the security policy under the profile. Required. - :type security_policy_name: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._delete_initial( # type: ignore - resource_group_name=resource_group_name, - profile_name=profile_name, - security_policy_name=security_policy_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, - AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore 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..b37125a8b52d 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 @@ -2,455 +2,438 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -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 import ( # type: ignore + AFDDomain, + AFDDomainHttpsCustomizedCipherSuiteSet, + AFDDomainHttpsParameters, + AFDDomainProperties, + AFDDomainUpdateParameters, + AFDDomainUpdatePropertiesParameters, + AFDEndpoint, + AFDEndpointProperties, + AFDEndpointPropertiesUpdateParameters, + AFDEndpointUpdateParameters, + AFDOrigin, + AFDOriginGroup, + AFDOriginGroupProperties, + AFDOriginGroupUpdateParameters, + AFDOriginGroupUpdatePropertiesParameters, + AFDOriginProperties, + AFDOriginUpdateParameters, + AFDOriginUpdatePropertiesParameters, + AFDStateProperties, + ActivatedResourceReference, + AfdPurgeParameters, + AfdRouteCacheConfiguration, + AzureFirstPartyManagedCertificateParameters, + BatchRuleProperties, + CacheConfiguration, + CacheExpirationActionParameters, + CacheKeyQueryStringActionParameters, + CanMigrateParameters, + CanMigrateProperties, + CanMigrateResult, + CdnCertificateSourceParameters, + CdnEndpoint, + CdnManagedHttpsParameters, + CdnMigrationToAfdParameters, + CdnWebApplicationFirewallPolicy, + CdnWebApplicationFirewallPolicyPatchParameters, + CdnWebApplicationFirewallPolicyProperties, + CertificateSourceParameters, + CheckEndpointNameAvailabilityInput, + CheckEndpointNameAvailabilityOutput, + CheckHostNameAvailabilityInput, + CheckNameAvailabilityInput, + CheckNameAvailabilityOutput, + CidrIpAddress, + ClientPortMatchConditionParameters, + Components18OrqelSchemasWafmetricsresponsePropertiesSeriesItemsPropertiesDataItems, + Components1Gs0LlpSchemasMetricsresponsePropertiesSeriesItemsPropertiesDataItems, + ComponentsKpo1PjSchemasWafrankingsresponsePropertiesDataItemsPropertiesMetricsItems, + CompressionSettings, + ContinentsResponse, + ContinentsResponseContinentsItem, + ContinentsResponseCountryOrRegionsItem, + CookiesMatchConditionParameters, + CustomDomain, + CustomDomainHttpsParameters, + CustomDomainParameters, + CustomDomainProperties, + CustomDomainPropertiesParameters, + CustomRule, + CustomRuleList, + CustomerCertificateParameters, + DeepCreatedCustomDomain, + DeepCreatedCustomDomainProperties, + DeepCreatedOrigin, + DeepCreatedOriginGroup, + DeepCreatedOriginGroupProperties, + DeepCreatedOriginProperties, + 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, + EdgeNodeProperties, + Endpoint, + EndpointProperties, + EndpointPropertiesUpdateParameters, + EndpointPropertiesUpdateParametersDeliveryPolicy, + EndpointPropertiesUpdateParametersWebApplicationFirewallPolicyLink, + EndpointUpdateParameters, + ErrorAdditionalInfo, + ErrorDetail, + ErrorResponse, + GeoFilter, + HeaderActionParameters, + HealthProbeParameters, + HostNameMatchConditionParameters, + HttpErrorRangeParameters, + HttpVersionMatchConditionParameters, + IpAddressGroup, + IsDeviceMatchConditionParameters, + KeyVaultCertificateSourceParameters, + KeyVaultSigningKeyParameters, + LoadBalancingSettingsParameters, + LoadParameters, + LogSpecification, + ManagedCertificateParameters, + ManagedRuleDefinition, + ManagedRuleGroupDefinition, + ManagedRuleGroupOverride, + ManagedRuleOverride, + ManagedRuleSet, + ManagedRuleSetDefinition, + ManagedRuleSetDefinitionProperties, + ManagedRuleSetList, + ManagedServiceIdentity, + MatchCondition, + MetricAvailability, + MetricSpecification, + MetricsResponse, + MetricsResponseSeriesItem, + MetricsResponseSeriesPropertiesItemsItem, + MigrateResult, + MigrateResultProperties, + MigrationEndpointMapping, + MigrationErrorType, + MigrationParameters, + MigrationWebApplicationFirewallMapping, + Operation, + OperationDisplay, + OperationProperties, + Origin, + OriginAuthenticationProperties, + OriginGroup, + OriginGroupOverride, + OriginGroupOverrideAction, + OriginGroupOverrideActionParameters, + OriginGroupProperties, + OriginGroupUpdateParameters, + OriginGroupUpdatePropertiesParameters, + OriginProperties, + OriginUpdateParameters, + OriginUpdatePropertiesParameters, + PolicySettings, + PostArgsMatchConditionParameters, + Profile, + ProfileChangeSkuWafMapping, + ProfileLogScrubbing, + ProfileProperties, + ProfilePropertiesUpdateParameters, + ProfileScrubbingRules, + ProfileUpdateParameters, + ProfileUpgradeParameters, + ProxyResource, + PurgeParameters, + QueryStringMatchConditionParameters, + RankingsResponse, + RankingsResponseTablesItem, + RankingsResponseTablesPropertiesItemsItem, + RankingsResponseTablesPropertiesItemsMetricsItem, + RateLimitRule, + RateLimitRuleList, + RemoteAddressMatchConditionParameters, + RequestBodyMatchConditionParameters, + RequestHeaderMatchConditionParameters, + RequestMethodMatchConditionParameters, + RequestSchemeMatchConditionParameters, + RequestUriMatchConditionParameters, + Resource, + ResourceReference, + ResourceUsage, + ResourcesResponse, + ResourcesResponseCustomDomainsItem, + ResourcesResponseEndpointsItem, + ResourcesResponseEndpointsPropertiesItemsItem, + ResponseBasedOriginErrorDetectionParameters, + Route, + RouteConfigurationOverrideActionParameters, + RouteProperties, + RouteUpdateParameters, + RouteUpdatePropertiesParameters, + Rule, + RuleProperties, + RuleSet, + RuleSetProperties, + RuleUpdateParameters, + RuleUpdatePropertiesParameters, + Secret, + SecretParameters, + SecretProperties, + SecurityPolicy, + SecurityPolicyProperties, + SecurityPolicyPropertiesParameters, + SecurityPolicyUpdateParameters, + SecurityPolicyUpdateProperties, + 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, + UserAssignedIdentity, + UserManagedHttpsParameters, + ValidateCustomDomainInput, + ValidateCustomDomainOutput, + ValidateProbeInput, + ValidateProbeOutput, + ValidateSecretInput, + ValidateSecretOutput, + WafMetricsResponse, + WafMetricsResponseSeriesItem, + WafMetricsResponseSeriesPropertiesItemsItem, + WafRankingsResponse, + WafRankingsResponseDataItem, +) + +from ._enums import ( # type: ignore + AFDEndpointProtocols, + ActionType, + AfdCertificateType, + AfdCipherSuiteSetType, + AfdCustomizedCipherSuiteForTls12, + AfdCustomizedCipherSuiteForTls13, + AfdMinimumTlsVersion, + AfdProvisioningState, + AfdQueryStringCachingBehavior, + Algorithm, + AutoGeneratedDomainNameLabelScope, + CacheBehavior, + CacheType, + CanMigrateDefaultSku, + CertificateSource, + CertificateSourceParametersType, + CertificateType, + ClientPortOperator, + CookiesOperator, + CreatedByType, + CustomDomainResourceState, + CustomHttpsProvisioningState, + CustomHttpsProvisioningSubstate, + CustomRuleEnabledState, + DeleteRule, + DeliveryRuleActionName, + DeliveryRuleActionParametersType, + DeliveryRuleConditionParametersType, + DeploymentStatus, + DestinationProtocol, + DomainValidationState, + EnabledState, + EndpointProvisioningState, + EndpointResourceState, + ForwardingProtocol, + GeoFilterActions, + HeaderAction, + HealthProbeRequestType, + HostNameOperator, + HttpVersionOperator, + HttpsRedirect, + IsDeviceMatchValue, + IsDeviceOperator, + KeyVaultSigningKeyParametersType, + LinkToDefaultDomain, + LogMetric, + LogMetricsGranularity, + LogMetricsGroupBy, + LogRanking, + LogRankingMetric, + ManagedRuleEnabledState, + ManagedServiceIdentityType, + MatchProcessingBehavior, + MatchVariable, + MetricsGranularity, + MetricsSeriesUnit, + MinimumTlsVersion, + Operator, + OptimizationType, + OriginAuthenticationType, + 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", "AFDDomainUpdateParameters", "AFDDomainUpdatePropertiesParameters", "AFDEndpoint", - "AFDEndpointListResult", "AFDEndpointProperties", "AFDEndpointPropertiesUpdateParameters", "AFDEndpointUpdateParameters", "AFDOrigin", "AFDOriginGroup", - "AFDOriginGroupListResult", "AFDOriginGroupProperties", "AFDOriginGroupUpdateParameters", "AFDOriginGroupUpdatePropertiesParameters", - "AFDOriginListResult", "AFDOriginProperties", "AFDOriginUpdateParameters", "AFDOriginUpdatePropertiesParameters", "AFDStateProperties", "ActivatedResourceReference", - "AfdErrorResponse", "AfdPurgeParameters", "AfdRouteCacheConfiguration", - "AzureFirstPartyManagedCertificate", "AzureFirstPartyManagedCertificateParameters", + "BatchRuleProperties", "CacheConfiguration", "CacheExpirationActionParameters", "CacheKeyQueryStringActionParameters", "CanMigrateParameters", + "CanMigrateProperties", "CanMigrateResult", "CdnCertificateSourceParameters", "CdnEndpoint", "CdnManagedHttpsParameters", + "CdnMigrationToAfdParameters", "CdnWebApplicationFirewallPolicy", - "CdnWebApplicationFirewallPolicyList", "CdnWebApplicationFirewallPolicyPatchParameters", - "Certificate", + "CdnWebApplicationFirewallPolicyProperties", + "CertificateSourceParameters", "CheckEndpointNameAvailabilityInput", "CheckEndpointNameAvailabilityOutput", "CheckHostNameAvailabilityInput", @@ -468,21 +451,26 @@ "CookiesMatchConditionParameters", "CustomDomain", "CustomDomainHttpsParameters", - "CustomDomainListResult", "CustomDomainParameters", + "CustomDomainProperties", + "CustomDomainPropertiesParameters", "CustomRule", "CustomRuleList", - "CustomerCertificate", "CustomerCertificateParameters", "DeepCreatedCustomDomain", + "DeepCreatedCustomDomainProperties", "DeepCreatedOrigin", "DeepCreatedOriginGroup", + "DeepCreatedOriginGroupProperties", + "DeepCreatedOriginProperties", "DeliveryRule", "DeliveryRuleAction", + "DeliveryRuleActionParameters", "DeliveryRuleCacheExpirationAction", "DeliveryRuleCacheKeyQueryStringAction", "DeliveryRuleClientPortCondition", "DeliveryRuleCondition", + "DeliveryRuleConditionParameters", "DeliveryRuleCookiesCondition", "DeliveryRuleHostNameCondition", "DeliveryRuleHttpVersionCondition", @@ -507,9 +495,8 @@ "DimensionProperties", "DomainValidationProperties", "EdgeNode", - "EdgenodeResult", + "EdgeNodeProperties", "Endpoint", - "EndpointListResult", "EndpointProperties", "EndpointPropertiesUpdateParameters", "EndpointPropertiesUpdateParametersDeliveryPolicy", @@ -531,7 +518,6 @@ "LoadBalancingSettingsParameters", "LoadParameters", "LogSpecification", - "ManagedCertificate", "ManagedCertificateParameters", "ManagedRuleDefinition", "ManagedRuleGroupDefinition", @@ -539,7 +525,7 @@ "ManagedRuleOverride", "ManagedRuleSet", "ManagedRuleSetDefinition", - "ManagedRuleSetDefinitionList", + "ManagedRuleSetDefinitionProperties", "ManagedRuleSetList", "ManagedServiceIdentity", "MatchCondition", @@ -549,22 +535,23 @@ "MetricsResponseSeriesItem", "MetricsResponseSeriesPropertiesItemsItem", "MigrateResult", + "MigrateResultProperties", + "MigrationEndpointMapping", "MigrationErrorType", "MigrationParameters", "MigrationWebApplicationFirewallMapping", "Operation", "OperationDisplay", - "OperationsListResult", + "OperationProperties", "Origin", + "OriginAuthenticationProperties", "OriginGroup", - "OriginGroupListResult", "OriginGroupOverride", "OriginGroupOverrideAction", "OriginGroupOverrideActionParameters", "OriginGroupProperties", "OriginGroupUpdateParameters", "OriginGroupUpdatePropertiesParameters", - "OriginListResult", "OriginProperties", "OriginUpdateParameters", "OriginUpdatePropertiesParameters", @@ -572,8 +559,9 @@ "PostArgsMatchConditionParameters", "Profile", "ProfileChangeSkuWafMapping", - "ProfileListResult", "ProfileLogScrubbing", + "ProfileProperties", + "ProfilePropertiesUpdateParameters", "ProfileScrubbingRules", "ProfileUpdateParameters", "ProfileUpgradeParameters", @@ -595,7 +583,6 @@ "Resource", "ResourceReference", "ResourceUsage", - "ResourceUsageListResult", "ResourcesResponse", "ResourcesResponseCustomDomainsItem", "ResourcesResponseEndpointsItem", @@ -603,27 +590,23 @@ "ResponseBasedOriginErrorDetectionParameters", "Route", "RouteConfigurationOverrideActionParameters", - "RouteListResult", "RouteProperties", "RouteUpdateParameters", "RouteUpdatePropertiesParameters", "Rule", - "RuleListResult", "RuleProperties", "RuleSet", - "RuleSetListResult", "RuleSetProperties", "RuleUpdateParameters", "RuleUpdatePropertiesParameters", "Secret", - "SecretListResult", "SecretParameters", "SecretProperties", "SecurityPolicy", - "SecurityPolicyListResult", "SecurityPolicyProperties", "SecurityPolicyPropertiesParameters", "SecurityPolicyUpdateParameters", + "SecurityPolicyUpdateProperties", "SecurityPolicyWebApplicationFirewallAssociation", "SecurityPolicyWebApplicationFirewallParameters", "ServerPortMatchConditionParameters", @@ -650,7 +633,6 @@ "UrlSigningParamIdentifier", "Usage", "UsageName", - "UsagesListResult", "UserAssignedIdentity", "UserManagedHttpsParameters", "ValidateCustomDomainInput", @@ -659,7 +641,6 @@ "ValidateProbeOutput", "ValidateSecretInput", "ValidateSecretOutput", - "ValidationToken", "WafMetricsResponse", "WafMetricsResponseSeriesItem", "WafMetricsResponseSeriesPropertiesItemsItem", @@ -668,29 +649,31 @@ "AFDEndpointProtocols", "ActionType", "AfdCertificateType", + "AfdCipherSuiteSetType", + "AfdCustomizedCipherSuiteForTls12", + "AfdCustomizedCipherSuiteForTls13", "AfdMinimumTlsVersion", "AfdProvisioningState", "AfdQueryStringCachingBehavior", "Algorithm", "AutoGeneratedDomainNameLabelScope", "CacheBehavior", - "CacheExpirationActionParametersTypeName", - "CacheKeyQueryStringActionParametersTypeName", "CacheType", "CanMigrateDefaultSku", - "CdnCertificateSourceParametersTypeName", "CertificateSource", + "CertificateSourceParametersType", "CertificateType", - "ClientPortMatchConditionParametersTypeName", "ClientPortOperator", - "CookiesMatchConditionParametersTypeName", "CookiesOperator", + "CreatedByType", "CustomDomainResourceState", "CustomHttpsProvisioningState", "CustomHttpsProvisioningSubstate", "CustomRuleEnabledState", "DeleteRule", - "DeliveryRuleActionEnum", + "DeliveryRuleActionName", + "DeliveryRuleActionParametersType", + "DeliveryRuleConditionParametersType", "DeploymentStatus", "DestinationProtocol", "DomainValidationState", @@ -700,19 +683,13 @@ "ForwardingProtocol", "GeoFilterActions", "HeaderAction", - "HeaderActionParametersTypeName", "HealthProbeRequestType", - "HostNameMatchConditionParametersTypeName", "HostNameOperator", - "HttpVersionMatchConditionParametersTypeName", "HttpVersionOperator", "HttpsRedirect", - "IdentityType", - "IsDeviceMatchConditionParametersMatchValuesItem", - "IsDeviceMatchConditionParametersTypeName", + "IsDeviceMatchValue", "IsDeviceOperator", - "KeyVaultCertificateSourceParametersTypeName", - "KeyVaultSigningKeyParametersTypeName", + "KeyVaultSigningKeyParametersType", "LinkToDefaultDomain", "LogMetric", "LogMetricsGranularity", @@ -728,7 +705,7 @@ "MinimumTlsVersion", "Operator", "OptimizationType", - "OriginGroupOverrideActionParametersTypeName", + "OriginAuthenticationType", "OriginGroupProvisioningState", "OriginGroupResourceState", "OriginProvisioningState", @@ -738,7 +715,6 @@ "PolicyMode", "PolicyResourceState", "PolicySettingsDefaultCustomBlockResponseStatusCode", - "PostArgsMatchConditionParametersTypeName", "PostArgsOperator", "PrivateEndpointStatus", "ProbeProtocol", @@ -749,27 +725,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 +746,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 +770,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/_enums.py similarity index 65% rename from sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/models/_cdn_management_client_enums.py rename to sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/models/_enums.py index d0164f2b6f7b..09543c57c233 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/_enums.py @@ -1,8 +1,9 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -14,41 +15,98 @@ class ActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Defines the action to take on rule match.""" ALLOW = "Allow" + """ALLOW.""" BLOCK = "Block" + """BLOCK.""" LOG = "Log" + """LOG.""" REDIRECT = "Redirect" + """REDIRECT.""" class AfdCertificateType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Defines the source of the SSL certificate.""" CUSTOMER_CERTIFICATE = "CustomerCertificate" + """CUSTOMER_CERTIFICATE.""" MANAGED_CERTIFICATE = "ManagedCertificate" + """MANAGED_CERTIFICATE.""" AZURE_FIRST_PARTY_MANAGED_CERTIFICATE = "AzureFirstPartyManagedCertificate" + """AZURE_FIRST_PARTY_MANAGED_CERTIFICATE.""" + + +class AfdCipherSuiteSetType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """cipher suite set type that will be used for Https.""" + + CUSTOMIZED = "Customized" + """CUSTOMIZED.""" + TLS10_2019 = "TLS10_2019" + """TLS10_2019.""" + TLS12_2022 = "TLS12_2022" + """TLS12_2022.""" + TLS12_2023 = "TLS12_2023" + """TLS12_2023.""" + + +class AfdCustomizedCipherSuiteForTls12(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of AfdCustomizedCipherSuiteForTls12.""" + + ECDHE_RSA_AES128_GCM_SHA256 = "ECDHE_RSA_AES128_GCM_SHA256" + """ECDHE_RSA_AES128_GCM_SHA256.""" + ECDHE_RSA_AES256_GCM_SHA384 = "ECDHE_RSA_AES256_GCM_SHA384" + """ECDHE_RSA_AES256_GCM_SHA384.""" + DHE_RSA_AES256_GCM_SHA384 = "DHE_RSA_AES256_GCM_SHA384" + """DHE_RSA_AES256_GCM_SHA384.""" + DHE_RSA_AES128_GCM_SHA256 = "DHE_RSA_AES128_GCM_SHA256" + """DHE_RSA_AES128_GCM_SHA256.""" + ECDHE_RSA_AES128_SHA256 = "ECDHE_RSA_AES128_SHA256" + """ECDHE_RSA_AES128_SHA256.""" + ECDHE_RSA_AES256_SHA384 = "ECDHE_RSA_AES256_SHA384" + """ECDHE_RSA_AES256_SHA384.""" + + +class AfdCustomizedCipherSuiteForTls13(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of AfdCustomizedCipherSuiteForTls13.""" + + TLS_AES128_GCM_SHA256 = "TLS_AES_128_GCM_SHA256" + """TLS_AES128_GCM_SHA256.""" + TLS_AES256_GCM_SHA384 = "TLS_AES_256_GCM_SHA384" + """TLS_AES256_GCM_SHA384.""" class AFDEndpointProtocols(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Supported protocols for the customer's endpoint.""" HTTP = "Http" + """HTTP.""" HTTPS = "Https" + """HTTPS.""" 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" + """TLS10.""" TLS12 = "TLS12" + """TLS12.""" + TLS13 = "TLS13" + """TLS13.""" class AfdProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Provisioning status.""" SUCCEEDED = "Succeeded" + """SUCCEEDED.""" FAILED = "Failed" + """FAILED.""" UPDATING = "Updating" + """UPDATING.""" DELETING = "Deleting" + """DELETING.""" CREATING = "Creating" + """CREATING.""" class AfdQueryStringCachingBehavior(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -58,139 +116,176 @@ class AfdQueryStringCachingBehavior(str, Enum, metaclass=CaseInsensitiveEnumMeta """ IGNORE_QUERY_STRING = "IgnoreQueryString" + """IGNORE_QUERY_STRING.""" USE_QUERY_STRING = "UseQueryString" + """USE_QUERY_STRING.""" IGNORE_SPECIFIED_QUERY_STRINGS = "IgnoreSpecifiedQueryStrings" + """IGNORE_SPECIFIED_QUERY_STRINGS.""" INCLUDE_SPECIFIED_QUERY_STRINGS = "IncludeSpecifiedQueryStrings" + """INCLUDE_SPECIFIED_QUERY_STRINGS.""" class Algorithm(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Algorithm to use for URL signing.""" SHA256 = "SHA256" + """SHA256.""" class AutoGeneratedDomainNameLabelScope(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Indicates the endpoint name reuse scope. The default value is TenantReuse.""" TENANT_REUSE = "TenantReuse" + """TENANT_REUSE.""" SUBSCRIPTION_REUSE = "SubscriptionReuse" + """SUBSCRIPTION_REUSE.""" RESOURCE_GROUP_REUSE = "ResourceGroupReuse" + """RESOURCE_GROUP_REUSE.""" NO_REUSE = "NoReuse" + """NO_REUSE.""" class CacheBehavior(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Caching behavior for the requests.""" BYPASS_CACHE = "BypassCache" + """BYPASS_CACHE.""" OVERRIDE = "Override" + """OVERRIDE.""" 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" - ) + """SET_IF_MISSING.""" class CacheType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The level at which the content needs to be cached.""" ALL = "All" + """ALL.""" class CanMigrateDefaultSku(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Recommended sku for the migration.""" STANDARD_AZURE_FRONT_DOOR = "Standard_AzureFrontDoor" + """STANDARD_AZURE_FRONT_DOOR.""" PREMIUM_AZURE_FRONT_DOOR = "Premium_AzureFrontDoor" - - -class CdnCertificateSourceParametersTypeName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """CdnCertificateSourceParametersTypeName.""" - - CDN_CERTIFICATE_SOURCE_PARAMETERS = "CdnCertificateSourceParameters" + """PREMIUM_AZURE_FRONT_DOOR.""" class CertificateSource(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Defines the source of the SSL certificate.""" AZURE_KEY_VAULT = "AzureKeyVault" + """AZURE_KEY_VAULT.""" CDN = "Cdn" + """CDN.""" + + +class CertificateSourceParametersType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of CertificateSourceParametersType.""" + + CDN_CERTIFICATE_SOURCE_PARAMETERS = "CdnCertificateSourceParameters" + """CDN_CERTIFICATE_SOURCE_PARAMETERS.""" + KEY_VAULT_CERTIFICATE_SOURCE_PARAMETERS = "KeyVaultCertificateSourceParameters" + """KEY_VAULT_CERTIFICATE_SOURCE_PARAMETERS.""" class CertificateType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Type of certificate used.""" SHARED = "Shared" + """SHARED.""" DEDICATED = "Dedicated" - - -class ClientPortMatchConditionParametersTypeName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """ClientPortMatchConditionParametersTypeName.""" - - DELIVERY_RULE_CLIENT_PORT_CONDITION_PARAMETERS = "DeliveryRuleClientPortConditionParameters" + """DEDICATED.""" class ClientPortOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Describes operator to be matched.""" ANY = "Any" + """ANY.""" EQUAL = "Equal" + """EQUAL.""" CONTAINS = "Contains" + """CONTAINS.""" BEGINS_WITH = "BeginsWith" + """BEGINS_WITH.""" ENDS_WITH = "EndsWith" + """ENDS_WITH.""" LESS_THAN = "LessThan" + """LESS_THAN.""" LESS_THAN_OR_EQUAL = "LessThanOrEqual" + """LESS_THAN_OR_EQUAL.""" GREATER_THAN = "GreaterThan" + """GREATER_THAN.""" GREATER_THAN_OR_EQUAL = "GreaterThanOrEqual" + """GREATER_THAN_OR_EQUAL.""" REG_EX = "RegEx" - - -class CookiesMatchConditionParametersTypeName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """CookiesMatchConditionParametersTypeName.""" - - DELIVERY_RULE_COOKIES_CONDITION_PARAMETERS = "DeliveryRuleCookiesConditionParameters" + """REG_EX.""" class CookiesOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Describes operator to be matched.""" ANY = "Any" + """ANY.""" EQUAL = "Equal" + """EQUAL.""" CONTAINS = "Contains" + """CONTAINS.""" BEGINS_WITH = "BeginsWith" + """BEGINS_WITH.""" ENDS_WITH = "EndsWith" + """ENDS_WITH.""" LESS_THAN = "LessThan" + """LESS_THAN.""" LESS_THAN_OR_EQUAL = "LessThanOrEqual" + """LESS_THAN_OR_EQUAL.""" GREATER_THAN = "GreaterThan" + """GREATER_THAN.""" GREATER_THAN_OR_EQUAL = "GreaterThanOrEqual" + """GREATER_THAN_OR_EQUAL.""" REG_EX = "RegEx" + """REG_EX.""" + + +class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The kind of entity that created the resource.""" + + USER = "User" + """The entity was created by a user.""" + APPLICATION = "Application" + """The entity was created by an application.""" + MANAGED_IDENTITY = "ManagedIdentity" + """The entity was created by a managed identity.""" + KEY = "Key" + """The entity was created by a key.""" class CustomDomainResourceState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Resource status of the custom domain.""" CREATING = "Creating" + """CREATING.""" ACTIVE = "Active" + """ACTIVE.""" DELETING = "Deleting" + """DELETING.""" class CustomHttpsProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Provisioning status of the custom domain.""" ENABLING = "Enabling" + """ENABLING.""" ENABLED = "Enabled" + """ENABLED.""" DISABLING = "Disabling" + """DISABLING.""" DISABLED = "Disabled" + """DISABLED.""" FAILED = "Failed" + """FAILED.""" class CustomHttpsProvisioningSubstate(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -199,15 +294,25 @@ class CustomHttpsProvisioningSubstate(str, Enum, metaclass=CaseInsensitiveEnumMe """ SUBMITTING_DOMAIN_CONTROL_VALIDATION_REQUEST = "SubmittingDomainControlValidationRequest" + """SUBMITTING_DOMAIN_CONTROL_VALIDATION_REQUEST.""" PENDING_DOMAIN_CONTROL_VALIDATION_R_EQUEST_APPROVAL = "PendingDomainControlValidationREquestApproval" + """PENDING_DOMAIN_CONTROL_VALIDATION_R_EQUEST_APPROVAL.""" DOMAIN_CONTROL_VALIDATION_REQUEST_APPROVED = "DomainControlValidationRequestApproved" + """DOMAIN_CONTROL_VALIDATION_REQUEST_APPROVED.""" DOMAIN_CONTROL_VALIDATION_REQUEST_REJECTED = "DomainControlValidationRequestRejected" + """DOMAIN_CONTROL_VALIDATION_REQUEST_REJECTED.""" DOMAIN_CONTROL_VALIDATION_REQUEST_TIMED_OUT = "DomainControlValidationRequestTimedOut" + """DOMAIN_CONTROL_VALIDATION_REQUEST_TIMED_OUT.""" ISSUING_CERTIFICATE = "IssuingCertificate" + """ISSUING_CERTIFICATE.""" DEPLOYING_CERTIFICATE = "DeployingCertificate" + """DEPLOYING_CERTIFICATE.""" CERTIFICATE_DEPLOYED = "CertificateDeployed" + """CERTIFICATE_DEPLOYED.""" DELETING_CERTIFICATE = "DeletingCertificate" + """DELETING_CERTIFICATE.""" CERTIFICATE_DELETED = "CertificateDeleted" + """CERTIFICATE_DELETED.""" class CustomRuleEnabledState(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -216,44 +321,131 @@ class CustomRuleEnabledState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """ DISABLED = "Disabled" + """DISABLED.""" ENABLED = "Enabled" + """ENABLED.""" class DeleteRule(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Describes the action that shall be taken when the certificate is removed from Key Vault.""" NO_ACTION = "NoAction" + """NO_ACTION.""" -class DeliveryRuleActionEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta): +class DeliveryRuleActionName(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The name of the action for the delivery rule.""" CACHE_EXPIRATION = "CacheExpiration" + """CACHE_EXPIRATION.""" CACHE_KEY_QUERY_STRING = "CacheKeyQueryString" + """CACHE_KEY_QUERY_STRING.""" MODIFY_REQUEST_HEADER = "ModifyRequestHeader" + """MODIFY_REQUEST_HEADER.""" MODIFY_RESPONSE_HEADER = "ModifyResponseHeader" + """MODIFY_RESPONSE_HEADER.""" URL_REDIRECT = "UrlRedirect" + """URL_REDIRECT.""" URL_REWRITE = "UrlRewrite" + """URL_REWRITE.""" URL_SIGNING = "UrlSigning" + """URL_SIGNING.""" ORIGIN_GROUP_OVERRIDE = "OriginGroupOverride" + """ORIGIN_GROUP_OVERRIDE.""" ROUTE_CONFIGURATION_OVERRIDE = "RouteConfigurationOverride" + """ROUTE_CONFIGURATION_OVERRIDE.""" + + +class DeliveryRuleActionParametersType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of DeliveryRuleActionParametersType.""" + + DELIVERY_RULE_URL_REDIRECT_ACTION_PARAMETERS = "DeliveryRuleUrlRedirectActionParameters" + """DELIVERY_RULE_URL_REDIRECT_ACTION_PARAMETERS.""" + DELIVERY_RULE_URL_SIGNING_ACTION_PARAMETERS = "DeliveryRuleUrlSigningActionParameters" + """DELIVERY_RULE_URL_SIGNING_ACTION_PARAMETERS.""" + DELIVERY_RULE_ORIGIN_GROUP_OVERRIDE_ACTION_PARAMETERS = "DeliveryRuleOriginGroupOverrideActionParameters" + """DELIVERY_RULE_ORIGIN_GROUP_OVERRIDE_ACTION_PARAMETERS.""" + DELIVERY_RULE_URL_REWRITE_ACTION_PARAMETERS = "DeliveryRuleUrlRewriteActionParameters" + """DELIVERY_RULE_URL_REWRITE_ACTION_PARAMETERS.""" + DELIVERY_RULE_HEADER_ACTION_PARAMETERS = "DeliveryRuleHeaderActionParameters" + """DELIVERY_RULE_HEADER_ACTION_PARAMETERS.""" + DELIVERY_RULE_CACHE_EXPIRATION_ACTION_PARAMETERS = "DeliveryRuleCacheExpirationActionParameters" + """DELIVERY_RULE_CACHE_EXPIRATION_ACTION_PARAMETERS.""" + DELIVERY_RULE_CACHE_KEY_QUERY_STRING_BEHAVIOR_ACTION_PARAMETERS = ( + "DeliveryRuleCacheKeyQueryStringBehaviorActionParameters" + ) + """DELIVERY_RULE_CACHE_KEY_QUERY_STRING_BEHAVIOR_ACTION_PARAMETERS.""" + DELIVERY_RULE_ROUTE_CONFIGURATION_OVERRIDE_ACTION_PARAMETERS = ( + "DeliveryRuleRouteConfigurationOverrideActionParameters" + ) + """DELIVERY_RULE_ROUTE_CONFIGURATION_OVERRIDE_ACTION_PARAMETERS.""" + + +class DeliveryRuleConditionParametersType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of DeliveryRuleConditionParametersType.""" + + DELIVERY_RULE_REMOTE_ADDRESS_CONDITION_PARAMETERS = "DeliveryRuleRemoteAddressConditionParameters" + """DELIVERY_RULE_REMOTE_ADDRESS_CONDITION_PARAMETERS.""" + DELIVERY_RULE_REQUEST_METHOD_CONDITION_PARAMETERS = "DeliveryRuleRequestMethodConditionParameters" + """DELIVERY_RULE_REQUEST_METHOD_CONDITION_PARAMETERS.""" + DELIVERY_RULE_QUERY_STRING_CONDITION_PARAMETERS = "DeliveryRuleQueryStringConditionParameters" + """DELIVERY_RULE_QUERY_STRING_CONDITION_PARAMETERS.""" + DELIVERY_RULE_POST_ARGS_CONDITION_PARAMETERS = "DeliveryRulePostArgsConditionParameters" + """DELIVERY_RULE_POST_ARGS_CONDITION_PARAMETERS.""" + DELIVERY_RULE_REQUEST_URI_CONDITION_PARAMETERS = "DeliveryRuleRequestUriConditionParameters" + """DELIVERY_RULE_REQUEST_URI_CONDITION_PARAMETERS.""" + DELIVERY_RULE_REQUEST_HEADER_CONDITION_PARAMETERS = "DeliveryRuleRequestHeaderConditionParameters" + """DELIVERY_RULE_REQUEST_HEADER_CONDITION_PARAMETERS.""" + DELIVERY_RULE_REQUEST_BODY_CONDITION_PARAMETERS = "DeliveryRuleRequestBodyConditionParameters" + """DELIVERY_RULE_REQUEST_BODY_CONDITION_PARAMETERS.""" + DELIVERY_RULE_REQUEST_SCHEME_CONDITION_PARAMETERS = "DeliveryRuleRequestSchemeConditionParameters" + """DELIVERY_RULE_REQUEST_SCHEME_CONDITION_PARAMETERS.""" + DELIVERY_RULE_URL_PATH_MATCH_CONDITION_PARAMETERS = "DeliveryRuleUrlPathMatchConditionParameters" + """DELIVERY_RULE_URL_PATH_MATCH_CONDITION_PARAMETERS.""" + DELIVERY_RULE_URL_FILE_EXTENSION_MATCH_CONDITION_PARAMETERS = "DeliveryRuleUrlFileExtensionMatchConditionParameters" + """DELIVERY_RULE_URL_FILE_EXTENSION_MATCH_CONDITION_PARAMETERS.""" + DELIVERY_RULE_URL_FILENAME_CONDITION_PARAMETERS = "DeliveryRuleUrlFilenameConditionParameters" + """DELIVERY_RULE_URL_FILENAME_CONDITION_PARAMETERS.""" + DELIVERY_RULE_HTTP_VERSION_CONDITION_PARAMETERS = "DeliveryRuleHttpVersionConditionParameters" + """DELIVERY_RULE_HTTP_VERSION_CONDITION_PARAMETERS.""" + DELIVERY_RULE_COOKIES_CONDITION_PARAMETERS = "DeliveryRuleCookiesConditionParameters" + """DELIVERY_RULE_COOKIES_CONDITION_PARAMETERS.""" + DELIVERY_RULE_IS_DEVICE_CONDITION_PARAMETERS = "DeliveryRuleIsDeviceConditionParameters" + """DELIVERY_RULE_IS_DEVICE_CONDITION_PARAMETERS.""" + DELIVERY_RULE_SOCKET_ADDR_CONDITION_PARAMETERS = "DeliveryRuleSocketAddrConditionParameters" + """DELIVERY_RULE_SOCKET_ADDR_CONDITION_PARAMETERS.""" + DELIVERY_RULE_CLIENT_PORT_CONDITION_PARAMETERS = "DeliveryRuleClientPortConditionParameters" + """DELIVERY_RULE_CLIENT_PORT_CONDITION_PARAMETERS.""" + DELIVERY_RULE_SERVER_PORT_CONDITION_PARAMETERS = "DeliveryRuleServerPortConditionParameters" + """DELIVERY_RULE_SERVER_PORT_CONDITION_PARAMETERS.""" + DELIVERY_RULE_HOST_NAME_CONDITION_PARAMETERS = "DeliveryRuleHostNameConditionParameters" + """DELIVERY_RULE_HOST_NAME_CONDITION_PARAMETERS.""" + DELIVERY_RULE_SSL_PROTOCOL_CONDITION_PARAMETERS = "DeliveryRuleSslProtocolConditionParameters" + """DELIVERY_RULE_SSL_PROTOCOL_CONDITION_PARAMETERS.""" class DeploymentStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """DeploymentStatus.""" + """Type of DeploymentStatus.""" NOT_STARTED = "NotStarted" + """NOT_STARTED.""" IN_PROGRESS = "InProgress" + """IN_PROGRESS.""" SUCCEEDED = "Succeeded" + """SUCCEEDED.""" FAILED = "Failed" + """FAILED.""" class DestinationProtocol(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Protocol to use for the redirect. The default value is MatchRequest.""" MATCH_REQUEST = "MatchRequest" + """MATCH_REQUEST.""" HTTP = "Http" + """HTTP.""" HTTPS = "Https" + """HTTPS.""" class DomainValidationState(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -262,100 +454,131 @@ class DomainValidationState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """ UNKNOWN = "Unknown" + """UNKNOWN.""" SUBMITTING = "Submitting" + """SUBMITTING.""" PENDING = "Pending" + """PENDING.""" REJECTED = "Rejected" + """REJECTED.""" TIMED_OUT = "TimedOut" + """TIMED_OUT.""" PENDING_REVALIDATION = "PendingRevalidation" + """PENDING_REVALIDATION.""" APPROVED = "Approved" + """APPROVED.""" REFRESHING_VALIDATION_TOKEN = "RefreshingValidationToken" + """REFRESHING_VALIDATION_TOKEN.""" INTERNAL_ERROR = "InternalError" + """INTERNAL_ERROR.""" class EnabledState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Whether to enable use of this rule. Permitted values are 'Enabled' or 'Disabled'.""" ENABLED = "Enabled" + """ENABLED.""" DISABLED = "Disabled" + """DISABLED.""" class EndpointProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Provisioning status of the endpoint.""" SUCCEEDED = "Succeeded" + """SUCCEEDED.""" FAILED = "Failed" + """FAILED.""" UPDATING = "Updating" + """UPDATING.""" DELETING = "Deleting" + """DELETING.""" CREATING = "Creating" + """CREATING.""" class EndpointResourceState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Resource status of the endpoint.""" CREATING = "Creating" + """CREATING.""" DELETING = "Deleting" + """DELETING.""" RUNNING = "Running" + """RUNNING.""" STARTING = "Starting" + """STARTING.""" STOPPED = "Stopped" + """STOPPED.""" STOPPING = "Stopping" + """STOPPING.""" class ForwardingProtocol(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Protocol this rule will use when forwarding traffic to backends.""" HTTP_ONLY = "HttpOnly" + """HTTP_ONLY.""" HTTPS_ONLY = "HttpsOnly" + """HTTPS_ONLY.""" MATCH_REQUEST = "MatchRequest" + """MATCH_REQUEST.""" class GeoFilterActions(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Action of the geo filter, i.e. allow or block access.""" BLOCK = "Block" + """BLOCK.""" ALLOW = "Allow" + """ALLOW.""" class HeaderAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Action to perform.""" APPEND = "Append" + """APPEND.""" OVERWRITE = "Overwrite" + """OVERWRITE.""" DELETE = "Delete" - - -class HeaderActionParametersTypeName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """HeaderActionParametersTypeName.""" - - DELIVERY_RULE_HEADER_ACTION_PARAMETERS = "DeliveryRuleHeaderActionParameters" + """DELETE.""" class HealthProbeRequestType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of health probe request that is made.""" NOT_SET = "NotSet" + """NOT_SET.""" GET = "GET" + """GET.""" HEAD = "HEAD" - - -class HostNameMatchConditionParametersTypeName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """HostNameMatchConditionParametersTypeName.""" - - DELIVERY_RULE_HOST_NAME_CONDITION_PARAMETERS = "DeliveryRuleHostNameConditionParameters" + """HEAD.""" class HostNameOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Describes operator to be matched.""" ANY = "Any" + """ANY.""" EQUAL = "Equal" + """EQUAL.""" CONTAINS = "Contains" + """CONTAINS.""" BEGINS_WITH = "BeginsWith" + """BEGINS_WITH.""" ENDS_WITH = "EndsWith" + """ENDS_WITH.""" LESS_THAN = "LessThan" + """LESS_THAN.""" LESS_THAN_OR_EQUAL = "LessThanOrEqual" + """LESS_THAN_OR_EQUAL.""" GREATER_THAN = "GreaterThan" + """GREATER_THAN.""" GREATER_THAN_OR_EQUAL = "GreaterThanOrEqual" + """GREATER_THAN_OR_EQUAL.""" REG_EX = "RegEx" + """REG_EX.""" class HttpsRedirect(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -364,125 +587,132 @@ class HttpsRedirect(str, Enum, metaclass=CaseInsensitiveEnumMeta): """ ENABLED = "Enabled" + """ENABLED.""" DISABLED = "Disabled" - - -class HttpVersionMatchConditionParametersTypeName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """HttpVersionMatchConditionParametersTypeName.""" - - DELIVERY_RULE_HTTP_VERSION_CONDITION_PARAMETERS = "DeliveryRuleHttpVersionConditionParameters" + """DISABLED.""" class HttpVersionOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Describes operator to be matched.""" EQUAL = "Equal" + """EQUAL.""" -class IdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of identity that creates/modifies resources.""" - - USER = "user" - APPLICATION = "application" - MANAGED_IDENTITY = "managedIdentity" - KEY = "key" - - -class IsDeviceMatchConditionParametersMatchValuesItem(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """IsDeviceMatchConditionParametersMatchValuesItem.""" +class IsDeviceMatchValue(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of IsDeviceMatchValue.""" MOBILE = "Mobile" + """MOBILE.""" DESKTOP = "Desktop" - - -class IsDeviceMatchConditionParametersTypeName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """IsDeviceMatchConditionParametersTypeName.""" - - DELIVERY_RULE_IS_DEVICE_CONDITION_PARAMETERS = "DeliveryRuleIsDeviceConditionParameters" + """DESKTOP.""" class IsDeviceOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Describes operator to be matched.""" EQUAL = "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): + """Type of KeyVaultSigningKeyParametersType.""" KEY_VAULT_SIGNING_KEY_PARAMETERS = "KeyVaultSigningKeyParameters" + """KEY_VAULT_SIGNING_KEY_PARAMETERS.""" class LinkToDefaultDomain(str, Enum, metaclass=CaseInsensitiveEnumMeta): """whether this route will be linked to the default endpoint domain.""" ENABLED = "Enabled" + """ENABLED.""" DISABLED = "Disabled" + """DISABLED.""" class LogMetric(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """LogMetric.""" + """Type of LogMetric.""" CLIENT_REQUEST_COUNT = "clientRequestCount" + """CLIENT_REQUEST_COUNT.""" CLIENT_REQUEST_TRAFFIC = "clientRequestTraffic" + """CLIENT_REQUEST_TRAFFIC.""" CLIENT_REQUEST_BANDWIDTH = "clientRequestBandwidth" + """CLIENT_REQUEST_BANDWIDTH.""" ORIGIN_REQUEST_TRAFFIC = "originRequestTraffic" + """ORIGIN_REQUEST_TRAFFIC.""" ORIGIN_REQUEST_BANDWIDTH = "originRequestBandwidth" + """ORIGIN_REQUEST_BANDWIDTH.""" TOTAL_LATENCY = "totalLatency" + """TOTAL_LATENCY.""" class LogMetricsGranularity(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """LogMetricsGranularity.""" + """Type of LogMetricsGranularity.""" PT5_M = "PT5M" + """PT5_M.""" PT1_H = "PT1H" + """PT1_H.""" P1_D = "P1D" + """P1_D.""" class LogMetricsGroupBy(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """LogMetricsGroupBy.""" + """Type of LogMetricsGroupBy.""" HTTP_STATUS_CODE = "httpStatusCode" + """HTTP_STATUS_CODE.""" PROTOCOL = "protocol" + """PROTOCOL.""" CACHE_STATUS = "cacheStatus" + """CACHE_STATUS.""" COUNTRY_OR_REGION = "countryOrRegion" + """COUNTRY_OR_REGION.""" CUSTOM_DOMAIN = "customDomain" + """CUSTOM_DOMAIN.""" class LogRanking(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """LogRanking.""" + """Type of LogRanking.""" URL = "url" + """URL.""" REFERRER = "referrer" + """REFERRER.""" BROWSER = "browser" + """BROWSER.""" USER_AGENT = "userAgent" + """USER_AGENT.""" COUNTRY_OR_REGION = "countryOrRegion" + """COUNTRY_OR_REGION.""" class LogRankingMetric(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """LogRankingMetric.""" + """Type of LogRankingMetric.""" CLIENT_REQUEST_COUNT = "clientRequestCount" + """CLIENT_REQUEST_COUNT.""" CLIENT_REQUEST_TRAFFIC = "clientRequestTraffic" + """CLIENT_REQUEST_TRAFFIC.""" HIT_COUNT = "hitCount" + """HIT_COUNT.""" MISS_COUNT = "missCount" + """MISS_COUNT.""" USER_ERROR_COUNT = "userErrorCount" + """USER_ERROR_COUNT.""" ERROR_COUNT = "errorCount" + """ERROR_COUNT.""" class ManagedRuleEnabledState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Describes if the managed rule is in enabled or disabled state. Defaults to Disabled if not - specified. - """ + """Describes if the managed rule is in enabled or disabled state.""" DISABLED = "Disabled" + """DISABLED.""" ENABLED = "Enabled" + """ENABLED.""" class ManagedServiceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -491,9 +721,13 @@ class ManagedServiceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """ NONE = "None" + """No managed identity.""" SYSTEM_ASSIGNED = "SystemAssigned" + """System assigned managed identity.""" USER_ASSIGNED = "UserAssigned" - SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned, UserAssigned" + """User assigned managed identity.""" + SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned,UserAssigned" + """System and user assigned managed identity.""" class MatchProcessingBehavior(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -501,74 +735,117 @@ class MatchProcessingBehavior(str, Enum, metaclass=CaseInsensitiveEnumMeta): If not present, defaults to Continue. """ - CONTINUE_ENUM = "Continue" + CONTINUE = "Continue" + """CONTINUE.""" STOP = "Stop" + """STOP.""" class MatchVariable(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The name of the condition for the delivery rule.""" + """Request variable to compare with.""" REMOTE_ADDRESS = "RemoteAddress" + """REMOTE_ADDRESS.""" REQUEST_METHOD = "RequestMethod" + """REQUEST_METHOD.""" QUERY_STRING = "QueryString" + """QUERY_STRING.""" POST_ARGS = "PostArgs" + """POST_ARGS.""" REQUEST_URI = "RequestUri" + """REQUEST_URI.""" REQUEST_HEADER = "RequestHeader" + """REQUEST_HEADER.""" REQUEST_BODY = "RequestBody" + """REQUEST_BODY.""" REQUEST_SCHEME = "RequestScheme" + """REQUEST_SCHEME.""" URL_PATH = "UrlPath" + """URL_PATH.""" URL_FILE_EXTENSION = "UrlFileExtension" + """URL_FILE_EXTENSION.""" URL_FILE_NAME = "UrlFileName" + """URL_FILE_NAME.""" HTTP_VERSION = "HttpVersion" + """HTTP_VERSION.""" COOKIES = "Cookies" + """COOKIES.""" IS_DEVICE = "IsDevice" + """IS_DEVICE.""" SOCKET_ADDR = "SocketAddr" + """SOCKET_ADDR.""" CLIENT_PORT = "ClientPort" + """CLIENT_PORT.""" SERVER_PORT = "ServerPort" + """SERVER_PORT.""" HOST_NAME = "HostName" + """HOST_NAME.""" SSL_PROTOCOL = "SslProtocol" + """SSL_PROTOCOL.""" class MetricsGranularity(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """MetricsGranularity.""" + """Type of MetricsGranularity.""" PT5_M = "PT5M" + """PT5_M.""" PT1_H = "PT1H" + """PT1_H.""" P1_D = "P1D" + """P1_D.""" class MetricsSeriesUnit(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """MetricsSeriesUnit.""" + """Type of MetricsSeriesUnit.""" COUNT = "count" + """COUNT.""" BYTES = "bytes" + """BYTES.""" BITS_PER_SECOND = "bitsPerSecond" + """BITS_PER_SECOND.""" MILLI_SECONDS = "milliSeconds" + """MILLI_SECONDS.""" class MinimumTlsVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta): """TLS protocol version that will be used for Https.""" NONE = "None" + """NONE.""" TLS10 = "TLS10" + """TLS10.""" TLS12 = "TLS12" + """TLS12.""" class Operator(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Describes operator to be matched.""" ANY = "Any" + """ANY.""" IP_MATCH = "IPMatch" + """IP_MATCH.""" GEO_MATCH = "GeoMatch" + """GEO_MATCH.""" EQUAL = "Equal" + """EQUAL.""" CONTAINS = "Contains" + """CONTAINS.""" LESS_THAN = "LessThan" + """LESS_THAN.""" GREATER_THAN = "GreaterThan" + """GREATER_THAN.""" LESS_THAN_OR_EQUAL = "LessThanOrEqual" + """LESS_THAN_OR_EQUAL.""" GREATER_THAN_OR_EQUAL = "GreaterThanOrEqual" + """GREATER_THAN_OR_EQUAL.""" BEGINS_WITH = "BeginsWith" + """BEGINS_WITH.""" ENDS_WITH = "EndsWith" + """ENDS_WITH.""" REG_EX = "RegEx" + """REG_EX.""" class OptimizationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -577,191 +854,272 @@ class OptimizationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """ GENERAL_WEB_DELIVERY = "GeneralWebDelivery" + """GENERAL_WEB_DELIVERY.""" GENERAL_MEDIA_STREAMING = "GeneralMediaStreaming" + """GENERAL_MEDIA_STREAMING.""" VIDEO_ON_DEMAND_MEDIA_STREAMING = "VideoOnDemandMediaStreaming" + """VIDEO_ON_DEMAND_MEDIA_STREAMING.""" LARGE_FILE_DOWNLOAD = "LargeFileDownload" + """LARGE_FILE_DOWNLOAD.""" DYNAMIC_SITE_ACCELERATION = "DynamicSiteAcceleration" + """DYNAMIC_SITE_ACCELERATION.""" -class OriginGroupOverrideActionParametersTypeName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """OriginGroupOverrideActionParametersTypeName.""" +class OriginAuthenticationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the authentication for the origin.""" - DELIVERY_RULE_ORIGIN_GROUP_OVERRIDE_ACTION_PARAMETERS = "DeliveryRuleOriginGroupOverrideActionParameters" + SYSTEM_ASSIGNED_IDENTITY = "SystemAssignedIdentity" + """SYSTEM_ASSIGNED_IDENTITY.""" + USER_ASSIGNED_IDENTITY = "UserAssignedIdentity" + """USER_ASSIGNED_IDENTITY.""" class OriginGroupProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Provisioning status of the origin group.""" SUCCEEDED = "Succeeded" + """SUCCEEDED.""" FAILED = "Failed" + """FAILED.""" UPDATING = "Updating" + """UPDATING.""" DELETING = "Deleting" + """DELETING.""" CREATING = "Creating" + """CREATING.""" class OriginGroupResourceState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Resource status of the origin group.""" CREATING = "Creating" + """CREATING.""" ACTIVE = "Active" + """ACTIVE.""" DELETING = "Deleting" + """DELETING.""" class OriginProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Provisioning status of the origin.""" SUCCEEDED = "Succeeded" + """SUCCEEDED.""" FAILED = "Failed" + """FAILED.""" UPDATING = "Updating" + """UPDATING.""" DELETING = "Deleting" + """DELETING.""" CREATING = "Creating" + """CREATING.""" class OriginResourceState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Resource status of the origin.""" CREATING = "Creating" + """CREATING.""" ACTIVE = "Active" + """ACTIVE.""" DELETING = "Deleting" + """DELETING.""" class ParamIndicator(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Indicates the purpose of the parameter.""" EXPIRES = "Expires" + """EXPIRES.""" KEY_ID = "KeyId" + """KEY_ID.""" SIGNATURE = "Signature" + """SIGNATURE.""" class PolicyEnabledState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """describes if the policy is in enabled state or disabled state.""" + """Describes if the policy is in enabled or disabled state. Defaults to Enabled if not specified.""" DISABLED = "Disabled" + """DISABLED.""" ENABLED = "Enabled" + """ENABLED.""" class PolicyMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Describes if it is in detection mode or prevention mode at policy level.""" PREVENTION = "Prevention" + """PREVENTION.""" DETECTION = "Detection" + """DETECTION.""" class PolicyResourceState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Resource status of the policy.""" CREATING = "Creating" + """CREATING.""" ENABLING = "Enabling" + """ENABLING.""" ENABLED = "Enabled" + """ENABLED.""" DISABLING = "Disabling" + """DISABLING.""" DISABLED = "Disabled" + """DISABLED.""" DELETING = "Deleting" + """DELETING.""" -class PolicySettingsDefaultCustomBlockResponseStatusCode(int, Enum, metaclass=CaseInsensitiveEnumMeta): +class PolicySettingsDefaultCustomBlockResponseStatusCode( # pylint: disable=name-too-long + int, Enum, metaclass=CaseInsensitiveEnumMeta +): """If the action type is block, this field defines the default customer overridable http response status code. """ TWO_HUNDRED = 200 + """TWO_HUNDRED.""" FOUR_HUNDRED_THREE = 403 + """FOUR_HUNDRED_THREE.""" FOUR_HUNDRED_FIVE = 405 + """FOUR_HUNDRED_FIVE.""" FOUR_HUNDRED_SIX = 406 + """FOUR_HUNDRED_SIX.""" FOUR_HUNDRED_TWENTY_NINE = 429 - - -class PostArgsMatchConditionParametersTypeName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """PostArgsMatchConditionParametersTypeName.""" - - DELIVERY_RULE_POST_ARGS_CONDITION_PARAMETERS = "DeliveryRulePostArgsConditionParameters" + """FOUR_HUNDRED_TWENTY_NINE.""" class PostArgsOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Describes operator to be matched.""" ANY = "Any" + """ANY.""" EQUAL = "Equal" + """EQUAL.""" CONTAINS = "Contains" + """CONTAINS.""" BEGINS_WITH = "BeginsWith" + """BEGINS_WITH.""" ENDS_WITH = "EndsWith" + """ENDS_WITH.""" LESS_THAN = "LessThan" + """LESS_THAN.""" LESS_THAN_OR_EQUAL = "LessThanOrEqual" + """LESS_THAN_OR_EQUAL.""" GREATER_THAN = "GreaterThan" + """GREATER_THAN.""" GREATER_THAN_OR_EQUAL = "GreaterThanOrEqual" + """GREATER_THAN_OR_EQUAL.""" REG_EX = "RegEx" + """REG_EX.""" class PrivateEndpointStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The approval status for the connection to the Private Link.""" PENDING = "Pending" + """PENDING.""" APPROVED = "Approved" + """APPROVED.""" REJECTED = "Rejected" + """REJECTED.""" DISCONNECTED = "Disconnected" + """DISCONNECTED.""" TIMEOUT = "Timeout" + """TIMEOUT.""" class ProbeProtocol(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Protocol to use for health probe.""" NOT_SET = "NotSet" + """NOT_SET.""" HTTP = "Http" + """HTTP.""" HTTPS = "Https" + """HTTPS.""" class ProfileProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Provisioning status of the profile.""" SUCCEEDED = "Succeeded" + """SUCCEEDED.""" FAILED = "Failed" + """FAILED.""" UPDATING = "Updating" + """UPDATING.""" DELETING = "Deleting" + """DELETING.""" CREATING = "Creating" + """CREATING.""" class ProfileResourceState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Resource status of the profile.""" CREATING = "Creating" + """CREATING.""" ACTIVE = "Active" + """ACTIVE.""" DELETING = "Deleting" + """DELETING.""" DISABLED = "Disabled" + """DISABLED.""" MIGRATING = "Migrating" + """MIGRATING.""" MIGRATED = "Migrated" + """MIGRATED.""" PENDING_MIGRATION_COMMIT = "PendingMigrationCommit" + """PENDING_MIGRATION_COMMIT.""" COMMITTING_MIGRATION = "CommittingMigration" + """COMMITTING_MIGRATION.""" ABORTING_MIGRATION = "AbortingMigration" + """ABORTING_MIGRATION.""" class ProfileScrubbingState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """State of the log scrubbing config. Default value is Enabled.""" ENABLED = "Enabled" + """ENABLED.""" DISABLED = "Disabled" + """DISABLED.""" class ProtocolType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Defines the TLS extension protocol that is used for secure delivery.""" SERVER_NAME_INDICATION = "ServerNameIndication" + """SERVER_NAME_INDICATION.""" IP_BASED = "IPBased" + """IP_BASED.""" class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Provisioning state of the WebApplicationFirewallPolicy.""" CREATING = "Creating" + """CREATING.""" SUCCEEDED = "Succeeded" + """SUCCEEDED.""" FAILED = "Failed" + """FAILED.""" class QueryStringBehavior(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Caching behavior for the requests.""" INCLUDE = "Include" + """INCLUDE.""" INCLUDE_ALL = "IncludeAll" + """INCLUDE_ALL.""" EXCLUDE = "Exclude" + """EXCLUDE.""" EXCLUDE_ALL = "ExcludeAll" + """EXCLUDE_ALL.""" class QueryStringCachingBehavior(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -771,196 +1129,219 @@ class QueryStringCachingBehavior(str, Enum, metaclass=CaseInsensitiveEnumMeta): """ IGNORE_QUERY_STRING = "IgnoreQueryString" + """IGNORE_QUERY_STRING.""" BYPASS_CACHING = "BypassCaching" + """BYPASS_CACHING.""" USE_QUERY_STRING = "UseQueryString" + """USE_QUERY_STRING.""" NOT_SET = "NotSet" - - -class QueryStringMatchConditionParametersTypeName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """QueryStringMatchConditionParametersTypeName.""" - - DELIVERY_RULE_QUERY_STRING_CONDITION_PARAMETERS = "DeliveryRuleQueryStringConditionParameters" + """NOT_SET.""" class QueryStringOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Describes operator to be matched.""" ANY = "Any" + """ANY.""" EQUAL = "Equal" + """EQUAL.""" CONTAINS = "Contains" + """CONTAINS.""" BEGINS_WITH = "BeginsWith" + """BEGINS_WITH.""" ENDS_WITH = "EndsWith" + """ENDS_WITH.""" LESS_THAN = "LessThan" + """LESS_THAN.""" LESS_THAN_OR_EQUAL = "LessThanOrEqual" + """LESS_THAN_OR_EQUAL.""" GREATER_THAN = "GreaterThan" + """GREATER_THAN.""" GREATER_THAN_OR_EQUAL = "GreaterThanOrEqual" + """GREATER_THAN_OR_EQUAL.""" REG_EX = "RegEx" + """REG_EX.""" class RedirectType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The redirect type the rule will use when redirecting traffic.""" MOVED = "Moved" + """MOVED.""" FOUND = "Found" + """FOUND.""" TEMPORARY_REDIRECT = "TemporaryRedirect" + """TEMPORARY_REDIRECT.""" PERMANENT_REDIRECT = "PermanentRedirect" - - -class RemoteAddressMatchConditionParametersTypeName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """RemoteAddressMatchConditionParametersTypeName.""" - - DELIVERY_RULE_REMOTE_ADDRESS_CONDITION_PARAMETERS = "DeliveryRuleRemoteAddressConditionParameters" + """PERMANENT_REDIRECT.""" class RemoteAddressOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Describes operator to be matched.""" ANY = "Any" + """ANY.""" IP_MATCH = "IPMatch" + """IP_MATCH.""" GEO_MATCH = "GeoMatch" - - -class RequestBodyMatchConditionParametersTypeName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """RequestBodyMatchConditionParametersTypeName.""" - - DELIVERY_RULE_REQUEST_BODY_CONDITION_PARAMETERS = "DeliveryRuleRequestBodyConditionParameters" + """GEO_MATCH.""" class RequestBodyOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Describes operator to be matched.""" ANY = "Any" + """ANY.""" EQUAL = "Equal" + """EQUAL.""" CONTAINS = "Contains" + """CONTAINS.""" BEGINS_WITH = "BeginsWith" + """BEGINS_WITH.""" ENDS_WITH = "EndsWith" + """ENDS_WITH.""" LESS_THAN = "LessThan" + """LESS_THAN.""" LESS_THAN_OR_EQUAL = "LessThanOrEqual" + """LESS_THAN_OR_EQUAL.""" GREATER_THAN = "GreaterThan" + """GREATER_THAN.""" GREATER_THAN_OR_EQUAL = "GreaterThanOrEqual" + """GREATER_THAN_OR_EQUAL.""" REG_EX = "RegEx" - - -class RequestHeaderMatchConditionParametersTypeName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """RequestHeaderMatchConditionParametersTypeName.""" - - DELIVERY_RULE_REQUEST_HEADER_CONDITION_PARAMETERS = "DeliveryRuleRequestHeaderConditionParameters" + """REG_EX.""" class RequestHeaderOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Describes operator to be matched.""" ANY = "Any" + """ANY.""" EQUAL = "Equal" + """EQUAL.""" CONTAINS = "Contains" + """CONTAINS.""" BEGINS_WITH = "BeginsWith" + """BEGINS_WITH.""" ENDS_WITH = "EndsWith" + """ENDS_WITH.""" LESS_THAN = "LessThan" + """LESS_THAN.""" LESS_THAN_OR_EQUAL = "LessThanOrEqual" + """LESS_THAN_OR_EQUAL.""" GREATER_THAN = "GreaterThan" + """GREATER_THAN.""" GREATER_THAN_OR_EQUAL = "GreaterThanOrEqual" + """GREATER_THAN_OR_EQUAL.""" REG_EX = "RegEx" + """REG_EX.""" -class RequestMethodMatchConditionParametersMatchValuesItem(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """RequestMethodMatchConditionParametersMatchValuesItem.""" +class RequestMethodMatchValue(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of RequestMethodMatchValue.""" GET = "GET" + """GET.""" HEAD = "HEAD" + """HEAD.""" POST = "POST" + """POST.""" PUT = "PUT" + """PUT.""" DELETE = "DELETE" + """DELETE.""" OPTIONS = "OPTIONS" + """OPTIONS.""" TRACE = "TRACE" - - -class RequestMethodMatchConditionParametersTypeName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """RequestMethodMatchConditionParametersTypeName.""" - - DELIVERY_RULE_REQUEST_METHOD_CONDITION_PARAMETERS = "DeliveryRuleRequestMethodConditionParameters" + """TRACE.""" class RequestMethodOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Describes operator to be matched.""" EQUAL = "Equal" + """EQUAL.""" -class RequestSchemeMatchConditionParametersMatchValuesItem(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """RequestSchemeMatchConditionParametersMatchValuesItem.""" - - HTTP = "HTTP" - HTTPS = "HTTPS" - - -class RequestSchemeMatchConditionParametersOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): +class RequestSchemeMatchConditionParametersOperator( # pylint: disable=name-too-long + str, Enum, metaclass=CaseInsensitiveEnumMeta +): """Describes operator to be matched.""" EQUAL = "Equal" + """EQUAL.""" -class RequestSchemeMatchConditionParametersTypeName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """RequestSchemeMatchConditionParametersTypeName.""" - - DELIVERY_RULE_REQUEST_SCHEME_CONDITION_PARAMETERS = "DeliveryRuleRequestSchemeConditionParameters" - - -class RequestUriMatchConditionParametersTypeName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """RequestUriMatchConditionParametersTypeName.""" +class RequestSchemeMatchValue(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of RequestSchemeMatchValue.""" - DELIVERY_RULE_REQUEST_URI_CONDITION_PARAMETERS = "DeliveryRuleRequestUriConditionParameters" + HTTP = "HTTP" + """HTTP.""" + HTTPS = "HTTPS" + """HTTPS.""" class RequestUriOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Describes operator to be matched.""" ANY = "Any" + """ANY.""" EQUAL = "Equal" + """EQUAL.""" CONTAINS = "Contains" + """CONTAINS.""" BEGINS_WITH = "BeginsWith" + """BEGINS_WITH.""" ENDS_WITH = "EndsWith" + """ENDS_WITH.""" LESS_THAN = "LessThan" + """LESS_THAN.""" LESS_THAN_OR_EQUAL = "LessThanOrEqual" + """LESS_THAN_OR_EQUAL.""" GREATER_THAN = "GreaterThan" + """GREATER_THAN.""" GREATER_THAN_OR_EQUAL = "GreaterThanOrEqual" + """GREATER_THAN_OR_EQUAL.""" REG_EX = "RegEx" + """REG_EX.""" class ResourceType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Type of CDN resource used in CheckNameAvailability.""" MICROSOFT_CDN_PROFILES_ENDPOINTS = "Microsoft.Cdn/Profiles/Endpoints" + """MICROSOFT_CDN_PROFILES_ENDPOINTS.""" MICROSOFT_CDN_PROFILES_AFD_ENDPOINTS = "Microsoft.Cdn/Profiles/AfdEndpoints" + """MICROSOFT_CDN_PROFILES_AFD_ENDPOINTS.""" class ResourceUsageUnit(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Unit of the usage. e.g. count.""" COUNT = "count" + """COUNT.""" class ResponseBasedDetectedErrorTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Type of response errors for real user requests for which origin will be deemed unhealthy.""" NONE = "None" + """NONE.""" TCP_ERRORS_ONLY = "TcpErrorsOnly" + """TCP_ERRORS_ONLY.""" TCP_AND_HTTP_ERRORS = "TcpAndHttpErrors" - - -class RouteConfigurationOverrideActionParametersTypeName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """RouteConfigurationOverrideActionParametersTypeName.""" - - DELIVERY_RULE_ROUTE_CONFIGURATION_OVERRIDE_ACTION_PARAMETERS = ( - "DeliveryRuleRouteConfigurationOverrideActionParameters" - ) + """TCP_AND_HTTP_ERRORS.""" class RuleCacheBehavior(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Caching behavior for the requests.""" HONOR_ORIGIN = "HonorOrigin" + """HONOR_ORIGIN.""" OVERRIDE_ALWAYS = "OverrideAlways" + """OVERRIDE_ALWAYS.""" OVERRIDE_IF_ORIGIN_MISSING = "OverrideIfOriginMissing" + """OVERRIDE_IF_ORIGIN_MISSING.""" class RuleIsCompressionEnabled(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -970,7 +1351,9 @@ class RuleIsCompressionEnabled(str, Enum, metaclass=CaseInsensitiveEnumMeta): """ ENABLED = "Enabled" + """ENABLED.""" DISABLED = "Disabled" + """DISABLED.""" class RuleQueryStringCachingBehavior(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -980,9 +1363,13 @@ class RuleQueryStringCachingBehavior(str, Enum, metaclass=CaseInsensitiveEnumMet """ IGNORE_QUERY_STRING = "IgnoreQueryString" + """IGNORE_QUERY_STRING.""" USE_QUERY_STRING = "UseQueryString" + """USE_QUERY_STRING.""" IGNORE_SPECIFIED_QUERY_STRINGS = "IgnoreSpecifiedQueryStrings" + """IGNORE_SPECIFIED_QUERY_STRINGS.""" INCLUDE_SPECIFIED_QUERY_STRINGS = "IncludeSpecifiedQueryStrings" + """INCLUDE_SPECIFIED_QUERY_STRINGS.""" class ScrubbingRuleEntryMatchOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -991,57 +1378,72 @@ class ScrubbingRuleEntryMatchOperator(str, Enum, metaclass=CaseInsensitiveEnumMe """ EQUALS_ANY = "EqualsAny" + """EQUALS_ANY.""" class ScrubbingRuleEntryMatchVariable(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The variable to be scrubbed from the logs.""" REQUEST_IP_ADDRESS = "RequestIPAddress" + """REQUEST_IP_ADDRESS.""" REQUEST_URI = "RequestUri" + """REQUEST_URI.""" QUERY_STRING_ARG_NAMES = "QueryStringArgNames" + """QUERY_STRING_ARG_NAMES.""" class ScrubbingRuleEntryState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Defines the state of a log scrubbing rule. Default value is enabled.""" ENABLED = "Enabled" + """ENABLED.""" DISABLED = "Disabled" + """DISABLED.""" class SecretType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of the secret resource.""" URL_SIGNING_KEY = "UrlSigningKey" + """URL_SIGNING_KEY.""" CUSTOMER_CERTIFICATE = "CustomerCertificate" + """CUSTOMER_CERTIFICATE.""" MANAGED_CERTIFICATE = "ManagedCertificate" + """MANAGED_CERTIFICATE.""" AZURE_FIRST_PARTY_MANAGED_CERTIFICATE = "AzureFirstPartyManagedCertificate" + """AZURE_FIRST_PARTY_MANAGED_CERTIFICATE.""" class SecurityPolicyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of the Security policy to create.""" WEB_APPLICATION_FIREWALL = "WebApplicationFirewall" - - -class ServerPortMatchConditionParametersTypeName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """ServerPortMatchConditionParametersTypeName.""" - - DELIVERY_RULE_SERVER_PORT_CONDITION_PARAMETERS = "DeliveryRuleServerPortConditionParameters" + """WEB_APPLICATION_FIREWALL.""" class ServerPortOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Describes operator to be matched.""" ANY = "Any" + """ANY.""" EQUAL = "Equal" + """EQUAL.""" CONTAINS = "Contains" + """CONTAINS.""" BEGINS_WITH = "BeginsWith" + """BEGINS_WITH.""" ENDS_WITH = "EndsWith" + """ENDS_WITH.""" LESS_THAN = "LessThan" + """LESS_THAN.""" LESS_THAN_OR_EQUAL = "LessThanOrEqual" + """LESS_THAN_OR_EQUAL.""" GREATER_THAN = "GreaterThan" + """GREATER_THAN.""" GREATER_THAN_OR_EQUAL = "GreaterThanOrEqual" + """GREATER_THAN_OR_EQUAL.""" REG_EX = "RegEx" + """REG_EX.""" class SharedPrivateLinkResourceStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -1050,262 +1452,321 @@ class SharedPrivateLinkResourceStatus(str, Enum, metaclass=CaseInsensitiveEnumMe """ PENDING = "Pending" + """PENDING.""" APPROVED = "Approved" + """APPROVED.""" REJECTED = "Rejected" + """REJECTED.""" DISCONNECTED = "Disconnected" + """DISCONNECTED.""" TIMEOUT = "Timeout" + """TIMEOUT.""" class SkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Name of the pricing tier.""" STANDARD_VERIZON = "Standard_Verizon" + """STANDARD_VERIZON.""" PREMIUM_VERIZON = "Premium_Verizon" + """PREMIUM_VERIZON.""" CUSTOM_VERIZON = "Custom_Verizon" + """CUSTOM_VERIZON.""" STANDARD_AKAMAI = "Standard_Akamai" + """STANDARD_AKAMAI.""" STANDARD_CHINA_CDN = "Standard_ChinaCdn" + """STANDARD_CHINA_CDN.""" STANDARD_MICROSOFT = "Standard_Microsoft" + """STANDARD_MICROSOFT.""" STANDARD_AZURE_FRONT_DOOR = "Standard_AzureFrontDoor" + """STANDARD_AZURE_FRONT_DOOR.""" PREMIUM_AZURE_FRONT_DOOR = "Premium_AzureFrontDoor" + """PREMIUM_AZURE_FRONT_DOOR.""" STANDARD955_BAND_WIDTH_CHINA_CDN = "Standard_955BandWidth_ChinaCdn" + """STANDARD955_BAND_WIDTH_CHINA_CDN.""" STANDARD_AVG_BAND_WIDTH_CHINA_CDN = "Standard_AvgBandWidth_ChinaCdn" + """STANDARD_AVG_BAND_WIDTH_CHINA_CDN.""" STANDARD_PLUS_CHINA_CDN = "StandardPlus_ChinaCdn" + """STANDARD_PLUS_CHINA_CDN.""" STANDARD_PLUS955_BAND_WIDTH_CHINA_CDN = "StandardPlus_955BandWidth_ChinaCdn" + """STANDARD_PLUS955_BAND_WIDTH_CHINA_CDN.""" STANDARD_PLUS_AVG_BAND_WIDTH_CHINA_CDN = "StandardPlus_AvgBandWidth_ChinaCdn" - - -class SocketAddrMatchConditionParametersTypeName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """SocketAddrMatchConditionParametersTypeName.""" - - DELIVERY_RULE_SOCKET_ADDR_CONDITION_PARAMETERS = "DeliveryRuleSocketAddrConditionParameters" + """STANDARD_PLUS_AVG_BAND_WIDTH_CHINA_CDN.""" class SocketAddrOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Describes operator to be matched.""" ANY = "Any" + """ANY.""" IP_MATCH = "IPMatch" + """IP_MATCH.""" class SslProtocol(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The protocol of an established TLS connection.""" TL_SV1 = "TLSv1" + """TL_SV1.""" TL_SV1_1 = "TLSv1.1" + """TL_SV1_1.""" TL_SV1_2 = "TLSv1.2" - - -class SslProtocolMatchConditionParametersTypeName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """SslProtocolMatchConditionParametersTypeName.""" - - DELIVERY_RULE_SSL_PROTOCOL_CONDITION_PARAMETERS = "DeliveryRuleSslProtocolConditionParameters" + """TL_SV1_2.""" class SslProtocolOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Describes operator to be matched.""" EQUAL = "Equal" + """EQUAL.""" class Status(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The validation status.""" VALID = "Valid" + """VALID.""" INVALID = "Invalid" + """INVALID.""" ACCESS_DENIED = "AccessDenied" + """ACCESS_DENIED.""" CERTIFICATE_EXPIRED = "CertificateExpired" + """CERTIFICATE_EXPIRED.""" class Transform(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Describes what transforms are applied before matching.""" LOWERCASE = "Lowercase" + """LOWERCASE.""" UPPERCASE = "Uppercase" + """UPPERCASE.""" TRIM = "Trim" + """TRIM.""" URL_DECODE = "UrlDecode" + """URL_DECODE.""" URL_ENCODE = "UrlEncode" + """URL_ENCODE.""" REMOVE_NULLS = "RemoveNulls" + """REMOVE_NULLS.""" class TransformType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Describes what transforms were applied before matching.""" LOWERCASE = "Lowercase" + """LOWERCASE.""" UPPERCASE = "Uppercase" + """UPPERCASE.""" TRIM = "Trim" + """TRIM.""" URL_DECODE = "UrlDecode" + """URL_DECODE.""" URL_ENCODE = "UrlEncode" + """URL_ENCODE.""" REMOVE_NULLS = "RemoveNulls" + """REMOVE_NULLS.""" class UpdateRule(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Describes the action that shall be taken when the certificate is updated in Key Vault.""" NO_ACTION = "NoAction" - - -class UrlFileExtensionMatchConditionParametersTypeName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """UrlFileExtensionMatchConditionParametersTypeName.""" - - DELIVERY_RULE_URL_FILE_EXTENSION_MATCH_CONDITION_PARAMETERS = "DeliveryRuleUrlFileExtensionMatchConditionParameters" + """NO_ACTION.""" class UrlFileExtensionOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Describes operator to be matched.""" ANY = "Any" + """ANY.""" EQUAL = "Equal" + """EQUAL.""" CONTAINS = "Contains" + """CONTAINS.""" BEGINS_WITH = "BeginsWith" + """BEGINS_WITH.""" ENDS_WITH = "EndsWith" + """ENDS_WITH.""" LESS_THAN = "LessThan" + """LESS_THAN.""" LESS_THAN_OR_EQUAL = "LessThanOrEqual" + """LESS_THAN_OR_EQUAL.""" GREATER_THAN = "GreaterThan" + """GREATER_THAN.""" GREATER_THAN_OR_EQUAL = "GreaterThanOrEqual" + """GREATER_THAN_OR_EQUAL.""" REG_EX = "RegEx" - - -class UrlFileNameMatchConditionParametersTypeName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """UrlFileNameMatchConditionParametersTypeName.""" - - DELIVERY_RULE_URL_FILENAME_CONDITION_PARAMETERS = "DeliveryRuleUrlFilenameConditionParameters" + """REG_EX.""" class UrlFileNameOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Describes operator to be matched.""" ANY = "Any" + """ANY.""" EQUAL = "Equal" + """EQUAL.""" CONTAINS = "Contains" + """CONTAINS.""" BEGINS_WITH = "BeginsWith" + """BEGINS_WITH.""" ENDS_WITH = "EndsWith" + """ENDS_WITH.""" LESS_THAN = "LessThan" + """LESS_THAN.""" LESS_THAN_OR_EQUAL = "LessThanOrEqual" + """LESS_THAN_OR_EQUAL.""" GREATER_THAN = "GreaterThan" + """GREATER_THAN.""" GREATER_THAN_OR_EQUAL = "GreaterThanOrEqual" + """GREATER_THAN_OR_EQUAL.""" REG_EX = "RegEx" - - -class UrlPathMatchConditionParametersTypeName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """UrlPathMatchConditionParametersTypeName.""" - - DELIVERY_RULE_URL_PATH_MATCH_CONDITION_PARAMETERS = "DeliveryRuleUrlPathMatchConditionParameters" + """REG_EX.""" class UrlPathOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Describes operator to be matched.""" ANY = "Any" + """ANY.""" EQUAL = "Equal" + """EQUAL.""" CONTAINS = "Contains" + """CONTAINS.""" BEGINS_WITH = "BeginsWith" + """BEGINS_WITH.""" ENDS_WITH = "EndsWith" + """ENDS_WITH.""" LESS_THAN = "LessThan" + """LESS_THAN.""" LESS_THAN_OR_EQUAL = "LessThanOrEqual" + """LESS_THAN_OR_EQUAL.""" GREATER_THAN = "GreaterThan" + """GREATER_THAN.""" GREATER_THAN_OR_EQUAL = "GreaterThanOrEqual" + """GREATER_THAN_OR_EQUAL.""" WILDCARD = "Wildcard" + """WILDCARD.""" 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" + """REG_EX.""" class UsageUnit(str, Enum, metaclass=CaseInsensitiveEnumMeta): """An enum describing the unit of measurement.""" COUNT = "Count" + """COUNT.""" class WafAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """WafAction.""" + """Type of WafAction.""" ALLOW = "allow" + """ALLOW.""" BLOCK = "block" + """BLOCK.""" LOG = "log" + """LOG.""" REDIRECT = "redirect" + """REDIRECT.""" class WafGranularity(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """WafGranularity.""" + """Type of WafGranularity.""" PT5_M = "PT5M" + """PT5_M.""" PT1_H = "PT1H" + """PT1_H.""" P1_D = "P1D" + """P1_D.""" class WafMatchVariable(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Match variable to compare against.""" REMOTE_ADDR = "RemoteAddr" + """REMOTE_ADDR.""" SOCKET_ADDR = "SocketAddr" + """SOCKET_ADDR.""" REQUEST_METHOD = "RequestMethod" + """REQUEST_METHOD.""" REQUEST_HEADER = "RequestHeader" + """REQUEST_HEADER.""" REQUEST_URI = "RequestUri" + """REQUEST_URI.""" QUERY_STRING = "QueryString" + """QUERY_STRING.""" REQUEST_BODY = "RequestBody" + """REQUEST_BODY.""" COOKIES = "Cookies" + """COOKIES.""" POST_ARGS = "PostArgs" + """POST_ARGS.""" class WafMetric(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """WafMetric.""" + """Type of WafMetric.""" CLIENT_REQUEST_COUNT = "clientRequestCount" + """CLIENT_REQUEST_COUNT.""" class WafMetricsGranularity(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """WafMetricsGranularity.""" + """Type of WafMetricsGranularity.""" PT5_M = "PT5M" + """PT5_M.""" PT1_H = "PT1H" + """PT1_H.""" P1_D = "P1D" + """P1_D.""" class WafMetricsSeriesUnit(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """WafMetricsSeriesUnit.""" + """Type of WafMetricsSeriesUnit.""" COUNT = "count" + """COUNT.""" class WafRankingGroupBy(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """WafRankingGroupBy.""" + """Type of WafRankingGroupBy.""" HTTP_STATUS_CODE = "httpStatusCode" + """HTTP_STATUS_CODE.""" CUSTOM_DOMAIN = "customDomain" + """CUSTOM_DOMAIN.""" class WafRankingType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """WafRankingType.""" + """Type of WafRankingType.""" ACTION = "action" + """ACTION.""" RULE_GROUP = "ruleGroup" + """RULE_GROUP.""" RULE_ID = "ruleId" + """RULE_ID.""" USER_AGENT = "userAgent" + """USER_AGENT.""" CLIENT_IP = "clientIp" + """CLIENT_IP.""" URL = "url" + """URL.""" COUNTRY_OR_REGION = "countryOrRegion" + """COUNTRY_OR_REGION.""" RULE_TYPE = "ruleType" + """RULE_TYPE.""" class WafRuleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """WafRuleType.""" + """Type of WafRuleType.""" MANAGED = "managed" + """MANAGED.""" CUSTOM = "custom" + """CUSTOM.""" BOT = "bot" + """BOT.""" diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/models/_models.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/models/_models.py new file mode 100644 index 000000000000..4bc7d1065f6e --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/models/_models.py @@ -0,0 +1,12397 @@ +# pylint: disable=line-too-long,useless-suppression,too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +# pylint: disable=useless-super-delegation + +import datetime +from typing import Any, Literal, Mapping, Optional, TYPE_CHECKING, Union, overload + +from .._utils.model_base import Model as _Model, rest_discriminator, rest_field +from ._enums import ( + CertificateSource, + CertificateSourceParametersType, + DeliveryRuleActionName, + DeliveryRuleActionParametersType, + DeliveryRuleConditionParametersType, + MatchVariable, + SecretType, + SecurityPolicyType, +) + +if TYPE_CHECKING: + from .. import models as _models + + +class ActivatedResourceReference(_Model): + """Reference to another resource along with its state. + + :ivar id: Resource ID. + :vartype id: str + :ivar is_active: Whether the resource is active or inactive. + :vartype is_active: bool + """ + + id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Resource ID.""" + is_active: Optional[bool] = rest_field(name="isActive", visibility=["read"]) + """Whether the resource is active or inactive.""" + + @overload + def __init__( + self, + *, + id: Optional[str] = None, # pylint: disable=redefined-builtin + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class Resource(_Model): + """Resource. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.cdn.models.SystemData + """ + + id: Optional[str] = rest_field(visibility=["read"]) + """Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}.""" + name: Optional[str] = rest_field(visibility=["read"]) + """The name of the resource.""" + type: Optional[str] = rest_field(visibility=["read"]) + """The type of the resource. E.g. \"Microsoft.Compute/virtualMachines\" or + \"Microsoft.Storage/storageAccounts\".""" + system_data: Optional["_models.SystemData"] = rest_field(name="systemData", visibility=["read"]) + """Azure Resource Manager metadata containing createdBy and modifiedBy information.""" + + +class ProxyResource(Resource): + """Proxy Resource. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.cdn.models.SystemData + """ + + +class AFDDomain(ProxyResource): + """Friendly domain name mapping to the endpoint hostname that the customer provides for branding + purposes, e.g. `www.contoso.com `_. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.cdn.models.SystemData + :ivar properties: The JSON object that contains the properties of the domain to create. + :vartype properties: ~azure.mgmt.cdn.models.AFDDomainProperties + """ + + properties: Optional["_models.AFDDomainProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The JSON object that contains the properties of the domain to create.""" + + __flattened_items = [ + "profile_name", + "tls_settings", + "azure_dns_zone", + "pre_validated_custom_domain_resource_id", + "provisioning_state", + "deployment_status", + "domain_validation_state", + "host_name", + "extended_properties", + "validation_properties", + ] + + @overload + def __init__( + self, + *, + properties: Optional["_models.AFDDomainProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class AFDDomainHttpsCustomizedCipherSuiteSet(_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] + """ + + cipher_suite_set_for_tls12: Optional[list[Union[str, "_models.AfdCustomizedCipherSuiteForTls12"]]] = rest_field( + name="cipherSuiteSetForTls12", visibility=["read", "create", "update", "delete", "query"] + ) + """Cipher suites for TLS 1.2. Required at least one in minimumTlsVersion TLS 1.2.""" + cipher_suite_set_for_tls13: Optional[list[Union[str, "_models.AfdCustomizedCipherSuiteForTls13"]]] = rest_field( + name="cipherSuiteSetForTls13", visibility=["read", "create", "update", "delete", "query"] + ) + """Cipher suites for TLS 1.3. Required at least one in minimumTlsVersion TLS 1.2, TLS 1.3.""" + + @overload + 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, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class AFDDomainHttpsParameters(_Model): + """The JSON object that contains the properties to secure a domain. + + :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 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 + """ + + certificate_type: Union[str, "_models.AfdCertificateType"] = rest_field( + name="certificateType", visibility=["read", "create", "update", "delete", "query"] + ) + """Defines the source of the SSL certificate. Required. Known values are: \"CustomerCertificate\", + \"ManagedCertificate\", and \"AzureFirstPartyManagedCertificate\".""" + cipher_suite_set_type: Optional[Union[str, "_models.AfdCipherSuiteSetType"]] = rest_field( + name="cipherSuiteSetType", visibility=["read", "create", "update", "delete", "query"] + ) + """cipher suite set type that will be used for Https. Known values are: \"Customized\", + \"TLS10_2019\", \"TLS12_2022\", and \"TLS12_2023\".""" + minimum_tls_version: Optional[Union[str, "_models.AfdMinimumTlsVersion"]] = rest_field( + name="minimumTlsVersion", visibility=["read", "create", "update", "delete", "query"] + ) + """TLS protocol version that will be used for Https when cipherSuiteSetType is Customized. Known + values are: \"TLS10\", \"TLS12\", and \"TLS13\".""" + customized_cipher_suite_set: Optional["_models.AFDDomainHttpsCustomizedCipherSuiteSet"] = rest_field( + name="customizedCipherSuiteSet", visibility=["read", "create", "update", "delete", "query"] + ) + """Customized cipher suites object that will be used for Https when cipherSuiteSetType is + Customized.""" + secret: Optional["_models.ResourceReference"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource reference to the secret. ie. subs/rg/profile/secret.""" + + @overload + 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, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class AFDDomainProperties(_Model): + """The JSON object that contains the properties of the domain to create. + + :ivar profile_name: The name of the profile which holds the domain. + :vartype profile_name: str + :ivar tls_settings: The configuration specifying how to enable HTTPS for the domain - using + AzureFrontDoor managed certificate or user's own certificate. If not specified, enabling ssl + uses AzureFrontDoor managed certificate by default. + :vartype tls_settings: ~azure.mgmt.cdn.models.AFDDomainHttpsParameters + :ivar azure_dns_zone: Resource reference to the Azure DNS zone. + :vartype azure_dns_zone: ~azure.mgmt.cdn.models.ResourceReference + :ivar pre_validated_custom_domain_resource_id: Resource reference to the Azure resource where + custom domain ownership was prevalidated. + :vartype pre_validated_custom_domain_resource_id: ~azure.mgmt.cdn.models.ResourceReference + :ivar provisioning_state: Provisioning status. Known values are: "Succeeded", "Failed", + "Updating", "Deleting", and "Creating". + :vartype provisioning_state: str or ~azure.mgmt.cdn.models.AfdProvisioningState + :ivar deployment_status: Known values are: "NotStarted", "InProgress", "Succeeded", and + "Failed". + :vartype deployment_status: str or ~azure.mgmt.cdn.models.DeploymentStatus + :ivar domain_validation_state: Provisioning substate shows the progress of custom HTTPS + enabling/disabling process step by step. DCV stands for DomainControlValidation. Known values + are: "Unknown", "Submitting", "Pending", "Rejected", "TimedOut", "PendingRevalidation", + "Approved", "RefreshingValidationToken", and "InternalError". + :vartype domain_validation_state: str or ~azure.mgmt.cdn.models.DomainValidationState + :ivar host_name: The host name of the domain. Must be a domain name. Required. + :vartype host_name: str + :ivar extended_properties: Key-Value pair representing migration properties for domains. + :vartype extended_properties: dict[str, str] + :ivar validation_properties: Values the customer needs to validate domain ownership. + :vartype validation_properties: ~azure.mgmt.cdn.models.DomainValidationProperties + """ + + profile_name: Optional[str] = rest_field(name="profileName", visibility=["read"]) + """The name of the profile which holds the domain.""" + tls_settings: Optional["_models.AFDDomainHttpsParameters"] = rest_field( + name="tlsSettings", visibility=["read", "create", "update", "delete", "query"] + ) + """The configuration specifying how to enable HTTPS for the domain - using AzureFrontDoor managed + certificate or user's own certificate. If not specified, enabling ssl uses AzureFrontDoor + managed certificate by default.""" + azure_dns_zone: Optional["_models.ResourceReference"] = rest_field( + name="azureDnsZone", visibility=["read", "create", "update", "delete", "query"] + ) + """Resource reference to the Azure DNS zone.""" + pre_validated_custom_domain_resource_id: Optional["_models.ResourceReference"] = rest_field( + name="preValidatedCustomDomainResourceId", visibility=["read", "create", "update", "delete", "query"] + ) + """Resource reference to the Azure resource where custom domain ownership was prevalidated.""" + provisioning_state: Optional[Union[str, "_models.AfdProvisioningState"]] = rest_field( + name="provisioningState", visibility=["read"] + ) + """Provisioning status. Known values are: \"Succeeded\", \"Failed\", \"Updating\", \"Deleting\", + and \"Creating\".""" + deployment_status: Optional[Union[str, "_models.DeploymentStatus"]] = rest_field( + name="deploymentStatus", visibility=["read"] + ) + """Known values are: \"NotStarted\", \"InProgress\", \"Succeeded\", and \"Failed\".""" + domain_validation_state: Optional[Union[str, "_models.DomainValidationState"]] = rest_field( + name="domainValidationState", visibility=["read"] + ) + """Provisioning substate shows the progress of custom HTTPS enabling/disabling process step by + step. DCV stands for DomainControlValidation. Known values are: \"Unknown\", \"Submitting\", + \"Pending\", \"Rejected\", \"TimedOut\", \"PendingRevalidation\", \"Approved\", + \"RefreshingValidationToken\", and \"InternalError\".""" + host_name: str = rest_field(name="hostName", visibility=["read", "create", "update", "delete", "query"]) + """The host name of the domain. Must be a domain name. Required.""" + extended_properties: Optional[dict[str, str]] = rest_field( + name="extendedProperties", visibility=["read", "create", "update", "delete", "query"] + ) + """Key-Value pair representing migration properties for domains.""" + validation_properties: Optional["_models.DomainValidationProperties"] = rest_field( + name="validationProperties", visibility=["read"] + ) + """Values the customer needs to validate domain ownership.""" + + @overload + def __init__( + self, + *, + host_name: str, + tls_settings: Optional["_models.AFDDomainHttpsParameters"] = None, + azure_dns_zone: Optional["_models.ResourceReference"] = None, + pre_validated_custom_domain_resource_id: Optional["_models.ResourceReference"] = None, + extended_properties: Optional[dict[str, str]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class AFDDomainUpdateParameters(_Model): + """The domain JSON object required for domain creation or update. + + :ivar properties: The JSON object that contains the properties of the domain to create. + :vartype properties: ~azure.mgmt.cdn.models.AFDDomainUpdatePropertiesParameters + """ + + properties: Optional["_models.AFDDomainUpdatePropertiesParameters"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The JSON object that contains the properties of the domain to create.""" + + __flattened_items = ["profile_name", "tls_settings", "azure_dns_zone", "pre_validated_custom_domain_resource_id"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.AFDDomainUpdatePropertiesParameters"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class AFDDomainUpdatePropertiesParameters(_Model): + """The JSON object that contains the properties of the domain to create. + + :ivar profile_name: The name of the profile which holds the domain. + :vartype profile_name: str + :ivar tls_settings: The configuration specifying how to enable HTTPS for the domain - using + AzureFrontDoor managed certificate or user's own certificate. If not specified, enabling ssl + uses AzureFrontDoor managed certificate by default. + :vartype tls_settings: ~azure.mgmt.cdn.models.AFDDomainHttpsParameters + :ivar azure_dns_zone: Resource reference to the Azure DNS zone. + :vartype azure_dns_zone: ~azure.mgmt.cdn.models.ResourceReference + :ivar pre_validated_custom_domain_resource_id: Resource reference to the Azure resource where + custom domain ownership was prevalidated. + :vartype pre_validated_custom_domain_resource_id: ~azure.mgmt.cdn.models.ResourceReference + """ + + profile_name: Optional[str] = rest_field(name="profileName", visibility=["read"]) + """The name of the profile which holds the domain.""" + tls_settings: Optional["_models.AFDDomainHttpsParameters"] = rest_field( + name="tlsSettings", visibility=["read", "create", "update", "delete", "query"] + ) + """The configuration specifying how to enable HTTPS for the domain - using AzureFrontDoor managed + certificate or user's own certificate. If not specified, enabling ssl uses AzureFrontDoor + managed certificate by default.""" + azure_dns_zone: Optional["_models.ResourceReference"] = rest_field( + name="azureDnsZone", visibility=["read", "create", "update", "delete", "query"] + ) + """Resource reference to the Azure DNS zone.""" + pre_validated_custom_domain_resource_id: Optional["_models.ResourceReference"] = rest_field( + name="preValidatedCustomDomainResourceId", visibility=["read", "create", "update", "delete", "query"] + ) + """Resource reference to the Azure resource where custom domain ownership was prevalidated.""" + + @overload + def __init__( + self, + *, + tls_settings: Optional["_models.AFDDomainHttpsParameters"] = None, + azure_dns_zone: Optional["_models.ResourceReference"] = None, + pre_validated_custom_domain_resource_id: Optional["_models.ResourceReference"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class TrackedResource(Resource): + """Tracked Resource. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.cdn.models.SystemData + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str + """ + + tags: Optional[dict[str, str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Resource tags.""" + location: str = rest_field(visibility=["read", "create"]) + """The geo-location where the resource lives. Required.""" + + @overload + def __init__( + self, + *, + location: str, + tags: Optional[dict[str, str]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class 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 .azureedge.net. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.cdn.models.SystemData + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str + :ivar properties: The JSON object that contains the properties required to create an endpoint. + :vartype properties: ~azure.mgmt.cdn.models.AFDEndpointProperties + """ + + properties: Optional["_models.AFDEndpointProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The JSON object that contains the properties required to create an endpoint.""" + + __flattened_items = [ + "profile_name", + "enabled_state", + "provisioning_state", + "deployment_status", + "host_name", + "auto_generated_domain_name_label_scope", + ] + + @overload + def __init__( + self, + *, + location: str, + tags: Optional[dict[str, str]] = None, + properties: Optional["_models.AFDEndpointProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class AFDEndpointProperties(_Model): + """The JSON object that contains the properties required to create an endpoint. + + :ivar profile_name: The name of the profile which holds the endpoint. + :vartype profile_name: str + :ivar enabled_state: Whether to enable use of this rule. Permitted values are 'Enabled' or + 'Disabled'. Known values are: "Enabled" and "Disabled". + :vartype enabled_state: str or ~azure.mgmt.cdn.models.EnabledState + :ivar provisioning_state: Provisioning status. Known values are: "Succeeded", "Failed", + "Updating", "Deleting", and "Creating". + :vartype provisioning_state: str or ~azure.mgmt.cdn.models.AfdProvisioningState + :ivar deployment_status: Known values are: "NotStarted", "InProgress", "Succeeded", and + "Failed". + :vartype deployment_status: str or ~azure.mgmt.cdn.models.DeploymentStatus + :ivar host_name: The host name of the endpoint structured as {endpointName}.{DNSZone}, e.g. + contoso.azureedge.net. + :vartype host_name: str + :ivar auto_generated_domain_name_label_scope: Indicates the endpoint name reuse scope. The + default value is TenantReuse. Known values are: "TenantReuse", "SubscriptionReuse", + "ResourceGroupReuse", and "NoReuse". + :vartype auto_generated_domain_name_label_scope: str or + ~azure.mgmt.cdn.models.AutoGeneratedDomainNameLabelScope + """ + + profile_name: Optional[str] = rest_field(name="profileName", visibility=["read"]) + """The name of the profile which holds the endpoint.""" + enabled_state: Optional[Union[str, "_models.EnabledState"]] = rest_field( + name="enabledState", visibility=["read", "create", "update", "delete", "query"] + ) + """Whether to enable use of this rule. Permitted values are 'Enabled' or 'Disabled'. Known values + are: \"Enabled\" and \"Disabled\".""" + provisioning_state: Optional[Union[str, "_models.AfdProvisioningState"]] = rest_field( + name="provisioningState", visibility=["read"] + ) + """Provisioning status. Known values are: \"Succeeded\", \"Failed\", \"Updating\", \"Deleting\", + and \"Creating\".""" + deployment_status: Optional[Union[str, "_models.DeploymentStatus"]] = rest_field( + name="deploymentStatus", visibility=["read"] + ) + """Known values are: \"NotStarted\", \"InProgress\", \"Succeeded\", and \"Failed\".""" + host_name: Optional[str] = rest_field(name="hostName", visibility=["read"]) + """The host name of the endpoint structured as {endpointName}.{DNSZone}, e.g. + contoso.azureedge.net.""" + auto_generated_domain_name_label_scope: Optional[Union[str, "_models.AutoGeneratedDomainNameLabelScope"]] = ( + rest_field(name="autoGeneratedDomainNameLabelScope", visibility=["read", "create", "update", "delete", "query"]) + ) + """Indicates the endpoint name reuse scope. The default value is TenantReuse. Known values are: + \"TenantReuse\", \"SubscriptionReuse\", \"ResourceGroupReuse\", and \"NoReuse\".""" + + @overload + def __init__( + self, + *, + enabled_state: Optional[Union[str, "_models.EnabledState"]] = None, + auto_generated_domain_name_label_scope: Optional[ + Union[str, "_models.AutoGeneratedDomainNameLabelScope"] + ] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class AFDEndpointPropertiesUpdateParameters(_Model): + """The JSON object containing endpoint update parameters. + + :ivar profile_name: The name of the profile which holds the endpoint. + :vartype profile_name: str + :ivar enabled_state: Whether to enable use of this rule. Permitted values are 'Enabled' or + 'Disabled'. Known values are: "Enabled" and "Disabled". + :vartype enabled_state: str or ~azure.mgmt.cdn.models.EnabledState + """ + + profile_name: Optional[str] = rest_field(name="profileName", visibility=["read"]) + """The name of the profile which holds the endpoint.""" + enabled_state: Optional[Union[str, "_models.EnabledState"]] = rest_field( + name="enabledState", visibility=["read", "create", "update", "delete", "query"] + ) + """Whether to enable use of this rule. Permitted values are 'Enabled' or 'Disabled'. Known values + are: \"Enabled\" and \"Disabled\".""" + + @overload + def __init__( + self, + *, + enabled_state: Optional[Union[str, "_models.EnabledState"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class AFDEndpointUpdateParameters(_Model): + """Properties required to create or update an endpoint. + + :ivar tags: Endpoint tags. + :vartype tags: dict[str, str] + :ivar properties: The JSON object containing endpoint update parameters. + :vartype properties: ~azure.mgmt.cdn.models.AFDEndpointPropertiesUpdateParameters + """ + + tags: Optional[dict[str, str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Endpoint tags.""" + properties: Optional["_models.AFDEndpointPropertiesUpdateParameters"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The JSON object containing endpoint update parameters.""" + + __flattened_items = ["profile_name", "enabled_state"] + + @overload + def __init__( + self, + *, + tags: Optional[dict[str, str]] = None, + properties: Optional["_models.AFDEndpointPropertiesUpdateParameters"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class 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. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.cdn.models.SystemData + :ivar properties: The JSON object that contains the properties of the origin. + :vartype properties: ~azure.mgmt.cdn.models.AFDOriginProperties + """ + + properties: Optional["_models.AFDOriginProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The JSON object that contains the properties of the origin.""" + + __flattened_items = [ + "origin_group_name", + "azure_origin", + "host_name", + "http_port", + "https_port", + "origin_host_header", + "priority", + "weight", + "shared_private_link_resource", + "enabled_state", + "enforce_certificate_name_check", + "provisioning_state", + "deployment_status", + ] + + @overload + def __init__( + self, + *, + properties: Optional["_models.AFDOriginProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class AFDOriginGroup(ProxyResource): + """AFDOrigin group comprising of origins is used for load balancing to origins when the content + cannot be served from Azure Front Door. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.cdn.models.SystemData + :ivar properties: The JSON object that contains the properties of the origin group. + :vartype properties: ~azure.mgmt.cdn.models.AFDOriginGroupProperties + """ + + properties: Optional["_models.AFDOriginGroupProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The JSON object that contains the properties of the origin group.""" + + __flattened_items = [ + "profile_name", + "load_balancing_settings", + "health_probe_settings", + "traffic_restoration_time_to_healed_or_new_endpoints_in_minutes", + "session_affinity_state", + "authentication", + "provisioning_state", + "deployment_status", + ] + + @overload + def __init__( + self, + *, + properties: Optional["_models.AFDOriginGroupProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class AFDOriginGroupProperties(_Model): + """The JSON object that contains the properties of the origin group. + + :ivar profile_name: The name of the profile which holds the origin group. + :vartype profile_name: str + :ivar load_balancing_settings: Load balancing settings for a backend pool. + :vartype load_balancing_settings: ~azure.mgmt.cdn.models.LoadBalancingSettingsParameters + :ivar health_probe_settings: Health probe settings to the origin that is used to determine the + health of the origin. + :vartype health_probe_settings: ~azure.mgmt.cdn.models.HealthProbeParameters + :ivar traffic_restoration_time_to_healed_or_new_endpoints_in_minutes: Time in minutes to shift + the traffic to the endpoint gradually when an unhealthy endpoint comes healthy or a new + endpoint is added. Default is 10 mins. This property is currently not supported. + :vartype traffic_restoration_time_to_healed_or_new_endpoints_in_minutes: int + :ivar session_affinity_state: Whether to allow session affinity on this host. Valid options are + 'Enabled' or 'Disabled'. Known values are: "Enabled" and "Disabled". + :vartype session_affinity_state: str or ~azure.mgmt.cdn.models.EnabledState + :ivar authentication: Authentication settings for origin in origin group. + :vartype authentication: ~azure.mgmt.cdn.models.OriginAuthenticationProperties + :ivar provisioning_state: Provisioning status. Known values are: "Succeeded", "Failed", + "Updating", "Deleting", and "Creating". + :vartype provisioning_state: str or ~azure.mgmt.cdn.models.AfdProvisioningState + :ivar deployment_status: Known values are: "NotStarted", "InProgress", "Succeeded", and + "Failed". + :vartype deployment_status: str or ~azure.mgmt.cdn.models.DeploymentStatus + """ + + profile_name: Optional[str] = rest_field(name="profileName", visibility=["read"]) + """The name of the profile which holds the origin group.""" + load_balancing_settings: Optional["_models.LoadBalancingSettingsParameters"] = rest_field( + name="loadBalancingSettings", visibility=["read", "create", "update", "delete", "query"] + ) + """Load balancing settings for a backend pool.""" + health_probe_settings: Optional["_models.HealthProbeParameters"] = rest_field( + name="healthProbeSettings", visibility=["read", "create", "update", "delete", "query"] + ) + """Health probe settings to the origin that is used to determine the health of the origin.""" + traffic_restoration_time_to_healed_or_new_endpoints_in_minutes: Optional[int] = rest_field( + name="trafficRestorationTimeToHealedOrNewEndpointsInMinutes", + visibility=["read", "create", "update", "delete", "query"], + ) + """Time in minutes to shift the traffic to the endpoint gradually when an unhealthy endpoint comes + healthy or a new endpoint is added. Default is 10 mins. This property is currently not + supported.""" + session_affinity_state: Optional[Union[str, "_models.EnabledState"]] = rest_field( + name="sessionAffinityState", visibility=["read", "create", "update", "delete", "query"] + ) + """Whether to allow session affinity on this host. Valid options are 'Enabled' or 'Disabled'. + Known values are: \"Enabled\" and \"Disabled\".""" + authentication: Optional["_models.OriginAuthenticationProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Authentication settings for origin in origin group.""" + provisioning_state: Optional[Union[str, "_models.AfdProvisioningState"]] = rest_field( + name="provisioningState", visibility=["read"] + ) + """Provisioning status. Known values are: \"Succeeded\", \"Failed\", \"Updating\", \"Deleting\", + and \"Creating\".""" + deployment_status: Optional[Union[str, "_models.DeploymentStatus"]] = rest_field( + name="deploymentStatus", visibility=["read"] + ) + """Known values are: \"NotStarted\", \"InProgress\", \"Succeeded\", and \"Failed\".""" + + @overload + def __init__( + self, + *, + load_balancing_settings: Optional["_models.LoadBalancingSettingsParameters"] = None, + health_probe_settings: Optional["_models.HealthProbeParameters"] = None, + traffic_restoration_time_to_healed_or_new_endpoints_in_minutes: Optional[int] = None, + session_affinity_state: Optional[Union[str, "_models.EnabledState"]] = None, + authentication: Optional["_models.OriginAuthenticationProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class AFDOriginGroupUpdateParameters(_Model): + """AFDOrigin group properties needed for origin group creation or update. + + :ivar properties: The JSON object that contains the properties of the origin group. + :vartype properties: ~azure.mgmt.cdn.models.AFDOriginGroupUpdatePropertiesParameters + """ + + properties: Optional["_models.AFDOriginGroupUpdatePropertiesParameters"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The JSON object that contains the properties of the origin group.""" + + __flattened_items = [ + "profile_name", + "load_balancing_settings", + "health_probe_settings", + "traffic_restoration_time_to_healed_or_new_endpoints_in_minutes", + "session_affinity_state", + "authentication", + ] + + @overload + def __init__( + self, + *, + properties: Optional["_models.AFDOriginGroupUpdatePropertiesParameters"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class AFDOriginGroupUpdatePropertiesParameters(_Model): + """The JSON object that contains the properties of the origin group. + + :ivar profile_name: The name of the profile which holds the origin group. + :vartype profile_name: str + :ivar load_balancing_settings: Load balancing settings for a backend pool. + :vartype load_balancing_settings: ~azure.mgmt.cdn.models.LoadBalancingSettingsParameters + :ivar health_probe_settings: Health probe settings to the origin that is used to determine the + health of the origin. + :vartype health_probe_settings: ~azure.mgmt.cdn.models.HealthProbeParameters + :ivar traffic_restoration_time_to_healed_or_new_endpoints_in_minutes: Time in minutes to shift + the traffic to the endpoint gradually when an unhealthy endpoint comes healthy or a new + endpoint is added. Default is 10 mins. This property is currently not supported. + :vartype traffic_restoration_time_to_healed_or_new_endpoints_in_minutes: int + :ivar session_affinity_state: Whether to allow session affinity on this host. Valid options are + 'Enabled' or 'Disabled'. Known values are: "Enabled" and "Disabled". + :vartype session_affinity_state: str or ~azure.mgmt.cdn.models.EnabledState + :ivar authentication: Authentication settings for origin in origin group. + :vartype authentication: ~azure.mgmt.cdn.models.OriginAuthenticationProperties + """ + + profile_name: Optional[str] = rest_field(name="profileName", visibility=["read"]) + """The name of the profile which holds the origin group.""" + load_balancing_settings: Optional["_models.LoadBalancingSettingsParameters"] = rest_field( + name="loadBalancingSettings", visibility=["read", "create", "update", "delete", "query"] + ) + """Load balancing settings for a backend pool.""" + health_probe_settings: Optional["_models.HealthProbeParameters"] = rest_field( + name="healthProbeSettings", visibility=["read", "create", "update", "delete", "query"] + ) + """Health probe settings to the origin that is used to determine the health of the origin.""" + traffic_restoration_time_to_healed_or_new_endpoints_in_minutes: Optional[int] = rest_field( + name="trafficRestorationTimeToHealedOrNewEndpointsInMinutes", + visibility=["read", "create", "update", "delete", "query"], + ) + """Time in minutes to shift the traffic to the endpoint gradually when an unhealthy endpoint comes + healthy or a new endpoint is added. Default is 10 mins. This property is currently not + supported.""" + session_affinity_state: Optional[Union[str, "_models.EnabledState"]] = rest_field( + name="sessionAffinityState", visibility=["read", "create", "update", "delete", "query"] + ) + """Whether to allow session affinity on this host. Valid options are 'Enabled' or 'Disabled'. + Known values are: \"Enabled\" and \"Disabled\".""" + authentication: Optional["_models.OriginAuthenticationProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Authentication settings for origin in origin group.""" + + @overload + def __init__( + self, + *, + load_balancing_settings: Optional["_models.LoadBalancingSettingsParameters"] = None, + health_probe_settings: Optional["_models.HealthProbeParameters"] = None, + traffic_restoration_time_to_healed_or_new_endpoints_in_minutes: Optional[int] = None, + session_affinity_state: Optional[Union[str, "_models.EnabledState"]] = None, + authentication: Optional["_models.OriginAuthenticationProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class AFDOriginProperties(_Model): + """The JSON object that contains the properties of the origin. + + :ivar origin_group_name: The name of the origin group which contains this origin. + :vartype origin_group_name: str + :ivar azure_origin: Resource reference to the Azure origin resource. + :vartype azure_origin: ~azure.mgmt.cdn.models.ResourceReference + :ivar host_name: The address of the origin. Domain names, IPv4 addresses, and IPv6 addresses + are supported.This should be unique across all origins in an endpoint. + :vartype host_name: str + :ivar http_port: The value of the HTTP port. Must be between 1 and 65535. + :vartype http_port: int + :ivar https_port: The value of the HTTPS port. Must be between 1 and 65535. + :vartype https_port: int + :ivar origin_host_header: The host header value sent to the origin with each request. If you + leave this blank, the request hostname determines this value. Azure Front Door origins, such as + Web Apps, Blob Storage, and Cloud Services require this host header value to match the origin + hostname by default. This overrides the host header defined at Endpoint. + :vartype origin_host_header: str + :ivar priority: Priority of origin in given origin group for load balancing. Higher priorities + will not be used for load balancing if any lower priority origin is healthy.Must be between 1 + and 5. + :vartype priority: int + :ivar weight: Weight of the origin in given origin group for load balancing. Must be between 1 + and 1000. + :vartype weight: int + :ivar shared_private_link_resource: The properties of the private link resource for private + origin. + :vartype shared_private_link_resource: + ~azure.mgmt.cdn.models.SharedPrivateLinkResourceProperties + :ivar enabled_state: Whether to enable health probes to be made against backends defined under + backendPools. Health probes can only be disabled if there is a single enabled backend in single + enabled backend pool. Known values are: "Enabled" and "Disabled". + :vartype enabled_state: str or ~azure.mgmt.cdn.models.EnabledState + :ivar enforce_certificate_name_check: Whether to enable certificate name check at origin level. + :vartype enforce_certificate_name_check: bool + :ivar provisioning_state: Provisioning status. Known values are: "Succeeded", "Failed", + "Updating", "Deleting", and "Creating". + :vartype provisioning_state: str or ~azure.mgmt.cdn.models.AfdProvisioningState + :ivar deployment_status: Known values are: "NotStarted", "InProgress", "Succeeded", and + "Failed". + :vartype deployment_status: str or ~azure.mgmt.cdn.models.DeploymentStatus + """ + + origin_group_name: Optional[str] = rest_field(name="originGroupName", visibility=["read"]) + """The name of the origin group which contains this origin.""" + azure_origin: Optional["_models.ResourceReference"] = rest_field( + name="azureOrigin", visibility=["read", "create", "update", "delete", "query"] + ) + """Resource reference to the Azure origin resource.""" + host_name: Optional[str] = rest_field(name="hostName", visibility=["read", "create", "update", "delete", "query"]) + """The address of the origin. Domain names, IPv4 addresses, and IPv6 addresses are supported.This + should be unique across all origins in an endpoint.""" + http_port: Optional[int] = rest_field(name="httpPort", visibility=["read", "create", "update", "delete", "query"]) + """The value of the HTTP port. Must be between 1 and 65535.""" + https_port: Optional[int] = rest_field(name="httpsPort", visibility=["read", "create", "update", "delete", "query"]) + """The value of the HTTPS port. Must be between 1 and 65535.""" + origin_host_header: Optional[str] = rest_field( + name="originHostHeader", visibility=["read", "create", "update", "delete", "query"] + ) + """The host header value sent to the origin with each request. If you leave this blank, the + request hostname determines this value. Azure Front Door origins, such as Web Apps, Blob + Storage, and Cloud Services require this host header value to match the origin hostname by + default. This overrides the host header defined at Endpoint.""" + priority: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Priority of origin in given origin group for load balancing. Higher priorities will not be used + for load balancing if any lower priority origin is healthy.Must be between 1 and 5.""" + weight: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Weight of the origin in given origin group for load balancing. Must be between 1 and 1000.""" + shared_private_link_resource: Optional["_models.SharedPrivateLinkResourceProperties"] = rest_field( + name="sharedPrivateLinkResource", visibility=["read", "create", "update", "delete", "query"] + ) + """The properties of the private link resource for private origin.""" + enabled_state: Optional[Union[str, "_models.EnabledState"]] = rest_field( + name="enabledState", visibility=["read", "create", "update", "delete", "query"] + ) + """Whether to enable health probes to be made against backends defined under backendPools. Health + probes can only be disabled if there is a single enabled backend in single enabled backend + pool. Known values are: \"Enabled\" and \"Disabled\".""" + enforce_certificate_name_check: Optional[bool] = rest_field( + name="enforceCertificateNameCheck", visibility=["read", "create", "update", "delete", "query"] + ) + """Whether to enable certificate name check at origin level.""" + provisioning_state: Optional[Union[str, "_models.AfdProvisioningState"]] = rest_field( + name="provisioningState", visibility=["read"] + ) + """Provisioning status. Known values are: \"Succeeded\", \"Failed\", \"Updating\", \"Deleting\", + and \"Creating\".""" + deployment_status: Optional[Union[str, "_models.DeploymentStatus"]] = rest_field( + name="deploymentStatus", visibility=["read"] + ) + """Known values are: \"NotStarted\", \"InProgress\", \"Succeeded\", and \"Failed\".""" + + @overload + def __init__( + self, + *, + azure_origin: Optional["_models.ResourceReference"] = None, + host_name: Optional[str] = None, + http_port: Optional[int] = None, + https_port: Optional[int] = None, + origin_host_header: Optional[str] = None, + priority: Optional[int] = None, + weight: Optional[int] = None, + shared_private_link_resource: Optional["_models.SharedPrivateLinkResourceProperties"] = None, + enabled_state: Optional[Union[str, "_models.EnabledState"]] = None, + enforce_certificate_name_check: Optional[bool] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class AFDOriginUpdateParameters(_Model): + """AFDOrigin properties needed for origin update. + + :ivar properties: The JSON object that contains the properties of the origin. + :vartype properties: ~azure.mgmt.cdn.models.AFDOriginUpdatePropertiesParameters + """ + + properties: Optional["_models.AFDOriginUpdatePropertiesParameters"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The JSON object that contains the properties of the origin.""" + + __flattened_items = [ + "origin_group_name", + "azure_origin", + "host_name", + "http_port", + "https_port", + "origin_host_header", + "priority", + "weight", + "shared_private_link_resource", + "enabled_state", + "enforce_certificate_name_check", + ] + + @overload + def __init__( + self, + *, + properties: Optional["_models.AFDOriginUpdatePropertiesParameters"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class AFDOriginUpdatePropertiesParameters(_Model): + """The JSON object that contains the properties of the origin. + + :ivar origin_group_name: The name of the origin group which contains this origin. + :vartype origin_group_name: str + :ivar azure_origin: Resource reference to the Azure origin resource. + :vartype azure_origin: ~azure.mgmt.cdn.models.ResourceReference + :ivar host_name: The address of the origin. Domain names, IPv4 addresses, and IPv6 addresses + are supported.This should be unique across all origins in an endpoint. + :vartype host_name: str + :ivar http_port: The value of the HTTP port. Must be between 1 and 65535. + :vartype http_port: int + :ivar https_port: The value of the HTTPS port. Must be between 1 and 65535. + :vartype https_port: int + :ivar origin_host_header: The host header value sent to the origin with each request. If you + leave this blank, the request hostname determines this value. Azure Front Door origins, such as + Web Apps, Blob Storage, and Cloud Services require this host header value to match the origin + hostname by default. This overrides the host header defined at Endpoint. + :vartype origin_host_header: str + :ivar priority: Priority of origin in given origin group for load balancing. Higher priorities + will not be used for load balancing if any lower priority origin is healthy.Must be between 1 + and 5. + :vartype priority: int + :ivar weight: Weight of the origin in given origin group for load balancing. Must be between 1 + and 1000. + :vartype weight: int + :ivar shared_private_link_resource: The properties of the private link resource for private + origin. + :vartype shared_private_link_resource: + ~azure.mgmt.cdn.models.SharedPrivateLinkResourceProperties + :ivar enabled_state: Whether to enable health probes to be made against backends defined under + backendPools. Health probes can only be disabled if there is a single enabled backend in single + enabled backend pool. Known values are: "Enabled" and "Disabled". + :vartype enabled_state: str or ~azure.mgmt.cdn.models.EnabledState + :ivar enforce_certificate_name_check: Whether to enable certificate name check at origin level. + :vartype enforce_certificate_name_check: bool + """ + + origin_group_name: Optional[str] = rest_field(name="originGroupName", visibility=["read"]) + """The name of the origin group which contains this origin.""" + azure_origin: Optional["_models.ResourceReference"] = rest_field( + name="azureOrigin", visibility=["read", "create", "update", "delete", "query"] + ) + """Resource reference to the Azure origin resource.""" + host_name: Optional[str] = rest_field(name="hostName", visibility=["read", "create", "update", "delete", "query"]) + """The address of the origin. Domain names, IPv4 addresses, and IPv6 addresses are supported.This + should be unique across all origins in an endpoint.""" + http_port: Optional[int] = rest_field(name="httpPort", visibility=["read", "create", "update", "delete", "query"]) + """The value of the HTTP port. Must be between 1 and 65535.""" + https_port: Optional[int] = rest_field(name="httpsPort", visibility=["read", "create", "update", "delete", "query"]) + """The value of the HTTPS port. Must be between 1 and 65535.""" + origin_host_header: Optional[str] = rest_field( + name="originHostHeader", visibility=["read", "create", "update", "delete", "query"] + ) + """The host header value sent to the origin with each request. If you leave this blank, the + request hostname determines this value. Azure Front Door origins, such as Web Apps, Blob + Storage, and Cloud Services require this host header value to match the origin hostname by + default. This overrides the host header defined at Endpoint.""" + priority: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Priority of origin in given origin group for load balancing. Higher priorities will not be used + for load balancing if any lower priority origin is healthy.Must be between 1 and 5.""" + weight: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Weight of the origin in given origin group for load balancing. Must be between 1 and 1000.""" + shared_private_link_resource: Optional["_models.SharedPrivateLinkResourceProperties"] = rest_field( + name="sharedPrivateLinkResource", visibility=["read", "create", "update", "delete", "query"] + ) + """The properties of the private link resource for private origin.""" + enabled_state: Optional[Union[str, "_models.EnabledState"]] = rest_field( + name="enabledState", visibility=["read", "create", "update", "delete", "query"] + ) + """Whether to enable health probes to be made against backends defined under backendPools. Health + probes can only be disabled if there is a single enabled backend in single enabled backend + pool. Known values are: \"Enabled\" and \"Disabled\".""" + enforce_certificate_name_check: Optional[bool] = rest_field( + name="enforceCertificateNameCheck", visibility=["read", "create", "update", "delete", "query"] + ) + """Whether to enable certificate name check at origin level.""" + + @overload + def __init__( + self, + *, + azure_origin: Optional["_models.ResourceReference"] = None, + host_name: Optional[str] = None, + http_port: Optional[int] = None, + https_port: Optional[int] = None, + origin_host_header: Optional[str] = None, + priority: Optional[int] = None, + weight: Optional[int] = None, + shared_private_link_resource: Optional["_models.SharedPrivateLinkResourceProperties"] = None, + enabled_state: Optional[Union[str, "_models.EnabledState"]] = None, + enforce_certificate_name_check: Optional[bool] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class AfdPurgeParameters(_Model): + """Parameters required for content purge. + + :ivar content_paths: The path to the content to be purged. Can describe a file path or a wild + card directory. Required. + :vartype content_paths: list[str] + :ivar domains: List of domains. + :vartype domains: list[str] + """ + + content_paths: list[str] = rest_field( + name="contentPaths", visibility=["read", "create", "update", "delete", "query"] + ) + """The path to the content to be purged. Can describe a file path or a wild card directory. + Required.""" + domains: Optional[list[str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """List of domains.""" + + @overload + def __init__( + self, + *, + content_paths: list[str], + domains: Optional[list[str]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class AfdRouteCacheConfiguration(_Model): + """Caching settings for a caching-type route. To disable caching, do not provide a + cacheConfiguration object. + + :ivar query_string_caching_behavior: Defines how Frontdoor caches requests that include query + strings. You can ignore any query strings when caching, ignore specific query strings, cache + every request with a unique URL, or cache specific query strings. Known values are: + "IgnoreQueryString", "UseQueryString", "IgnoreSpecifiedQueryStrings", and + "IncludeSpecifiedQueryStrings". + :vartype query_string_caching_behavior: str or + ~azure.mgmt.cdn.models.AfdQueryStringCachingBehavior + :ivar query_parameters: query parameters to include or exclude (comma separated). + :vartype query_parameters: str + :ivar compression_settings: compression settings. + :vartype compression_settings: ~azure.mgmt.cdn.models.CompressionSettings + """ + + query_string_caching_behavior: Optional[Union[str, "_models.AfdQueryStringCachingBehavior"]] = rest_field( + name="queryStringCachingBehavior", visibility=["read", "create", "update", "delete", "query"] + ) + """Defines how Frontdoor caches requests that include query strings. You can ignore any query + strings when caching, ignore specific query strings, cache every request with a unique URL, or + cache specific query strings. Known values are: \"IgnoreQueryString\", \"UseQueryString\", + \"IgnoreSpecifiedQueryStrings\", and \"IncludeSpecifiedQueryStrings\".""" + query_parameters: Optional[str] = rest_field( + name="queryParameters", visibility=["read", "create", "update", "delete", "query"] + ) + """query parameters to include or exclude (comma separated).""" + compression_settings: Optional["_models.CompressionSettings"] = rest_field( + name="compressionSettings", visibility=["read", "create", "update", "delete", "query"] + ) + """compression settings.""" + + @overload + def __init__( + self, + *, + query_string_caching_behavior: Optional[Union[str, "_models.AfdQueryStringCachingBehavior"]] = None, + query_parameters: Optional[str] = None, + compression_settings: Optional["_models.CompressionSettings"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class AFDStateProperties(_Model): + """The tracking states for afd resources. + + :ivar provisioning_state: Provisioning status. Known values are: "Succeeded", "Failed", + "Updating", "Deleting", and "Creating". + :vartype provisioning_state: str or ~azure.mgmt.cdn.models.AfdProvisioningState + :ivar deployment_status: Known values are: "NotStarted", "InProgress", "Succeeded", and + "Failed". + :vartype deployment_status: str or ~azure.mgmt.cdn.models.DeploymentStatus + """ + + provisioning_state: Optional[Union[str, "_models.AfdProvisioningState"]] = rest_field( + name="provisioningState", visibility=["read"] + ) + """Provisioning status. Known values are: \"Succeeded\", \"Failed\", \"Updating\", \"Deleting\", + and \"Creating\".""" + deployment_status: Optional[Union[str, "_models.DeploymentStatus"]] = rest_field( + name="deploymentStatus", visibility=["read"] + ) + """Known values are: \"NotStarted\", \"InProgress\", \"Succeeded\", and \"Failed\".""" + + +class SecretParameters(_Model): + """The json object containing secret parameters. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + AzureFirstPartyManagedCertificateParameters, CustomerCertificateParameters, + ManagedCertificateParameters, UrlSigningKeyParameters + + :ivar type: The type of the secret resource. Required. Known values are: "UrlSigningKey", + "CustomerCertificate", "ManagedCertificate", and "AzureFirstPartyManagedCertificate". + :vartype type: str or ~azure.mgmt.cdn.models.SecretType + """ + + __mapping__: dict[str, _Model] = {} + type: str = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) + """The type of the secret resource. Required. Known values are: \"UrlSigningKey\", + \"CustomerCertificate\", \"ManagedCertificate\", and \"AzureFirstPartyManagedCertificate\".""" + + @overload + def __init__( + self, + *, + type: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class AzureFirstPartyManagedCertificateParameters( + SecretParameters, discriminator="AzureFirstPartyManagedCertificate" +): # pylint: disable=name-too-long + """Azure FirstParty Managed Certificate provided by other first party resource providers to enable + HTTPS. + + :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}. + :vartype secret_source: ~azure.mgmt.cdn.models.ResourceReference + :ivar subject: Subject name in the certificate. + :vartype subject: str + :ivar expiration_date: Certificate expiration date. + :vartype expiration_date: str + :ivar certificate_authority: Certificate issuing authority. + :vartype certificate_authority: str + :ivar subject_alternative_names: The list of SANs. + :vartype subject_alternative_names: list[str] + :ivar thumbprint: Certificate thumbprint. + :vartype thumbprint: str + :ivar type: The type of the secret resource. Required. AZURE_FIRST_PARTY_MANAGED_CERTIFICATE. + :vartype type: str or ~azure.mgmt.cdn.models.AZURE_FIRST_PARTY_MANAGED_CERTIFICATE + """ + + secret_source: Optional["_models.ResourceReference"] = rest_field(name="secretSource", visibility=["read"]) + """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}.""" + subject: Optional[str] = rest_field(visibility=["read"]) + """Subject name in the certificate.""" + expiration_date: Optional[str] = rest_field(name="expirationDate", visibility=["read"]) + """Certificate expiration date.""" + certificate_authority: Optional[str] = rest_field(name="certificateAuthority", visibility=["read"]) + """Certificate issuing authority.""" + subject_alternative_names: Optional[list[str]] = rest_field( + name="subjectAlternativeNames", visibility=["read", "create", "update", "delete", "query"] + ) + """The list of SANs.""" + thumbprint: Optional[str] = rest_field(visibility=["read"]) + """Certificate thumbprint.""" + type: Literal[SecretType.AZURE_FIRST_PARTY_MANAGED_CERTIFICATE] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """The type of the secret resource. Required. AZURE_FIRST_PARTY_MANAGED_CERTIFICATE.""" + + @overload + def __init__( + self, + *, + subject_alternative_names: Optional[list[str]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type = SecretType.AZURE_FIRST_PARTY_MANAGED_CERTIFICATE # type: ignore + + +class BatchRuleProperties(_Model): + """The JSON object that contains a rule with its name for batch mode operations. + + :ivar rule_name: Name of the rule. Required. + :vartype rule_name: str + :ivar rule_set_name: The name of the rule set containing the rule. + :vartype rule_set_name: str + :ivar order: The order in which the rules are applied for the endpoint. Possible values + {0,1,2,3,………}. A rule with a lesser order will be applied before a rule with a greater order. + Rule with order 0 is a special rule. It does not require any condition and actions listed in it + will always be applied. + :vartype order: int + :ivar conditions: A list of conditions that must be matched for the actions to be executed. + :vartype conditions: list[~azure.mgmt.cdn.models.DeliveryRuleCondition] + :ivar actions: A list of actions that are executed when all the conditions of a rule are + satisfied. + :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". + :vartype match_processing_behavior: str or ~azure.mgmt.cdn.models.MatchProcessingBehavior + """ + + rule_name: str = rest_field(name="ruleName", visibility=["read", "create"]) + """Name of the rule. Required.""" + rule_set_name: Optional[str] = rest_field(name="ruleSetName", visibility=["read"]) + """The name of the rule set containing the rule.""" + order: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The order in which the rules are applied for the endpoint. Possible values {0,1,2,3,………}. A + rule with a lesser order will be applied before a rule with a greater order. Rule with order 0 + is a special rule. It does not require any condition and actions listed in it will always be + applied.""" + conditions: Optional[list["_models.DeliveryRuleCondition"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """A list of conditions that must be matched for the actions to be executed.""" + actions: Optional[list["_models.DeliveryRuleAction"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """A list of actions that are executed when all the conditions of a rule are satisfied.""" + match_processing_behavior: Optional[Union[str, "_models.MatchProcessingBehavior"]] = rest_field( + name="matchProcessingBehavior", visibility=["read", "create", "update", "delete", "query"] + ) + """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\".""" + + @overload + def __init__( + self, + *, + rule_name: str, + order: Optional[int] = None, + conditions: Optional[list["_models.DeliveryRuleCondition"]] = None, + actions: Optional[list["_models.DeliveryRuleAction"]] = None, + match_processing_behavior: Optional[Union[str, "_models.MatchProcessingBehavior"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class CacheConfiguration(_Model): + """Caching settings for a caching-type route. To disable caching, do not provide a + cacheConfiguration object. + + :ivar query_string_caching_behavior: Defines how Frontdoor caches requests that include query + strings. You can ignore any query strings when caching, ignore specific query strings, cache + every request with a unique URL, or cache specific query strings. Known values are: + "IgnoreQueryString", "UseQueryString", "IgnoreSpecifiedQueryStrings", and + "IncludeSpecifiedQueryStrings". + :vartype query_string_caching_behavior: str or + ~azure.mgmt.cdn.models.RuleQueryStringCachingBehavior + :ivar query_parameters: query parameters to include or exclude (comma separated). + :vartype query_parameters: str + :ivar is_compression_enabled: Indicates whether content compression is enabled. If compression + is enabled, content will be served as compressed if user requests for a compressed version. + Content won't be compressed on AzureFrontDoor when requested content is smaller than 1 byte or + larger than 1 MB. Known values are: "Enabled" and "Disabled". + :vartype is_compression_enabled: str or ~azure.mgmt.cdn.models.RuleIsCompressionEnabled + :ivar cache_behavior: Caching behavior for the requests. Known values are: "HonorOrigin", + "OverrideAlways", and "OverrideIfOriginMissing". + :vartype cache_behavior: str or ~azure.mgmt.cdn.models.RuleCacheBehavior + :ivar cache_duration: The duration for which the content needs to be cached. Allowed format is + [d.]hh:mm:ss. + :vartype cache_duration: str + """ + + query_string_caching_behavior: Optional[Union[str, "_models.RuleQueryStringCachingBehavior"]] = rest_field( + name="queryStringCachingBehavior", visibility=["read", "create", "update", "delete", "query"] + ) + """Defines how Frontdoor caches requests that include query strings. You can ignore any query + strings when caching, ignore specific query strings, cache every request with a unique URL, or + cache specific query strings. Known values are: \"IgnoreQueryString\", \"UseQueryString\", + \"IgnoreSpecifiedQueryStrings\", and \"IncludeSpecifiedQueryStrings\".""" + query_parameters: Optional[str] = rest_field( + name="queryParameters", visibility=["read", "create", "update", "delete", "query"] + ) + """query parameters to include or exclude (comma separated).""" + is_compression_enabled: Optional[Union[str, "_models.RuleIsCompressionEnabled"]] = rest_field( + name="isCompressionEnabled", visibility=["read", "create", "update", "delete", "query"] + ) + """Indicates whether content compression is enabled. If compression is enabled, content will be + served as compressed if user requests for a compressed version. Content won't be compressed on + AzureFrontDoor when requested content is smaller than 1 byte or larger than 1 MB. Known values + are: \"Enabled\" and \"Disabled\".""" + cache_behavior: Optional[Union[str, "_models.RuleCacheBehavior"]] = rest_field( + name="cacheBehavior", visibility=["read", "create", "update", "delete", "query"] + ) + """Caching behavior for the requests. Known values are: \"HonorOrigin\", \"OverrideAlways\", and + \"OverrideIfOriginMissing\".""" + cache_duration: Optional[str] = rest_field( + name="cacheDuration", visibility=["read", "create", "update", "delete", "query"] + ) + """The duration for which the content needs to be cached. Allowed format is [d.]hh:mm:ss.""" + + @overload + def __init__( + self, + *, + query_string_caching_behavior: Optional[Union[str, "_models.RuleQueryStringCachingBehavior"]] = None, + query_parameters: Optional[str] = None, + is_compression_enabled: Optional[Union[str, "_models.RuleIsCompressionEnabled"]] = None, + cache_behavior: Optional[Union[str, "_models.RuleCacheBehavior"]] = None, + cache_duration: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class DeliveryRuleActionParameters(_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 + + :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 + """ + + __mapping__: dict[str, _Model] = {} + type_name: str = rest_discriminator(name="typeName", visibility=["read", "create", "update", "delete", "query"]) + """Required. Known values are: \"DeliveryRuleUrlRedirectActionParameters\", + \"DeliveryRuleUrlSigningActionParameters\", + \"DeliveryRuleOriginGroupOverrideActionParameters\", + \"DeliveryRuleUrlRewriteActionParameters\", \"DeliveryRuleHeaderActionParameters\", + \"DeliveryRuleCacheExpirationActionParameters\", + \"DeliveryRuleCacheKeyQueryStringBehaviorActionParameters\", and + \"DeliveryRuleRouteConfigurationOverrideActionParameters\".""" + + @overload + def __init__( + self, + *, + type_name: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class CacheExpirationActionParameters( + DeliveryRuleActionParameters, discriminator="DeliveryRuleCacheExpirationActionParameters" +): + """Defines the parameters for the cache expiration action. + + :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 + :ivar cache_type: The level at which the content needs to be cached. Required. "All" + :vartype cache_type: str or ~azure.mgmt.cdn.models.CacheType + :ivar cache_duration: The duration for which the content needs to be cached. Allowed format is + [d.]hh:mm:ss. + :vartype cache_duration: str + :ivar type_name: Required. DELIVERY_RULE_CACHE_EXPIRATION_ACTION_PARAMETERS. + :vartype type_name: str or + ~azure.mgmt.cdn.models.DELIVERY_RULE_CACHE_EXPIRATION_ACTION_PARAMETERS + """ + + cache_behavior: Union[str, "_models.CacheBehavior"] = rest_field( + name="cacheBehavior", visibility=["read", "create", "update", "delete", "query"] + ) + """Caching behavior for the requests. Required. Known values are: \"BypassCache\", \"Override\", + and \"SetIfMissing\".""" + cache_type: Union[str, "_models.CacheType"] = rest_field( + name="cacheType", visibility=["read", "create", "update", "delete", "query"] + ) + """The level at which the content needs to be cached. Required. \"All\"""" + cache_duration: Optional[str] = rest_field( + name="cacheDuration", visibility=["read", "create", "update", "delete", "query"] + ) + """The duration for which the content needs to be cached. Allowed format is [d.]hh:mm:ss.""" + type_name: Literal[DeliveryRuleActionParametersType.DELIVERY_RULE_CACHE_EXPIRATION_ACTION_PARAMETERS] = rest_discriminator(name="typeName", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Required. DELIVERY_RULE_CACHE_EXPIRATION_ACTION_PARAMETERS.""" + + @overload + def __init__( + self, + *, + cache_behavior: Union[str, "_models.CacheBehavior"], + cache_type: Union[str, "_models.CacheType"], + cache_duration: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type_name = DeliveryRuleActionParametersType.DELIVERY_RULE_CACHE_EXPIRATION_ACTION_PARAMETERS # type: ignore + + +class CacheKeyQueryStringActionParameters( + DeliveryRuleActionParameters, discriminator="DeliveryRuleCacheKeyQueryStringBehaviorActionParameters" +): + """Defines the parameters for the cache-key query string action. + + :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 + :ivar query_parameters: query parameters to include or exclude (comma separated). + :vartype query_parameters: str + :ivar type_name: Required. DELIVERY_RULE_CACHE_KEY_QUERY_STRING_BEHAVIOR_ACTION_PARAMETERS. + :vartype type_name: str or + ~azure.mgmt.cdn.models.DELIVERY_RULE_CACHE_KEY_QUERY_STRING_BEHAVIOR_ACTION_PARAMETERS + """ + + query_string_behavior: Union[str, "_models.QueryStringBehavior"] = rest_field( + name="queryStringBehavior", visibility=["read", "create", "update", "delete", "query"] + ) + """Caching behavior for the requests. Required. Known values are: \"Include\", \"IncludeAll\", + \"Exclude\", and \"ExcludeAll\".""" + query_parameters: Optional[str] = rest_field( + name="queryParameters", visibility=["read", "create", "update", "delete", "query"] + ) + """query parameters to include or exclude (comma separated).""" + type_name: Literal[DeliveryRuleActionParametersType.DELIVERY_RULE_CACHE_KEY_QUERY_STRING_BEHAVIOR_ACTION_PARAMETERS] = rest_discriminator(name="typeName", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Required. DELIVERY_RULE_CACHE_KEY_QUERY_STRING_BEHAVIOR_ACTION_PARAMETERS.""" + + @overload + def __init__( + self, + *, + query_string_behavior: Union[str, "_models.QueryStringBehavior"], + query_parameters: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type_name = DeliveryRuleActionParametersType.DELIVERY_RULE_CACHE_KEY_QUERY_STRING_BEHAVIOR_ACTION_PARAMETERS # type: ignore + + +class CanMigrateParameters(_Model): + """Request body for CanMigrate operation. + + :ivar classic_resource_reference: Resource reference of the classic cdn profile or classic + frontdoor that need to be migrated. Required. + :vartype classic_resource_reference: ~azure.mgmt.cdn.models.ResourceReference + """ + + classic_resource_reference: "_models.ResourceReference" = rest_field( + name="classicResourceReference", visibility=["read", "create", "update", "delete", "query"] + ) + """Resource reference of the classic cdn profile or classic frontdoor that need to be migrated. + Required.""" + + @overload + def __init__( + self, + *, + classic_resource_reference: "_models.ResourceReference", + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class CanMigrateProperties(_Model): + """CanMigrateProperties. + + :ivar can_migrate: Flag that says if the profile can be migrated. + :vartype can_migrate: bool + :ivar default_sku: Recommended sku for the migration. Known values are: + "Standard_AzureFrontDoor" and "Premium_AzureFrontDoor". + :vartype default_sku: str or ~azure.mgmt.cdn.models.CanMigrateDefaultSku + :ivar errors: + :vartype errors: list[~azure.mgmt.cdn.models.MigrationErrorType] + """ + + can_migrate: Optional[bool] = rest_field(name="canMigrate", visibility=["read"]) + """Flag that says if the profile can be migrated.""" + default_sku: Optional[Union[str, "_models.CanMigrateDefaultSku"]] = rest_field( + name="defaultSku", visibility=["read"] + ) + """Recommended sku for the migration. Known values are: \"Standard_AzureFrontDoor\" and + \"Premium_AzureFrontDoor\".""" + errors: Optional[list["_models.MigrationErrorType"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + + @overload + def __init__( + self, + *, + errors: Optional[list["_models.MigrationErrorType"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class CanMigrateResult(_Model): + """Result for canMigrate operation. + + :ivar id: Resource ID. + :vartype id: str + :ivar type: Resource type. + :vartype type: str + :ivar properties: + :vartype properties: ~azure.mgmt.cdn.models.CanMigrateProperties + """ + + id: Optional[str] = rest_field(visibility=["read"]) + """Resource ID.""" + type: Optional[str] = rest_field(visibility=["read"]) + """Resource type.""" + properties: Optional["_models.CanMigrateProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + + __flattened_items = ["can_migrate", "default_sku", "errors"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.CanMigrateProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class CertificateSourceParameters(_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 + + :ivar type_name: Required. Known values are: "CdnCertificateSourceParameters" and + "KeyVaultCertificateSourceParameters". + :vartype type_name: str or ~azure.mgmt.cdn.models.CertificateSourceParametersType + """ + + __mapping__: dict[str, _Model] = {} + type_name: str = rest_discriminator(name="typeName", visibility=["read", "create", "update", "delete", "query"]) + """Required. Known values are: \"CdnCertificateSourceParameters\" and + \"KeyVaultCertificateSourceParameters\".""" + + @overload + def __init__( + self, + *, + type_name: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class CdnCertificateSourceParameters(CertificateSourceParameters, discriminator="CdnCertificateSourceParameters"): + """Defines the parameters for using CDN managed certificate for securing custom domain. + + :ivar certificate_type: Type of certificate used. Required. Known values are: "Shared" and + "Dedicated". + :vartype certificate_type: str or ~azure.mgmt.cdn.models.CertificateType + :ivar type_name: Required. CDN_CERTIFICATE_SOURCE_PARAMETERS. + :vartype type_name: str or ~azure.mgmt.cdn.models.CDN_CERTIFICATE_SOURCE_PARAMETERS + """ + + certificate_type: Union[str, "_models.CertificateType"] = rest_field( + name="certificateType", visibility=["read", "create", "update", "delete", "query"] + ) + """Type of certificate used. Required. Known values are: \"Shared\" and \"Dedicated\".""" + type_name: Literal[CertificateSourceParametersType.CDN_CERTIFICATE_SOURCE_PARAMETERS] = rest_discriminator(name="typeName", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Required. CDN_CERTIFICATE_SOURCE_PARAMETERS.""" + + @overload + def __init__( + self, + *, + certificate_type: Union[str, "_models.CertificateType"], + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type_name = CertificateSourceParametersType.CDN_CERTIFICATE_SOURCE_PARAMETERS # type: ignore + + +class CdnEndpoint(_Model): + """Defines the ARM Resource ID for the linked endpoints. + + :ivar id: ARM Resource ID string. + :vartype id: str + """ + + id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """ARM Resource ID string.""" + + @overload + def __init__( + self, + *, + id: Optional[str] = None, # pylint: disable=redefined-builtin + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class CustomDomainHttpsParameters(_Model): + """The JSON object that contains the properties to secure a custom domain. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + UserManagedHttpsParameters, CdnManagedHttpsParameters + + :ivar certificate_source: Defines the source of the SSL certificate. Required. Known values + are: "AzureKeyVault" and "Cdn". + :vartype certificate_source: str or ~azure.mgmt.cdn.models.CertificateSource + :ivar protocol_type: Defines the TLS extension protocol that is used for secure delivery. + Required. Known values are: "ServerNameIndication" and "IPBased". + :vartype protocol_type: str or ~azure.mgmt.cdn.models.ProtocolType + :ivar minimum_tls_version: TLS protocol version that will be used for Https. Known values are: + "None", "TLS10", and "TLS12". + :vartype minimum_tls_version: str or ~azure.mgmt.cdn.models.MinimumTlsVersion + """ + + __mapping__: dict[str, _Model] = {} + certificate_source: str = rest_discriminator( + name="certificateSource", visibility=["read", "create", "update", "delete", "query"] + ) + """Defines the source of the SSL certificate. Required. Known values are: \"AzureKeyVault\" and + \"Cdn\".""" + protocol_type: Union[str, "_models.ProtocolType"] = rest_field( + name="protocolType", visibility=["read", "create", "update", "delete", "query"] + ) + """Defines the TLS extension protocol that is used for secure delivery. Required. Known values + are: \"ServerNameIndication\" and \"IPBased\".""" + minimum_tls_version: Optional[Union[str, "_models.MinimumTlsVersion"]] = rest_field( + name="minimumTlsVersion", visibility=["read", "create", "update", "delete", "query"] + ) + """TLS protocol version that will be used for Https. Known values are: \"None\", \"TLS10\", and + \"TLS12\".""" + + @overload + def __init__( + self, + *, + certificate_source: str, + protocol_type: Union[str, "_models.ProtocolType"], + minimum_tls_version: Optional[Union[str, "_models.MinimumTlsVersion"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class CdnManagedHttpsParameters(CustomDomainHttpsParameters, discriminator="Cdn"): + """Defines the certificate source parameters using CDN managed certificate for enabling SSL. + + :ivar protocol_type: Defines the TLS extension protocol that is used for secure delivery. + Required. Known values are: "ServerNameIndication" and "IPBased". + :vartype protocol_type: str or ~azure.mgmt.cdn.models.ProtocolType + :ivar minimum_tls_version: TLS protocol version that will be used for Https. Known values are: + "None", "TLS10", and "TLS12". + :vartype minimum_tls_version: str or ~azure.mgmt.cdn.models.MinimumTlsVersion + :ivar certificate_source_parameters: Defines the certificate source parameters using CDN + managed certificate for enabling SSL. Required. + :vartype certificate_source_parameters: ~azure.mgmt.cdn.models.CdnCertificateSourceParameters + :ivar certificate_source: Defines the source of the SSL certificate. Required. CDN. + :vartype certificate_source: str or ~azure.mgmt.cdn.models.CDN + """ + + certificate_source_parameters: "_models.CdnCertificateSourceParameters" = rest_field( + name="certificateSourceParameters", visibility=["read", "create", "update", "delete", "query"] + ) + """Defines the certificate source parameters using CDN managed certificate for enabling SSL. + Required.""" + certificate_source: Literal[CertificateSource.CDN] = rest_discriminator(name="certificateSource", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Defines the source of the SSL certificate. Required. CDN.""" + + @overload + def __init__( + self, + *, + protocol_type: Union[str, "_models.ProtocolType"], + certificate_source_parameters: "_models.CdnCertificateSourceParameters", + minimum_tls_version: Optional[Union[str, "_models.MinimumTlsVersion"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.certificate_source = CertificateSource.CDN # type: ignore + + +class CdnMigrationToAfdParameters(_Model): + """Request body for Migrate operation. + + :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] + """ + + sku: "_models.Sku" = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Sku for the migration. Required.""" + migration_endpoint_mappings: Optional[list["_models.MigrationEndpointMapping"]] = rest_field( + name="migrationEndpointMappings", visibility=["read", "create", "update", "delete", "query"] + ) + """A name map between classic CDN endpoints and AFD Premium/Standard endpoints.""" + + @overload + def __init__( + self, + *, + sku: "_models.Sku", + migration_endpoint_mappings: Optional[list["_models.MigrationEndpointMapping"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class CdnWebApplicationFirewallPolicy(TrackedResource): + """Defines web application firewall policy for Azure CDN. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.cdn.models.SystemData + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str + :ivar properties: Properties of the web application firewall policy. + :vartype properties: ~azure.mgmt.cdn.models.CdnWebApplicationFirewallPolicyProperties + :ivar etag: Gets a unique read-only string that changes whenever the resource is updated. + :vartype etag: str + :ivar sku: The pricing tier (defines a CDN provider, feature list and rate) of the + CdnWebApplicationFirewallPolicy. Required. + :vartype sku: ~azure.mgmt.cdn.models.Sku + """ + + properties: Optional["_models.CdnWebApplicationFirewallPolicyProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Properties of the web application firewall policy.""" + etag: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Gets a unique read-only string that changes whenever the resource is updated.""" + sku: "_models.Sku" = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The pricing tier (defines a CDN provider, feature list and rate) of the + CdnWebApplicationFirewallPolicy. Required.""" + + __flattened_items = [ + "policy_settings", + "rate_limit_rules", + "custom_rules", + "managed_rules", + "endpoint_links", + "extended_properties", + "provisioning_state", + "resource_state", + ] + + @overload + def __init__( + self, + *, + location: str, + sku: "_models.Sku", + tags: Optional[dict[str, str]] = None, + properties: Optional["_models.CdnWebApplicationFirewallPolicyProperties"] = None, + etag: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class CdnWebApplicationFirewallPolicyPatchParameters(_Model): # pylint: disable=name-too-long + """Properties required to update a CdnWebApplicationFirewallPolicy. + + :ivar tags: CdnWebApplicationFirewallPolicy tags. + :vartype tags: dict[str, str] + """ + + tags: Optional[dict[str, str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """CdnWebApplicationFirewallPolicy tags.""" + + @overload + def __init__( + self, + *, + tags: Optional[dict[str, str]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class CdnWebApplicationFirewallPolicyProperties(_Model): # pylint: disable=name-too-long + """Defines CDN web application firewall policy properties. + + :ivar policy_settings: Describes policySettings for policy. + :vartype policy_settings: ~azure.mgmt.cdn.models.PolicySettings + :ivar rate_limit_rules: Describes rate limit rules inside the policy. + :vartype rate_limit_rules: ~azure.mgmt.cdn.models.RateLimitRuleList + :ivar custom_rules: Describes custom rules inside the policy. + :vartype custom_rules: ~azure.mgmt.cdn.models.CustomRuleList + :ivar managed_rules: Describes managed rules inside the policy. + :vartype managed_rules: ~azure.mgmt.cdn.models.ManagedRuleSetList + :ivar endpoint_links: Describes Azure CDN endpoints associated with this Web Application + Firewall policy. + :vartype endpoint_links: list[~azure.mgmt.cdn.models.CdnEndpoint] + :ivar extended_properties: Key-Value pair representing additional properties for Web + Application Firewall policy. + :vartype extended_properties: dict[str, str] + :ivar provisioning_state: Provisioning state of the WebApplicationFirewallPolicy. Known values + are: "Creating", "Succeeded", and "Failed". + :vartype provisioning_state: str or ~azure.mgmt.cdn.models.ProvisioningState + :ivar resource_state: Resource status of the policy. Known values are: "Creating", "Enabling", + "Enabled", "Disabling", "Disabled", and "Deleting". + :vartype resource_state: str or ~azure.mgmt.cdn.models.PolicyResourceState + """ + + policy_settings: Optional["_models.PolicySettings"] = rest_field( + name="policySettings", visibility=["read", "create", "update", "delete", "query"] + ) + """Describes policySettings for policy.""" + rate_limit_rules: Optional["_models.RateLimitRuleList"] = rest_field( + name="rateLimitRules", visibility=["read", "create", "update", "delete", "query"] + ) + """Describes rate limit rules inside the policy.""" + custom_rules: Optional["_models.CustomRuleList"] = rest_field( + name="customRules", visibility=["read", "create", "update", "delete", "query"] + ) + """Describes custom rules inside the policy.""" + managed_rules: Optional["_models.ManagedRuleSetList"] = rest_field( + name="managedRules", visibility=["read", "create", "update", "delete", "query"] + ) + """Describes managed rules inside the policy.""" + endpoint_links: Optional[list["_models.CdnEndpoint"]] = rest_field(name="endpointLinks", visibility=["read"]) + """Describes Azure CDN endpoints associated with this Web Application Firewall policy.""" + extended_properties: Optional[dict[str, str]] = rest_field( + name="extendedProperties", visibility=["read", "create", "update", "delete", "query"] + ) + """Key-Value pair representing additional properties for Web Application Firewall policy.""" + provisioning_state: Optional[Union[str, "_models.ProvisioningState"]] = rest_field( + name="provisioningState", visibility=["read"] + ) + """Provisioning state of the WebApplicationFirewallPolicy. Known values are: \"Creating\", + \"Succeeded\", and \"Failed\".""" + resource_state: Optional[Union[str, "_models.PolicyResourceState"]] = rest_field( + name="resourceState", visibility=["read"] + ) + """Resource status of the policy. Known values are: \"Creating\", \"Enabling\", \"Enabled\", + \"Disabling\", \"Disabled\", and \"Deleting\".""" + + @overload + def __init__( + self, + *, + policy_settings: Optional["_models.PolicySettings"] = None, + rate_limit_rules: Optional["_models.RateLimitRuleList"] = None, + custom_rules: Optional["_models.CustomRuleList"] = None, + managed_rules: Optional["_models.ManagedRuleSetList"] = None, + extended_properties: Optional[dict[str, str]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class CheckEndpointNameAvailabilityInput(_Model): + """Input of CheckNameAvailability API. + + :ivar name: The resource name to validate. Required. + :vartype name: str + :ivar type: The type of the resource whose name is to be validated. Required. Known values are: + "Microsoft.Cdn/Profiles/Endpoints" and "Microsoft.Cdn/Profiles/AfdEndpoints". + :vartype type: str or ~azure.mgmt.cdn.models.ResourceType + :ivar auto_generated_domain_name_label_scope: Indicates the endpoint name reuse scope. The + default value is TenantReuse. Known values are: "TenantReuse", "SubscriptionReuse", + "ResourceGroupReuse", and "NoReuse". + :vartype auto_generated_domain_name_label_scope: str or + ~azure.mgmt.cdn.models.AutoGeneratedDomainNameLabelScope + """ + + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The resource name to validate. Required.""" + type: Union[str, "_models.ResourceType"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The type of the resource whose name is to be validated. Required. Known values are: + \"Microsoft.Cdn/Profiles/Endpoints\" and \"Microsoft.Cdn/Profiles/AfdEndpoints\".""" + auto_generated_domain_name_label_scope: Optional[Union[str, "_models.AutoGeneratedDomainNameLabelScope"]] = ( + rest_field(name="autoGeneratedDomainNameLabelScope", visibility=["read", "create", "update", "delete", "query"]) + ) + """Indicates the endpoint name reuse scope. The default value is TenantReuse. Known values are: + \"TenantReuse\", \"SubscriptionReuse\", \"ResourceGroupReuse\", and \"NoReuse\".""" + + @overload + def __init__( + self, + *, + name: str, + type: Union[str, "_models.ResourceType"], + auto_generated_domain_name_label_scope: Optional[ + Union[str, "_models.AutoGeneratedDomainNameLabelScope"] + ] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class CheckEndpointNameAvailabilityOutput(_Model): + """Output of check name availability API. + + :ivar name_available: Indicates whether the name is available. + :vartype name_available: bool + :ivar available_hostname: Returns the available hostname generated based on the + AutoGeneratedDomainNameLabelScope when the name is available, otherwise it returns empty + string. + :vartype available_hostname: str + :ivar reason: The reason why the name is not available. + :vartype reason: str + :ivar message: The detailed error message describing why the name is not available. + :vartype message: str + """ + + name_available: Optional[bool] = rest_field(name="nameAvailable", visibility=["read"]) + """Indicates whether the name is available.""" + available_hostname: Optional[str] = rest_field(name="availableHostname", visibility=["read"]) + """Returns the available hostname generated based on the AutoGeneratedDomainNameLabelScope when + the name is available, otherwise it returns empty string.""" + reason: Optional[str] = rest_field(visibility=["read"]) + """The reason why the name is not available.""" + message: Optional[str] = rest_field(visibility=["read"]) + """The detailed error message describing why the name is not available.""" + + +class CheckHostNameAvailabilityInput(_Model): + """Input of CheckHostNameAvailability API. + + :ivar host_name: The host name to validate. Required. + :vartype host_name: str + """ + + host_name: str = rest_field(name="hostName", visibility=["read", "create", "update", "delete", "query"]) + """The host name to validate. Required.""" + + @overload + def __init__( + self, + *, + host_name: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class CheckNameAvailabilityInput(_Model): + """Input of CheckNameAvailability API. + + :ivar name: The resource name to validate. Required. + :vartype name: str + :ivar type: The type of the resource whose name is to be validated. Required. Known values are: + "Microsoft.Cdn/Profiles/Endpoints" and "Microsoft.Cdn/Profiles/AfdEndpoints". + :vartype type: str or ~azure.mgmt.cdn.models.ResourceType + """ + + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The resource name to validate. Required.""" + type: Union[str, "_models.ResourceType"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The type of the resource whose name is to be validated. Required. Known values are: + \"Microsoft.Cdn/Profiles/Endpoints\" and \"Microsoft.Cdn/Profiles/AfdEndpoints\".""" + + @overload + def __init__( + self, + *, + name: str, + type: Union[str, "_models.ResourceType"], + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class CheckNameAvailabilityOutput(_Model): + """Output of check name availability API. + + :ivar name_available: Indicates whether the name is available. + :vartype name_available: bool + :ivar reason: The reason why the name is not available. + :vartype reason: str + :ivar message: The detailed error message describing why the name is not available. + :vartype message: str + """ + + name_available: Optional[bool] = rest_field(name="nameAvailable", visibility=["read"]) + """Indicates whether the name is available.""" + reason: Optional[str] = rest_field(visibility=["read"]) + """The reason why the name is not available.""" + message: Optional[str] = rest_field(visibility=["read"]) + """The detailed error message describing why the name is not available.""" + + +class CidrIpAddress(_Model): + """CIDR Ip address. + + :ivar base_ip_address: Ip address itself. + :vartype base_ip_address: str + :ivar prefix_length: The length of the prefix of the ip address. + :vartype prefix_length: int + """ + + base_ip_address: Optional[str] = rest_field( + name="baseIpAddress", visibility=["read", "create", "update", "delete", "query"] + ) + """Ip address itself.""" + prefix_length: Optional[int] = rest_field( + name="prefixLength", visibility=["read", "create", "update", "delete", "query"] + ) + """The length of the prefix of the ip address.""" + + @overload + def __init__( + self, + *, + base_ip_address: Optional[str] = None, + prefix_length: Optional[int] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class DeliveryRuleConditionParameters(_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 + + :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 + """ + + __mapping__: dict[str, _Model] = {} + type_name: str = rest_discriminator(name="typeName", visibility=["read", "create", "update", "delete", "query"]) + """Required. Known values are: \"DeliveryRuleRemoteAddressConditionParameters\", + \"DeliveryRuleRequestMethodConditionParameters\", + \"DeliveryRuleQueryStringConditionParameters\", \"DeliveryRulePostArgsConditionParameters\", + \"DeliveryRuleRequestUriConditionParameters\", + \"DeliveryRuleRequestHeaderConditionParameters\", + \"DeliveryRuleRequestBodyConditionParameters\", + \"DeliveryRuleRequestSchemeConditionParameters\", + \"DeliveryRuleUrlPathMatchConditionParameters\", + \"DeliveryRuleUrlFileExtensionMatchConditionParameters\", + \"DeliveryRuleUrlFilenameConditionParameters\", \"DeliveryRuleHttpVersionConditionParameters\", + \"DeliveryRuleCookiesConditionParameters\", \"DeliveryRuleIsDeviceConditionParameters\", + \"DeliveryRuleSocketAddrConditionParameters\", \"DeliveryRuleClientPortConditionParameters\", + \"DeliveryRuleServerPortConditionParameters\", \"DeliveryRuleHostNameConditionParameters\", and + \"DeliveryRuleSslProtocolConditionParameters\".""" + + @overload + def __init__( + self, + *, + type_name: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ClientPortMatchConditionParameters( + DeliveryRuleConditionParameters, discriminator="DeliveryRuleClientPortConditionParameters" +): + """Defines the parameters for ClientPort match conditions. + + :ivar operator: Describes operator to be matched. Required. Known values are: "Any", "Equal", + "Contains", "BeginsWith", "EndsWith", "LessThan", "LessThanOrEqual", "GreaterThan", + "GreaterThanOrEqual", and "RegEx". + :vartype operator: str or ~azure.mgmt.cdn.models.ClientPortOperator + :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] + :ivar transforms: List of transforms. + :vartype transforms: list[str or ~azure.mgmt.cdn.models.Transform] + :ivar type_name: Required. DELIVERY_RULE_CLIENT_PORT_CONDITION_PARAMETERS. + :vartype type_name: str or + ~azure.mgmt.cdn.models.DELIVERY_RULE_CLIENT_PORT_CONDITION_PARAMETERS + """ + + operator: Union[str, "_models.ClientPortOperator"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Describes operator to be matched. Required. Known values are: \"Any\", \"Equal\", \"Contains\", + \"BeginsWith\", \"EndsWith\", \"LessThan\", \"LessThanOrEqual\", \"GreaterThan\", + \"GreaterThanOrEqual\", and \"RegEx\".""" + negate_condition: Optional[bool] = rest_field( + name="negateCondition", visibility=["read", "create", "update", "delete", "query"] + ) + """Describes if this is negate condition or not.""" + match_values: Optional[list[str]] = rest_field( + name="matchValues", visibility=["read", "create", "update", "delete", "query"] + ) + """The match value for the condition of the delivery rule.""" + transforms: Optional[list[Union[str, "_models.Transform"]]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """List of transforms.""" + type_name: Literal[DeliveryRuleConditionParametersType.DELIVERY_RULE_CLIENT_PORT_CONDITION_PARAMETERS] = rest_discriminator(name="typeName", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Required. DELIVERY_RULE_CLIENT_PORT_CONDITION_PARAMETERS.""" + + @overload + def __init__( + self, + *, + operator: Union[str, "_models.ClientPortOperator"], + negate_condition: Optional[bool] = None, + match_values: Optional[list[str]] = None, + transforms: Optional[list[Union[str, "_models.Transform"]]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type_name = DeliveryRuleConditionParametersType.DELIVERY_RULE_CLIENT_PORT_CONDITION_PARAMETERS # type: ignore + + +class Components18OrqelSchemasWafmetricsresponsePropertiesSeriesItemsPropertiesDataItems( + _Model +): # pylint: disable=name-too-long + """Components18OrqelSchemasWafmetricsresponsePropertiesSeriesItemsPropertiesDataItems. + + :ivar date_time: + :vartype date_time: ~datetime.datetime + :ivar value: + :vartype value: float + """ + + date_time: Optional[datetime.datetime] = rest_field( + name="dateTime", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) + value: Optional[float] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + + @overload + def __init__( + self, + *, + date_time: Optional[datetime.datetime] = None, + value: Optional[float] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class Components1Gs0LlpSchemasMetricsresponsePropertiesSeriesItemsPropertiesDataItems( + _Model +): # pylint: disable=name-too-long + """Components1Gs0LlpSchemasMetricsresponsePropertiesSeriesItemsPropertiesDataItems. + + :ivar date_time: + :vartype date_time: ~datetime.datetime + :ivar value: + :vartype value: float + """ + + date_time: Optional[datetime.datetime] = rest_field( + name="dateTime", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) + value: Optional[float] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + + @overload + def __init__( + self, + *, + date_time: Optional[datetime.datetime] = None, + value: Optional[float] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ComponentsKpo1PjSchemasWafrankingsresponsePropertiesDataItemsPropertiesMetricsItems( + _Model +): # pylint: disable=name-too-long + """ComponentsKpo1PjSchemasWafrankingsresponsePropertiesDataItemsPropertiesMetricsItems. + + :ivar metric: + :vartype metric: str + :ivar value: + :vartype value: int + :ivar percentage: + :vartype percentage: float + """ + + metric: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + value: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + percentage: Optional[float] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + + @overload + def __init__( + self, + *, + metric: Optional[str] = None, + value: Optional[int] = None, + percentage: Optional[float] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class CompressionSettings(_Model): + """settings for compression. + + :ivar content_types_to_compress: List of content types on which compression applies. The value + should be a valid MIME type. + :vartype content_types_to_compress: list[str] + :ivar is_compression_enabled: Indicates whether content compression is enabled on + AzureFrontDoor. Default value is false. If compression is enabled, content will be served as + compressed if user requests for a compressed version. Content won't be compressed on + AzureFrontDoor when requested content is smaller than 1 byte or larger than 1 MB. + :vartype is_compression_enabled: bool + """ + + content_types_to_compress: Optional[list[str]] = rest_field( + name="contentTypesToCompress", visibility=["read", "create", "update", "delete", "query"] + ) + """List of content types on which compression applies. The value should be a valid MIME type.""" + is_compression_enabled: Optional[bool] = rest_field( + name="isCompressionEnabled", visibility=["read", "create", "update", "delete", "query"] + ) + """Indicates whether content compression is enabled on AzureFrontDoor. Default value is false. If + compression is enabled, content will be served as compressed if user requests for a compressed + version. Content won't be compressed on AzureFrontDoor when requested content is smaller than 1 + byte or larger than 1 MB.""" + + @overload + def __init__( + self, + *, + content_types_to_compress: Optional[list[str]] = None, + is_compression_enabled: Optional[bool] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ContinentsResponse(_Model): + """Continents Response. + + :ivar continents: + :vartype continents: list[~azure.mgmt.cdn.models.ContinentsResponseContinentsItem] + :ivar country_or_regions: + :vartype country_or_regions: + list[~azure.mgmt.cdn.models.ContinentsResponseCountryOrRegionsItem] + """ + + continents: Optional[list["_models.ContinentsResponseContinentsItem"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + country_or_regions: Optional[list["_models.ContinentsResponseCountryOrRegionsItem"]] = rest_field( + name="countryOrRegions", visibility=["read", "create", "update", "delete", "query"] + ) + + @overload + def __init__( + self, + *, + continents: Optional[list["_models.ContinentsResponseContinentsItem"]] = None, + country_or_regions: Optional[list["_models.ContinentsResponseCountryOrRegionsItem"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ContinentsResponseContinentsItem(_Model): + """ContinentsResponseContinentsItem. + + :ivar id: + :vartype id: str + """ + + id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + + @overload + def __init__( + self, + *, + id: Optional[str] = None, # pylint: disable=redefined-builtin + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ContinentsResponseCountryOrRegionsItem(_Model): + """ContinentsResponseCountryOrRegionsItem. + + :ivar id: + :vartype id: str + :ivar continent_id: + :vartype continent_id: str + """ + + id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + continent_id: Optional[str] = rest_field( + name="continentId", visibility=["read", "create", "update", "delete", "query"] + ) + + @overload + def __init__( + self, + *, + id: Optional[str] = None, # pylint: disable=redefined-builtin + continent_id: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class CookiesMatchConditionParameters( + DeliveryRuleConditionParameters, discriminator="DeliveryRuleCookiesConditionParameters" +): + """Defines the parameters for Cookies match conditions. + + :ivar selector: Name of Cookies to be matched. + :vartype selector: str + :ivar operator: Describes operator to be matched. Required. Known values are: "Any", "Equal", + "Contains", "BeginsWith", "EndsWith", "LessThan", "LessThanOrEqual", "GreaterThan", + "GreaterThanOrEqual", and "RegEx". + :vartype operator: str or ~azure.mgmt.cdn.models.CookiesOperator + :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] + :ivar transforms: List of transforms. + :vartype transforms: list[str or ~azure.mgmt.cdn.models.Transform] + :ivar type_name: Required. DELIVERY_RULE_COOKIES_CONDITION_PARAMETERS. + :vartype type_name: str or ~azure.mgmt.cdn.models.DELIVERY_RULE_COOKIES_CONDITION_PARAMETERS + """ + + selector: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Name of Cookies to be matched.""" + operator: Union[str, "_models.CookiesOperator"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Describes operator to be matched. Required. Known values are: \"Any\", \"Equal\", \"Contains\", + \"BeginsWith\", \"EndsWith\", \"LessThan\", \"LessThanOrEqual\", \"GreaterThan\", + \"GreaterThanOrEqual\", and \"RegEx\".""" + negate_condition: Optional[bool] = rest_field( + name="negateCondition", visibility=["read", "create", "update", "delete", "query"] + ) + """Describes if this is negate condition or not.""" + match_values: Optional[list[str]] = rest_field( + name="matchValues", visibility=["read", "create", "update", "delete", "query"] + ) + """The match value for the condition of the delivery rule.""" + transforms: Optional[list[Union[str, "_models.Transform"]]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """List of transforms.""" + type_name: Literal[DeliveryRuleConditionParametersType.DELIVERY_RULE_COOKIES_CONDITION_PARAMETERS] = rest_discriminator(name="typeName", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Required. DELIVERY_RULE_COOKIES_CONDITION_PARAMETERS.""" + + @overload + def __init__( + self, + *, + operator: Union[str, "_models.CookiesOperator"], + selector: Optional[str] = None, + negate_condition: Optional[bool] = None, + match_values: Optional[list[str]] = None, + transforms: Optional[list[Union[str, "_models.Transform"]]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type_name = DeliveryRuleConditionParametersType.DELIVERY_RULE_COOKIES_CONDITION_PARAMETERS # type: ignore + + +class CustomDomain(ProxyResource): + """Friendly domain name mapping to the endpoint hostname that the customer provides for branding + purposes, e.g. `www.contoso.com `_. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.cdn.models.SystemData + :ivar properties: The JSON object that contains the properties of the custom domain to create. + :vartype properties: ~azure.mgmt.cdn.models.CustomDomainProperties + """ + + properties: Optional["_models.CustomDomainProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The JSON object that contains the properties of the custom domain to create.""" + + __flattened_items = [ + "host_name", + "resource_state", + "custom_https_provisioning_state", + "custom_https_provisioning_substate", + "custom_https_parameters", + "validation_data", + "provisioning_state", + ] + + @overload + def __init__( + self, + *, + properties: Optional["_models.CustomDomainProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class CustomDomainParameters(_Model): + """The customDomain JSON object required for custom domain creation or update. + + :ivar properties: The JSON object that contains the properties of the custom domain to create. + :vartype properties: ~azure.mgmt.cdn.models.CustomDomainPropertiesParameters + """ + + properties: Optional["_models.CustomDomainPropertiesParameters"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The JSON object that contains the properties of the custom domain to create.""" + + __flattened_items = ["host_name"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.CustomDomainPropertiesParameters"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class CustomDomainProperties(_Model): + """The JSON object that contains the properties of the custom domain to create. + + :ivar host_name: The host name of the custom domain. Must be a domain name. Required. + :vartype host_name: str + :ivar resource_state: Resource status of the custom domain. Known values are: "Creating", + "Active", and "Deleting". + :vartype resource_state: str or ~azure.mgmt.cdn.models.CustomDomainResourceState + :ivar custom_https_provisioning_state: Provisioning status of the custom domain. Known values + are: "Enabling", "Enabled", "Disabling", "Disabled", and "Failed". + :vartype custom_https_provisioning_state: str or + ~azure.mgmt.cdn.models.CustomHttpsProvisioningState + :ivar custom_https_provisioning_substate: Provisioning substate shows the progress of custom + HTTPS enabling/disabling process step by step. Known values are: + "SubmittingDomainControlValidationRequest", "PendingDomainControlValidationREquestApproval", + "DomainControlValidationRequestApproved", "DomainControlValidationRequestRejected", + "DomainControlValidationRequestTimedOut", "IssuingCertificate", "DeployingCertificate", + "CertificateDeployed", "DeletingCertificate", and "CertificateDeleted". + :vartype custom_https_provisioning_substate: str or + ~azure.mgmt.cdn.models.CustomHttpsProvisioningSubstate + :ivar custom_https_parameters: Certificate parameters for securing custom HTTPS. + :vartype custom_https_parameters: ~azure.mgmt.cdn.models.CustomDomainHttpsParameters + :ivar validation_data: Special validation or data may be required when delivering CDN to some + regions due to local compliance reasons. E.g. ICP license number of a custom domain is required + to deliver content in China. + :vartype validation_data: str + :ivar provisioning_state: Provisioning status of Custom Https of the custom domain. Known + values are: "Enabling", "Enabled", "Disabling", "Disabled", and "Failed". + :vartype provisioning_state: str or ~azure.mgmt.cdn.models.CustomHttpsProvisioningState + """ + + host_name: str = rest_field(name="hostName", visibility=["read", "create", "update", "delete", "query"]) + """The host name of the custom domain. Must be a domain name. Required.""" + resource_state: Optional[Union[str, "_models.CustomDomainResourceState"]] = rest_field( + name="resourceState", visibility=["read"] + ) + """Resource status of the custom domain. Known values are: \"Creating\", \"Active\", and + \"Deleting\".""" + custom_https_provisioning_state: Optional[Union[str, "_models.CustomHttpsProvisioningState"]] = rest_field( + name="customHttpsProvisioningState", visibility=["read"] + ) + """Provisioning status of the custom domain. Known values are: \"Enabling\", \"Enabled\", + \"Disabling\", \"Disabled\", and \"Failed\".""" + custom_https_provisioning_substate: Optional[Union[str, "_models.CustomHttpsProvisioningSubstate"]] = rest_field( + name="customHttpsProvisioningSubstate", visibility=["read"] + ) + """Provisioning substate shows the progress of custom HTTPS enabling/disabling process step by + step. Known values are: \"SubmittingDomainControlValidationRequest\", + \"PendingDomainControlValidationREquestApproval\", \"DomainControlValidationRequestApproved\", + \"DomainControlValidationRequestRejected\", \"DomainControlValidationRequestTimedOut\", + \"IssuingCertificate\", \"DeployingCertificate\", \"CertificateDeployed\", + \"DeletingCertificate\", and \"CertificateDeleted\".""" + custom_https_parameters: Optional["_models.CustomDomainHttpsParameters"] = rest_field( + name="customHttpsParameters", visibility=["read", "create", "update", "delete", "query"] + ) + """Certificate parameters for securing custom HTTPS.""" + validation_data: Optional[str] = rest_field( + name="validationData", visibility=["read", "create", "update", "delete", "query"] + ) + """Special validation or data may be required when delivering CDN to some regions due to local + compliance reasons. E.g. ICP license number of a custom domain is required to deliver content + in China.""" + provisioning_state: Optional[Union[str, "_models.CustomHttpsProvisioningState"]] = rest_field( + name="provisioningState", visibility=["read"] + ) + """Provisioning status of Custom Https of the custom domain. Known values are: \"Enabling\", + \"Enabled\", \"Disabling\", \"Disabled\", and \"Failed\".""" + + @overload + def __init__( + self, + *, + host_name: str, + custom_https_parameters: Optional["_models.CustomDomainHttpsParameters"] = None, + validation_data: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class CustomDomainPropertiesParameters(_Model): + """The JSON object that contains the properties of the custom domain to create. + + :ivar host_name: The host name of the custom domain. Must be a domain name. Required. + :vartype host_name: str + """ + + host_name: str = rest_field(name="hostName", visibility=["read", "create", "update", "delete", "query"]) + """The host name of the custom domain. Must be a domain name. Required.""" + + @overload + def __init__( + self, + *, + host_name: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class CustomerCertificateParameters(SecretParameters, discriminator="CustomerCertificate"): + """Customer Certificate used for https. + + :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}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​. + Required. + :vartype secret_source: ~azure.mgmt.cdn.models.ResourceReference + :ivar secret_version: Version of the secret to be used. + :vartype secret_version: str + :ivar use_latest_version: Whether to use the latest version for the certificate. + :vartype use_latest_version: bool + :ivar subject: Subject name in the certificate. + :vartype subject: str + :ivar expiration_date: Certificate expiration date. + :vartype expiration_date: str + :ivar certificate_authority: Certificate issuing authority. + :vartype certificate_authority: str + :ivar subject_alternative_names: The list of SANs. + :vartype subject_alternative_names: list[str] + :ivar thumbprint: Certificate thumbprint. + :vartype thumbprint: str + :ivar type: The type of the secret resource. Required. CUSTOMER_CERTIFICATE. + :vartype type: str or ~azure.mgmt.cdn.models.CUSTOMER_CERTIFICATE + """ + + secret_source: "_models.ResourceReference" = rest_field( + name="secretSource", visibility=["read", "create", "update", "delete", "query"] + ) + """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}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​. + Required.""" + secret_version: Optional[str] = rest_field( + name="secretVersion", visibility=["read", "create", "update", "delete", "query"] + ) + """Version of the secret to be used.""" + use_latest_version: Optional[bool] = rest_field( + name="useLatestVersion", visibility=["read", "create", "update", "delete", "query"] + ) + """Whether to use the latest version for the certificate.""" + subject: Optional[str] = rest_field(visibility=["read"]) + """Subject name in the certificate.""" + expiration_date: Optional[str] = rest_field(name="expirationDate", visibility=["read"]) + """Certificate expiration date.""" + certificate_authority: Optional[str] = rest_field(name="certificateAuthority", visibility=["read"]) + """Certificate issuing authority.""" + subject_alternative_names: Optional[list[str]] = rest_field(name="subjectAlternativeNames", visibility=["read"]) + """The list of SANs.""" + thumbprint: Optional[str] = rest_field(visibility=["read"]) + """Certificate thumbprint.""" + type: Literal[SecretType.CUSTOMER_CERTIFICATE] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """The type of the secret resource. Required. CUSTOMER_CERTIFICATE.""" + + @overload + def __init__( + self, + *, + secret_source: "_models.ResourceReference", + secret_version: Optional[str] = None, + use_latest_version: Optional[bool] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type = SecretType.CUSTOMER_CERTIFICATE # type: ignore + + +class CustomRule(_Model): + """Defines the common attributes for a custom rule that can be included in a waf policy. + + :ivar name: Defines the name of the custom rule. Required. + :vartype name: str + :ivar enabled_state: Describes if the custom rule is in enabled or disabled state. Defaults to + Enabled if not specified. Known values are: "Disabled" and "Enabled". + :vartype enabled_state: str or ~azure.mgmt.cdn.models.CustomRuleEnabledState + :ivar priority: Defines in what order this rule be evaluated in the overall list of custom + rules. Required. + :vartype priority: int + :ivar match_conditions: List of match conditions. Required. + :vartype match_conditions: list[~azure.mgmt.cdn.models.MatchCondition] + :ivar action: Describes what action to be applied when rule matches. Required. Known values + are: "Allow", "Block", "Log", and "Redirect". + :vartype action: str or ~azure.mgmt.cdn.models.ActionType + """ + + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Defines the name of the custom rule. Required.""" + enabled_state: Optional[Union[str, "_models.CustomRuleEnabledState"]] = rest_field( + name="enabledState", visibility=["read", "create", "update", "delete", "query"] + ) + """Describes if the custom rule is in enabled or disabled state. Defaults to Enabled if not + specified. Known values are: \"Disabled\" and \"Enabled\".""" + priority: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Defines in what order this rule be evaluated in the overall list of custom rules. Required.""" + match_conditions: list["_models.MatchCondition"] = rest_field( + name="matchConditions", visibility=["read", "create", "update", "delete", "query"] + ) + """List of match conditions. Required.""" + action: Union[str, "_models.ActionType"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Describes what action to be applied when rule matches. Required. Known values are: \"Allow\", + \"Block\", \"Log\", and \"Redirect\".""" + + @overload + def __init__( + self, + *, + name: str, + priority: int, + match_conditions: list["_models.MatchCondition"], + action: Union[str, "_models.ActionType"], + enabled_state: Optional[Union[str, "_models.CustomRuleEnabledState"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class CustomRuleList(_Model): + """Defines contents of custom rules. + + :ivar rules: List of rules. + :vartype rules: list[~azure.mgmt.cdn.models.CustomRule] + """ + + rules: Optional[list["_models.CustomRule"]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """List of rules.""" + + @overload + def __init__( + self, + *, + rules: Optional[list["_models.CustomRule"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class DeepCreatedCustomDomain(_Model): + """Custom domains created on the CDN endpoint. + + :ivar name: Custom domain name. Required. + :vartype name: str + :ivar properties: Properties of the custom domain created on the CDN endpoint. + :vartype properties: ~azure.mgmt.cdn.models.DeepCreatedCustomDomainProperties + """ + + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Custom domain name. Required.""" + properties: Optional["_models.DeepCreatedCustomDomainProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Properties of the custom domain created on the CDN endpoint.""" + + __flattened_items = ["host_name", "validation_data"] + + @overload + def __init__( + self, + *, + name: str, + properties: Optional["_models.DeepCreatedCustomDomainProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class DeepCreatedCustomDomainProperties(_Model): + """Properties of the custom domain created on the CDN endpoint. + + :ivar host_name: The host name of the custom domain. Must be a domain name. Required. + :vartype host_name: str + :ivar validation_data: Special validation or data may be required when delivering CDN to some + regions due to local compliance reasons. E.g. ICP license number of a custom domain is required + to deliver content in China. + :vartype validation_data: str + """ + + host_name: str = rest_field(name="hostName", visibility=["read", "create", "update", "delete", "query"]) + """The host name of the custom domain. Must be a domain name. Required.""" + validation_data: Optional[str] = rest_field( + name="validationData", visibility=["read", "create", "update", "delete", "query"] + ) + """Special validation or data may be required when delivering CDN to some regions due to local + compliance reasons. E.g. ICP license number of a custom domain is required to deliver content + in China.""" + + @overload + def __init__( + self, + *, + host_name: str, + validation_data: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class DeepCreatedOrigin(_Model): + """The main origin of CDN content which is added when creating a CDN endpoint. + + :ivar name: Origin name which must be unique within the endpoint. Required. + :vartype name: str + :ivar properties: Properties of the origin created on the CDN endpoint. + :vartype properties: ~azure.mgmt.cdn.models.DeepCreatedOriginProperties + """ + + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Origin name which must be unique within the endpoint. Required.""" + properties: Optional["_models.DeepCreatedOriginProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Properties of the origin created on the CDN endpoint.""" + + __flattened_items = [ + "host_name", + "http_port", + "https_port", + "origin_host_header", + "priority", + "weight", + "enabled", + "private_link_alias", + "private_link_resource_id", + "private_link_location", + "private_link_approval_message", + "private_endpoint_status", + ] + + @overload + def __init__( + self, + *, + name: str, + properties: Optional["_models.DeepCreatedOriginProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class DeepCreatedOriginGroup(_Model): + """The origin group for CDN content which is added when creating a CDN endpoint. Traffic is sent + to the origins within the origin group based on origin health. + + :ivar name: Origin group name which must be unique within the endpoint. Required. + :vartype name: str + :ivar properties: Properties of the origin group created on the CDN endpoint. + :vartype properties: ~azure.mgmt.cdn.models.DeepCreatedOriginGroupProperties + """ + + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Origin group name which must be unique within the endpoint. Required.""" + properties: Optional["_models.DeepCreatedOriginGroupProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Properties of the origin group created on the CDN endpoint.""" + + __flattened_items = [ + "health_probe_settings", + "origins", + "traffic_restoration_time_to_healed_or_new_endpoints_in_minutes", + "response_based_origin_error_detection_settings", + ] + + @overload + def __init__( + self, + *, + name: str, + properties: Optional["_models.DeepCreatedOriginGroupProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class DeepCreatedOriginGroupProperties(_Model): + """Properties of the origin group created on the CDN endpoint. + + :ivar health_probe_settings: Health probe settings to the origin that is used to determine the + health of the origin. + :vartype health_probe_settings: ~azure.mgmt.cdn.models.HealthProbeParameters + :ivar origins: The source of the content being delivered via CDN within given origin group. + Required. + :vartype origins: list[~azure.mgmt.cdn.models.ResourceReference] + :ivar traffic_restoration_time_to_healed_or_new_endpoints_in_minutes: Time in minutes to shift + the traffic to the endpoint gradually when an unhealthy endpoint comes healthy or a new + endpoint is added. Default is 10 mins. This property is currently not supported. + :vartype traffic_restoration_time_to_healed_or_new_endpoints_in_minutes: int + :ivar response_based_origin_error_detection_settings: The JSON object that contains the + properties to determine origin health using real requests/responses.This property is currently + not supported. + :vartype response_based_origin_error_detection_settings: + ~azure.mgmt.cdn.models.ResponseBasedOriginErrorDetectionParameters + """ + + health_probe_settings: Optional["_models.HealthProbeParameters"] = rest_field( + name="healthProbeSettings", visibility=["read", "create", "update", "delete", "query"] + ) + """Health probe settings to the origin that is used to determine the health of the origin.""" + origins: list["_models.ResourceReference"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The source of the content being delivered via CDN within given origin group. Required.""" + traffic_restoration_time_to_healed_or_new_endpoints_in_minutes: Optional[int] = rest_field( + name="trafficRestorationTimeToHealedOrNewEndpointsInMinutes", + visibility=["read", "create", "update", "delete", "query"], + ) + """Time in minutes to shift the traffic to the endpoint gradually when an unhealthy endpoint comes + healthy or a new endpoint is added. Default is 10 mins. This property is currently not + supported.""" + response_based_origin_error_detection_settings: Optional["_models.ResponseBasedOriginErrorDetectionParameters"] = ( + rest_field( + name="responseBasedOriginErrorDetectionSettings", visibility=["read", "create", "update", "delete", "query"] + ) + ) + """The JSON object that contains the properties to determine origin health using real + requests/responses.This property is currently not supported.""" + + @overload + def __init__( + self, + *, + origins: list["_models.ResourceReference"], + health_probe_settings: Optional["_models.HealthProbeParameters"] = None, + traffic_restoration_time_to_healed_or_new_endpoints_in_minutes: Optional[int] = None, + response_based_origin_error_detection_settings: Optional[ + "_models.ResponseBasedOriginErrorDetectionParameters" + ] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class DeepCreatedOriginProperties(_Model): + """Properties of the origin created on the CDN endpoint. + + :ivar host_name: The address of the origin. It can be a domain name, IPv4 address, or IPv6 + address. This should be unique across all origins in an endpoint. Required. + :vartype host_name: str + :ivar http_port: The value of the HTTP port. Must be between 1 and 65535. + :vartype http_port: int + :ivar https_port: The value of the HTTPS port. Must be between 1 and 65535. + :vartype https_port: int + :ivar origin_host_header: The host header value sent to the origin with each request. If you + leave this blank, the request hostname determines this value. Azure CDN origins, such as Web + Apps, Blob Storage, and Cloud Services require this host header value to match the origin + hostname by default. + :vartype origin_host_header: str + :ivar priority: Priority of origin in given origin group for load balancing. Higher priorities + will not be used for load balancing if any lower priority origin is healthy.Must be between 1 + and 5. + :vartype priority: int + :ivar weight: Weight of the origin in given origin group for load balancing. Must be between 1 + and 1000. + :vartype weight: int + :ivar enabled: Origin is enabled for load balancing or not. By default, origin is always + enabled. + :vartype enabled: bool + :ivar private_link_alias: The Alias of the Private Link resource. Populating this optional + field indicates that this origin is 'Private'. + :vartype private_link_alias: str + :ivar private_link_resource_id: The Resource Id of the Private Link resource. Populating this + optional field indicates that this backend is 'Private'. + :vartype private_link_resource_id: str + :ivar private_link_location: The location of the Private Link resource. Required only if + 'privateLinkResourceId' is populated. + :vartype private_link_location: str + :ivar private_link_approval_message: A custom message to be included in the approval request to + connect to the Private Link. + :vartype private_link_approval_message: str + :ivar private_endpoint_status: The approval status for the connection to the Private Link. + Known values are: "Pending", "Approved", "Rejected", "Disconnected", and "Timeout". + :vartype private_endpoint_status: str or ~azure.mgmt.cdn.models.PrivateEndpointStatus + """ + + host_name: str = rest_field(name="hostName", visibility=["read", "create", "update", "delete", "query"]) + """The address of the origin. It can be a domain name, IPv4 address, or IPv6 address. This should + be unique across all origins in an endpoint. Required.""" + http_port: Optional[int] = rest_field(name="httpPort", visibility=["read", "create", "update", "delete", "query"]) + """The value of the HTTP port. Must be between 1 and 65535.""" + https_port: Optional[int] = rest_field(name="httpsPort", visibility=["read", "create", "update", "delete", "query"]) + """The value of the HTTPS port. Must be between 1 and 65535.""" + origin_host_header: Optional[str] = rest_field( + name="originHostHeader", visibility=["read", "create", "update", "delete", "query"] + ) + """The host header value sent to the origin with each request. If you leave this blank, the + request hostname determines this value. Azure CDN origins, such as Web Apps, Blob Storage, and + Cloud Services require this host header value to match the origin hostname by default.""" + priority: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Priority of origin in given origin group for load balancing. Higher priorities will not be used + for load balancing if any lower priority origin is healthy.Must be between 1 and 5.""" + weight: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Weight of the origin in given origin group for load balancing. Must be between 1 and 1000.""" + enabled: Optional[bool] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Origin is enabled for load balancing or not. By default, origin is always enabled.""" + private_link_alias: Optional[str] = rest_field( + name="privateLinkAlias", visibility=["read", "create", "update", "delete", "query"] + ) + """The Alias of the Private Link resource. Populating this optional field indicates that this + origin is 'Private'.""" + private_link_resource_id: Optional[str] = rest_field( + name="privateLinkResourceId", visibility=["read", "create", "update", "delete", "query"] + ) + """The Resource Id of the Private Link resource. Populating this optional field indicates that + this backend is 'Private'.""" + private_link_location: Optional[str] = rest_field( + name="privateLinkLocation", visibility=["read", "create", "update", "delete", "query"] + ) + """The location of the Private Link resource. Required only if 'privateLinkResourceId' is + populated.""" + private_link_approval_message: Optional[str] = rest_field( + name="privateLinkApprovalMessage", visibility=["read", "create", "update", "delete", "query"] + ) + """A custom message to be included in the approval request to connect to the Private Link.""" + private_endpoint_status: Optional[Union[str, "_models.PrivateEndpointStatus"]] = rest_field( + name="privateEndpointStatus", visibility=["read"] + ) + """The approval status for the connection to the Private Link. Known values are: \"Pending\", + \"Approved\", \"Rejected\", \"Disconnected\", and \"Timeout\".""" + + @overload + def __init__( + self, + *, + host_name: str, + http_port: Optional[int] = None, + https_port: Optional[int] = None, + origin_host_header: Optional[str] = None, + priority: Optional[int] = None, + weight: Optional[int] = None, + enabled: Optional[bool] = None, + private_link_alias: Optional[str] = None, + private_link_resource_id: Optional[str] = None, + private_link_location: Optional[str] = None, + private_link_approval_message: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class DeliveryRule(_Model): + """A rule that specifies a set of actions and conditions. + + :ivar name: Name of the rule. + :vartype name: str + :ivar order: The order in which the rules are applied for the endpoint. Possible values + {0,1,2,3,………}. A rule with a lesser order will be applied before a rule with a greater order. + Rule with order 0 is a special rule. It does not require any condition and actions listed in it + will always be applied. Required. + :vartype order: int + :ivar conditions: A list of conditions that must be matched for the actions to be executed. + :vartype conditions: list[~azure.mgmt.cdn.models.DeliveryRuleCondition] + :ivar actions: A list of actions that are executed when all the conditions of a rule are + satisfied. Required. + :vartype actions: list[~azure.mgmt.cdn.models.DeliveryRuleAction] + """ + + name: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Name of the rule.""" + order: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The order in which the rules are applied for the endpoint. Possible values {0,1,2,3,………}. A + rule with a lesser order will be applied before a rule with a greater order. Rule with order 0 + is a special rule. It does not require any condition and actions listed in it will always be + applied. Required.""" + conditions: Optional[list["_models.DeliveryRuleCondition"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """A list of conditions that must be matched for the actions to be executed.""" + actions: list["_models.DeliveryRuleAction"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """A list of actions that are executed when all the conditions of a rule are satisfied. Required.""" + + @overload + def __init__( + self, + *, + order: int, + actions: list["_models.DeliveryRuleAction"], + name: Optional[str] = None, + conditions: Optional[list["_models.DeliveryRuleCondition"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class DeliveryRuleAction(_Model): + """An action for the delivery rule. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + DeliveryRuleCacheExpirationAction, DeliveryRuleCacheKeyQueryStringAction, + DeliveryRuleRequestHeaderAction, DeliveryRuleResponseHeaderAction, OriginGroupOverrideAction, + DeliveryRuleRouteConfigurationOverrideAction, UrlRedirectAction, UrlRewriteAction, + UrlSigningAction + + :ivar name: The name of the action for the delivery rule. Required. Known values are: + "CacheExpiration", "CacheKeyQueryString", "ModifyRequestHeader", "ModifyResponseHeader", + "UrlRedirect", "UrlRewrite", "UrlSigning", "OriginGroupOverride", and + "RouteConfigurationOverride". + :vartype name: str or ~azure.mgmt.cdn.models.DeliveryRuleActionName + """ + + __mapping__: dict[str, _Model] = {} + name: str = rest_discriminator(name="name", visibility=["read", "create", "update", "delete", "query"]) + """The name of the action for the delivery rule. Required. Known values are: \"CacheExpiration\", + \"CacheKeyQueryString\", \"ModifyRequestHeader\", \"ModifyResponseHeader\", \"UrlRedirect\", + \"UrlRewrite\", \"UrlSigning\", \"OriginGroupOverride\", and \"RouteConfigurationOverride\".""" + + @overload + def __init__( + self, + *, + name: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class DeliveryRuleCacheExpirationAction(DeliveryRuleAction, discriminator="CacheExpiration"): + """Defines the cache expiration action for the delivery rule. + + :ivar parameters: Defines the parameters for the action. Required. + :vartype parameters: ~azure.mgmt.cdn.models.CacheExpirationActionParameters + :ivar name: The name of the action for the delivery rule. Required. CACHE_EXPIRATION. + :vartype name: str or ~azure.mgmt.cdn.models.CACHE_EXPIRATION + """ + + parameters: "_models.CacheExpirationActionParameters" = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Defines the parameters for the action. Required.""" + name: Literal[DeliveryRuleActionName.CACHE_EXPIRATION] = rest_discriminator(name="name", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """The name of the action for the delivery rule. Required. CACHE_EXPIRATION.""" + + @overload + def __init__( + self, + *, + parameters: "_models.CacheExpirationActionParameters", + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.name = DeliveryRuleActionName.CACHE_EXPIRATION # type: ignore + + +class DeliveryRuleCacheKeyQueryStringAction(DeliveryRuleAction, discriminator="CacheKeyQueryString"): + """Defines the cache-key query string action for the delivery rule. + + :ivar parameters: Defines the parameters for the action. Required. + :vartype parameters: ~azure.mgmt.cdn.models.CacheKeyQueryStringActionParameters + :ivar name: The name of the action for the delivery rule. Required. CACHE_KEY_QUERY_STRING. + :vartype name: str or ~azure.mgmt.cdn.models.CACHE_KEY_QUERY_STRING + """ + + parameters: "_models.CacheKeyQueryStringActionParameters" = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Defines the parameters for the action. Required.""" + name: Literal[DeliveryRuleActionName.CACHE_KEY_QUERY_STRING] = rest_discriminator(name="name", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """The name of the action for the delivery rule. Required. CACHE_KEY_QUERY_STRING.""" + + @overload + def __init__( + self, + *, + parameters: "_models.CacheKeyQueryStringActionParameters", + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.name = DeliveryRuleActionName.CACHE_KEY_QUERY_STRING # type: ignore + + +class DeliveryRuleCondition(_Model): + """A condition for the delivery rule. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + DeliveryRuleClientPortCondition, DeliveryRuleCookiesCondition, DeliveryRuleHostNameCondition, + DeliveryRuleHttpVersionCondition, DeliveryRuleIsDeviceCondition, DeliveryRulePostArgsCondition, + DeliveryRuleQueryStringCondition, DeliveryRuleRemoteAddressCondition, + DeliveryRuleRequestBodyCondition, DeliveryRuleRequestHeaderCondition, + DeliveryRuleRequestMethodCondition, DeliveryRuleRequestSchemeCondition, + DeliveryRuleRequestUriCondition, DeliveryRuleServerPortCondition, + DeliveryRuleSocketAddrCondition, DeliveryRuleSslProtocolCondition, + DeliveryRuleUrlFileExtensionCondition, DeliveryRuleUrlFileNameCondition, + DeliveryRuleUrlPathCondition + + :ivar name: The name of the condition for the delivery rule. Required. Known values are: + "RemoteAddress", "RequestMethod", "QueryString", "PostArgs", "RequestUri", "RequestHeader", + "RequestBody", "RequestScheme", "UrlPath", "UrlFileExtension", "UrlFileName", "HttpVersion", + "Cookies", "IsDevice", "SocketAddr", "ClientPort", "ServerPort", "HostName", and "SslProtocol". + :vartype name: str or ~azure.mgmt.cdn.models.MatchVariable + """ + + __mapping__: dict[str, _Model] = {} + name: str = rest_discriminator(name="name", visibility=["read", "create", "update", "delete", "query"]) + """The name of the condition for the delivery rule. Required. Known values are: \"RemoteAddress\", + \"RequestMethod\", \"QueryString\", \"PostArgs\", \"RequestUri\", \"RequestHeader\", + \"RequestBody\", \"RequestScheme\", \"UrlPath\", \"UrlFileExtension\", \"UrlFileName\", + \"HttpVersion\", \"Cookies\", \"IsDevice\", \"SocketAddr\", \"ClientPort\", \"ServerPort\", + \"HostName\", and \"SslProtocol\".""" + + @overload + def __init__( + self, + *, + name: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class DeliveryRuleClientPortCondition(DeliveryRuleCondition, discriminator="ClientPort"): + """Defines the ClientPort condition for the delivery rule. + + :ivar parameters: Defines the parameters for the condition. Required. + :vartype parameters: ~azure.mgmt.cdn.models.ClientPortMatchConditionParameters + :ivar name: The name of the condition for the delivery rule. Required. CLIENT_PORT. + :vartype name: str or ~azure.mgmt.cdn.models.CLIENT_PORT + """ + + parameters: "_models.ClientPortMatchConditionParameters" = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Defines the parameters for the condition. Required.""" + name: Literal[MatchVariable.CLIENT_PORT] = rest_discriminator(name="name", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """The name of the condition for the delivery rule. Required. CLIENT_PORT.""" + + @overload + def __init__( + self, + *, + parameters: "_models.ClientPortMatchConditionParameters", + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.name = MatchVariable.CLIENT_PORT # type: ignore + + +class DeliveryRuleCookiesCondition(DeliveryRuleCondition, discriminator="Cookies"): + """Defines the Cookies condition for the delivery rule. + + :ivar parameters: Defines the parameters for the condition. Required. + :vartype parameters: ~azure.mgmt.cdn.models.CookiesMatchConditionParameters + :ivar name: The name of the condition for the delivery rule. Required. COOKIES. + :vartype name: str or ~azure.mgmt.cdn.models.COOKIES + """ + + parameters: "_models.CookiesMatchConditionParameters" = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Defines the parameters for the condition. Required.""" + name: Literal[MatchVariable.COOKIES] = rest_discriminator(name="name", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """The name of the condition for the delivery rule. Required. COOKIES.""" + + @overload + def __init__( + self, + *, + parameters: "_models.CookiesMatchConditionParameters", + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.name = MatchVariable.COOKIES # type: ignore + + +class DeliveryRuleHostNameCondition(DeliveryRuleCondition, discriminator="HostName"): + """Defines the HostName condition for the delivery rule. + + :ivar parameters: Defines the parameters for the condition. Required. + :vartype parameters: ~azure.mgmt.cdn.models.HostNameMatchConditionParameters + :ivar name: The name of the condition for the delivery rule. Required. HOST_NAME. + :vartype name: str or ~azure.mgmt.cdn.models.HOST_NAME + """ + + parameters: "_models.HostNameMatchConditionParameters" = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Defines the parameters for the condition. Required.""" + name: Literal[MatchVariable.HOST_NAME] = rest_discriminator(name="name", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """The name of the condition for the delivery rule. Required. HOST_NAME.""" + + @overload + def __init__( + self, + *, + parameters: "_models.HostNameMatchConditionParameters", + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.name = MatchVariable.HOST_NAME # type: ignore + + +class DeliveryRuleHttpVersionCondition(DeliveryRuleCondition, discriminator="HttpVersion"): + """Defines the HttpVersion condition for the delivery rule. + + :ivar parameters: Defines the parameters for the condition. Required. + :vartype parameters: ~azure.mgmt.cdn.models.HttpVersionMatchConditionParameters + :ivar name: The name of the condition for the delivery rule. Required. HTTP_VERSION. + :vartype name: str or ~azure.mgmt.cdn.models.HTTP_VERSION + """ + + parameters: "_models.HttpVersionMatchConditionParameters" = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Defines the parameters for the condition. Required.""" + name: Literal[MatchVariable.HTTP_VERSION] = rest_discriminator(name="name", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """The name of the condition for the delivery rule. Required. HTTP_VERSION.""" + + @overload + def __init__( + self, + *, + parameters: "_models.HttpVersionMatchConditionParameters", + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.name = MatchVariable.HTTP_VERSION # type: ignore + + +class DeliveryRuleIsDeviceCondition(DeliveryRuleCondition, discriminator="IsDevice"): + """Defines the IsDevice condition for the delivery rule. + + :ivar parameters: Defines the parameters for the condition. Required. + :vartype parameters: ~azure.mgmt.cdn.models.IsDeviceMatchConditionParameters + :ivar name: The name of the condition for the delivery rule. Required. IS_DEVICE. + :vartype name: str or ~azure.mgmt.cdn.models.IS_DEVICE + """ + + parameters: "_models.IsDeviceMatchConditionParameters" = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Defines the parameters for the condition. Required.""" + name: Literal[MatchVariable.IS_DEVICE] = rest_discriminator(name="name", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """The name of the condition for the delivery rule. Required. IS_DEVICE.""" + + @overload + def __init__( + self, + *, + parameters: "_models.IsDeviceMatchConditionParameters", + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.name = MatchVariable.IS_DEVICE # type: ignore + + +class DeliveryRulePostArgsCondition(DeliveryRuleCondition, discriminator="PostArgs"): + """Defines the PostArgs condition for the delivery rule. + + :ivar parameters: Defines the parameters for the condition. Required. + :vartype parameters: ~azure.mgmt.cdn.models.PostArgsMatchConditionParameters + :ivar name: The name of the condition for the delivery rule. Required. POST_ARGS. + :vartype name: str or ~azure.mgmt.cdn.models.POST_ARGS + """ + + parameters: "_models.PostArgsMatchConditionParameters" = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Defines the parameters for the condition. Required.""" + name: Literal[MatchVariable.POST_ARGS] = rest_discriminator(name="name", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """The name of the condition for the delivery rule. Required. POST_ARGS.""" + + @overload + def __init__( + self, + *, + parameters: "_models.PostArgsMatchConditionParameters", + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.name = MatchVariable.POST_ARGS # type: ignore + + +class DeliveryRuleQueryStringCondition(DeliveryRuleCondition, discriminator="QueryString"): + """Defines the QueryString condition for the delivery rule. + + :ivar parameters: Defines the parameters for the condition. Required. + :vartype parameters: ~azure.mgmt.cdn.models.QueryStringMatchConditionParameters + :ivar name: The name of the condition for the delivery rule. Required. QUERY_STRING. + :vartype name: str or ~azure.mgmt.cdn.models.QUERY_STRING + """ + + parameters: "_models.QueryStringMatchConditionParameters" = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Defines the parameters for the condition. Required.""" + name: Literal[MatchVariable.QUERY_STRING] = rest_discriminator(name="name", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """The name of the condition for the delivery rule. Required. QUERY_STRING.""" + + @overload + def __init__( + self, + *, + parameters: "_models.QueryStringMatchConditionParameters", + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.name = MatchVariable.QUERY_STRING # type: ignore + + +class DeliveryRuleRemoteAddressCondition(DeliveryRuleCondition, discriminator="RemoteAddress"): + """Defines the RemoteAddress condition for the delivery rule. + + :ivar parameters: Defines the parameters for the condition. Required. + :vartype parameters: ~azure.mgmt.cdn.models.RemoteAddressMatchConditionParameters + :ivar name: The name of the condition for the delivery rule. Required. REMOTE_ADDRESS. + :vartype name: str or ~azure.mgmt.cdn.models.REMOTE_ADDRESS + """ + + parameters: "_models.RemoteAddressMatchConditionParameters" = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Defines the parameters for the condition. Required.""" + name: Literal[MatchVariable.REMOTE_ADDRESS] = rest_discriminator(name="name", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """The name of the condition for the delivery rule. Required. REMOTE_ADDRESS.""" + + @overload + def __init__( + self, + *, + parameters: "_models.RemoteAddressMatchConditionParameters", + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.name = MatchVariable.REMOTE_ADDRESS # type: ignore + + +class DeliveryRuleRequestBodyCondition(DeliveryRuleCondition, discriminator="RequestBody"): + """Defines the RequestBody condition for the delivery rule. + + :ivar parameters: Defines the parameters for the condition. Required. + :vartype parameters: ~azure.mgmt.cdn.models.RequestBodyMatchConditionParameters + :ivar name: The name of the condition for the delivery rule. Required. REQUEST_BODY. + :vartype name: str or ~azure.mgmt.cdn.models.REQUEST_BODY + """ + + parameters: "_models.RequestBodyMatchConditionParameters" = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Defines the parameters for the condition. Required.""" + name: Literal[MatchVariable.REQUEST_BODY] = rest_discriminator(name="name", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """The name of the condition for the delivery rule. Required. REQUEST_BODY.""" + + @overload + def __init__( + self, + *, + parameters: "_models.RequestBodyMatchConditionParameters", + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.name = MatchVariable.REQUEST_BODY # type: ignore + + +class DeliveryRuleRequestHeaderAction(DeliveryRuleAction, discriminator="ModifyRequestHeader"): + """Defines the request header action for the delivery rule. + + :ivar parameters: Defines the parameters for the action. Required. + :vartype parameters: ~azure.mgmt.cdn.models.HeaderActionParameters + :ivar name: The name of the action for the delivery rule. Required. MODIFY_REQUEST_HEADER. + :vartype name: str or ~azure.mgmt.cdn.models.MODIFY_REQUEST_HEADER + """ + + parameters: "_models.HeaderActionParameters" = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Defines the parameters for the action. Required.""" + name: Literal[DeliveryRuleActionName.MODIFY_REQUEST_HEADER] = rest_discriminator(name="name", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """The name of the action for the delivery rule. Required. MODIFY_REQUEST_HEADER.""" + + @overload + def __init__( + self, + *, + parameters: "_models.HeaderActionParameters", + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.name = DeliveryRuleActionName.MODIFY_REQUEST_HEADER # type: ignore + + +class DeliveryRuleRequestHeaderCondition(DeliveryRuleCondition, discriminator="RequestHeader"): + """Defines the RequestHeader condition for the delivery rule. + + :ivar parameters: Defines the parameters for the condition. Required. + :vartype parameters: ~azure.mgmt.cdn.models.RequestHeaderMatchConditionParameters + :ivar name: The name of the condition for the delivery rule. Required. REQUEST_HEADER. + :vartype name: str or ~azure.mgmt.cdn.models.REQUEST_HEADER + """ + + parameters: "_models.RequestHeaderMatchConditionParameters" = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Defines the parameters for the condition. Required.""" + name: Literal[MatchVariable.REQUEST_HEADER] = rest_discriminator(name="name", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """The name of the condition for the delivery rule. Required. REQUEST_HEADER.""" + + @overload + def __init__( + self, + *, + parameters: "_models.RequestHeaderMatchConditionParameters", + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.name = MatchVariable.REQUEST_HEADER # type: ignore + + +class DeliveryRuleRequestMethodCondition(DeliveryRuleCondition, discriminator="RequestMethod"): + """Defines the RequestMethod condition for the delivery rule. + + :ivar parameters: Defines the parameters for the condition. Required. + :vartype parameters: ~azure.mgmt.cdn.models.RequestMethodMatchConditionParameters + :ivar name: The name of the condition for the delivery rule. Required. REQUEST_METHOD. + :vartype name: str or ~azure.mgmt.cdn.models.REQUEST_METHOD + """ + + parameters: "_models.RequestMethodMatchConditionParameters" = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Defines the parameters for the condition. Required.""" + name: Literal[MatchVariable.REQUEST_METHOD] = rest_discriminator(name="name", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """The name of the condition for the delivery rule. Required. REQUEST_METHOD.""" + + @overload + def __init__( + self, + *, + parameters: "_models.RequestMethodMatchConditionParameters", + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.name = MatchVariable.REQUEST_METHOD # type: ignore + + +class DeliveryRuleRequestSchemeCondition(DeliveryRuleCondition, discriminator="RequestScheme"): + """Defines the RequestScheme condition for the delivery rule. + + :ivar parameters: Defines the parameters for the condition. Required. + :vartype parameters: ~azure.mgmt.cdn.models.RequestSchemeMatchConditionParameters + :ivar name: The name of the condition for the delivery rule. Required. REQUEST_SCHEME. + :vartype name: str or ~azure.mgmt.cdn.models.REQUEST_SCHEME + """ + + parameters: "_models.RequestSchemeMatchConditionParameters" = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Defines the parameters for the condition. Required.""" + name: Literal[MatchVariable.REQUEST_SCHEME] = rest_discriminator(name="name", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """The name of the condition for the delivery rule. Required. REQUEST_SCHEME.""" + + @overload + def __init__( + self, + *, + parameters: "_models.RequestSchemeMatchConditionParameters", + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.name = MatchVariable.REQUEST_SCHEME # type: ignore + + +class DeliveryRuleRequestUriCondition(DeliveryRuleCondition, discriminator="RequestUri"): + """Defines the RequestUri condition for the delivery rule. + + :ivar parameters: Defines the parameters for the condition. Required. + :vartype parameters: ~azure.mgmt.cdn.models.RequestUriMatchConditionParameters + :ivar name: The name of the condition for the delivery rule. Required. REQUEST_URI. + :vartype name: str or ~azure.mgmt.cdn.models.REQUEST_URI + """ + + parameters: "_models.RequestUriMatchConditionParameters" = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Defines the parameters for the condition. Required.""" + name: Literal[MatchVariable.REQUEST_URI] = rest_discriminator(name="name", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """The name of the condition for the delivery rule. Required. REQUEST_URI.""" + + @overload + def __init__( + self, + *, + parameters: "_models.RequestUriMatchConditionParameters", + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.name = MatchVariable.REQUEST_URI # type: ignore + + +class DeliveryRuleResponseHeaderAction(DeliveryRuleAction, discriminator="ModifyResponseHeader"): + """Defines the response header action for the delivery rule. + + :ivar parameters: Defines the parameters for the action. Required. + :vartype parameters: ~azure.mgmt.cdn.models.HeaderActionParameters + :ivar name: The name of the action for the delivery rule. Required. MODIFY_RESPONSE_HEADER. + :vartype name: str or ~azure.mgmt.cdn.models.MODIFY_RESPONSE_HEADER + """ + + parameters: "_models.HeaderActionParameters" = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Defines the parameters for the action. Required.""" + name: Literal[DeliveryRuleActionName.MODIFY_RESPONSE_HEADER] = rest_discriminator(name="name", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """The name of the action for the delivery rule. Required. MODIFY_RESPONSE_HEADER.""" + + @overload + def __init__( + self, + *, + parameters: "_models.HeaderActionParameters", + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.name = DeliveryRuleActionName.MODIFY_RESPONSE_HEADER # type: ignore + + +class DeliveryRuleRouteConfigurationOverrideAction( + DeliveryRuleAction, discriminator="RouteConfigurationOverride" +): # pylint: disable=name-too-long + """Defines the route configuration override action for the delivery rule. Only applicable to + Frontdoor Standard/Premium Profiles. + + :ivar parameters: Defines the parameters for the action. Required. + :vartype parameters: ~azure.mgmt.cdn.models.RouteConfigurationOverrideActionParameters + :ivar name: The name of the action for the delivery rule. Required. + ROUTE_CONFIGURATION_OVERRIDE. + :vartype name: str or ~azure.mgmt.cdn.models.ROUTE_CONFIGURATION_OVERRIDE + """ + + parameters: "_models.RouteConfigurationOverrideActionParameters" = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Defines the parameters for the action. Required.""" + name: Literal[DeliveryRuleActionName.ROUTE_CONFIGURATION_OVERRIDE] = rest_discriminator(name="name", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """The name of the action for the delivery rule. Required. ROUTE_CONFIGURATION_OVERRIDE.""" + + @overload + def __init__( + self, + *, + parameters: "_models.RouteConfigurationOverrideActionParameters", + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.name = DeliveryRuleActionName.ROUTE_CONFIGURATION_OVERRIDE # type: ignore + + +class DeliveryRuleServerPortCondition(DeliveryRuleCondition, discriminator="ServerPort"): + """Defines the ServerPort condition for the delivery rule. + + :ivar parameters: Defines the parameters for the condition. Required. + :vartype parameters: ~azure.mgmt.cdn.models.ServerPortMatchConditionParameters + :ivar name: The name of the condition for the delivery rule. Required. SERVER_PORT. + :vartype name: str or ~azure.mgmt.cdn.models.SERVER_PORT + """ + + parameters: "_models.ServerPortMatchConditionParameters" = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Defines the parameters for the condition. Required.""" + name: Literal[MatchVariable.SERVER_PORT] = rest_discriminator(name="name", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """The name of the condition for the delivery rule. Required. SERVER_PORT.""" + + @overload + def __init__( + self, + *, + parameters: "_models.ServerPortMatchConditionParameters", + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.name = MatchVariable.SERVER_PORT # type: ignore + + +class DeliveryRuleSocketAddrCondition(DeliveryRuleCondition, discriminator="SocketAddr"): + """Defines the SocketAddress condition for the delivery rule. + + :ivar parameters: Defines the parameters for the condition. Required. + :vartype parameters: ~azure.mgmt.cdn.models.SocketAddrMatchConditionParameters + :ivar name: The name of the condition for the delivery rule. Required. SOCKET_ADDR. + :vartype name: str or ~azure.mgmt.cdn.models.SOCKET_ADDR + """ + + parameters: "_models.SocketAddrMatchConditionParameters" = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Defines the parameters for the condition. Required.""" + name: Literal[MatchVariable.SOCKET_ADDR] = rest_discriminator(name="name", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """The name of the condition for the delivery rule. Required. SOCKET_ADDR.""" + + @overload + def __init__( + self, + *, + parameters: "_models.SocketAddrMatchConditionParameters", + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.name = MatchVariable.SOCKET_ADDR # type: ignore + + +class DeliveryRuleSslProtocolCondition(DeliveryRuleCondition, discriminator="SslProtocol"): + """Defines the SslProtocol condition for the delivery rule. + + :ivar parameters: Defines the parameters for the condition. Required. + :vartype parameters: ~azure.mgmt.cdn.models.SslProtocolMatchConditionParameters + :ivar name: The name of the condition for the delivery rule. Required. SSL_PROTOCOL. + :vartype name: str or ~azure.mgmt.cdn.models.SSL_PROTOCOL + """ + + parameters: "_models.SslProtocolMatchConditionParameters" = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Defines the parameters for the condition. Required.""" + name: Literal[MatchVariable.SSL_PROTOCOL] = rest_discriminator(name="name", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """The name of the condition for the delivery rule. Required. SSL_PROTOCOL.""" + + @overload + def __init__( + self, + *, + parameters: "_models.SslProtocolMatchConditionParameters", + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.name = MatchVariable.SSL_PROTOCOL # type: ignore + + +class DeliveryRuleUrlFileExtensionCondition(DeliveryRuleCondition, discriminator="UrlFileExtension"): + """Defines the UrlFileExtension condition for the delivery rule. + + :ivar parameters: Defines the parameters for the condition. Required. + :vartype parameters: ~azure.mgmt.cdn.models.UrlFileExtensionMatchConditionParameters + :ivar name: The name of the condition for the delivery rule. Required. URL_FILE_EXTENSION. + :vartype name: str or ~azure.mgmt.cdn.models.URL_FILE_EXTENSION + """ + + parameters: "_models.UrlFileExtensionMatchConditionParameters" = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Defines the parameters for the condition. Required.""" + name: Literal[MatchVariable.URL_FILE_EXTENSION] = rest_discriminator(name="name", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """The name of the condition for the delivery rule. Required. URL_FILE_EXTENSION.""" + + @overload + def __init__( + self, + *, + parameters: "_models.UrlFileExtensionMatchConditionParameters", + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.name = MatchVariable.URL_FILE_EXTENSION # type: ignore + + +class DeliveryRuleUrlFileNameCondition(DeliveryRuleCondition, discriminator="UrlFileName"): + """Defines the UrlFileName condition for the delivery rule. + + :ivar parameters: Defines the parameters for the condition. Required. + :vartype parameters: ~azure.mgmt.cdn.models.UrlFileNameMatchConditionParameters + :ivar name: The name of the condition for the delivery rule. Required. URL_FILE_NAME. + :vartype name: str or ~azure.mgmt.cdn.models.URL_FILE_NAME + """ + + parameters: "_models.UrlFileNameMatchConditionParameters" = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Defines the parameters for the condition. Required.""" + name: Literal[MatchVariable.URL_FILE_NAME] = rest_discriminator(name="name", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """The name of the condition for the delivery rule. Required. URL_FILE_NAME.""" + + @overload + def __init__( + self, + *, + parameters: "_models.UrlFileNameMatchConditionParameters", + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.name = MatchVariable.URL_FILE_NAME # type: ignore + + +class DeliveryRuleUrlPathCondition(DeliveryRuleCondition, discriminator="UrlPath"): + """Defines the UrlPath condition for the delivery rule. + + :ivar parameters: Defines the parameters for the condition. Required. + :vartype parameters: ~azure.mgmt.cdn.models.UrlPathMatchConditionParameters + :ivar name: The name of the condition for the delivery rule. Required. URL_PATH. + :vartype name: str or ~azure.mgmt.cdn.models.URL_PATH + """ + + parameters: "_models.UrlPathMatchConditionParameters" = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Defines the parameters for the condition. Required.""" + name: Literal[MatchVariable.URL_PATH] = rest_discriminator(name="name", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """The name of the condition for the delivery rule. Required. URL_PATH.""" + + @overload + def __init__( + self, + *, + parameters: "_models.UrlPathMatchConditionParameters", + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.name = MatchVariable.URL_PATH # type: ignore + + +class DimensionProperties(_Model): + """Type of operation: get, read, delete, etc. + + :ivar name: Name of dimension. + :vartype name: str + :ivar display_name: Display name of dimension. + :vartype display_name: str + :ivar internal_name: Internal name of dimension. + :vartype internal_name: str + """ + + name: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Name of dimension.""" + display_name: Optional[str] = rest_field( + name="displayName", visibility=["read", "create", "update", "delete", "query"] + ) + """Display name of dimension.""" + internal_name: Optional[str] = rest_field( + name="internalName", visibility=["read", "create", "update", "delete", "query"] + ) + """Internal name of dimension.""" + + @overload + def __init__( + self, + *, + name: Optional[str] = None, + display_name: Optional[str] = None, + internal_name: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class DomainValidationProperties(_Model): + """The JSON object that contains the properties to validate a domain. + + :ivar validation_token: Challenge used for DNS TXT record or file based validation. + :vartype validation_token: str + :ivar expiration_date: The date time that the token expires. + :vartype expiration_date: str + """ + + validation_token: Optional[str] = rest_field(name="validationToken", visibility=["read"]) + """Challenge used for DNS TXT record or file based validation.""" + expiration_date: Optional[str] = rest_field(name="expirationDate", visibility=["read"]) + """The date time that the token expires.""" + + +class EdgeNode(ProxyResource): + """Edgenode is a global Point of Presence (POP) location used to deliver CDN content to end users. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.cdn.models.SystemData + :ivar properties: The JSON object that contains the properties required to create an edgenode. + :vartype properties: ~azure.mgmt.cdn.models.EdgeNodeProperties + """ + + properties: Optional["_models.EdgeNodeProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The JSON object that contains the properties required to create an edgenode.""" + + __flattened_items = ["ip_address_groups"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.EdgeNodeProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class EdgeNodeProperties(_Model): + """The JSON object that contains the properties required to create an edgenode. + + :ivar ip_address_groups: List of ip address groups. Required. + :vartype ip_address_groups: list[~azure.mgmt.cdn.models.IpAddressGroup] + """ + + ip_address_groups: list["_models.IpAddressGroup"] = rest_field( + name="ipAddressGroups", visibility=["read", "create", "update", "delete", "query"] + ) + """List of ip address groups. Required.""" + + @overload + def __init__( + self, + *, + ip_address_groups: list["_models.IpAddressGroup"], + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +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 + .azureedge.net. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.cdn.models.SystemData + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str + :ivar properties: The JSON object that contains the properties required to create an endpoint. + :vartype properties: ~azure.mgmt.cdn.models.EndpointProperties + """ + + properties: Optional["_models.EndpointProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The JSON object that contains the properties required to create an endpoint.""" + + __flattened_items = [ + "origin_path", + "content_types_to_compress", + "origin_host_header", + "is_compression_enabled", + "is_http_allowed", + "is_https_allowed", + "query_string_caching_behavior", + "optimization_type", + "probe_path", + "geo_filters", + "default_origin_group", + "url_signing_keys", + "delivery_policy", + "web_application_firewall_policy_link", + "host_name", + "origins", + "origin_groups", + "custom_domains", + "resource_state", + "provisioning_state", + ] + + @overload + def __init__( + self, + *, + location: str, + tags: Optional[dict[str, str]] = None, + properties: Optional["_models.EndpointProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class EndpointPropertiesUpdateParameters(_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, + e.g. contoso.cloudapp.net/originpath. + :vartype origin_path: str + :ivar content_types_to_compress: List of content types on which compression applies. The value + should be a valid MIME type. + :vartype content_types_to_compress: list[str] + :ivar origin_host_header: The host header value sent to the origin with each request. This + property at Endpoint is only allowed when endpoint uses single origin and can be overridden by + the same property specified at origin.If you leave this blank, the request hostname determines + this value. Azure CDN origins, such as Web Apps, Blob Storage, and Cloud Services require this + host header value to match the origin hostname by default. + :vartype origin_host_header: str + :ivar is_compression_enabled: Indicates whether content compression is enabled on CDN. Default + value is false. If compression is enabled, content will be served as compressed if user + requests for a compressed version. Content won't be compressed on CDN when requested content is + smaller than 1 byte or larger than 1 MB. + :vartype is_compression_enabled: bool + :ivar is_http_allowed: Indicates whether HTTP traffic is allowed on the endpoint. Default value + is true. At least one protocol (HTTP or HTTPS) must be allowed. + :vartype is_http_allowed: bool + :ivar is_https_allowed: Indicates whether HTTPS traffic is allowed on the endpoint. Default + value is true. At least one protocol (HTTP or HTTPS) must be allowed. + :vartype is_https_allowed: bool + :ivar query_string_caching_behavior: Defines how CDN caches requests that include query + strings. You can ignore any query strings when caching, bypass caching to prevent requests that + contain query strings from being cached, or cache every request with a unique URL. Known values + are: "IgnoreQueryString", "BypassCaching", "UseQueryString", and "NotSet". + :vartype query_string_caching_behavior: str or + ~azure.mgmt.cdn.models.QueryStringCachingBehavior + :ivar optimization_type: Specifies what scenario the customer wants this CDN endpoint to + optimize for, e.g. Download, Media services. With this information, CDN can apply scenario + driven optimization. Known values are: "GeneralWebDelivery", "GeneralMediaStreaming", + "VideoOnDemandMediaStreaming", "LargeFileDownload", and "DynamicSiteAcceleration". + :vartype optimization_type: str or ~azure.mgmt.cdn.models.OptimizationType + :ivar probe_path: Path to a file hosted on the origin which helps accelerate delivery of the + dynamic content and calculate the most optimal routes for the CDN. This is relative to the + origin path. This property is only relevant when using a single origin. + :vartype probe_path: str + :ivar geo_filters: List of rules defining the user's geo access within a CDN endpoint. Each geo + filter defines an access rule to a specified path or content, e.g. block APAC for path + /pictures/. + :vartype geo_filters: list[~azure.mgmt.cdn.models.GeoFilter] + :ivar default_origin_group: A reference to the origin group. + :vartype default_origin_group: ~azure.mgmt.cdn.models.ResourceReference + :ivar url_signing_keys: List of keys used to validate the signed URL hashes. + :vartype url_signing_keys: list[~azure.mgmt.cdn.models.UrlSigningKey] + :ivar delivery_policy: A policy that specifies the delivery rules to be used for an endpoint. + :vartype delivery_policy: + ~azure.mgmt.cdn.models.EndpointPropertiesUpdateParametersDeliveryPolicy + :ivar web_application_firewall_policy_link: Defines the Web Application Firewall policy for the + endpoint (if applicable). + :vartype web_application_firewall_policy_link: + ~azure.mgmt.cdn.models.EndpointPropertiesUpdateParametersWebApplicationFirewallPolicyLink + """ + + origin_path: Optional[str] = rest_field( + name="originPath", visibility=["read", "create", "update", "delete", "query"] + ) + """A directory path on the origin that CDN can use to retrieve content from, e.g. + contoso.cloudapp.net/originpath.""" + content_types_to_compress: Optional[list[str]] = rest_field( + name="contentTypesToCompress", visibility=["read", "create", "update", "delete", "query"] + ) + """List of content types on which compression applies. The value should be a valid MIME type.""" + origin_host_header: Optional[str] = rest_field( + name="originHostHeader", visibility=["read", "create", "update", "delete", "query"] + ) + """The host header value sent to the origin with each request. This property at Endpoint is only + allowed when endpoint uses single origin and can be overridden by the same property specified + at origin.If you leave this blank, the request hostname determines this value. Azure CDN + origins, such as Web Apps, Blob Storage, and Cloud Services require this host header value to + match the origin hostname by default.""" + is_compression_enabled: Optional[bool] = rest_field( + name="isCompressionEnabled", visibility=["read", "create", "update", "delete", "query"] + ) + """Indicates whether content compression is enabled on CDN. Default value is false. If compression + is enabled, content will be served as compressed if user requests for a compressed version. + Content won't be compressed on CDN when requested content is smaller than 1 byte or larger than + 1 MB.""" + is_http_allowed: Optional[bool] = rest_field( + name="isHttpAllowed", visibility=["read", "create", "update", "delete", "query"] + ) + """Indicates whether HTTP traffic is allowed on the endpoint. Default value is true. At least one + protocol (HTTP or HTTPS) must be allowed.""" + is_https_allowed: Optional[bool] = rest_field( + name="isHttpsAllowed", visibility=["read", "create", "update", "delete", "query"] + ) + """Indicates whether HTTPS traffic is allowed on the endpoint. Default value is true. At least one + protocol (HTTP or HTTPS) must be allowed.""" + query_string_caching_behavior: Optional[Union[str, "_models.QueryStringCachingBehavior"]] = rest_field( + name="queryStringCachingBehavior", visibility=["read", "create", "update", "delete", "query"] + ) + """Defines how CDN caches requests that include query strings. You can ignore any query strings + when caching, bypass caching to prevent requests that contain query strings from being cached, + or cache every request with a unique URL. Known values are: \"IgnoreQueryString\", + \"BypassCaching\", \"UseQueryString\", and \"NotSet\".""" + optimization_type: Optional[Union[str, "_models.OptimizationType"]] = rest_field( + name="optimizationType", visibility=["read", "create", "update", "delete", "query"] + ) + """Specifies what scenario the customer wants this CDN endpoint to optimize for, e.g. Download, + Media services. With this information, CDN can apply scenario driven optimization. Known values + are: \"GeneralWebDelivery\", \"GeneralMediaStreaming\", \"VideoOnDemandMediaStreaming\", + \"LargeFileDownload\", and \"DynamicSiteAcceleration\".""" + probe_path: Optional[str] = rest_field(name="probePath", visibility=["read", "create", "update", "delete", "query"]) + """Path to a file hosted on the origin which helps accelerate delivery of the dynamic content and + calculate the most optimal routes for the CDN. This is relative to the origin path. This + property is only relevant when using a single origin.""" + geo_filters: Optional[list["_models.GeoFilter"]] = rest_field( + name="geoFilters", visibility=["read", "create", "update", "delete", "query"] + ) + """List of rules defining the user's geo access within a CDN endpoint. Each geo filter defines an + access rule to a specified path or content, e.g. block APAC for path /pictures/.""" + default_origin_group: Optional["_models.ResourceReference"] = rest_field( + name="defaultOriginGroup", visibility=["read", "create", "update", "delete", "query"] + ) + """A reference to the origin group.""" + url_signing_keys: Optional[list["_models.UrlSigningKey"]] = rest_field( + name="urlSigningKeys", visibility=["read", "create", "update", "delete", "query"] + ) + """List of keys used to validate the signed URL hashes.""" + delivery_policy: Optional["_models.EndpointPropertiesUpdateParametersDeliveryPolicy"] = rest_field( + name="deliveryPolicy", visibility=["read", "create", "update", "delete", "query"] + ) + """A policy that specifies the delivery rules to be used for an endpoint.""" + web_application_firewall_policy_link: Optional[ + "_models.EndpointPropertiesUpdateParametersWebApplicationFirewallPolicyLink" + ] = rest_field(name="webApplicationFirewallPolicyLink", visibility=["read", "create", "update", "delete", "query"]) + """Defines the Web Application Firewall policy for the endpoint (if applicable).""" + + @overload + def __init__( + self, + *, + origin_path: Optional[str] = None, + content_types_to_compress: Optional[list[str]] = None, + origin_host_header: Optional[str] = None, + is_compression_enabled: Optional[bool] = None, + is_http_allowed: Optional[bool] = None, + is_https_allowed: Optional[bool] = None, + query_string_caching_behavior: Optional[Union[str, "_models.QueryStringCachingBehavior"]] = None, + optimization_type: Optional[Union[str, "_models.OptimizationType"]] = None, + probe_path: Optional[str] = None, + geo_filters: Optional[list["_models.GeoFilter"]] = None, + default_origin_group: Optional["_models.ResourceReference"] = None, + url_signing_keys: Optional[list["_models.UrlSigningKey"]] = None, + delivery_policy: Optional["_models.EndpointPropertiesUpdateParametersDeliveryPolicy"] = None, + web_application_firewall_policy_link: Optional[ + "_models.EndpointPropertiesUpdateParametersWebApplicationFirewallPolicyLink" + ] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class EndpointProperties(EndpointPropertiesUpdateParameters): + """The JSON object that contains the properties required to create an endpoint. + + :ivar origin_path: A directory path on the origin that CDN can use to retrieve content from, + e.g. contoso.cloudapp.net/originpath. + :vartype origin_path: str + :ivar content_types_to_compress: List of content types on which compression applies. The value + should be a valid MIME type. + :vartype content_types_to_compress: list[str] + :ivar origin_host_header: The host header value sent to the origin with each request. This + property at Endpoint is only allowed when endpoint uses single origin and can be overridden by + the same property specified at origin.If you leave this blank, the request hostname determines + this value. Azure CDN origins, such as Web Apps, Blob Storage, and Cloud Services require this + host header value to match the origin hostname by default. + :vartype origin_host_header: str + :ivar is_compression_enabled: Indicates whether content compression is enabled on CDN. Default + value is false. If compression is enabled, content will be served as compressed if user + requests for a compressed version. Content won't be compressed on CDN when requested content is + smaller than 1 byte or larger than 1 MB. + :vartype is_compression_enabled: bool + :ivar is_http_allowed: Indicates whether HTTP traffic is allowed on the endpoint. Default value + is true. At least one protocol (HTTP or HTTPS) must be allowed. + :vartype is_http_allowed: bool + :ivar is_https_allowed: Indicates whether HTTPS traffic is allowed on the endpoint. Default + value is true. At least one protocol (HTTP or HTTPS) must be allowed. + :vartype is_https_allowed: bool + :ivar query_string_caching_behavior: Defines how CDN caches requests that include query + strings. You can ignore any query strings when caching, bypass caching to prevent requests that + contain query strings from being cached, or cache every request with a unique URL. Known values + are: "IgnoreQueryString", "BypassCaching", "UseQueryString", and "NotSet". + :vartype query_string_caching_behavior: str or + ~azure.mgmt.cdn.models.QueryStringCachingBehavior + :ivar optimization_type: Specifies what scenario the customer wants this CDN endpoint to + optimize for, e.g. Download, Media services. With this information, CDN can apply scenario + driven optimization. Known values are: "GeneralWebDelivery", "GeneralMediaStreaming", + "VideoOnDemandMediaStreaming", "LargeFileDownload", and "DynamicSiteAcceleration". + :vartype optimization_type: str or ~azure.mgmt.cdn.models.OptimizationType + :ivar probe_path: Path to a file hosted on the origin which helps accelerate delivery of the + dynamic content and calculate the most optimal routes for the CDN. This is relative to the + origin path. This property is only relevant when using a single origin. + :vartype probe_path: str + :ivar geo_filters: List of rules defining the user's geo access within a CDN endpoint. Each geo + filter defines an access rule to a specified path or content, e.g. block APAC for path + /pictures/. + :vartype geo_filters: list[~azure.mgmt.cdn.models.GeoFilter] + :ivar default_origin_group: A reference to the origin group. + :vartype default_origin_group: ~azure.mgmt.cdn.models.ResourceReference + :ivar url_signing_keys: List of keys used to validate the signed URL hashes. + :vartype url_signing_keys: list[~azure.mgmt.cdn.models.UrlSigningKey] + :ivar delivery_policy: A policy that specifies the delivery rules to be used for an endpoint. + :vartype delivery_policy: + ~azure.mgmt.cdn.models.EndpointPropertiesUpdateParametersDeliveryPolicy + :ivar web_application_firewall_policy_link: Defines the Web Application Firewall policy for the + endpoint (if applicable). + :vartype web_application_firewall_policy_link: + ~azure.mgmt.cdn.models.EndpointPropertiesUpdateParametersWebApplicationFirewallPolicyLink + :ivar host_name: The host name of the endpoint structured as {endpointName}.{DNSZone}, e.g. + contoso.azureedge.net. + :vartype host_name: str + :ivar origins: The source of the content being delivered via CDN. Required. + :vartype origins: list[~azure.mgmt.cdn.models.DeepCreatedOrigin] + :ivar origin_groups: The origin groups comprising of origins that are used for load balancing + the traffic based on availability. + :vartype origin_groups: list[~azure.mgmt.cdn.models.DeepCreatedOriginGroup] + :ivar custom_domains: The custom domains under the endpoint. + :vartype custom_domains: list[~azure.mgmt.cdn.models.DeepCreatedCustomDomain] + :ivar resource_state: Resource status of the endpoint. Known values are: "Creating", + "Deleting", "Running", "Starting", "Stopped", and "Stopping". + :vartype resource_state: str or ~azure.mgmt.cdn.models.EndpointResourceState + :ivar provisioning_state: Provisioning status of the endpoint. Known values are: "Succeeded", + "Failed", "Updating", "Deleting", and "Creating". + :vartype provisioning_state: str or ~azure.mgmt.cdn.models.EndpointProvisioningState + """ + + host_name: Optional[str] = rest_field(name="hostName", visibility=["read"]) + """The host name of the endpoint structured as {endpointName}.{DNSZone}, e.g. + contoso.azureedge.net.""" + origins: list["_models.DeepCreatedOrigin"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The source of the content being delivered via CDN. Required.""" + origin_groups: Optional[list["_models.DeepCreatedOriginGroup"]] = rest_field( + name="originGroups", visibility=["read", "create", "update", "delete", "query"] + ) + """The origin groups comprising of origins that are used for load balancing the traffic based on + availability.""" + custom_domains: Optional[list["_models.DeepCreatedCustomDomain"]] = rest_field( + name="customDomains", visibility=["read"] + ) + """The custom domains under the endpoint.""" + resource_state: Optional[Union[str, "_models.EndpointResourceState"]] = rest_field( + name="resourceState", visibility=["read"] + ) + """Resource status of the endpoint. Known values are: \"Creating\", \"Deleting\", \"Running\", + \"Starting\", \"Stopped\", and \"Stopping\".""" + provisioning_state: Optional[Union[str, "_models.EndpointProvisioningState"]] = rest_field( + name="provisioningState", visibility=["read"] + ) + """Provisioning status of the endpoint. Known values are: \"Succeeded\", \"Failed\", \"Updating\", + \"Deleting\", and \"Creating\".""" + + @overload + def __init__( + self, + *, + origins: list["_models.DeepCreatedOrigin"], + origin_path: Optional[str] = None, + content_types_to_compress: Optional[list[str]] = None, + origin_host_header: Optional[str] = None, + is_compression_enabled: Optional[bool] = None, + is_http_allowed: Optional[bool] = None, + is_https_allowed: Optional[bool] = None, + query_string_caching_behavior: Optional[Union[str, "_models.QueryStringCachingBehavior"]] = None, + optimization_type: Optional[Union[str, "_models.OptimizationType"]] = None, + probe_path: Optional[str] = None, + geo_filters: Optional[list["_models.GeoFilter"]] = None, + default_origin_group: Optional["_models.ResourceReference"] = None, + url_signing_keys: Optional[list["_models.UrlSigningKey"]] = None, + delivery_policy: Optional["_models.EndpointPropertiesUpdateParametersDeliveryPolicy"] = None, + web_application_firewall_policy_link: Optional[ + "_models.EndpointPropertiesUpdateParametersWebApplicationFirewallPolicyLink" + ] = None, + origin_groups: Optional[list["_models.DeepCreatedOriginGroup"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class EndpointPropertiesUpdateParametersDeliveryPolicy(_Model): # pylint: disable=name-too-long + """A policy that specifies the delivery rules to be used for an endpoint. + + :ivar description: User-friendly description of the policy. + :vartype description: str + :ivar rules: A list of the delivery rules. Required. + :vartype rules: list[~azure.mgmt.cdn.models.DeliveryRule] + """ + + description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """User-friendly description of the policy.""" + rules: list["_models.DeliveryRule"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """A list of the delivery rules. Required.""" + + @overload + def __init__( + self, + *, + rules: list["_models.DeliveryRule"], + description: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class EndpointPropertiesUpdateParametersWebApplicationFirewallPolicyLink(_Model): # pylint: disable=name-too-long + """Defines the Web Application Firewall policy for the endpoint (if applicable). + + :ivar id: Resource ID. + :vartype id: str + """ + + id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Resource ID.""" + + @overload + def __init__( + self, + *, + id: Optional[str] = None, # pylint: disable=redefined-builtin + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class EndpointUpdateParameters(_Model): + """Properties required to create or update an endpoint. + + :ivar tags: Endpoint tags. + :vartype tags: dict[str, str] + :ivar properties: The JSON object containing endpoint update parameters. + :vartype properties: ~azure.mgmt.cdn.models.EndpointPropertiesUpdateParameters + """ + + tags: Optional[dict[str, str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Endpoint tags.""" + properties: Optional["_models.EndpointPropertiesUpdateParameters"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The JSON object containing endpoint update parameters.""" + + __flattened_items = [ + "origin_path", + "content_types_to_compress", + "origin_host_header", + "is_compression_enabled", + "is_http_allowed", + "is_https_allowed", + "query_string_caching_behavior", + "optimization_type", + "probe_path", + "geo_filters", + "default_origin_group", + "url_signing_keys", + "delivery_policy", + "web_application_firewall_policy_link", + ] + + @overload + def __init__( + self, + *, + tags: Optional[dict[str, str]] = None, + properties: Optional["_models.EndpointPropertiesUpdateParameters"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class ErrorAdditionalInfo(_Model): + """The resource management error additional info. + + :ivar type: The additional info type. + :vartype type: str + :ivar info: The additional info. + :vartype info: any + """ + + type: Optional[str] = rest_field(visibility=["read"]) + """The additional info type.""" + info: Optional[Any] = rest_field(visibility=["read"]) + """The additional info.""" + + +class ErrorDetail(_Model): + """The error detail. + + :ivar code: The error code. + :vartype code: str + :ivar message: The error message. + :vartype message: str + :ivar target: The error target. + :vartype target: str + :ivar details: The error details. + :vartype details: list[~azure.mgmt.cdn.models.ErrorDetail] + :ivar additional_info: The error additional info. + :vartype additional_info: list[~azure.mgmt.cdn.models.ErrorAdditionalInfo] + """ + + code: Optional[str] = rest_field(visibility=["read"]) + """The error code.""" + message: Optional[str] = rest_field(visibility=["read"]) + """The error message.""" + target: Optional[str] = rest_field(visibility=["read"]) + """The error target.""" + details: Optional[list["_models.ErrorDetail"]] = rest_field(visibility=["read"]) + """The error details.""" + additional_info: Optional[list["_models.ErrorAdditionalInfo"]] = rest_field( + name="additionalInfo", visibility=["read"] + ) + """The error additional info.""" + + +class ErrorResponse(_Model): + """Error response. + + :ivar error: The error object. + :vartype error: ~azure.mgmt.cdn.models.ErrorDetail + """ + + error: Optional["_models.ErrorDetail"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The error object.""" + + @overload + def __init__( + self, + *, + error: Optional["_models.ErrorDetail"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class GeoFilter(_Model): + """Rules defining user's geo access within a CDN endpoint. + + :ivar relative_path: Relative path applicable to geo filter. (e.g. '/mypictures', + '/mypicture/kitty.jpg', and etc.). Required. + :vartype relative_path: str + :ivar action: Action of the geo filter, i.e. allow or block access. Required. Known values are: + "Block" and "Allow". + :vartype action: str or ~azure.mgmt.cdn.models.GeoFilterActions + :ivar country_codes: Two letter country or region codes defining user country or region access + in a geo filter, e.g. AU, MX, US. Required. + :vartype country_codes: list[str] + """ + + relative_path: str = rest_field(name="relativePath", visibility=["read", "create", "update", "delete", "query"]) + """Relative path applicable to geo filter. (e.g. '/mypictures', '/mypicture/kitty.jpg', and etc.). + Required.""" + action: Union[str, "_models.GeoFilterActions"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Action of the geo filter, i.e. allow or block access. Required. Known values are: \"Block\" and + \"Allow\".""" + country_codes: list[str] = rest_field( + name="countryCodes", visibility=["read", "create", "update", "delete", "query"] + ) + """Two letter country or region codes defining user country or region access in a geo filter, e.g. + AU, MX, US. Required.""" + + @overload + def __init__( + self, + *, + relative_path: str, + action: Union[str, "_models.GeoFilterActions"], + country_codes: list[str], + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class HeaderActionParameters(DeliveryRuleActionParameters, discriminator="DeliveryRuleHeaderActionParameters"): + """Defines the parameters for the request header action. + + :ivar header_action: Action to perform. Required. Known values are: "Append", "Overwrite", and + "Delete". + :vartype header_action: str or ~azure.mgmt.cdn.models.HeaderAction + :ivar header_name: Name of the header to modify. Required. + :vartype header_name: str + :ivar value: Value for the specified action. + :vartype value: str + :ivar type_name: Required. DELIVERY_RULE_HEADER_ACTION_PARAMETERS. + :vartype type_name: str or ~azure.mgmt.cdn.models.DELIVERY_RULE_HEADER_ACTION_PARAMETERS + """ + + header_action: Union[str, "_models.HeaderAction"] = rest_field( + name="headerAction", visibility=["read", "create", "update", "delete", "query"] + ) + """Action to perform. Required. Known values are: \"Append\", \"Overwrite\", and \"Delete\".""" + header_name: str = rest_field(name="headerName", visibility=["read", "create", "update", "delete", "query"]) + """Name of the header to modify. Required.""" + value: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Value for the specified action.""" + type_name: Literal[DeliveryRuleActionParametersType.DELIVERY_RULE_HEADER_ACTION_PARAMETERS] = rest_discriminator(name="typeName", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Required. DELIVERY_RULE_HEADER_ACTION_PARAMETERS.""" + + @overload + def __init__( + self, + *, + header_action: Union[str, "_models.HeaderAction"], + header_name: str, + value: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type_name = DeliveryRuleActionParametersType.DELIVERY_RULE_HEADER_ACTION_PARAMETERS # type: ignore + + +class HealthProbeParameters(_Model): + """The JSON object that contains the properties to send health probes to origin. + + :ivar probe_path: The path relative to the origin that is used to determine the health of the + origin. + :vartype probe_path: str + :ivar probe_request_type: The type of health probe request that is made. Known values are: + "NotSet", "GET", and "HEAD". + :vartype probe_request_type: str or ~azure.mgmt.cdn.models.HealthProbeRequestType + :ivar probe_protocol: Protocol to use for health probe. Known values are: "NotSet", "Http", and + "Https". + :vartype probe_protocol: str or ~azure.mgmt.cdn.models.ProbeProtocol + :ivar probe_interval_in_seconds: The number of seconds between health probes.Default is 240sec. + :vartype probe_interval_in_seconds: int + """ + + probe_path: Optional[str] = rest_field(name="probePath", visibility=["read", "create", "update", "delete", "query"]) + """The path relative to the origin that is used to determine the health of the origin.""" + probe_request_type: Optional[Union[str, "_models.HealthProbeRequestType"]] = rest_field( + name="probeRequestType", visibility=["read", "create", "update", "delete", "query"] + ) + """The type of health probe request that is made. Known values are: \"NotSet\", \"GET\", and + \"HEAD\".""" + probe_protocol: Optional[Union[str, "_models.ProbeProtocol"]] = rest_field( + name="probeProtocol", visibility=["read", "create", "update", "delete", "query"] + ) + """Protocol to use for health probe. Known values are: \"NotSet\", \"Http\", and \"Https\".""" + probe_interval_in_seconds: Optional[int] = rest_field( + name="probeIntervalInSeconds", visibility=["read", "create", "update", "delete", "query"] + ) + """The number of seconds between health probes.Default is 240sec.""" + + @overload + def __init__( + self, + *, + probe_path: Optional[str] = None, + probe_request_type: Optional[Union[str, "_models.HealthProbeRequestType"]] = None, + probe_protocol: Optional[Union[str, "_models.ProbeProtocol"]] = None, + probe_interval_in_seconds: Optional[int] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class HostNameMatchConditionParameters( + DeliveryRuleConditionParameters, discriminator="DeliveryRuleHostNameConditionParameters" +): + """Defines the parameters for HostName match conditions. + + :ivar operator: Describes operator to be matched. Required. Known values are: "Any", "Equal", + "Contains", "BeginsWith", "EndsWith", "LessThan", "LessThanOrEqual", "GreaterThan", + "GreaterThanOrEqual", and "RegEx". + :vartype operator: str or ~azure.mgmt.cdn.models.HostNameOperator + :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] + :ivar transforms: List of transforms. + :vartype transforms: list[str or ~azure.mgmt.cdn.models.Transform] + :ivar type_name: Required. DELIVERY_RULE_HOST_NAME_CONDITION_PARAMETERS. + :vartype type_name: str or ~azure.mgmt.cdn.models.DELIVERY_RULE_HOST_NAME_CONDITION_PARAMETERS + """ + + operator: Union[str, "_models.HostNameOperator"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Describes operator to be matched. Required. Known values are: \"Any\", \"Equal\", \"Contains\", + \"BeginsWith\", \"EndsWith\", \"LessThan\", \"LessThanOrEqual\", \"GreaterThan\", + \"GreaterThanOrEqual\", and \"RegEx\".""" + negate_condition: Optional[bool] = rest_field( + name="negateCondition", visibility=["read", "create", "update", "delete", "query"] + ) + """Describes if this is negate condition or not.""" + match_values: Optional[list[str]] = rest_field( + name="matchValues", visibility=["read", "create", "update", "delete", "query"] + ) + """The match value for the condition of the delivery rule.""" + transforms: Optional[list[Union[str, "_models.Transform"]]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """List of transforms.""" + type_name: Literal[DeliveryRuleConditionParametersType.DELIVERY_RULE_HOST_NAME_CONDITION_PARAMETERS] = rest_discriminator(name="typeName", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Required. DELIVERY_RULE_HOST_NAME_CONDITION_PARAMETERS.""" + + @overload + def __init__( + self, + *, + operator: Union[str, "_models.HostNameOperator"], + negate_condition: Optional[bool] = None, + match_values: Optional[list[str]] = None, + transforms: Optional[list[Union[str, "_models.Transform"]]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type_name = DeliveryRuleConditionParametersType.DELIVERY_RULE_HOST_NAME_CONDITION_PARAMETERS # type: ignore + + +class HttpErrorRangeParameters(_Model): + """The JSON object that represents the range for http status codes. + + :ivar begin: The inclusive start of the http status code range. + :vartype begin: int + :ivar end: The inclusive end of the http status code range. + :vartype end: int + """ + + begin: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The inclusive start of the http status code range.""" + end: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The inclusive end of the http status code range.""" + + @overload + def __init__( + self, + *, + begin: Optional[int] = None, + end: Optional[int] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class HttpVersionMatchConditionParameters( + DeliveryRuleConditionParameters, discriminator="DeliveryRuleHttpVersionConditionParameters" +): + """Defines the parameters for HttpVersion match conditions. + + :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. + :vartype negate_condition: bool + :ivar match_values: The match value for the condition of the delivery rule. + :vartype match_values: list[str] + :ivar transforms: List of transforms. + :vartype transforms: list[str or ~azure.mgmt.cdn.models.Transform] + :ivar type_name: Required. DELIVERY_RULE_HTTP_VERSION_CONDITION_PARAMETERS. + :vartype type_name: str or + ~azure.mgmt.cdn.models.DELIVERY_RULE_HTTP_VERSION_CONDITION_PARAMETERS + """ + + operator: Union[str, "_models.HttpVersionOperator"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Describes operator to be matched. Required. \"Equal\"""" + negate_condition: Optional[bool] = rest_field( + name="negateCondition", visibility=["read", "create", "update", "delete", "query"] + ) + """Describes if this is negate condition or not.""" + match_values: Optional[list[str]] = rest_field( + name="matchValues", visibility=["read", "create", "update", "delete", "query"] + ) + """The match value for the condition of the delivery rule.""" + transforms: Optional[list[Union[str, "_models.Transform"]]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """List of transforms.""" + type_name: Literal[DeliveryRuleConditionParametersType.DELIVERY_RULE_HTTP_VERSION_CONDITION_PARAMETERS] = rest_discriminator(name="typeName", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Required. DELIVERY_RULE_HTTP_VERSION_CONDITION_PARAMETERS.""" + + @overload + def __init__( + self, + *, + operator: Union[str, "_models.HttpVersionOperator"], + negate_condition: Optional[bool] = None, + match_values: Optional[list[str]] = None, + transforms: Optional[list[Union[str, "_models.Transform"]]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type_name = DeliveryRuleConditionParametersType.DELIVERY_RULE_HTTP_VERSION_CONDITION_PARAMETERS # type: ignore + + +class IpAddressGroup(_Model): + """CDN Ip address group. + + :ivar delivery_region: The delivery region of the ip address group. + :vartype delivery_region: str + :ivar ipv4_addresses: The list of ip v4 addresses. + :vartype ipv4_addresses: list[~azure.mgmt.cdn.models.CidrIpAddress] + :ivar ipv6_addresses: The list of ip v6 addresses. + :vartype ipv6_addresses: list[~azure.mgmt.cdn.models.CidrIpAddress] + """ + + delivery_region: Optional[str] = rest_field( + name="deliveryRegion", visibility=["read", "create", "update", "delete", "query"] + ) + """The delivery region of the ip address group.""" + ipv4_addresses: Optional[list["_models.CidrIpAddress"]] = rest_field( + name="ipv4Addresses", visibility=["read", "create", "update", "delete", "query"] + ) + """The list of ip v4 addresses.""" + ipv6_addresses: Optional[list["_models.CidrIpAddress"]] = rest_field( + name="ipv6Addresses", visibility=["read", "create", "update", "delete", "query"] + ) + """The list of ip v6 addresses.""" + + @overload + def __init__( + self, + *, + delivery_region: Optional[str] = None, + ipv4_addresses: Optional[list["_models.CidrIpAddress"]] = None, + ipv6_addresses: Optional[list["_models.CidrIpAddress"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class IsDeviceMatchConditionParameters( + DeliveryRuleConditionParameters, discriminator="DeliveryRuleIsDeviceConditionParameters" +): + """Defines the parameters for IsDevice match conditions. + + :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.IsDeviceMatchValue] + :ivar transforms: List of transforms. + :vartype transforms: list[str or ~azure.mgmt.cdn.models.Transform] + :ivar type_name: Required. DELIVERY_RULE_IS_DEVICE_CONDITION_PARAMETERS. + :vartype type_name: str or ~azure.mgmt.cdn.models.DELIVERY_RULE_IS_DEVICE_CONDITION_PARAMETERS + """ + + operator: Union[str, "_models.IsDeviceOperator"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Describes operator to be matched. Required. \"Equal\"""" + negate_condition: Optional[bool] = rest_field( + name="negateCondition", visibility=["read", "create", "update", "delete", "query"] + ) + """Describes if this is negate condition or not.""" + match_values: Optional[list[Union[str, "_models.IsDeviceMatchValue"]]] = rest_field( + name="matchValues", visibility=["read", "create", "update", "delete", "query"] + ) + """The match value for the condition of the delivery rule.""" + transforms: Optional[list[Union[str, "_models.Transform"]]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """List of transforms.""" + type_name: Literal[DeliveryRuleConditionParametersType.DELIVERY_RULE_IS_DEVICE_CONDITION_PARAMETERS] = rest_discriminator(name="typeName", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Required. DELIVERY_RULE_IS_DEVICE_CONDITION_PARAMETERS.""" + + @overload + def __init__( + self, + *, + operator: Union[str, "_models.IsDeviceOperator"], + negate_condition: Optional[bool] = None, + match_values: Optional[list[Union[str, "_models.IsDeviceMatchValue"]]] = None, + transforms: Optional[list[Union[str, "_models.Transform"]]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type_name = DeliveryRuleConditionParametersType.DELIVERY_RULE_IS_DEVICE_CONDITION_PARAMETERS # type: ignore + + +class KeyVaultCertificateSourceParameters( + CertificateSourceParameters, discriminator="KeyVaultCertificateSourceParameters" +): + """Describes the parameters for using a user's KeyVault certificate for securing custom domain. + + :ivar subscription_id: Subscription Id of the user's Key Vault containing the SSL certificate. + Required. + :vartype subscription_id: str + :ivar resource_group_name: Resource group of the user's Key Vault containing the SSL + certificate. Required. + :vartype resource_group_name: str + :ivar vault_name: The name of the user's Key Vault containing the SSL certificate. Required. + :vartype vault_name: str + :ivar secret_name: The name of Key Vault Secret (representing the full certificate PFX) in Key + Vault. Required. + :vartype secret_name: str + :ivar secret_version: The version(GUID) of Key Vault Secret in Key Vault. + :vartype secret_version: str + :ivar update_rule: Describes the action that shall be taken when the certificate is updated in + Key Vault. Required. "NoAction" + :vartype update_rule: str or ~azure.mgmt.cdn.models.UpdateRule + :ivar delete_rule: Describes the action that shall be taken when the certificate is removed + from Key Vault. Required. "NoAction" + :vartype delete_rule: str or ~azure.mgmt.cdn.models.DeleteRule + :ivar type_name: Required. KEY_VAULT_CERTIFICATE_SOURCE_PARAMETERS. + :vartype type_name: str or ~azure.mgmt.cdn.models.KEY_VAULT_CERTIFICATE_SOURCE_PARAMETERS + """ + + subscription_id: str = rest_field(name="subscriptionId", visibility=["read", "create", "update", "delete", "query"]) + """Subscription Id of the user's Key Vault containing the SSL certificate. Required.""" + resource_group_name: str = rest_field( + name="resourceGroupName", visibility=["read", "create", "update", "delete", "query"] + ) + """Resource group of the user's Key Vault containing the SSL certificate. Required.""" + vault_name: str = rest_field(name="vaultName", visibility=["read", "create", "update", "delete", "query"]) + """The name of the user's Key Vault containing the SSL certificate. Required.""" + secret_name: str = rest_field(name="secretName", visibility=["read", "create", "update", "delete", "query"]) + """The name of Key Vault Secret (representing the full certificate PFX) in Key Vault. Required.""" + secret_version: Optional[str] = rest_field( + name="secretVersion", visibility=["read", "create", "update", "delete", "query"] + ) + """The version(GUID) of Key Vault Secret in Key Vault.""" + update_rule: Union[str, "_models.UpdateRule"] = rest_field( + name="updateRule", visibility=["read", "create", "update", "delete", "query"] + ) + """Describes the action that shall be taken when the certificate is updated in Key Vault. + Required. \"NoAction\"""" + delete_rule: Union[str, "_models.DeleteRule"] = rest_field( + name="deleteRule", visibility=["read", "create", "update", "delete", "query"] + ) + """Describes the action that shall be taken when the certificate is removed from Key Vault. + Required. \"NoAction\"""" + type_name: Literal[CertificateSourceParametersType.KEY_VAULT_CERTIFICATE_SOURCE_PARAMETERS] = rest_discriminator(name="typeName", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Required. KEY_VAULT_CERTIFICATE_SOURCE_PARAMETERS.""" + + @overload + def __init__( + self, + *, + subscription_id: str, + resource_group_name: str, + vault_name: str, + secret_name: str, + update_rule: Union[str, "_models.UpdateRule"], + delete_rule: Union[str, "_models.DeleteRule"], + secret_version: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type_name = CertificateSourceParametersType.KEY_VAULT_CERTIFICATE_SOURCE_PARAMETERS # type: ignore + + +class KeyVaultSigningKeyParameters(_Model): + """Describes the parameters for using a user's KeyVault for URL Signing Key. + + :ivar type_name: Required. "KeyVaultSigningKeyParameters" + :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. + Required. + :vartype resource_group_name: str + :ivar vault_name: The name of the user's Key Vault containing the secret. Required. + :vartype vault_name: str + :ivar secret_name: The name of secret in Key Vault. Required. + :vartype secret_name: str + :ivar secret_version: The version(GUID) of secret in Key Vault. Required. + :vartype secret_version: str + """ + + type_name: Union[str, "_models.KeyVaultSigningKeyParametersType"] = rest_field( + name="typeName", visibility=["read", "create", "update", "delete", "query"] + ) + """Required. \"KeyVaultSigningKeyParameters\"""" + subscription_id: str = rest_field(name="subscriptionId", visibility=["read", "create", "update", "delete", "query"]) + """Subscription Id of the user's Key Vault containing the secret. Required.""" + resource_group_name: str = rest_field( + name="resourceGroupName", visibility=["read", "create", "update", "delete", "query"] + ) + """Resource group of the user's Key Vault containing the secret. Required.""" + vault_name: str = rest_field(name="vaultName", visibility=["read", "create", "update", "delete", "query"]) + """The name of the user's Key Vault containing the secret. Required.""" + secret_name: str = rest_field(name="secretName", visibility=["read", "create", "update", "delete", "query"]) + """The name of secret in Key Vault. Required.""" + secret_version: str = rest_field(name="secretVersion", visibility=["read", "create", "update", "delete", "query"]) + """The version(GUID) of secret in Key Vault. Required.""" + + @overload + def __init__( + self, + *, + type_name: Union[str, "_models.KeyVaultSigningKeyParametersType"], + subscription_id: str, + resource_group_name: str, + vault_name: str, + secret_name: str, + secret_version: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class LoadBalancingSettingsParameters(_Model): + """Round-Robin load balancing settings for a backend pool. + + :ivar sample_size: The number of samples to consider for load balancing decisions. + :vartype sample_size: int + :ivar successful_samples_required: The number of samples within the sample period that must + succeed. + :vartype successful_samples_required: int + :ivar additional_latency_in_milliseconds: The additional latency in milliseconds for probes to + fall into the lowest latency bucket. + :vartype additional_latency_in_milliseconds: int + """ + + sample_size: Optional[int] = rest_field( + name="sampleSize", visibility=["read", "create", "update", "delete", "query"] + ) + """The number of samples to consider for load balancing decisions.""" + successful_samples_required: Optional[int] = rest_field( + name="successfulSamplesRequired", visibility=["read", "create", "update", "delete", "query"] + ) + """The number of samples within the sample period that must succeed.""" + additional_latency_in_milliseconds: Optional[int] = rest_field( + name="additionalLatencyInMilliseconds", visibility=["read", "create", "update", "delete", "query"] + ) + """The additional latency in milliseconds for probes to fall into the lowest latency bucket.""" + + @overload + def __init__( + self, + *, + sample_size: Optional[int] = None, + successful_samples_required: Optional[int] = None, + additional_latency_in_milliseconds: Optional[int] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class LoadParameters(_Model): + """Parameters required for content load. + + :ivar content_paths: The path to the content to be loaded. Path should be a relative file URL + of the origin. Required. + :vartype content_paths: list[str] + """ + + content_paths: list[str] = rest_field( + name="contentPaths", visibility=["read", "create", "update", "delete", "query"] + ) + """The path to the content to be loaded. Path should be a relative file URL of the origin. + Required.""" + + @overload + def __init__( + self, + *, + content_paths: list[str], + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class LogSpecification(_Model): + """Log specification of operation. + + :ivar name: Name of log specification. + :vartype name: str + :ivar display_name: Display name of log specification. + :vartype display_name: str + :ivar blob_duration: Blob duration of specification. + :vartype blob_duration: str + :ivar log_filter_pattern: Pattern to filter based on name. + :vartype log_filter_pattern: str + """ + + name: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Name of log specification.""" + display_name: Optional[str] = rest_field( + name="displayName", visibility=["read", "create", "update", "delete", "query"] + ) + """Display name of log specification.""" + blob_duration: Optional[str] = rest_field( + name="blobDuration", visibility=["read", "create", "update", "delete", "query"] + ) + """Blob duration of specification.""" + log_filter_pattern: Optional[str] = rest_field( + name="logFilterPattern", visibility=["read", "create", "update", "delete", "query"] + ) + """Pattern to filter based on name.""" + + @overload + def __init__( + self, + *, + name: Optional[str] = None, + display_name: Optional[str] = None, + blob_duration: Optional[str] = None, + log_filter_pattern: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ManagedCertificateParameters(SecretParameters, discriminator="ManagedCertificate"): + """Managed Certificate used for https. + + :ivar subject: Subject name in the certificate. + :vartype subject: str + :ivar expiration_date: Certificate expiration date. + :vartype expiration_date: str + :ivar type: The type of the secret resource. Required. MANAGED_CERTIFICATE. + :vartype type: str or ~azure.mgmt.cdn.models.MANAGED_CERTIFICATE + """ + + subject: Optional[str] = rest_field(visibility=["read"]) + """Subject name in the certificate.""" + expiration_date: Optional[str] = rest_field(name="expirationDate", visibility=["read"]) + """Certificate expiration date.""" + type: Literal[SecretType.MANAGED_CERTIFICATE] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """The type of the secret resource. Required. MANAGED_CERTIFICATE.""" + + @overload + def __init__( + self, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type = SecretType.MANAGED_CERTIFICATE # type: ignore + + +class ManagedRuleDefinition(_Model): + """Describes a managed rule definition. + + :ivar rule_id: Identifier for the managed rule. + :vartype rule_id: str + :ivar description: Describes the functionality of the managed rule. + :vartype description: str + """ + + rule_id: Optional[str] = rest_field(name="ruleId", visibility=["read"]) + """Identifier for the managed rule.""" + description: Optional[str] = rest_field(visibility=["read"]) + """Describes the functionality of the managed rule.""" + + +class ManagedRuleGroupDefinition(_Model): + """Describes a managed rule group. + + :ivar rule_group_name: Name of the managed rule group. + :vartype rule_group_name: str + :ivar description: Description of the managed rule group. + :vartype description: str + :ivar rules: List of rules within the managed rule group. + :vartype rules: list[~azure.mgmt.cdn.models.ManagedRuleDefinition] + """ + + rule_group_name: Optional[str] = rest_field(name="ruleGroupName", visibility=["read"]) + """Name of the managed rule group.""" + description: Optional[str] = rest_field(visibility=["read"]) + """Description of the managed rule group.""" + rules: Optional[list["_models.ManagedRuleDefinition"]] = rest_field(visibility=["read"]) + """List of rules within the managed rule group.""" + + +class ManagedRuleGroupOverride(_Model): + """Defines a managed rule group override setting. + + :ivar rule_group_name: Describes the managed rule group within the rule set to override. + Required. + :vartype rule_group_name: str + :ivar rules: List of rules that will be enabled. If none specified, all rules in the group will + be disabled. + :vartype rules: list[~azure.mgmt.cdn.models.ManagedRuleOverride] + """ + + rule_group_name: str = rest_field(name="ruleGroupName", visibility=["read", "create", "update", "delete", "query"]) + """Describes the managed rule group within the rule set to override. Required.""" + rules: Optional[list["_models.ManagedRuleOverride"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """List of rules that will be enabled. If none specified, all rules in the group will be disabled.""" + + @overload + def __init__( + self, + *, + rule_group_name: str, + rules: Optional[list["_models.ManagedRuleOverride"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ManagedRuleOverride(_Model): + """Defines a managed rule group override setting. + + :ivar rule_id: Identifier for the managed rule. Required. + :vartype rule_id: str + :ivar enabled_state: Describes if the managed rule is in enabled or disabled state. Defaults to + Disabled if not specified. Known values are: "Disabled" and "Enabled". + :vartype enabled_state: str or ~azure.mgmt.cdn.models.ManagedRuleEnabledState + :ivar action: Describes the override action to be applied when rule matches. Known values are: + "Allow", "Block", "Log", and "Redirect". + :vartype action: str or ~azure.mgmt.cdn.models.ActionType + """ + + rule_id: str = rest_field(name="ruleId", visibility=["read", "create", "update", "delete", "query"]) + """Identifier for the managed rule. Required.""" + enabled_state: Optional[Union[str, "_models.ManagedRuleEnabledState"]] = rest_field( + name="enabledState", visibility=["read", "create", "update", "delete", "query"] + ) + """Describes if the managed rule is in enabled or disabled state. Defaults to Disabled if not + specified. Known values are: \"Disabled\" and \"Enabled\".""" + action: Optional[Union[str, "_models.ActionType"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Describes the override action to be applied when rule matches. Known values are: \"Allow\", + \"Block\", \"Log\", and \"Redirect\".""" + + @overload + def __init__( + self, + *, + rule_id: str, + enabled_state: Optional[Union[str, "_models.ManagedRuleEnabledState"]] = None, + action: Optional[Union[str, "_models.ActionType"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ManagedRuleSet(_Model): + """Defines a managed rule set. + + :ivar rule_set_type: Defines the rule set type to use. Required. + :vartype rule_set_type: str + :ivar rule_set_version: Defines the version of the rule set to use. Required. + :vartype rule_set_version: str + :ivar anomaly_score: Verizon only : If the rule set supports anomaly detection mode, this + describes the threshold for blocking requests. + :vartype anomaly_score: int + :ivar rule_group_overrides: Defines the rule overrides to apply to the rule set. + :vartype rule_group_overrides: list[~azure.mgmt.cdn.models.ManagedRuleGroupOverride] + """ + + rule_set_type: str = rest_field(name="ruleSetType", visibility=["read", "create", "update", "delete", "query"]) + """Defines the rule set type to use. Required.""" + rule_set_version: str = rest_field( + name="ruleSetVersion", visibility=["read", "create", "update", "delete", "query"] + ) + """Defines the version of the rule set to use. Required.""" + anomaly_score: Optional[int] = rest_field( + name="anomalyScore", visibility=["read", "create", "update", "delete", "query"] + ) + """Verizon only : If the rule set supports anomaly detection mode, this describes the threshold + for blocking requests.""" + rule_group_overrides: Optional[list["_models.ManagedRuleGroupOverride"]] = rest_field( + name="ruleGroupOverrides", visibility=["read", "create", "update", "delete", "query"] + ) + """Defines the rule overrides to apply to the rule set.""" + + @overload + def __init__( + self, + *, + rule_set_type: str, + rule_set_version: str, + anomaly_score: Optional[int] = None, + rule_group_overrides: Optional[list["_models.ManagedRuleGroupOverride"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ManagedRuleSetDefinition(Resource): + """Describes a managed rule set definition. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.cdn.models.SystemData + :ivar properties: Describes managed rule set definition properties. + :vartype properties: ~azure.mgmt.cdn.models.ManagedRuleSetDefinitionProperties + :ivar sku: The pricing tier (defines a CDN provider, feature list and rate) of the + CdnWebApplicationFirewallPolicy. + :vartype sku: ~azure.mgmt.cdn.models.Sku + """ + + properties: Optional["_models.ManagedRuleSetDefinitionProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Describes managed rule set definition properties.""" + sku: Optional["_models.Sku"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The pricing tier (defines a CDN provider, feature list and rate) of the + CdnWebApplicationFirewallPolicy.""" + + __flattened_items = ["provisioning_state", "rule_set_type", "rule_set_version", "rule_groups"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.ManagedRuleSetDefinitionProperties"] = None, + sku: Optional["_models.Sku"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class ManagedRuleSetDefinitionProperties(_Model): + """Properties for a managed rule set definition. + + :ivar provisioning_state: Provisioning state of the managed rule set. + :vartype provisioning_state: str + :ivar rule_set_type: Type of the managed rule set. + :vartype rule_set_type: str + :ivar rule_set_version: Version of the managed rule set type. + :vartype rule_set_version: str + :ivar rule_groups: Rule groups of the managed rule set. + :vartype rule_groups: list[~azure.mgmt.cdn.models.ManagedRuleGroupDefinition] + """ + + provisioning_state: Optional[str] = rest_field(name="provisioningState", visibility=["read"]) + """Provisioning state of the managed rule set.""" + rule_set_type: Optional[str] = rest_field(name="ruleSetType", visibility=["read"]) + """Type of the managed rule set.""" + rule_set_version: Optional[str] = rest_field(name="ruleSetVersion", visibility=["read"]) + """Version of the managed rule set type.""" + rule_groups: Optional[list["_models.ManagedRuleGroupDefinition"]] = rest_field( + name="ruleGroups", visibility=["read"] + ) + """Rule groups of the managed rule set.""" + + +class ManagedRuleSetList(_Model): + """Defines the list of managed rule sets for the policy. + + :ivar managed_rule_sets: List of rule sets. + :vartype managed_rule_sets: list[~azure.mgmt.cdn.models.ManagedRuleSet] + """ + + managed_rule_sets: Optional[list["_models.ManagedRuleSet"]] = rest_field( + name="managedRuleSets", visibility=["read", "create", "update", "delete", "query"] + ) + """List of rule sets.""" + + @overload + def __init__( + self, + *, + managed_rule_sets: Optional[list["_models.ManagedRuleSet"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ManagedServiceIdentity(_Model): + """Managed service identity (system assigned and/or user assigned identities). + + :ivar principal_id: The service principal ID of the system assigned identity. This property + will only be provided for a system assigned identity. + :vartype principal_id: str + :ivar tenant_id: The tenant ID of the system assigned identity. This property will only be + provided for a system assigned identity. + :vartype tenant_id: str + :ivar type: The type of managed identity assigned to this resource. Required. Known values are: + "None", "SystemAssigned", "UserAssigned", and "SystemAssigned,UserAssigned". + :vartype type: str or ~azure.mgmt.cdn.models.ManagedServiceIdentityType + :ivar user_assigned_identities: The identities assigned to this resource by the user. + :vartype user_assigned_identities: dict[str, ~azure.mgmt.cdn.models.UserAssignedIdentity] + """ + + principal_id: Optional[str] = rest_field(name="principalId", visibility=["read"]) + """The service principal ID of the system assigned identity. This property will only be provided + for a system assigned identity.""" + tenant_id: Optional[str] = rest_field(name="tenantId", visibility=["read"]) + """The tenant ID of the system assigned identity. This property will only be provided for a system + assigned identity.""" + type: Union[str, "_models.ManagedServiceIdentityType"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The type of managed identity assigned to this resource. Required. Known values are: \"None\", + \"SystemAssigned\", \"UserAssigned\", and \"SystemAssigned,UserAssigned\".""" + user_assigned_identities: Optional[dict[str, "_models.UserAssignedIdentity"]] = rest_field( + name="userAssignedIdentities", visibility=["read", "create", "update", "delete", "query"] + ) + """The identities assigned to this resource by the user.""" + + @overload + def __init__( + self, + *, + type: Union[str, "_models.ManagedServiceIdentityType"], + user_assigned_identities: Optional[dict[str, "_models.UserAssignedIdentity"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class MatchCondition(_Model): + """Define match conditions. + + :ivar match_variable: Match variable to compare against. Required. Known values are: + "RemoteAddr", "SocketAddr", "RequestMethod", "RequestHeader", "RequestUri", "QueryString", + "RequestBody", "Cookies", and "PostArgs". + :vartype match_variable: str or ~azure.mgmt.cdn.models.WafMatchVariable + :ivar selector: Selector can used to match a specific key for QueryString, Cookies, + RequestHeader or PostArgs. + :vartype selector: str + :ivar operator: Describes operator to be matched. Required. Known values are: "Any", "IPMatch", + "GeoMatch", "Equal", "Contains", "LessThan", "GreaterThan", "LessThanOrEqual", + "GreaterThanOrEqual", "BeginsWith", "EndsWith", and "RegEx". + :vartype operator: str or ~azure.mgmt.cdn.models.Operator + :ivar negate_condition: Describes if the result of this condition should be negated. + :vartype negate_condition: bool + :ivar match_value: List of possible match values. Required. + :vartype match_value: list[str] + :ivar transforms: List of transforms. + :vartype transforms: list[str or ~azure.mgmt.cdn.models.TransformType] + """ + + match_variable: Union[str, "_models.WafMatchVariable"] = rest_field( + name="matchVariable", visibility=["read", "create", "update", "delete", "query"] + ) + """Match variable to compare against. Required. Known values are: \"RemoteAddr\", \"SocketAddr\", + \"RequestMethod\", \"RequestHeader\", \"RequestUri\", \"QueryString\", \"RequestBody\", + \"Cookies\", and \"PostArgs\".""" + selector: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Selector can used to match a specific key for QueryString, Cookies, RequestHeader or PostArgs.""" + operator: Union[str, "_models.Operator"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Describes operator to be matched. Required. Known values are: \"Any\", \"IPMatch\", + \"GeoMatch\", \"Equal\", \"Contains\", \"LessThan\", \"GreaterThan\", \"LessThanOrEqual\", + \"GreaterThanOrEqual\", \"BeginsWith\", \"EndsWith\", and \"RegEx\".""" + negate_condition: Optional[bool] = rest_field( + name="negateCondition", visibility=["read", "create", "update", "delete", "query"] + ) + """Describes if the result of this condition should be negated.""" + match_value: list[str] = rest_field(name="matchValue", visibility=["read", "create", "update", "delete", "query"]) + """List of possible match values. Required.""" + transforms: Optional[list[Union[str, "_models.TransformType"]]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """List of transforms.""" + + @overload + def __init__( + self, + *, + match_variable: Union[str, "_models.WafMatchVariable"], + operator: Union[str, "_models.Operator"], + match_value: list[str], + selector: Optional[str] = None, + negate_condition: Optional[bool] = None, + transforms: Optional[list[Union[str, "_models.TransformType"]]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class MetricAvailability(_Model): + """Retention policy of a resource metric. + + :ivar time_grain: + :vartype time_grain: str + :ivar blob_duration: + :vartype blob_duration: str + """ + + time_grain: Optional[str] = rest_field(name="timeGrain", visibility=["read", "create", "update", "delete", "query"]) + blob_duration: Optional[str] = rest_field( + name="blobDuration", visibility=["read", "create", "update", "delete", "query"] + ) + + @overload + def __init__( + self, + *, + time_grain: Optional[str] = None, + blob_duration: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class MetricSpecification(_Model): + """Metric specification of operation. + + :ivar name: Name of metric specification. + :vartype name: str + :ivar display_name: Display name of metric specification. + :vartype display_name: str + :ivar display_description: Display description of metric specification. + :vartype display_description: str + :ivar unit: The metric unit. Possible values include: 'Bytes', 'Count', 'Milliseconds'. + :vartype unit: str + :ivar aggregation_type: The metric aggregation type. Possible values include: 'Average', + 'Count', 'Total'. + :vartype aggregation_type: str + :ivar availabilities: Retention policies of a resource metric. + :vartype availabilities: list[~azure.mgmt.cdn.models.MetricAvailability] + :ivar supported_time_grain_types: The supported time grain types for the metrics. + :vartype supported_time_grain_types: list[str] + :ivar dimensions: The dimensions of metric. + :vartype dimensions: list[~azure.mgmt.cdn.models.DimensionProperties] + :ivar fill_gap_with_zero: Property to specify whether to fill gap with zero. + :vartype fill_gap_with_zero: bool + :ivar metric_filter_pattern: Pattern to filter based on name. + :vartype metric_filter_pattern: str + :ivar is_internal: Property to specify metric is internal or not. + :vartype is_internal: bool + """ + + name: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Name of metric specification.""" + display_name: Optional[str] = rest_field( + name="displayName", visibility=["read", "create", "update", "delete", "query"] + ) + """Display name of metric specification.""" + display_description: Optional[str] = rest_field( + name="displayDescription", visibility=["read", "create", "update", "delete", "query"] + ) + """Display description of metric specification.""" + unit: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The metric unit. Possible values include: 'Bytes', 'Count', 'Milliseconds'.""" + aggregation_type: Optional[str] = rest_field( + name="aggregationType", visibility=["read", "create", "update", "delete", "query"] + ) + """The metric aggregation type. Possible values include: 'Average', 'Count', 'Total'.""" + availabilities: Optional[list["_models.MetricAvailability"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Retention policies of a resource metric.""" + supported_time_grain_types: Optional[list[str]] = rest_field( + name="supportedTimeGrainTypes", visibility=["read", "create", "update", "delete", "query"] + ) + """The supported time grain types for the metrics.""" + dimensions: Optional[list["_models.DimensionProperties"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The dimensions of metric.""" + fill_gap_with_zero: Optional[bool] = rest_field( + name="fillGapWithZero", visibility=["read", "create", "update", "delete", "query"] + ) + """Property to specify whether to fill gap with zero.""" + metric_filter_pattern: Optional[str] = rest_field( + name="metricFilterPattern", visibility=["read", "create", "update", "delete", "query"] + ) + """Pattern to filter based on name.""" + is_internal: Optional[bool] = rest_field( + name="isInternal", visibility=["read", "create", "update", "delete", "query"] + ) + """Property to specify metric is internal or not.""" + + @overload + def __init__( + self, + *, + name: Optional[str] = None, + display_name: Optional[str] = None, + display_description: Optional[str] = None, + unit: Optional[str] = None, + aggregation_type: Optional[str] = None, + availabilities: Optional[list["_models.MetricAvailability"]] = None, + supported_time_grain_types: Optional[list[str]] = None, + dimensions: Optional[list["_models.DimensionProperties"]] = None, + fill_gap_with_zero: Optional[bool] = None, + metric_filter_pattern: Optional[str] = None, + is_internal: Optional[bool] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class MetricsResponse(_Model): + """Metrics Response. + + :ivar date_time_begin: + :vartype date_time_begin: ~datetime.datetime + :ivar date_time_end: + :vartype date_time_end: ~datetime.datetime + :ivar granularity: Known values are: "PT5M", "PT1H", and "P1D". + :vartype granularity: str or ~azure.mgmt.cdn.models.MetricsGranularity + :ivar series: + :vartype series: list[~azure.mgmt.cdn.models.MetricsResponseSeriesItem] + """ + + date_time_begin: Optional[datetime.datetime] = rest_field( + name="dateTimeBegin", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) + date_time_end: Optional[datetime.datetime] = rest_field( + name="dateTimeEnd", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) + granularity: Optional[Union[str, "_models.MetricsGranularity"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Known values are: \"PT5M\", \"PT1H\", and \"P1D\".""" + series: Optional[list["_models.MetricsResponseSeriesItem"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + + @overload + def __init__( + self, + *, + date_time_begin: Optional[datetime.datetime] = None, + date_time_end: Optional[datetime.datetime] = None, + granularity: Optional[Union[str, "_models.MetricsGranularity"]] = None, + series: Optional[list["_models.MetricsResponseSeriesItem"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class MetricsResponseSeriesItem(_Model): + """MetricsResponseSeriesItem. + + :ivar metric: + :vartype metric: str + :ivar unit: Known values are: "count", "bytes", "bitsPerSecond", and "milliSeconds". + :vartype unit: str or ~azure.mgmt.cdn.models.MetricsSeriesUnit + :ivar groups: + :vartype groups: list[~azure.mgmt.cdn.models.MetricsResponseSeriesPropertiesItemsItem] + :ivar data: + :vartype data: + list[~azure.mgmt.cdn.models.Components1Gs0LlpSchemasMetricsresponsePropertiesSeriesItemsPropertiesDataItems] + """ + + metric: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + unit: Optional[Union[str, "_models.MetricsSeriesUnit"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Known values are: \"count\", \"bytes\", \"bitsPerSecond\", and \"milliSeconds\".""" + groups: Optional[list["_models.MetricsResponseSeriesPropertiesItemsItem"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + data: Optional[list["_models.Components1Gs0LlpSchemasMetricsresponsePropertiesSeriesItemsPropertiesDataItems"]] = ( + rest_field(visibility=["read", "create", "update", "delete", "query"]) + ) + + @overload + def __init__( + self, + *, + metric: Optional[str] = None, + unit: Optional[Union[str, "_models.MetricsSeriesUnit"]] = None, + groups: Optional[list["_models.MetricsResponseSeriesPropertiesItemsItem"]] = None, + data: Optional[ + list["_models.Components1Gs0LlpSchemasMetricsresponsePropertiesSeriesItemsPropertiesDataItems"] + ] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class MetricsResponseSeriesPropertiesItemsItem(_Model): + """MetricsResponseSeriesPropertiesItemsItem. + + :ivar name: + :vartype name: str + :ivar value: + :vartype value: str + """ + + name: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + value: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + + @overload + def __init__( + self, + *, + name: Optional[str] = None, + value: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class MigrateResult(_Model): + """Result for migrate operation. + + :ivar id: Resource ID. + :vartype id: str + :ivar type: Resource type. + :vartype type: str + :ivar properties: + :vartype properties: ~azure.mgmt.cdn.models.MigrateResultProperties + """ + + id: Optional[str] = rest_field(visibility=["read"]) + """Resource ID.""" + type: Optional[str] = rest_field(visibility=["read"]) + """Resource type.""" + properties: Optional["_models.MigrateResultProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + + __flattened_items = ["migrated_profile_resource_id"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.MigrateResultProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class MigrateResultProperties(_Model): + """MigrateResultProperties. + + :ivar migrated_profile_resource_id: Arm resource id of the migrated profile. + :vartype migrated_profile_resource_id: ~azure.mgmt.cdn.models.ResourceReference + """ + + migrated_profile_resource_id: Optional["_models.ResourceReference"] = rest_field( + name="migratedProfileResourceId", visibility=["read"] + ) + """Arm resource id of the migrated profile.""" + + +class MigrationEndpointMapping(_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 + """ + + migrated_from: Optional[str] = rest_field( + name="migratedFrom", visibility=["read", "create", "update", "delete", "query"] + ) + """Name of the classic CDN profile endpoint.""" + migrated_to: Optional[str] = rest_field( + name="migratedTo", visibility=["read", "create", "update", "delete", "query"] + ) + """Name of the newly created migrated Azure Frontdoor Standard/Premium profile endpoint. This name + will replace the name of the classic CDN endpoint resource.""" + + @overload + def __init__( + self, + *, + migrated_from: Optional[str] = None, + migrated_to: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class MigrationErrorType(_Model): + """Error response indicates CDN service is not able to process the incoming request. The reason is + provided in the error message. + + :ivar code: Error code. + :vartype code: str + :ivar resource_name: Resource which has the problem. + :vartype resource_name: str + :ivar error_message: Error message indicating why the operation failed. + :vartype error_message: str + :ivar next_steps: Describes what needs to be done to fix the problem. + :vartype next_steps: str + """ + + code: Optional[str] = rest_field(visibility=["read"]) + """Error code.""" + resource_name: Optional[str] = rest_field(name="resourceName", visibility=["read"]) + """Resource which has the problem.""" + error_message: Optional[str] = rest_field(name="errorMessage", visibility=["read"]) + """Error message indicating why the operation failed.""" + next_steps: Optional[str] = rest_field(name="nextSteps", visibility=["read"]) + """Describes what needs to be done to fix the problem.""" + + +class MigrationParameters(_Model): + """Request body for Migrate operation. + + :ivar sku: Sku for the migration. Required. + :vartype sku: ~azure.mgmt.cdn.models.Sku + :ivar classic_resource_reference: Resource reference of the classic cdn profile or classic + frontdoor that need to be migrated. Required. + :vartype classic_resource_reference: ~azure.mgmt.cdn.models.ResourceReference + :ivar profile_name: Name of the new profile that need to be created. Required. + :vartype profile_name: str + :ivar migration_web_application_firewall_mappings: Waf mapping for the migrated profile. + :vartype migration_web_application_firewall_mappings: + list[~azure.mgmt.cdn.models.MigrationWebApplicationFirewallMapping] + """ + + sku: "_models.Sku" = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Sku for the migration. Required.""" + classic_resource_reference: "_models.ResourceReference" = rest_field( + name="classicResourceReference", visibility=["read", "create", "update", "delete", "query"] + ) + """Resource reference of the classic cdn profile or classic frontdoor that need to be migrated. + Required.""" + profile_name: str = rest_field(name="profileName", visibility=["read", "create", "update", "delete", "query"]) + """Name of the new profile that need to be created. Required.""" + migration_web_application_firewall_mappings: Optional[list["_models.MigrationWebApplicationFirewallMapping"]] = ( + rest_field( + name="migrationWebApplicationFirewallMappings", visibility=["read", "create", "update", "delete", "query"] + ) + ) + """Waf mapping for the migrated profile.""" + + @overload + def __init__( + self, + *, + sku: "_models.Sku", + classic_resource_reference: "_models.ResourceReference", + profile_name: str, + migration_web_application_firewall_mappings: Optional[ + list["_models.MigrationWebApplicationFirewallMapping"] + ] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class MigrationWebApplicationFirewallMapping(_Model): + """Web Application Firewall Mapping. + + :ivar migrated_from: Migration From Waf policy. + :vartype migrated_from: ~azure.mgmt.cdn.models.ResourceReference + :ivar migrated_to: Migration to Waf policy. + :vartype migrated_to: ~azure.mgmt.cdn.models.ResourceReference + """ + + migrated_from: Optional["_models.ResourceReference"] = rest_field( + name="migratedFrom", visibility=["read", "create", "update", "delete", "query"] + ) + """Migration From Waf policy.""" + migrated_to: Optional["_models.ResourceReference"] = rest_field( + name="migratedTo", visibility=["read", "create", "update", "delete", "query"] + ) + """Migration to Waf policy.""" + + @overload + def __init__( + self, + *, + migrated_from: Optional["_models.ResourceReference"] = None, + migrated_to: Optional["_models.ResourceReference"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class Operation(_Model): + """CDN REST API operation. + + :ivar name: Operation name: {provider}/{resource}/{operation}. + :vartype name: str + :ivar is_data_action: Indicates whether the operation is a data action. + :vartype is_data_action: bool + :ivar display: The object that represents the operation. + :vartype display: ~azure.mgmt.cdn.models.OperationDisplay + :ivar origin: The origin of operations. + :vartype origin: str + :ivar operation_properties: Properties of operation, include metric specifications. + :vartype operation_properties: ~azure.mgmt.cdn.models.OperationProperties + """ + + name: Optional[str] = rest_field(visibility=["read"]) + """Operation name: {provider}/{resource}/{operation}.""" + is_data_action: Optional[bool] = rest_field( + name="isDataAction", visibility=["read", "create", "update", "delete", "query"] + ) + """Indicates whether the operation is a data action.""" + display: Optional["_models.OperationDisplay"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The object that represents the operation.""" + origin: Optional[str] = rest_field(visibility=["read"]) + """The origin of operations.""" + operation_properties: Optional["_models.OperationProperties"] = rest_field( + name="properties", visibility=["read", "create", "update", "delete", "query"] + ) + """Properties of operation, include metric specifications.""" + + __flattened_items = ["service_specification"] + + @overload + def __init__( + self, + *, + is_data_action: Optional[bool] = None, + display: Optional["_models.OperationDisplay"] = None, + operation_properties: Optional["_models.OperationProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.operation_properties is None: + return None + return getattr(self.operation_properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.operation_properties is None: + self.operation_properties = self._attr_to_rest_field["operation_properties"]._class_type() + setattr(self.operation_properties, key, value) + else: + super().__setattr__(key, value) + + +class OperationDisplay(_Model): + """The object that represents the operation. + + :ivar provider: Service provider: Microsoft.Cdn. + :vartype provider: str + :ivar resource: Resource on which the operation is performed: Profile, endpoint, etc. + :vartype resource: str + :ivar operation: Operation type: Read, write, delete, etc. + :vartype operation: str + :ivar description: Description of operation. + :vartype description: str + """ + + provider: Optional[str] = rest_field(visibility=["read"]) + """Service provider: Microsoft.Cdn.""" + resource: Optional[str] = rest_field(visibility=["read"]) + """Resource on which the operation is performed: Profile, endpoint, etc.""" + operation: Optional[str] = rest_field(visibility=["read"]) + """Operation type: Read, write, delete, etc.""" + description: Optional[str] = rest_field(visibility=["read"]) + """Description of operation.""" + + +class OperationProperties(_Model): + """Properties of operation, include metric specifications. + + :ivar service_specification: One property of operation, include metric specifications. + :vartype service_specification: ~azure.mgmt.cdn.models.ServiceSpecification + """ + + service_specification: Optional["_models.ServiceSpecification"] = rest_field( + name="serviceSpecification", visibility=["read", "create", "update", "delete", "query"] + ) + """One property of operation, include metric specifications.""" + + @overload + def __init__( + self, + *, + service_specification: Optional["_models.ServiceSpecification"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +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. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.cdn.models.SystemData + :ivar properties: The JSON object that contains the properties of the origin. + :vartype properties: ~azure.mgmt.cdn.models.OriginProperties + """ + + properties: Optional["_models.OriginProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The JSON object that contains the properties of the origin.""" + + __flattened_items = [ + "http_port", + "https_port", + "origin_host_header", + "priority", + "weight", + "enabled", + "private_link_alias", + "private_link_resource_id", + "private_link_location", + "private_link_approval_message", + "resource_state", + "provisioning_state", + "private_endpoint_status", + "host_name", + ] + + @overload + def __init__( + self, + *, + properties: Optional["_models.OriginProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class OriginAuthenticationProperties(_Model): + """The JSON object that contains the properties of the origin authentication settings. + + :ivar type: The type of the authentication for the origin. Known values are: + "SystemAssignedIdentity" and "UserAssignedIdentity". + :vartype type: str or ~azure.mgmt.cdn.models.OriginAuthenticationType + :ivar user_assigned_identity: The user assigned managed identity to use for the origin + authentication if type is UserAssignedIdentity. + :vartype user_assigned_identity: ~azure.mgmt.cdn.models.ResourceReference + :ivar scope: The scope used when requesting token from Microsoft Entra. For example, for Azure + Blob Storage, scope could be "`https://storage.azure.com/.default + `_". + :vartype scope: str + """ + + type: Optional[Union[str, "_models.OriginAuthenticationType"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The type of the authentication for the origin. Known values are: \"SystemAssignedIdentity\" and + \"UserAssignedIdentity\".""" + user_assigned_identity: Optional["_models.ResourceReference"] = rest_field( + name="userAssignedIdentity", visibility=["read", "create", "update", "delete", "query"] + ) + """The user assigned managed identity to use for the origin authentication if type is + UserAssignedIdentity.""" + scope: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The scope used when requesting token from Microsoft Entra. For example, for Azure Blob Storage, + scope could be \"`https://storage.azure.com/.default `_\".""" + + @overload + def __init__( + self, + *, + type: Optional[Union[str, "_models.OriginAuthenticationType"]] = None, + user_assigned_identity: Optional["_models.ResourceReference"] = None, + scope: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class OriginGroup(ProxyResource): + """Origin group comprising of origins is used for load balancing to origins when the content + cannot be served from CDN. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.cdn.models.SystemData + :ivar properties: The JSON object that contains the properties of the origin group. + :vartype properties: ~azure.mgmt.cdn.models.OriginGroupProperties + """ + + properties: Optional["_models.OriginGroupProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The JSON object that contains the properties of the origin group.""" + + __flattened_items = [ + "health_probe_settings", + "origins", + "traffic_restoration_time_to_healed_or_new_endpoints_in_minutes", + "response_based_origin_error_detection_settings", + "resource_state", + "provisioning_state", + ] + + @overload + def __init__( + self, + *, + properties: Optional["_models.OriginGroupProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class OriginGroupOverride(_Model): + """Defines the parameters for the origin group override configuration. + + :ivar origin_group: defines the OriginGroup that would override the DefaultOriginGroup on + route. + :vartype origin_group: ~azure.mgmt.cdn.models.ResourceReference + :ivar forwarding_protocol: Protocol this rule will use when forwarding traffic to backends. + Known values are: "HttpOnly", "HttpsOnly", and "MatchRequest". + :vartype forwarding_protocol: str or ~azure.mgmt.cdn.models.ForwardingProtocol + """ + + origin_group: Optional["_models.ResourceReference"] = rest_field( + name="originGroup", visibility=["read", "create", "update", "delete", "query"] + ) + """defines the OriginGroup that would override the DefaultOriginGroup on route.""" + forwarding_protocol: Optional[Union[str, "_models.ForwardingProtocol"]] = rest_field( + name="forwardingProtocol", visibility=["read", "create", "update", "delete", "query"] + ) + """Protocol this rule will use when forwarding traffic to backends. Known values are: + \"HttpOnly\", \"HttpsOnly\", and \"MatchRequest\".""" + + @overload + def __init__( + self, + *, + origin_group: Optional["_models.ResourceReference"] = None, + forwarding_protocol: Optional[Union[str, "_models.ForwardingProtocol"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class OriginGroupOverrideAction(DeliveryRuleAction, discriminator="OriginGroupOverride"): + """Defines the origin group override action for the delivery rule. + + :ivar parameters: Defines the parameters for the action. Required. + :vartype parameters: ~azure.mgmt.cdn.models.OriginGroupOverrideActionParameters + :ivar name: The name of the action for the delivery rule. Required. ORIGIN_GROUP_OVERRIDE. + :vartype name: str or ~azure.mgmt.cdn.models.ORIGIN_GROUP_OVERRIDE + """ + + parameters: "_models.OriginGroupOverrideActionParameters" = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Defines the parameters for the action. Required.""" + name: Literal[DeliveryRuleActionName.ORIGIN_GROUP_OVERRIDE] = rest_discriminator(name="name", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """The name of the action for the delivery rule. Required. ORIGIN_GROUP_OVERRIDE.""" + + @overload + def __init__( + self, + *, + parameters: "_models.OriginGroupOverrideActionParameters", + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.name = DeliveryRuleActionName.ORIGIN_GROUP_OVERRIDE # type: ignore + + +class OriginGroupOverrideActionParameters( + DeliveryRuleActionParameters, discriminator="DeliveryRuleOriginGroupOverrideActionParameters" +): + """Defines the parameters for the origin group override action. + + :ivar origin_group: defines the OriginGroup that would override the DefaultOriginGroup. + Required. + :vartype origin_group: ~azure.mgmt.cdn.models.ResourceReference + :ivar type_name: Required. DELIVERY_RULE_ORIGIN_GROUP_OVERRIDE_ACTION_PARAMETERS. + :vartype type_name: str or + ~azure.mgmt.cdn.models.DELIVERY_RULE_ORIGIN_GROUP_OVERRIDE_ACTION_PARAMETERS + """ + + origin_group: "_models.ResourceReference" = rest_field( + name="originGroup", visibility=["read", "create", "update", "delete", "query"] + ) + """defines the OriginGroup that would override the DefaultOriginGroup. Required.""" + type_name: Literal[DeliveryRuleActionParametersType.DELIVERY_RULE_ORIGIN_GROUP_OVERRIDE_ACTION_PARAMETERS] = rest_discriminator(name="typeName", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Required. DELIVERY_RULE_ORIGIN_GROUP_OVERRIDE_ACTION_PARAMETERS.""" + + @overload + def __init__( + self, + *, + origin_group: "_models.ResourceReference", + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type_name = DeliveryRuleActionParametersType.DELIVERY_RULE_ORIGIN_GROUP_OVERRIDE_ACTION_PARAMETERS # type: ignore + + +class OriginGroupUpdatePropertiesParameters(_Model): + """The JSON object that contains the properties of the origin group. + + :ivar health_probe_settings: Health probe settings to the origin that is used to determine the + health of the origin. + :vartype health_probe_settings: ~azure.mgmt.cdn.models.HealthProbeParameters + :ivar origins: The source of the content being delivered via CDN within given origin group. + :vartype origins: list[~azure.mgmt.cdn.models.ResourceReference] + :ivar traffic_restoration_time_to_healed_or_new_endpoints_in_minutes: Time in minutes to shift + the traffic to the endpoint gradually when an unhealthy endpoint comes healthy or a new + endpoint is added. Default is 10 mins. This property is currently not supported. + :vartype traffic_restoration_time_to_healed_or_new_endpoints_in_minutes: int + :ivar response_based_origin_error_detection_settings: The JSON object that contains the + properties to determine origin health using real requests/responses. This property is currently + not supported. + :vartype response_based_origin_error_detection_settings: + ~azure.mgmt.cdn.models.ResponseBasedOriginErrorDetectionParameters + """ + + health_probe_settings: Optional["_models.HealthProbeParameters"] = rest_field( + name="healthProbeSettings", visibility=["read", "create", "update", "delete", "query"] + ) + """Health probe settings to the origin that is used to determine the health of the origin.""" + origins: Optional[list["_models.ResourceReference"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The source of the content being delivered via CDN within given origin group.""" + traffic_restoration_time_to_healed_or_new_endpoints_in_minutes: Optional[int] = rest_field( + name="trafficRestorationTimeToHealedOrNewEndpointsInMinutes", + visibility=["read", "create", "update", "delete", "query"], + ) + """Time in minutes to shift the traffic to the endpoint gradually when an unhealthy endpoint comes + healthy or a new endpoint is added. Default is 10 mins. This property is currently not + supported.""" + response_based_origin_error_detection_settings: Optional["_models.ResponseBasedOriginErrorDetectionParameters"] = ( + rest_field( + name="responseBasedOriginErrorDetectionSettings", visibility=["read", "create", "update", "delete", "query"] + ) + ) + """The JSON object that contains the properties to determine origin health using real + requests/responses. This property is currently not supported.""" + + @overload + def __init__( + self, + *, + health_probe_settings: Optional["_models.HealthProbeParameters"] = None, + origins: Optional[list["_models.ResourceReference"]] = None, + traffic_restoration_time_to_healed_or_new_endpoints_in_minutes: Optional[int] = None, + response_based_origin_error_detection_settings: Optional[ + "_models.ResponseBasedOriginErrorDetectionParameters" + ] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class OriginGroupProperties(OriginGroupUpdatePropertiesParameters): + """The JSON object that contains the properties of the origin group. + + :ivar health_probe_settings: Health probe settings to the origin that is used to determine the + health of the origin. + :vartype health_probe_settings: ~azure.mgmt.cdn.models.HealthProbeParameters + :ivar origins: The source of the content being delivered via CDN within given origin group. + :vartype origins: list[~azure.mgmt.cdn.models.ResourceReference] + :ivar traffic_restoration_time_to_healed_or_new_endpoints_in_minutes: Time in minutes to shift + the traffic to the endpoint gradually when an unhealthy endpoint comes healthy or a new + endpoint is added. Default is 10 mins. This property is currently not supported. + :vartype traffic_restoration_time_to_healed_or_new_endpoints_in_minutes: int + :ivar response_based_origin_error_detection_settings: The JSON object that contains the + properties to determine origin health using real requests/responses. This property is currently + not supported. + :vartype response_based_origin_error_detection_settings: + ~azure.mgmt.cdn.models.ResponseBasedOriginErrorDetectionParameters + :ivar resource_state: Resource status of the origin group. Known values are: "Creating", + "Active", and "Deleting". + :vartype resource_state: str or ~azure.mgmt.cdn.models.OriginGroupResourceState + :ivar provisioning_state: Provisioning status of the origin group. Known values are: + "Succeeded", "Failed", "Updating", "Deleting", and "Creating". + :vartype provisioning_state: str or ~azure.mgmt.cdn.models.OriginGroupProvisioningState + """ + + resource_state: Optional[Union[str, "_models.OriginGroupResourceState"]] = rest_field( + name="resourceState", visibility=["read"] + ) + """Resource status of the origin group. Known values are: \"Creating\", \"Active\", and + \"Deleting\".""" + provisioning_state: Optional[Union[str, "_models.OriginGroupProvisioningState"]] = rest_field( + name="provisioningState", visibility=["read"] + ) + """Provisioning status of the origin group. Known values are: \"Succeeded\", \"Failed\", + \"Updating\", \"Deleting\", and \"Creating\".""" + + @overload + def __init__( + self, + *, + health_probe_settings: Optional["_models.HealthProbeParameters"] = None, + origins: Optional[list["_models.ResourceReference"]] = None, + traffic_restoration_time_to_healed_or_new_endpoints_in_minutes: Optional[int] = None, + response_based_origin_error_detection_settings: Optional[ + "_models.ResponseBasedOriginErrorDetectionParameters" + ] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class OriginGroupUpdateParameters(_Model): + """Origin group properties needed for origin group creation or update. + + :ivar properties: The JSON object that contains the properties of the origin group. + :vartype properties: ~azure.mgmt.cdn.models.OriginGroupUpdatePropertiesParameters + """ + + properties: Optional["_models.OriginGroupUpdatePropertiesParameters"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The JSON object that contains the properties of the origin group.""" + + __flattened_items = [ + "health_probe_settings", + "origins", + "traffic_restoration_time_to_healed_or_new_endpoints_in_minutes", + "response_based_origin_error_detection_settings", + ] + + @overload + def __init__( + self, + *, + properties: Optional["_models.OriginGroupUpdatePropertiesParameters"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class OriginUpdatePropertiesParameters(_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 + are supported.This should be unique across all origins in an endpoint. + :vartype host_name: str + :ivar http_port: The value of the HTTP port. Must be between 1 and 65535. + :vartype http_port: int + :ivar https_port: The value of the HTTPS port. Must be between 1 and 65535. + :vartype https_port: int + :ivar origin_host_header: The host header value sent to the origin with each request. If you + leave this blank, the request hostname determines this value. Azure CDN origins, such as Web + Apps, Blob Storage, and Cloud Services require this host header value to match the origin + hostname by default. This overrides the host header defined at Endpoint. + :vartype origin_host_header: str + :ivar priority: Priority of origin in given origin group for load balancing. Higher priorities + will not be used for load balancing if any lower priority origin is healthy.Must be between 1 + and 5. + :vartype priority: int + :ivar weight: Weight of the origin in given origin group for load balancing. Must be between 1 + and 1000. + :vartype weight: int + :ivar enabled: Origin is enabled for load balancing or not. + :vartype enabled: bool + :ivar private_link_alias: The Alias of the Private Link resource. Populating this optional + field indicates that this origin is 'Private'. + :vartype private_link_alias: str + :ivar private_link_resource_id: The Resource Id of the Private Link resource. Populating this + optional field indicates that this backend is 'Private'. + :vartype private_link_resource_id: str + :ivar private_link_location: The location of the Private Link resource. Required only if + 'privateLinkResourceId' is populated. + :vartype private_link_location: str + :ivar private_link_approval_message: A custom message to be included in the approval request to + connect to the Private Link. + :vartype private_link_approval_message: str + """ + + host_name: Optional[str] = rest_field(name="hostName", visibility=["read", "create", "update", "delete", "query"]) + """The address of the origin. Domain names, IPv4 addresses, and IPv6 addresses are supported.This + should be unique across all origins in an endpoint.""" + http_port: Optional[int] = rest_field(name="httpPort", visibility=["read", "create", "update", "delete", "query"]) + """The value of the HTTP port. Must be between 1 and 65535.""" + https_port: Optional[int] = rest_field(name="httpsPort", visibility=["read", "create", "update", "delete", "query"]) + """The value of the HTTPS port. Must be between 1 and 65535.""" + origin_host_header: Optional[str] = rest_field( + name="originHostHeader", visibility=["read", "create", "update", "delete", "query"] + ) + """The host header value sent to the origin with each request. If you leave this blank, the + request hostname determines this value. Azure CDN origins, such as Web Apps, Blob Storage, and + Cloud Services require this host header value to match the origin hostname by default. This + overrides the host header defined at Endpoint.""" + priority: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Priority of origin in given origin group for load balancing. Higher priorities will not be used + for load balancing if any lower priority origin is healthy.Must be between 1 and 5.""" + weight: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Weight of the origin in given origin group for load balancing. Must be between 1 and 1000.""" + enabled: Optional[bool] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Origin is enabled for load balancing or not.""" + private_link_alias: Optional[str] = rest_field( + name="privateLinkAlias", visibility=["read", "create", "update", "delete", "query"] + ) + """The Alias of the Private Link resource. Populating this optional field indicates that this + origin is 'Private'.""" + private_link_resource_id: Optional[str] = rest_field( + name="privateLinkResourceId", visibility=["read", "create", "update", "delete", "query"] + ) + """The Resource Id of the Private Link resource. Populating this optional field indicates that + this backend is 'Private'.""" + private_link_location: Optional[str] = rest_field( + name="privateLinkLocation", visibility=["read", "create", "update", "delete", "query"] + ) + """The location of the Private Link resource. Required only if 'privateLinkResourceId' is + populated.""" + private_link_approval_message: Optional[str] = rest_field( + name="privateLinkApprovalMessage", visibility=["read", "create", "update", "delete", "query"] + ) + """A custom message to be included in the approval request to connect to the Private Link.""" + + @overload + def __init__( + self, + *, + host_name: Optional[str] = None, + http_port: Optional[int] = None, + https_port: Optional[int] = None, + origin_host_header: Optional[str] = None, + priority: Optional[int] = None, + weight: Optional[int] = None, + enabled: Optional[bool] = None, + private_link_alias: Optional[str] = None, + private_link_resource_id: Optional[str] = None, + private_link_location: Optional[str] = None, + private_link_approval_message: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class OriginProperties(OriginUpdatePropertiesParameters): + """The JSON object that contains the properties of the origin. + + :ivar http_port: The value of the HTTP port. Must be between 1 and 65535. + :vartype http_port: int + :ivar https_port: The value of the HTTPS port. Must be between 1 and 65535. + :vartype https_port: int + :ivar origin_host_header: The host header value sent to the origin with each request. If you + leave this blank, the request hostname determines this value. Azure CDN origins, such as Web + Apps, Blob Storage, and Cloud Services require this host header value to match the origin + hostname by default. This overrides the host header defined at Endpoint. + :vartype origin_host_header: str + :ivar priority: Priority of origin in given origin group for load balancing. Higher priorities + will not be used for load balancing if any lower priority origin is healthy.Must be between 1 + and 5. + :vartype priority: int + :ivar weight: Weight of the origin in given origin group for load balancing. Must be between 1 + and 1000. + :vartype weight: int + :ivar enabled: Origin is enabled for load balancing or not. + :vartype enabled: bool + :ivar private_link_alias: The Alias of the Private Link resource. Populating this optional + field indicates that this origin is 'Private'. + :vartype private_link_alias: str + :ivar private_link_resource_id: The Resource Id of the Private Link resource. Populating this + optional field indicates that this backend is 'Private'. + :vartype private_link_resource_id: str + :ivar private_link_location: The location of the Private Link resource. Required only if + 'privateLinkResourceId' is populated. + :vartype private_link_location: str + :ivar private_link_approval_message: A custom message to be included in the approval request to + connect to the Private Link. + :vartype private_link_approval_message: str + :ivar resource_state: Resource status of the origin. Known values are: "Creating", "Active", + and "Deleting". + :vartype resource_state: str or ~azure.mgmt.cdn.models.OriginResourceState + :ivar provisioning_state: Provisioning status of the origin. Known values are: "Succeeded", + "Failed", "Updating", "Deleting", and "Creating". + :vartype provisioning_state: str or ~azure.mgmt.cdn.models.OriginProvisioningState + :ivar private_endpoint_status: The approval status for the connection to the Private Link. + Known values are: "Pending", "Approved", "Rejected", "Disconnected", and "Timeout". + :vartype private_endpoint_status: str or ~azure.mgmt.cdn.models.PrivateEndpointStatus + :ivar host_name: The address of the origin. Domain names, IPv4 addresses, and IPv6 addresses + are supported.This should be unique across all origins in an endpoint. Required. + :vartype host_name: str + """ + + resource_state: Optional[Union[str, "_models.OriginResourceState"]] = rest_field( + name="resourceState", visibility=["read"] + ) + """Resource status of the origin. Known values are: \"Creating\", \"Active\", and \"Deleting\".""" + provisioning_state: Optional[Union[str, "_models.OriginProvisioningState"]] = rest_field( + name="provisioningState", visibility=["read"] + ) + """Provisioning status of the origin. Known values are: \"Succeeded\", \"Failed\", \"Updating\", + \"Deleting\", and \"Creating\".""" + private_endpoint_status: Optional[Union[str, "_models.PrivateEndpointStatus"]] = rest_field( + name="privateEndpointStatus", visibility=["read"] + ) + """The approval status for the connection to the Private Link. Known values are: \"Pending\", + \"Approved\", \"Rejected\", \"Disconnected\", and \"Timeout\".""" + host_name: str = rest_field(name="hostName", visibility=["read", "create", "update", "delete", "query"]) + """The address of the origin. Domain names, IPv4 addresses, and IPv6 addresses are supported.This + should be unique across all origins in an endpoint. Required.""" + + @overload + def __init__( + self, + *, + host_name: str, + http_port: Optional[int] = None, + https_port: Optional[int] = None, + origin_host_header: Optional[str] = None, + priority: Optional[int] = None, + weight: Optional[int] = None, + enabled: Optional[bool] = None, + private_link_alias: Optional[str] = None, + private_link_resource_id: Optional[str] = None, + private_link_location: Optional[str] = None, + private_link_approval_message: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class OriginUpdateParameters(_Model): + """Origin properties needed for origin update. + + :ivar properties: The JSON object that contains the properties of the origin. + :vartype properties: ~azure.mgmt.cdn.models.OriginUpdatePropertiesParameters + """ + + properties: Optional["_models.OriginUpdatePropertiesParameters"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The JSON object that contains the properties of the origin.""" + + __flattened_items = [ + "host_name", + "http_port", + "https_port", + "origin_host_header", + "priority", + "weight", + "enabled", + "private_link_alias", + "private_link_resource_id", + "private_link_location", + "private_link_approval_message", + ] + + @overload + def __init__( + self, + *, + properties: Optional["_models.OriginUpdatePropertiesParameters"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class PolicySettings(_Model): + """Defines contents of a web application firewall global configuration. + + :ivar enabled_state: describes if the policy is in enabled state or disabled state. Known + values are: "Disabled" and "Enabled". + :vartype enabled_state: str or ~azure.mgmt.cdn.models.PolicyEnabledState + :ivar mode: Describes if it is in detection mode or prevention mode at policy level. Known + values are: "Prevention" and "Detection". + :vartype mode: str or ~azure.mgmt.cdn.models.PolicyMode + :ivar default_redirect_url: If action type is redirect, this field represents the default + redirect URL for the client. + :vartype default_redirect_url: str + :ivar default_custom_block_response_status_code: If the action type is block, this field + defines the default customer overridable http response status code. Known values are: 200, 403, + 405, 406, and 429. + :vartype default_custom_block_response_status_code: int or + ~azure.mgmt.cdn.models.PolicySettingsDefaultCustomBlockResponseStatusCode + :ivar default_custom_block_response_body: If the action type is block, customer can override + the response body. The body must be specified in base64 encoding. + :vartype default_custom_block_response_body: str + """ + + enabled_state: Optional[Union[str, "_models.PolicyEnabledState"]] = rest_field( + name="enabledState", visibility=["read", "create", "update", "delete", "query"] + ) + """describes if the policy is in enabled state or disabled state. Known values are: \"Disabled\" + and \"Enabled\".""" + mode: Optional[Union[str, "_models.PolicyMode"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Describes if it is in detection mode or prevention mode at policy level. Known values are: + \"Prevention\" and \"Detection\".""" + default_redirect_url: Optional[str] = rest_field( + name="defaultRedirectUrl", visibility=["read", "create", "update", "delete", "query"] + ) + """If action type is redirect, this field represents the default redirect URL for the client.""" + default_custom_block_response_status_code: Optional[ + Union[int, "_models.PolicySettingsDefaultCustomBlockResponseStatusCode"] + ] = rest_field( + name="defaultCustomBlockResponseStatusCode", visibility=["read", "create", "update", "delete", "query"] + ) + """If the action type is block, this field defines the default customer overridable http response + status code. Known values are: 200, 403, 405, 406, and 429.""" + default_custom_block_response_body: Optional[str] = rest_field( + name="defaultCustomBlockResponseBody", visibility=["read", "create", "update", "delete", "query"] + ) + """If the action type is block, customer can override the response body. The body must be + specified in base64 encoding.""" + + @overload + def __init__( + self, + *, + enabled_state: Optional[Union[str, "_models.PolicyEnabledState"]] = None, + mode: Optional[Union[str, "_models.PolicyMode"]] = None, + default_redirect_url: Optional[str] = None, + default_custom_block_response_status_code: Optional[ + Union[int, "_models.PolicySettingsDefaultCustomBlockResponseStatusCode"] + ] = None, + default_custom_block_response_body: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class PostArgsMatchConditionParameters( + DeliveryRuleConditionParameters, discriminator="DeliveryRulePostArgsConditionParameters" +): + """Defines the parameters for PostArgs match conditions. + + :ivar selector: Name of PostArg to be matched. + :vartype selector: str + :ivar operator: Describes operator to be matched. Required. Known values are: "Any", "Equal", + "Contains", "BeginsWith", "EndsWith", "LessThan", "LessThanOrEqual", "GreaterThan", + "GreaterThanOrEqual", and "RegEx". + :vartype operator: str or ~azure.mgmt.cdn.models.PostArgsOperator + :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] + :ivar transforms: List of transforms. + :vartype transforms: list[str or ~azure.mgmt.cdn.models.Transform] + :ivar type_name: Required. DELIVERY_RULE_POST_ARGS_CONDITION_PARAMETERS. + :vartype type_name: str or ~azure.mgmt.cdn.models.DELIVERY_RULE_POST_ARGS_CONDITION_PARAMETERS + """ + + selector: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Name of PostArg to be matched.""" + operator: Union[str, "_models.PostArgsOperator"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Describes operator to be matched. Required. Known values are: \"Any\", \"Equal\", \"Contains\", + \"BeginsWith\", \"EndsWith\", \"LessThan\", \"LessThanOrEqual\", \"GreaterThan\", + \"GreaterThanOrEqual\", and \"RegEx\".""" + negate_condition: Optional[bool] = rest_field( + name="negateCondition", visibility=["read", "create", "update", "delete", "query"] + ) + """Describes if this is negate condition or not.""" + match_values: Optional[list[str]] = rest_field( + name="matchValues", visibility=["read", "create", "update", "delete", "query"] + ) + """The match value for the condition of the delivery rule.""" + transforms: Optional[list[Union[str, "_models.Transform"]]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """List of transforms.""" + type_name: Literal[DeliveryRuleConditionParametersType.DELIVERY_RULE_POST_ARGS_CONDITION_PARAMETERS] = rest_discriminator(name="typeName", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Required. DELIVERY_RULE_POST_ARGS_CONDITION_PARAMETERS.""" + + @overload + def __init__( + self, + *, + operator: Union[str, "_models.PostArgsOperator"], + selector: Optional[str] = None, + negate_condition: Optional[bool] = None, + match_values: Optional[list[str]] = None, + transforms: Optional[list[Union[str, "_models.Transform"]]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type_name = DeliveryRuleConditionParametersType.DELIVERY_RULE_POST_ARGS_CONDITION_PARAMETERS # type: ignore + + +class Profile(TrackedResource): + """A profile is a logical grouping of endpoints that share the same settings. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.cdn.models.SystemData + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str + :ivar properties: The JSON object that contains the properties required to create a profile. + :vartype properties: ~azure.mgmt.cdn.models.ProfileProperties + :ivar sku: The pricing tier (defines Azure Front Door Standard or Premium or a CDN provider, + feature list and rate) of the profile. Required. + :vartype sku: ~azure.mgmt.cdn.models.Sku + :ivar kind: Kind of the profile. Used by portal to differentiate traditional CDN profile and + new AFD profile. + :vartype kind: str + :ivar identity: The managed service identities assigned to this resource. + :vartype identity: ~azure.mgmt.cdn.models.ManagedServiceIdentity + """ + + properties: Optional["_models.ProfileProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The JSON object that contains the properties required to create a profile.""" + sku: "_models.Sku" = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The pricing tier (defines Azure Front Door Standard or Premium or a CDN provider, feature list + and rate) of the profile. Required.""" + kind: Optional[str] = rest_field(visibility=["read"]) + """Kind of the profile. Used by portal to differentiate traditional CDN profile and new AFD + profile.""" + identity: Optional["_models.ManagedServiceIdentity"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The managed service identities assigned to this resource.""" + + __flattened_items = [ + "resource_state", + "provisioning_state", + "extended_properties", + "front_door_id", + "origin_response_timeout_seconds", + "log_scrubbing", + ] + + @overload + def __init__( + self, + *, + location: str, + sku: "_models.Sku", + tags: Optional[dict[str, str]] = None, + properties: Optional["_models.ProfileProperties"] = None, + identity: Optional["_models.ManagedServiceIdentity"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class ProfileChangeSkuWafMapping(_Model): + """Parameters required for profile upgrade. + + :ivar security_policy_name: The security policy name. Required. + :vartype security_policy_name: str + :ivar change_to_waf_policy: The new waf resource for the security policy to use. Required. + :vartype change_to_waf_policy: ~azure.mgmt.cdn.models.ResourceReference + """ + + security_policy_name: str = rest_field( + name="securityPolicyName", visibility=["read", "create", "update", "delete", "query"] + ) + """The security policy name. Required.""" + change_to_waf_policy: "_models.ResourceReference" = rest_field( + name="changeToWafPolicy", visibility=["read", "create", "update", "delete", "query"] + ) + """The new waf resource for the security policy to use. Required.""" + + @overload + def __init__( + self, + *, + security_policy_name: str, + change_to_waf_policy: "_models.ResourceReference", + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ProfileLogScrubbing(_Model): + """Defines rules that scrub sensitive fields in the Azure Front Door profile logs. + + :ivar state: State of the log scrubbing config. Default value is Enabled. Known values are: + "Enabled" and "Disabled". + :vartype state: str or ~azure.mgmt.cdn.models.ProfileScrubbingState + :ivar scrubbing_rules: List of log scrubbing rules applied to the Azure Front Door profile + logs. + :vartype scrubbing_rules: list[~azure.mgmt.cdn.models.ProfileScrubbingRules] + """ + + state: Optional[Union[str, "_models.ProfileScrubbingState"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """State of the log scrubbing config. Default value is Enabled. Known values are: \"Enabled\" and + \"Disabled\".""" + scrubbing_rules: Optional[list["_models.ProfileScrubbingRules"]] = rest_field( + name="scrubbingRules", visibility=["read", "create", "update", "delete", "query"] + ) + """List of log scrubbing rules applied to the Azure Front Door profile logs.""" + + @overload + def __init__( + self, + *, + state: Optional[Union[str, "_models.ProfileScrubbingState"]] = None, + scrubbing_rules: Optional[list["_models.ProfileScrubbingRules"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ProfileProperties(_Model): + """The JSON object that contains the properties required to create a profile. + + :ivar resource_state: Resource status of the profile. Known values are: "Creating", "Active", + "Deleting", "Disabled", "Migrating", "Migrated", "PendingMigrationCommit", + "CommittingMigration", and "AbortingMigration". + :vartype resource_state: str or ~azure.mgmt.cdn.models.ProfileResourceState + :ivar provisioning_state: Provisioning status of the profile. Known values are: "Succeeded", + "Failed", "Updating", "Deleting", and "Creating". + :vartype provisioning_state: str or ~azure.mgmt.cdn.models.ProfileProvisioningState + :ivar extended_properties: Key-Value pair representing additional properties for profiles. + :vartype extended_properties: dict[str, str] + :ivar front_door_id: The Id of the frontdoor. + :vartype front_door_id: str + :ivar origin_response_timeout_seconds: Send and receive timeout on forwarding request to the + origin. When timeout is reached, the request fails and returns. + :vartype origin_response_timeout_seconds: int + :ivar log_scrubbing: Defines rules that scrub sensitive fields in the Azure Front Door profile + logs. + :vartype log_scrubbing: ~azure.mgmt.cdn.models.ProfileLogScrubbing + """ + + resource_state: Optional[Union[str, "_models.ProfileResourceState"]] = rest_field( + name="resourceState", visibility=["read"] + ) + """Resource status of the profile. Known values are: \"Creating\", \"Active\", \"Deleting\", + \"Disabled\", \"Migrating\", \"Migrated\", \"PendingMigrationCommit\", \"CommittingMigration\", + and \"AbortingMigration\".""" + provisioning_state: Optional[Union[str, "_models.ProfileProvisioningState"]] = rest_field( + name="provisioningState", visibility=["read"] + ) + """Provisioning status of the profile. Known values are: \"Succeeded\", \"Failed\", \"Updating\", + \"Deleting\", and \"Creating\".""" + extended_properties: Optional[dict[str, str]] = rest_field(name="extendedProperties", visibility=["read"]) + """Key-Value pair representing additional properties for profiles.""" + front_door_id: Optional[str] = rest_field(name="frontDoorId", visibility=["read"]) + """The Id of the frontdoor.""" + origin_response_timeout_seconds: Optional[int] = rest_field( + name="originResponseTimeoutSeconds", visibility=["read", "create", "update", "delete", "query"] + ) + """Send and receive timeout on forwarding request to the origin. When timeout is reached, the + request fails and returns.""" + log_scrubbing: Optional["_models.ProfileLogScrubbing"] = rest_field( + name="logScrubbing", visibility=["read", "create", "update", "delete", "query"] + ) + """Defines rules that scrub sensitive fields in the Azure Front Door profile logs.""" + + @overload + def __init__( + self, + *, + origin_response_timeout_seconds: Optional[int] = None, + log_scrubbing: Optional["_models.ProfileLogScrubbing"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ProfilePropertiesUpdateParameters(_Model): + """The JSON object containing profile update parameters. + + :ivar origin_response_timeout_seconds: Send and receive timeout on forwarding request to the + origin. When timeout is reached, the request fails and returns. + :vartype origin_response_timeout_seconds: int + :ivar log_scrubbing: Defines rules to scrub sensitive fields in logs. + :vartype log_scrubbing: ~azure.mgmt.cdn.models.ProfileLogScrubbing + """ + + origin_response_timeout_seconds: Optional[int] = rest_field( + name="originResponseTimeoutSeconds", visibility=["read", "create", "update", "delete", "query"] + ) + """Send and receive timeout on forwarding request to the origin. When timeout is reached, the + request fails and returns.""" + log_scrubbing: Optional["_models.ProfileLogScrubbing"] = rest_field( + name="logScrubbing", visibility=["read", "create", "update", "delete", "query"] + ) + """Defines rules to scrub sensitive fields in logs.""" + + @overload + def __init__( + self, + *, + origin_response_timeout_seconds: Optional[int] = None, + log_scrubbing: Optional["_models.ProfileLogScrubbing"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ProfileScrubbingRules(_Model): + """Defines the contents of the log scrubbing rules. + + :ivar match_variable: The variable to be scrubbed from the logs. Required. Known values are: + "RequestIPAddress", "RequestUri", and "QueryStringArgNames". + :vartype match_variable: str or ~azure.mgmt.cdn.models.ScrubbingRuleEntryMatchVariable + :ivar selector_match_operator: When matchVariable is a collection, operate on the selector to + specify which elements in the collection this rule applies to. Required. "EqualsAny" + :vartype selector_match_operator: str or ~azure.mgmt.cdn.models.ScrubbingRuleEntryMatchOperator + :ivar selector: When matchVariable is a collection, operator used to specify which elements in + the collection this rule applies to. + :vartype selector: str + :ivar state: Defines the state of a log scrubbing rule. Default value is enabled. Known values + are: "Enabled" and "Disabled". + :vartype state: str or ~azure.mgmt.cdn.models.ScrubbingRuleEntryState + """ + + match_variable: Union[str, "_models.ScrubbingRuleEntryMatchVariable"] = rest_field( + name="matchVariable", visibility=["read", "create", "update", "delete", "query"] + ) + """The variable to be scrubbed from the logs. Required. Known values are: \"RequestIPAddress\", + \"RequestUri\", and \"QueryStringArgNames\".""" + selector_match_operator: Union[str, "_models.ScrubbingRuleEntryMatchOperator"] = rest_field( + name="selectorMatchOperator", visibility=["read", "create", "update", "delete", "query"] + ) + """When matchVariable is a collection, operate on the selector to specify which elements in the + collection this rule applies to. Required. \"EqualsAny\"""" + selector: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """When matchVariable is a collection, operator used to specify which elements in the collection + this rule applies to.""" + state: Optional[Union[str, "_models.ScrubbingRuleEntryState"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Defines the state of a log scrubbing rule. Default value is enabled. Known values are: + \"Enabled\" and \"Disabled\".""" + + @overload + def __init__( + self, + *, + match_variable: Union[str, "_models.ScrubbingRuleEntryMatchVariable"], + selector_match_operator: Union[str, "_models.ScrubbingRuleEntryMatchOperator"], + selector: Optional[str] = None, + state: Optional[Union[str, "_models.ScrubbingRuleEntryState"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ProfileUpdateParameters(_Model): + """Properties required to update a profile. + + :ivar tags: Profile tags. + :vartype tags: dict[str, str] + :ivar identity: Managed service identity (system assigned and/or user assigned identities). + :vartype identity: ~azure.mgmt.cdn.models.ManagedServiceIdentity + :ivar properties: The JSON object containing profile update parameters. + :vartype properties: ~azure.mgmt.cdn.models.ProfilePropertiesUpdateParameters + """ + + tags: Optional[dict[str, str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Profile tags.""" + identity: Optional["_models.ManagedServiceIdentity"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Managed service identity (system assigned and/or user assigned identities).""" + properties: Optional["_models.ProfilePropertiesUpdateParameters"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The JSON object containing profile update parameters.""" + + __flattened_items = ["origin_response_timeout_seconds", "log_scrubbing"] + + @overload + def __init__( + self, + *, + tags: Optional[dict[str, str]] = None, + identity: Optional["_models.ManagedServiceIdentity"] = None, + properties: Optional["_models.ProfilePropertiesUpdateParameters"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class ProfileUpgradeParameters(_Model): + """Parameters required for profile upgrade. + + :ivar waf_mapping_list: Web Application Firewall (WAF) and security policy mapping for the + profile upgrade. Required. + :vartype waf_mapping_list: list[~azure.mgmt.cdn.models.ProfileChangeSkuWafMapping] + """ + + waf_mapping_list: list["_models.ProfileChangeSkuWafMapping"] = rest_field( + name="wafMappingList", visibility=["read", "create", "update", "delete", "query"] + ) + """Web Application Firewall (WAF) and security policy mapping for the profile upgrade. Required.""" + + @overload + def __init__( + self, + *, + waf_mapping_list: list["_models.ProfileChangeSkuWafMapping"], + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class PurgeParameters(_Model): + """Parameters required for content purge. + + :ivar content_paths: The path to the content to be purged. Can describe a file path or a wild + card directory. Required. + :vartype content_paths: list[str] + """ + + content_paths: list[str] = rest_field( + name="contentPaths", visibility=["read", "create", "update", "delete", "query"] + ) + """The path to the content to be purged. Can describe a file path or a wild card directory. + Required.""" + + @overload + def __init__( + self, + *, + content_paths: list[str], + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class QueryStringMatchConditionParameters( + DeliveryRuleConditionParameters, discriminator="DeliveryRuleQueryStringConditionParameters" +): + """Defines the parameters for QueryString match conditions. + + :ivar operator: Describes operator to be matched. Required. Known values are: "Any", "Equal", + "Contains", "BeginsWith", "EndsWith", "LessThan", "LessThanOrEqual", "GreaterThan", + "GreaterThanOrEqual", and "RegEx". + :vartype operator: str or ~azure.mgmt.cdn.models.QueryStringOperator + :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] + :ivar transforms: List of transforms. + :vartype transforms: list[str or ~azure.mgmt.cdn.models.Transform] + :ivar type_name: Required. DELIVERY_RULE_QUERY_STRING_CONDITION_PARAMETERS. + :vartype type_name: str or + ~azure.mgmt.cdn.models.DELIVERY_RULE_QUERY_STRING_CONDITION_PARAMETERS + """ + + operator: Union[str, "_models.QueryStringOperator"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Describes operator to be matched. Required. Known values are: \"Any\", \"Equal\", \"Contains\", + \"BeginsWith\", \"EndsWith\", \"LessThan\", \"LessThanOrEqual\", \"GreaterThan\", + \"GreaterThanOrEqual\", and \"RegEx\".""" + negate_condition: Optional[bool] = rest_field( + name="negateCondition", visibility=["read", "create", "update", "delete", "query"] + ) + """Describes if this is negate condition or not.""" + match_values: Optional[list[str]] = rest_field( + name="matchValues", visibility=["read", "create", "update", "delete", "query"] + ) + """The match value for the condition of the delivery rule.""" + transforms: Optional[list[Union[str, "_models.Transform"]]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """List of transforms.""" + type_name: Literal[DeliveryRuleConditionParametersType.DELIVERY_RULE_QUERY_STRING_CONDITION_PARAMETERS] = rest_discriminator(name="typeName", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Required. DELIVERY_RULE_QUERY_STRING_CONDITION_PARAMETERS.""" + + @overload + def __init__( + self, + *, + operator: Union[str, "_models.QueryStringOperator"], + negate_condition: Optional[bool] = None, + match_values: Optional[list[str]] = None, + transforms: Optional[list[Union[str, "_models.Transform"]]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type_name = DeliveryRuleConditionParametersType.DELIVERY_RULE_QUERY_STRING_CONDITION_PARAMETERS # type: ignore + + +class RankingsResponse(_Model): + """Rankings Response. + + :ivar date_time_begin: + :vartype date_time_begin: ~datetime.datetime + :ivar date_time_end: + :vartype date_time_end: ~datetime.datetime + :ivar tables: + :vartype tables: list[~azure.mgmt.cdn.models.RankingsResponseTablesItem] + """ + + date_time_begin: Optional[datetime.datetime] = rest_field( + name="dateTimeBegin", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) + date_time_end: Optional[datetime.datetime] = rest_field( + name="dateTimeEnd", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) + tables: Optional[list["_models.RankingsResponseTablesItem"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + + @overload + def __init__( + self, + *, + date_time_begin: Optional[datetime.datetime] = None, + date_time_end: Optional[datetime.datetime] = None, + tables: Optional[list["_models.RankingsResponseTablesItem"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class RankingsResponseTablesItem(_Model): + """RankingsResponseTablesItem. + + :ivar ranking: + :vartype ranking: str + :ivar data: + :vartype data: list[~azure.mgmt.cdn.models.RankingsResponseTablesPropertiesItemsItem] + """ + + ranking: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + data: Optional[list["_models.RankingsResponseTablesPropertiesItemsItem"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + + @overload + def __init__( + self, + *, + ranking: Optional[str] = None, + data: Optional[list["_models.RankingsResponseTablesPropertiesItemsItem"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class RankingsResponseTablesPropertiesItemsItem(_Model): # pylint: disable=name-too-long + """RankingsResponseTablesPropertiesItemsItem. + + :ivar name: + :vartype name: str + :ivar metrics: + :vartype metrics: list[~azure.mgmt.cdn.models.RankingsResponseTablesPropertiesItemsMetricsItem] + """ + + name: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + metrics: Optional[list["_models.RankingsResponseTablesPropertiesItemsMetricsItem"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + + @overload + def __init__( + self, + *, + name: Optional[str] = None, + metrics: Optional[list["_models.RankingsResponseTablesPropertiesItemsMetricsItem"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class RankingsResponseTablesPropertiesItemsMetricsItem(_Model): # pylint: disable=name-too-long + """RankingsResponseTablesPropertiesItemsMetricsItem. + + :ivar metric: + :vartype metric: str + :ivar value: + :vartype value: int + :ivar percentage: + :vartype percentage: float + """ + + metric: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + value: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + percentage: Optional[float] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + + @overload + def __init__( + self, + *, + metric: Optional[str] = None, + value: Optional[int] = None, + percentage: Optional[float] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class RateLimitRule(CustomRule): + """Defines a rate limiting rule that can be included in a waf policy. + + :ivar name: Defines the name of the custom rule. Required. + :vartype name: str + :ivar enabled_state: Describes if the custom rule is in enabled or disabled state. Defaults to + Enabled if not specified. Known values are: "Disabled" and "Enabled". + :vartype enabled_state: str or ~azure.mgmt.cdn.models.CustomRuleEnabledState + :ivar priority: Defines in what order this rule be evaluated in the overall list of custom + rules. Required. + :vartype priority: int + :ivar match_conditions: List of match conditions. Required. + :vartype match_conditions: list[~azure.mgmt.cdn.models.MatchCondition] + :ivar action: Describes what action to be applied when rule matches. Required. Known values + are: "Allow", "Block", "Log", and "Redirect". + :vartype action: str or ~azure.mgmt.cdn.models.ActionType + :ivar rate_limit_threshold: Defines rate limit threshold. Required. + :vartype rate_limit_threshold: int + :ivar rate_limit_duration_in_minutes: Defines rate limit duration. Default is 1 minute. + Required. + :vartype rate_limit_duration_in_minutes: int + """ + + rate_limit_threshold: int = rest_field( + name="rateLimitThreshold", visibility=["read", "create", "update", "delete", "query"] + ) + """Defines rate limit threshold. Required.""" + rate_limit_duration_in_minutes: int = rest_field( + name="rateLimitDurationInMinutes", visibility=["read", "create", "update", "delete", "query"] + ) + """Defines rate limit duration. Default is 1 minute. Required.""" + + @overload + def __init__( + self, + *, + name: str, + priority: int, + match_conditions: list["_models.MatchCondition"], + action: Union[str, "_models.ActionType"], + rate_limit_threshold: int, + rate_limit_duration_in_minutes: int, + enabled_state: Optional[Union[str, "_models.CustomRuleEnabledState"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class RateLimitRuleList(_Model): + """Defines contents of rate limit rules. + + :ivar rules: List of rules. + :vartype rules: list[~azure.mgmt.cdn.models.RateLimitRule] + """ + + rules: Optional[list["_models.RateLimitRule"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """List of rules.""" + + @overload + def __init__( + self, + *, + rules: Optional[list["_models.RateLimitRule"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class RemoteAddressMatchConditionParameters( + DeliveryRuleConditionParameters, discriminator="DeliveryRuleRemoteAddressConditionParameters" +): + """Defines the parameters for RemoteAddress match conditions. + + :ivar operator: Describes operator to be matched. Required. Known values are: "Any", "IPMatch", + and "GeoMatch". + :vartype operator: str or ~azure.mgmt.cdn.models.RemoteAddressOperator + :ivar negate_condition: Describes if this is negate condition or not. + :vartype negate_condition: bool + :ivar match_values: Match values to match against. The operator will apply to each value in + here with OR semantics. If any of them match the variable with the given operator this match + condition is considered a match. + :vartype match_values: list[str] + :ivar transforms: List of transforms. + :vartype transforms: list[str or ~azure.mgmt.cdn.models.Transform] + :ivar type_name: Required. DELIVERY_RULE_REMOTE_ADDRESS_CONDITION_PARAMETERS. + :vartype type_name: str or + ~azure.mgmt.cdn.models.DELIVERY_RULE_REMOTE_ADDRESS_CONDITION_PARAMETERS + """ + + operator: Union[str, "_models.RemoteAddressOperator"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Describes operator to be matched. Required. Known values are: \"Any\", \"IPMatch\", and + \"GeoMatch\".""" + negate_condition: Optional[bool] = rest_field( + name="negateCondition", visibility=["read", "create", "update", "delete", "query"] + ) + """Describes if this is negate condition or not.""" + match_values: Optional[list[str]] = rest_field( + name="matchValues", visibility=["read", "create", "update", "delete", "query"] + ) + """Match values to match against. The operator will apply to each value in here with OR semantics. + If any of them match the variable with the given operator this match condition is considered a + match.""" + transforms: Optional[list[Union[str, "_models.Transform"]]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """List of transforms.""" + type_name: Literal[DeliveryRuleConditionParametersType.DELIVERY_RULE_REMOTE_ADDRESS_CONDITION_PARAMETERS] = rest_discriminator(name="typeName", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Required. DELIVERY_RULE_REMOTE_ADDRESS_CONDITION_PARAMETERS.""" + + @overload + def __init__( + self, + *, + operator: Union[str, "_models.RemoteAddressOperator"], + negate_condition: Optional[bool] = None, + match_values: Optional[list[str]] = None, + transforms: Optional[list[Union[str, "_models.Transform"]]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type_name = DeliveryRuleConditionParametersType.DELIVERY_RULE_REMOTE_ADDRESS_CONDITION_PARAMETERS # type: ignore + + +class RequestBodyMatchConditionParameters( + DeliveryRuleConditionParameters, discriminator="DeliveryRuleRequestBodyConditionParameters" +): + """Defines the parameters for RequestBody match conditions. + + :ivar operator: Describes operator to be matched. Required. Known values are: "Any", "Equal", + "Contains", "BeginsWith", "EndsWith", "LessThan", "LessThanOrEqual", "GreaterThan", + "GreaterThanOrEqual", and "RegEx". + :vartype operator: str or ~azure.mgmt.cdn.models.RequestBodyOperator + :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] + :ivar transforms: List of transforms. + :vartype transforms: list[str or ~azure.mgmt.cdn.models.Transform] + :ivar type_name: Required. DELIVERY_RULE_REQUEST_BODY_CONDITION_PARAMETERS. + :vartype type_name: str or + ~azure.mgmt.cdn.models.DELIVERY_RULE_REQUEST_BODY_CONDITION_PARAMETERS + """ + + operator: Union[str, "_models.RequestBodyOperator"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Describes operator to be matched. Required. Known values are: \"Any\", \"Equal\", \"Contains\", + \"BeginsWith\", \"EndsWith\", \"LessThan\", \"LessThanOrEqual\", \"GreaterThan\", + \"GreaterThanOrEqual\", and \"RegEx\".""" + negate_condition: Optional[bool] = rest_field( + name="negateCondition", visibility=["read", "create", "update", "delete", "query"] + ) + """Describes if this is negate condition or not.""" + match_values: Optional[list[str]] = rest_field( + name="matchValues", visibility=["read", "create", "update", "delete", "query"] + ) + """The match value for the condition of the delivery rule.""" + transforms: Optional[list[Union[str, "_models.Transform"]]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """List of transforms.""" + type_name: Literal[DeliveryRuleConditionParametersType.DELIVERY_RULE_REQUEST_BODY_CONDITION_PARAMETERS] = rest_discriminator(name="typeName", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Required. DELIVERY_RULE_REQUEST_BODY_CONDITION_PARAMETERS.""" + + @overload + def __init__( + self, + *, + operator: Union[str, "_models.RequestBodyOperator"], + negate_condition: Optional[bool] = None, + match_values: Optional[list[str]] = None, + transforms: Optional[list[Union[str, "_models.Transform"]]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type_name = DeliveryRuleConditionParametersType.DELIVERY_RULE_REQUEST_BODY_CONDITION_PARAMETERS # type: ignore + + +class RequestHeaderMatchConditionParameters( + DeliveryRuleConditionParameters, discriminator="DeliveryRuleRequestHeaderConditionParameters" +): + """Defines the parameters for RequestHeader match conditions. + + :ivar selector: Name of Header to be matched. + :vartype selector: str + :ivar operator: Describes operator to be matched. Required. Known values are: "Any", "Equal", + "Contains", "BeginsWith", "EndsWith", "LessThan", "LessThanOrEqual", "GreaterThan", + "GreaterThanOrEqual", and "RegEx". + :vartype operator: str or ~azure.mgmt.cdn.models.RequestHeaderOperator + :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] + :ivar transforms: List of transforms. + :vartype transforms: list[str or ~azure.mgmt.cdn.models.Transform] + :ivar type_name: Required. DELIVERY_RULE_REQUEST_HEADER_CONDITION_PARAMETERS. + :vartype type_name: str or + ~azure.mgmt.cdn.models.DELIVERY_RULE_REQUEST_HEADER_CONDITION_PARAMETERS + """ + + selector: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Name of Header to be matched.""" + operator: Union[str, "_models.RequestHeaderOperator"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Describes operator to be matched. Required. Known values are: \"Any\", \"Equal\", \"Contains\", + \"BeginsWith\", \"EndsWith\", \"LessThan\", \"LessThanOrEqual\", \"GreaterThan\", + \"GreaterThanOrEqual\", and \"RegEx\".""" + negate_condition: Optional[bool] = rest_field( + name="negateCondition", visibility=["read", "create", "update", "delete", "query"] + ) + """Describes if this is negate condition or not.""" + match_values: Optional[list[str]] = rest_field( + name="matchValues", visibility=["read", "create", "update", "delete", "query"] + ) + """The match value for the condition of the delivery rule.""" + transforms: Optional[list[Union[str, "_models.Transform"]]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """List of transforms.""" + type_name: Literal[DeliveryRuleConditionParametersType.DELIVERY_RULE_REQUEST_HEADER_CONDITION_PARAMETERS] = rest_discriminator(name="typeName", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Required. DELIVERY_RULE_REQUEST_HEADER_CONDITION_PARAMETERS.""" + + @overload + def __init__( + self, + *, + operator: Union[str, "_models.RequestHeaderOperator"], + selector: Optional[str] = None, + negate_condition: Optional[bool] = None, + match_values: Optional[list[str]] = None, + transforms: Optional[list[Union[str, "_models.Transform"]]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type_name = DeliveryRuleConditionParametersType.DELIVERY_RULE_REQUEST_HEADER_CONDITION_PARAMETERS # type: ignore + + +class RequestMethodMatchConditionParameters( + DeliveryRuleConditionParameters, discriminator="DeliveryRuleRequestMethodConditionParameters" +): + """Defines the parameters for RequestMethod match conditions. + + :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. + :vartype negate_condition: bool + :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.RequestMethodMatchValue] + :ivar type_name: Required. DELIVERY_RULE_REQUEST_METHOD_CONDITION_PARAMETERS. + :vartype type_name: str or + ~azure.mgmt.cdn.models.DELIVERY_RULE_REQUEST_METHOD_CONDITION_PARAMETERS + """ + + operator: Union[str, "_models.RequestMethodOperator"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Describes operator to be matched. Required. \"Equal\"""" + negate_condition: Optional[bool] = rest_field( + name="negateCondition", visibility=["read", "create", "update", "delete", "query"] + ) + """Describes if this is negate condition or not.""" + transforms: Optional[list[Union[str, "_models.Transform"]]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """List of transforms.""" + match_values: Optional[list[Union[str, "_models.RequestMethodMatchValue"]]] = rest_field( + name="matchValues", visibility=["read", "create", "update", "delete", "query"] + ) + """The match value for the condition of the delivery rule.""" + type_name: Literal[DeliveryRuleConditionParametersType.DELIVERY_RULE_REQUEST_METHOD_CONDITION_PARAMETERS] = rest_discriminator(name="typeName", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Required. DELIVERY_RULE_REQUEST_METHOD_CONDITION_PARAMETERS.""" + + @overload + def __init__( + self, + *, + operator: Union[str, "_models.RequestMethodOperator"], + negate_condition: Optional[bool] = None, + transforms: Optional[list[Union[str, "_models.Transform"]]] = None, + match_values: Optional[list[Union[str, "_models.RequestMethodMatchValue"]]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type_name = DeliveryRuleConditionParametersType.DELIVERY_RULE_REQUEST_METHOD_CONDITION_PARAMETERS # type: ignore + + +class RequestSchemeMatchConditionParameters( + DeliveryRuleConditionParameters, discriminator="DeliveryRuleRequestSchemeConditionParameters" +): + """Defines the parameters for RequestScheme match conditions. + + :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. + :vartype negate_condition: bool + :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.RequestSchemeMatchValue] + :ivar type_name: Required. DELIVERY_RULE_REQUEST_SCHEME_CONDITION_PARAMETERS. + :vartype type_name: str or + ~azure.mgmt.cdn.models.DELIVERY_RULE_REQUEST_SCHEME_CONDITION_PARAMETERS + """ + + operator: Union[str, "_models.RequestSchemeMatchConditionParametersOperator"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Describes operator to be matched. Required. \"Equal\"""" + negate_condition: Optional[bool] = rest_field( + name="negateCondition", visibility=["read", "create", "update", "delete", "query"] + ) + """Describes if this is negate condition or not.""" + transforms: Optional[list[Union[str, "_models.Transform"]]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """List of transforms.""" + match_values: Optional[list[Union[str, "_models.RequestSchemeMatchValue"]]] = rest_field( + name="matchValues", visibility=["read", "create", "update", "delete", "query"] + ) + """The match value for the condition of the delivery rule.""" + type_name: Literal[DeliveryRuleConditionParametersType.DELIVERY_RULE_REQUEST_SCHEME_CONDITION_PARAMETERS] = rest_discriminator(name="typeName", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Required. DELIVERY_RULE_REQUEST_SCHEME_CONDITION_PARAMETERS.""" + + @overload + def __init__( + self, + *, + operator: Union[str, "_models.RequestSchemeMatchConditionParametersOperator"], + negate_condition: Optional[bool] = None, + transforms: Optional[list[Union[str, "_models.Transform"]]] = None, + match_values: Optional[list[Union[str, "_models.RequestSchemeMatchValue"]]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type_name = DeliveryRuleConditionParametersType.DELIVERY_RULE_REQUEST_SCHEME_CONDITION_PARAMETERS # type: ignore + + +class RequestUriMatchConditionParameters( + DeliveryRuleConditionParameters, discriminator="DeliveryRuleRequestUriConditionParameters" +): + """Defines the parameters for RequestUri match conditions. + + :ivar operator: Describes operator to be matched. Required. Known values are: "Any", "Equal", + "Contains", "BeginsWith", "EndsWith", "LessThan", "LessThanOrEqual", "GreaterThan", + "GreaterThanOrEqual", and "RegEx". + :vartype operator: str or ~azure.mgmt.cdn.models.RequestUriOperator + :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] + :ivar transforms: List of transforms. + :vartype transforms: list[str or ~azure.mgmt.cdn.models.Transform] + :ivar type_name: Required. DELIVERY_RULE_REQUEST_URI_CONDITION_PARAMETERS. + :vartype type_name: str or + ~azure.mgmt.cdn.models.DELIVERY_RULE_REQUEST_URI_CONDITION_PARAMETERS + """ + + operator: Union[str, "_models.RequestUriOperator"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Describes operator to be matched. Required. Known values are: \"Any\", \"Equal\", \"Contains\", + \"BeginsWith\", \"EndsWith\", \"LessThan\", \"LessThanOrEqual\", \"GreaterThan\", + \"GreaterThanOrEqual\", and \"RegEx\".""" + negate_condition: Optional[bool] = rest_field( + name="negateCondition", visibility=["read", "create", "update", "delete", "query"] + ) + """Describes if this is negate condition or not.""" + match_values: Optional[list[str]] = rest_field( + name="matchValues", visibility=["read", "create", "update", "delete", "query"] + ) + """The match value for the condition of the delivery rule.""" + transforms: Optional[list[Union[str, "_models.Transform"]]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """List of transforms.""" + type_name: Literal[DeliveryRuleConditionParametersType.DELIVERY_RULE_REQUEST_URI_CONDITION_PARAMETERS] = rest_discriminator(name="typeName", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Required. DELIVERY_RULE_REQUEST_URI_CONDITION_PARAMETERS.""" + + @overload + def __init__( + self, + *, + operator: Union[str, "_models.RequestUriOperator"], + negate_condition: Optional[bool] = None, + match_values: Optional[list[str]] = None, + transforms: Optional[list[Union[str, "_models.Transform"]]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type_name = DeliveryRuleConditionParametersType.DELIVERY_RULE_REQUEST_URI_CONDITION_PARAMETERS # type: ignore + + +class ResourceReference(_Model): + """Reference to another resource. + + :ivar id: Resource ID. + :vartype id: str + """ + + id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Resource ID.""" + + @overload + def __init__( + self, + *, + id: Optional[str] = None, # pylint: disable=redefined-builtin + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ResourcesResponse(_Model): + """Resources Response. + + :ivar endpoints: + :vartype endpoints: list[~azure.mgmt.cdn.models.ResourcesResponseEndpointsItem] + :ivar custom_domains: + :vartype custom_domains: list[~azure.mgmt.cdn.models.ResourcesResponseCustomDomainsItem] + """ + + endpoints: Optional[list["_models.ResourcesResponseEndpointsItem"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + custom_domains: Optional[list["_models.ResourcesResponseCustomDomainsItem"]] = rest_field( + name="customDomains", visibility=["read", "create", "update", "delete", "query"] + ) + + @overload + def __init__( + self, + *, + endpoints: Optional[list["_models.ResourcesResponseEndpointsItem"]] = None, + custom_domains: Optional[list["_models.ResourcesResponseCustomDomainsItem"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ResourcesResponseCustomDomainsItem(_Model): + """ResourcesResponseCustomDomainsItem. + + :ivar id: + :vartype id: str + :ivar name: + :vartype name: str + :ivar endpoint_id: + :vartype endpoint_id: str + :ivar history: + :vartype history: bool + """ + + id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + name: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + endpoint_id: Optional[str] = rest_field( + name="endpointId", visibility=["read", "create", "update", "delete", "query"] + ) + history: Optional[bool] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + + @overload + def __init__( + self, + *, + id: Optional[str] = None, # pylint: disable=redefined-builtin + name: Optional[str] = None, + endpoint_id: Optional[str] = None, + history: Optional[bool] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ResourcesResponseEndpointsItem(_Model): + """ResourcesResponseEndpointsItem. + + :ivar id: + :vartype id: str + :ivar name: + :vartype name: str + :ivar history: + :vartype history: bool + :ivar custom_domains: + :vartype custom_domains: + list[~azure.mgmt.cdn.models.ResourcesResponseEndpointsPropertiesItemsItem] + """ + + id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + name: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + history: Optional[bool] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + custom_domains: Optional[list["_models.ResourcesResponseEndpointsPropertiesItemsItem"]] = rest_field( + name="customDomains", visibility=["read", "create", "update", "delete", "query"] + ) + + @overload + def __init__( + self, + *, + id: Optional[str] = None, # pylint: disable=redefined-builtin + name: Optional[str] = None, + history: Optional[bool] = None, + custom_domains: Optional[list["_models.ResourcesResponseEndpointsPropertiesItemsItem"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ResourcesResponseEndpointsPropertiesItemsItem(_Model): # pylint: disable=name-too-long + """ResourcesResponseEndpointsPropertiesItemsItem. + + :ivar id: + :vartype id: str + :ivar name: + :vartype name: str + :ivar endpoint_id: + :vartype endpoint_id: str + :ivar history: + :vartype history: bool + """ + + id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + name: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + endpoint_id: Optional[str] = rest_field( + name="endpointId", visibility=["read", "create", "update", "delete", "query"] + ) + history: Optional[bool] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + + @overload + def __init__( + self, + *, + id: Optional[str] = None, # pylint: disable=redefined-builtin + name: Optional[str] = None, + endpoint_id: Optional[str] = None, + history: Optional[bool] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ResourceUsage(_Model): + """Output of check resource usage API. + + :ivar resource_type: Resource type for which the usage is provided. + :vartype resource_type: str + :ivar unit: Unit of the usage. e.g. count. "count" + :vartype unit: str or ~azure.mgmt.cdn.models.ResourceUsageUnit + :ivar current_value: Actual value of usage on the specified resource type. + :vartype current_value: int + :ivar limit: Quota of the specified resource type. + :vartype limit: int + """ + + resource_type: Optional[str] = rest_field(name="resourceType", visibility=["read"]) + """Resource type for which the usage is provided.""" + unit: Optional[Union[str, "_models.ResourceUsageUnit"]] = rest_field(visibility=["read"]) + """Unit of the usage. e.g. count. \"count\"""" + current_value: Optional[int] = rest_field(name="currentValue", visibility=["read"]) + """Actual value of usage on the specified resource type.""" + limit: Optional[int] = rest_field(visibility=["read"]) + """Quota of the specified resource type.""" + + +class ResponseBasedOriginErrorDetectionParameters(_Model): # pylint: disable=name-too-long + """The JSON object that contains the properties to determine origin health using real + requests/responses. + + :ivar response_based_detected_error_types: Type of response errors for real user requests for + which origin will be deemed unhealthy. Known values are: "None", "TcpErrorsOnly", and + "TcpAndHttpErrors". + :vartype response_based_detected_error_types: str or + ~azure.mgmt.cdn.models.ResponseBasedDetectedErrorTypes + :ivar response_based_failover_threshold_percentage: The percentage of failed requests in the + sample where failover should trigger. + :vartype response_based_failover_threshold_percentage: int + :ivar http_error_ranges: The list of Http status code ranges that are considered as server + errors for origin and it is marked as unhealthy. + :vartype http_error_ranges: list[~azure.mgmt.cdn.models.HttpErrorRangeParameters] + """ + + response_based_detected_error_types: Optional[Union[str, "_models.ResponseBasedDetectedErrorTypes"]] = rest_field( + name="responseBasedDetectedErrorTypes", visibility=["read", "create", "update", "delete", "query"] + ) + """Type of response errors for real user requests for which origin will be deemed unhealthy. Known + values are: \"None\", \"TcpErrorsOnly\", and \"TcpAndHttpErrors\".""" + response_based_failover_threshold_percentage: Optional[int] = rest_field( + name="responseBasedFailoverThresholdPercentage", visibility=["read", "create", "update", "delete", "query"] + ) + """The percentage of failed requests in the sample where failover should trigger.""" + http_error_ranges: Optional[list["_models.HttpErrorRangeParameters"]] = rest_field( + name="httpErrorRanges", visibility=["read", "create", "update", "delete", "query"] + ) + """The list of Http status code ranges that are considered as server errors for origin and it is + marked as unhealthy.""" + + @overload + def __init__( + self, + *, + response_based_detected_error_types: Optional[Union[str, "_models.ResponseBasedDetectedErrorTypes"]] = None, + response_based_failover_threshold_percentage: Optional[int] = None, + http_error_ranges: Optional[list["_models.HttpErrorRangeParameters"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class Route(ProxyResource): + """Friendly Routes name mapping to the any Routes or secret related information. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.cdn.models.SystemData + :ivar properties: The JSON object that contains the properties of the Routes to create. + :vartype properties: ~azure.mgmt.cdn.models.RouteProperties + """ + + properties: Optional["_models.RouteProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The JSON object that contains the properties of the Routes to create.""" + + __flattened_items = [ + "endpoint_name", + "custom_domains", + "origin_group", + "origin_path", + "rule_sets", + "supported_protocols", + "patterns_to_match", + "cache_configuration", + "forwarding_protocol", + "link_to_default_domain", + "https_redirect", + "enabled_state", + "provisioning_state", + "deployment_status", + ] + + @overload + def __init__( + self, + *, + properties: Optional["_models.RouteProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class RouteConfigurationOverrideActionParameters( + DeliveryRuleActionParameters, discriminator="DeliveryRuleRouteConfigurationOverrideActionParameters" +): # pylint: disable=name-too-long + """Defines the parameters for the route configuration override action. + + :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 + :ivar cache_configuration: The caching configuration associated with this rule. To disable + caching, do not provide a cacheConfiguration object. + :vartype cache_configuration: ~azure.mgmt.cdn.models.CacheConfiguration + :ivar type_name: Required. DELIVERY_RULE_ROUTE_CONFIGURATION_OVERRIDE_ACTION_PARAMETERS. + :vartype type_name: str or + ~azure.mgmt.cdn.models.DELIVERY_RULE_ROUTE_CONFIGURATION_OVERRIDE_ACTION_PARAMETERS + """ + + origin_group_override: Optional["_models.OriginGroupOverride"] = rest_field( + name="originGroupOverride", visibility=["read", "create", "update", "delete", "query"] + ) + """A reference to the origin group override configuration. Leave empty to use the default origin + group on route.""" + cache_configuration: Optional["_models.CacheConfiguration"] = rest_field( + name="cacheConfiguration", visibility=["read", "create", "update", "delete", "query"] + ) + """The caching configuration associated with this rule. To disable caching, do not provide a + cacheConfiguration object.""" + type_name: Literal[DeliveryRuleActionParametersType.DELIVERY_RULE_ROUTE_CONFIGURATION_OVERRIDE_ACTION_PARAMETERS] = rest_discriminator(name="typeName", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Required. DELIVERY_RULE_ROUTE_CONFIGURATION_OVERRIDE_ACTION_PARAMETERS.""" + + @overload + def __init__( + self, + *, + origin_group_override: Optional["_models.OriginGroupOverride"] = None, + cache_configuration: Optional["_models.CacheConfiguration"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type_name = DeliveryRuleActionParametersType.DELIVERY_RULE_ROUTE_CONFIGURATION_OVERRIDE_ACTION_PARAMETERS # type: ignore + + +class RouteProperties(_Model): + """The JSON object that contains the properties of the Routes to create. + + :ivar endpoint_name: The name of the endpoint which holds the route. + :vartype endpoint_name: str + :ivar custom_domains: Domains referenced by this endpoint. + :vartype custom_domains: list[~azure.mgmt.cdn.models.ActivatedResourceReference] + :ivar origin_group: A reference to the origin group. + :vartype origin_group: ~azure.mgmt.cdn.models.ResourceReference + :ivar origin_path: A directory path on the origin that AzureFrontDoor can use to retrieve + content from, e.g. contoso.cloudapp.net/originpath. + :vartype origin_path: str + :ivar rule_sets: rule sets referenced by this endpoint. + :vartype rule_sets: list[~azure.mgmt.cdn.models.ResourceReference] + :ivar supported_protocols: List of supported protocols for this route. + :vartype supported_protocols: list[str or ~azure.mgmt.cdn.models.AFDEndpointProtocols] + :ivar patterns_to_match: The route patterns of the rule. + :vartype patterns_to_match: list[str] + :ivar cache_configuration: The caching configuration for this route. To disable caching, do not + provide a cacheConfiguration object. + :vartype cache_configuration: ~azure.mgmt.cdn.models.AfdRouteCacheConfiguration + :ivar forwarding_protocol: Protocol this rule will use when forwarding traffic to backends. + Known values are: "HttpOnly", "HttpsOnly", and "MatchRequest". + :vartype forwarding_protocol: str or ~azure.mgmt.cdn.models.ForwardingProtocol + :ivar link_to_default_domain: whether this route will be linked to the default endpoint domain. + Known values are: "Enabled" and "Disabled". + :vartype link_to_default_domain: str or ~azure.mgmt.cdn.models.LinkToDefaultDomain + :ivar https_redirect: Whether to automatically redirect HTTP traffic to HTTPS traffic. Note + that this is a easy way to set up this rule and it will be the first rule that gets executed. + Known values are: "Enabled" and "Disabled". + :vartype https_redirect: str or ~azure.mgmt.cdn.models.HttpsRedirect + :ivar enabled_state: Whether to enable use of this rule. Permitted values are 'Enabled' or + 'Disabled'. Known values are: "Enabled" and "Disabled". + :vartype enabled_state: str or ~azure.mgmt.cdn.models.EnabledState + :ivar provisioning_state: Provisioning status. Known values are: "Succeeded", "Failed", + "Updating", "Deleting", and "Creating". + :vartype provisioning_state: str or ~azure.mgmt.cdn.models.AfdProvisioningState + :ivar deployment_status: Known values are: "NotStarted", "InProgress", "Succeeded", and + "Failed". + :vartype deployment_status: str or ~azure.mgmt.cdn.models.DeploymentStatus + """ + + endpoint_name: Optional[str] = rest_field(name="endpointName", visibility=["read"]) + """The name of the endpoint which holds the route.""" + custom_domains: Optional[list["_models.ActivatedResourceReference"]] = rest_field( + name="customDomains", visibility=["read", "create", "update", "delete", "query"] + ) + """Domains referenced by this endpoint.""" + origin_group: Optional["_models.ResourceReference"] = rest_field( + name="originGroup", visibility=["read", "create", "update", "delete", "query"] + ) + """A reference to the origin group.""" + origin_path: Optional[str] = rest_field( + name="originPath", visibility=["read", "create", "update", "delete", "query"] + ) + """A directory path on the origin that AzureFrontDoor can use to retrieve content from, e.g. + contoso.cloudapp.net/originpath.""" + rule_sets: Optional[list["_models.ResourceReference"]] = rest_field( + name="ruleSets", visibility=["read", "create", "update", "delete", "query"] + ) + """rule sets referenced by this endpoint.""" + supported_protocols: Optional[list[Union[str, "_models.AFDEndpointProtocols"]]] = rest_field( + name="supportedProtocols", visibility=["read", "create", "update", "delete", "query"] + ) + """List of supported protocols for this route.""" + patterns_to_match: Optional[list[str]] = rest_field( + name="patternsToMatch", visibility=["read", "create", "update", "delete", "query"] + ) + """The route patterns of the rule.""" + cache_configuration: Optional["_models.AfdRouteCacheConfiguration"] = rest_field( + name="cacheConfiguration", visibility=["read", "create", "update", "delete", "query"] + ) + """The caching configuration for this route. To disable caching, do not provide a + cacheConfiguration object.""" + forwarding_protocol: Optional[Union[str, "_models.ForwardingProtocol"]] = rest_field( + name="forwardingProtocol", visibility=["read", "create", "update", "delete", "query"] + ) + """Protocol this rule will use when forwarding traffic to backends. Known values are: + \"HttpOnly\", \"HttpsOnly\", and \"MatchRequest\".""" + link_to_default_domain: Optional[Union[str, "_models.LinkToDefaultDomain"]] = rest_field( + name="linkToDefaultDomain", visibility=["read", "create", "update", "delete", "query"] + ) + """whether this route will be linked to the default endpoint domain. Known values are: \"Enabled\" + and \"Disabled\".""" + https_redirect: Optional[Union[str, "_models.HttpsRedirect"]] = rest_field( + name="httpsRedirect", visibility=["read", "create", "update", "delete", "query"] + ) + """Whether to automatically redirect HTTP traffic to HTTPS traffic. Note that this is a easy way + to set up this rule and it will be the first rule that gets executed. Known values are: + \"Enabled\" and \"Disabled\".""" + enabled_state: Optional[Union[str, "_models.EnabledState"]] = rest_field( + name="enabledState", visibility=["read", "create", "update", "delete", "query"] + ) + """Whether to enable use of this rule. Permitted values are 'Enabled' or 'Disabled'. Known values + are: \"Enabled\" and \"Disabled\".""" + provisioning_state: Optional[Union[str, "_models.AfdProvisioningState"]] = rest_field( + name="provisioningState", visibility=["read"] + ) + """Provisioning status. Known values are: \"Succeeded\", \"Failed\", \"Updating\", \"Deleting\", + and \"Creating\".""" + deployment_status: Optional[Union[str, "_models.DeploymentStatus"]] = rest_field( + name="deploymentStatus", visibility=["read"] + ) + """Known values are: \"NotStarted\", \"InProgress\", \"Succeeded\", and \"Failed\".""" + + @overload + def __init__( + self, + *, + custom_domains: Optional[list["_models.ActivatedResourceReference"]] = None, + origin_group: Optional["_models.ResourceReference"] = None, + origin_path: Optional[str] = None, + rule_sets: Optional[list["_models.ResourceReference"]] = None, + supported_protocols: Optional[list[Union[str, "_models.AFDEndpointProtocols"]]] = None, + patterns_to_match: Optional[list[str]] = None, + cache_configuration: Optional["_models.AfdRouteCacheConfiguration"] = None, + forwarding_protocol: Optional[Union[str, "_models.ForwardingProtocol"]] = None, + link_to_default_domain: Optional[Union[str, "_models.LinkToDefaultDomain"]] = None, + https_redirect: Optional[Union[str, "_models.HttpsRedirect"]] = None, + enabled_state: Optional[Union[str, "_models.EnabledState"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class RouteUpdateParameters(_Model): + """The domain JSON object required for domain creation or update. + + :ivar properties: The JSON object that contains the properties of the domain to create. + :vartype properties: ~azure.mgmt.cdn.models.RouteUpdatePropertiesParameters + """ + + properties: Optional["_models.RouteUpdatePropertiesParameters"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The JSON object that contains the properties of the domain to create.""" + + __flattened_items = [ + "endpoint_name", + "custom_domains", + "origin_group", + "origin_path", + "rule_sets", + "supported_protocols", + "patterns_to_match", + "cache_configuration", + "forwarding_protocol", + "link_to_default_domain", + "https_redirect", + "enabled_state", + ] + + @overload + def __init__( + self, + *, + properties: Optional["_models.RouteUpdatePropertiesParameters"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class RouteUpdatePropertiesParameters(_Model): + """The JSON object that contains the properties of the domain to create. + + :ivar endpoint_name: The name of the endpoint which holds the route. + :vartype endpoint_name: str + :ivar custom_domains: Domains referenced by this endpoint. + :vartype custom_domains: list[~azure.mgmt.cdn.models.ActivatedResourceReference] + :ivar origin_group: A reference to the origin group. + :vartype origin_group: ~azure.mgmt.cdn.models.ResourceReference + :ivar origin_path: A directory path on the origin that AzureFrontDoor can use to retrieve + content from, e.g. contoso.cloudapp.net/originpath. + :vartype origin_path: str + :ivar rule_sets: rule sets referenced by this endpoint. + :vartype rule_sets: list[~azure.mgmt.cdn.models.ResourceReference] + :ivar supported_protocols: List of supported protocols for this route. + :vartype supported_protocols: list[str or ~azure.mgmt.cdn.models.AFDEndpointProtocols] + :ivar patterns_to_match: The route patterns of the rule. + :vartype patterns_to_match: list[str] + :ivar cache_configuration: The caching configuration for this route. To disable caching, do not + provide a cacheConfiguration object. + :vartype cache_configuration: ~azure.mgmt.cdn.models.AfdRouteCacheConfiguration + :ivar forwarding_protocol: Protocol this rule will use when forwarding traffic to backends. + Known values are: "HttpOnly", "HttpsOnly", and "MatchRequest". + :vartype forwarding_protocol: str or ~azure.mgmt.cdn.models.ForwardingProtocol + :ivar link_to_default_domain: whether this route will be linked to the default endpoint domain. + Known values are: "Enabled" and "Disabled". + :vartype link_to_default_domain: str or ~azure.mgmt.cdn.models.LinkToDefaultDomain + :ivar https_redirect: Whether to automatically redirect HTTP traffic to HTTPS traffic. Note + that this is a easy way to set up this rule and it will be the first rule that gets executed. + Known values are: "Enabled" and "Disabled". + :vartype https_redirect: str or ~azure.mgmt.cdn.models.HttpsRedirect + :ivar enabled_state: Whether to enable use of this rule. Permitted values are 'Enabled' or + 'Disabled'. Known values are: "Enabled" and "Disabled". + :vartype enabled_state: str or ~azure.mgmt.cdn.models.EnabledState + """ + + endpoint_name: Optional[str] = rest_field(name="endpointName", visibility=["read"]) + """The name of the endpoint which holds the route.""" + custom_domains: Optional[list["_models.ActivatedResourceReference"]] = rest_field( + name="customDomains", visibility=["read", "create", "update", "delete", "query"] + ) + """Domains referenced by this endpoint.""" + origin_group: Optional["_models.ResourceReference"] = rest_field( + name="originGroup", visibility=["read", "create", "update", "delete", "query"] + ) + """A reference to the origin group.""" + origin_path: Optional[str] = rest_field( + name="originPath", visibility=["read", "create", "update", "delete", "query"] + ) + """A directory path on the origin that AzureFrontDoor can use to retrieve content from, e.g. + contoso.cloudapp.net/originpath.""" + rule_sets: Optional[list["_models.ResourceReference"]] = rest_field( + name="ruleSets", visibility=["read", "create", "update", "delete", "query"] + ) + """rule sets referenced by this endpoint.""" + supported_protocols: Optional[list[Union[str, "_models.AFDEndpointProtocols"]]] = rest_field( + name="supportedProtocols", visibility=["read", "create", "update", "delete", "query"] + ) + """List of supported protocols for this route.""" + patterns_to_match: Optional[list[str]] = rest_field( + name="patternsToMatch", visibility=["read", "create", "update", "delete", "query"] + ) + """The route patterns of the rule.""" + cache_configuration: Optional["_models.AfdRouteCacheConfiguration"] = rest_field( + name="cacheConfiguration", visibility=["read", "create", "update", "delete", "query"] + ) + """The caching configuration for this route. To disable caching, do not provide a + cacheConfiguration object.""" + forwarding_protocol: Optional[Union[str, "_models.ForwardingProtocol"]] = rest_field( + name="forwardingProtocol", visibility=["read", "create", "update", "delete", "query"] + ) + """Protocol this rule will use when forwarding traffic to backends. Known values are: + \"HttpOnly\", \"HttpsOnly\", and \"MatchRequest\".""" + link_to_default_domain: Optional[Union[str, "_models.LinkToDefaultDomain"]] = rest_field( + name="linkToDefaultDomain", visibility=["read", "create", "update", "delete", "query"] + ) + """whether this route will be linked to the default endpoint domain. Known values are: \"Enabled\" + and \"Disabled\".""" + https_redirect: Optional[Union[str, "_models.HttpsRedirect"]] = rest_field( + name="httpsRedirect", visibility=["read", "create", "update", "delete", "query"] + ) + """Whether to automatically redirect HTTP traffic to HTTPS traffic. Note that this is a easy way + to set up this rule and it will be the first rule that gets executed. Known values are: + \"Enabled\" and \"Disabled\".""" + enabled_state: Optional[Union[str, "_models.EnabledState"]] = rest_field( + name="enabledState", visibility=["read", "create", "update", "delete", "query"] + ) + """Whether to enable use of this rule. Permitted values are 'Enabled' or 'Disabled'. Known values + are: \"Enabled\" and \"Disabled\".""" + + @overload + def __init__( + self, + *, + custom_domains: Optional[list["_models.ActivatedResourceReference"]] = None, + origin_group: Optional["_models.ResourceReference"] = None, + origin_path: Optional[str] = None, + rule_sets: Optional[list["_models.ResourceReference"]] = None, + supported_protocols: Optional[list[Union[str, "_models.AFDEndpointProtocols"]]] = None, + patterns_to_match: Optional[list[str]] = None, + cache_configuration: Optional["_models.AfdRouteCacheConfiguration"] = None, + forwarding_protocol: Optional[Union[str, "_models.ForwardingProtocol"]] = None, + link_to_default_domain: Optional[Union[str, "_models.LinkToDefaultDomain"]] = None, + https_redirect: Optional[Union[str, "_models.HttpsRedirect"]] = None, + enabled_state: Optional[Union[str, "_models.EnabledState"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class Rule(ProxyResource): + """Friendly Rules name mapping to the any Rules or secret related information. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.cdn.models.SystemData + :ivar properties: The JSON object that contains the properties of the Rules to create. + :vartype properties: ~azure.mgmt.cdn.models.RuleProperties + """ + + properties: Optional["_models.RuleProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The JSON object that contains the properties of the Rules to create.""" + + __flattened_items = [ + "rule_set_name", + "order", + "conditions", + "actions", + "match_processing_behavior", + "provisioning_state", + "deployment_status", + ] + + @overload + def __init__( + self, + *, + properties: Optional["_models.RuleProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class RuleProperties(_Model): + """The JSON object that contains the properties of the Rules to create. + + :ivar rule_set_name: The name of the rule set containing the rule. + :vartype rule_set_name: str + :ivar order: The order in which the rules are applied for the endpoint. Possible values + {0,1,2,3,………}. A rule with a lesser order will be applied before a rule with a greater order. + Rule with order 0 is a special rule. It does not require any condition and actions listed in it + will always be applied. + :vartype order: int + :ivar conditions: A list of conditions that must be matched for the actions to be executed. + :vartype conditions: list[~azure.mgmt.cdn.models.DeliveryRuleCondition] + :ivar actions: A list of actions that are executed when all the conditions of a rule are + satisfied. + :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". + :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". + :vartype provisioning_state: str or ~azure.mgmt.cdn.models.AfdProvisioningState + :ivar deployment_status: Known values are: "NotStarted", "InProgress", "Succeeded", and + "Failed". + :vartype deployment_status: str or ~azure.mgmt.cdn.models.DeploymentStatus + """ + + rule_set_name: Optional[str] = rest_field(name="ruleSetName", visibility=["read"]) + """The name of the rule set containing the rule.""" + order: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The order in which the rules are applied for the endpoint. Possible values {0,1,2,3,………}. A + rule with a lesser order will be applied before a rule with a greater order. Rule with order 0 + is a special rule. It does not require any condition and actions listed in it will always be + applied.""" + conditions: Optional[list["_models.DeliveryRuleCondition"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """A list of conditions that must be matched for the actions to be executed.""" + actions: Optional[list["_models.DeliveryRuleAction"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """A list of actions that are executed when all the conditions of a rule are satisfied.""" + match_processing_behavior: Optional[Union[str, "_models.MatchProcessingBehavior"]] = rest_field( + name="matchProcessingBehavior", visibility=["read", "create", "update", "delete", "query"] + ) + """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\".""" + provisioning_state: Optional[Union[str, "_models.AfdProvisioningState"]] = rest_field( + name="provisioningState", visibility=["read"] + ) + """Provisioning status. Known values are: \"Succeeded\", \"Failed\", \"Updating\", \"Deleting\", + and \"Creating\".""" + deployment_status: Optional[Union[str, "_models.DeploymentStatus"]] = rest_field( + name="deploymentStatus", visibility=["read"] + ) + """Known values are: \"NotStarted\", \"InProgress\", \"Succeeded\", and \"Failed\".""" + + @overload + def __init__( + self, + *, + order: Optional[int] = None, + conditions: Optional[list["_models.DeliveryRuleCondition"]] = None, + actions: Optional[list["_models.DeliveryRuleAction"]] = None, + match_processing_behavior: Optional[Union[str, "_models.MatchProcessingBehavior"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class RuleSet(ProxyResource): + """Friendly RuleSet name mapping to the any RuleSet or secret related information. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.cdn.models.SystemData + :ivar properties: The JSON object that contains the properties of the Rule Set to create. + :vartype properties: ~azure.mgmt.cdn.models.RuleSetProperties + """ + + properties: Optional["_models.RuleSetProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The JSON object that contains the properties of the Rule Set to create.""" + + __flattened_items = ["provisioning_state", "deployment_status", "profile_name", "batch_mode", "rules"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.RuleSetProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class RuleSetProperties(AFDStateProperties): + """The JSON object that contains the properties of the Rule Set to create. + + :ivar provisioning_state: Provisioning status. Known values are: "Succeeded", "Failed", + "Updating", "Deleting", and "Creating". + :vartype provisioning_state: str or ~azure.mgmt.cdn.models.AfdProvisioningState + :ivar deployment_status: Known values are: "NotStarted", "InProgress", "Succeeded", and + "Failed". + :vartype deployment_status: str or ~azure.mgmt.cdn.models.DeploymentStatus + :ivar profile_name: The name of the profile which holds the rule set. + :vartype profile_name: str + :ivar batch_mode: Indicates whether rule set is in batch mode. When batch mode is enabled, + rules will be processed in a batch along with the rule set. When batch mode is disabled, rules + would need to be processed independently. This property can only be set during rule set + creation and cannot be updated later. For switching modes, a new rule set needs to be created + with the desired mode and rules need to be migrated to the new rule set. + :vartype batch_mode: bool + :ivar rules: A list of rules that are part of this rule set provided the rule set is in batch + mode. This property will be ignored if the rule set is not in batch mode. + :vartype rules: list[~azure.mgmt.cdn.models.BatchRuleProperties] + """ + + profile_name: Optional[str] = rest_field(name="profileName", visibility=["read"]) + """The name of the profile which holds the rule set.""" + batch_mode: Optional[bool] = rest_field(name="batchMode", visibility=["read", "create"]) + """Indicates whether rule set is in batch mode. When batch mode is enabled, rules will be + processed in a batch along with the rule set. When batch mode is disabled, rules would need to + be processed independently. This property can only be set during rule set creation and cannot + be updated later. For switching modes, a new rule set needs to be created with the desired mode + and rules need to be migrated to the new rule set.""" + rules: Optional[list["_models.BatchRuleProperties"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """A list of rules that are part of this rule set provided the rule set is in batch mode. This + property will be ignored if the rule set is not in batch mode.""" + + @overload + def __init__( + self, + *, + batch_mode: Optional[bool] = None, + rules: Optional[list["_models.BatchRuleProperties"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class RuleUpdateParameters(_Model): + """The domain JSON object required for domain creation or update. + + :ivar properties: The JSON object that contains the properties of the rule to update. + :vartype properties: ~azure.mgmt.cdn.models.RuleUpdatePropertiesParameters + """ + + properties: Optional["_models.RuleUpdatePropertiesParameters"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The JSON object that contains the properties of the rule to update.""" + + __flattened_items = ["rule_set_name", "order", "conditions", "actions", "match_processing_behavior"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.RuleUpdatePropertiesParameters"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class RuleUpdatePropertiesParameters(_Model): + """The JSON object that contains the properties of the rule to update. + + :ivar rule_set_name: The name of the rule set containing the rule. + :vartype rule_set_name: str + :ivar order: The order in which the rules are applied for the endpoint. Possible values + {0,1,2,3,………}. A rule with a lesser order will be applied before a rule with a greater order. + Rule with order 0 is a special rule. It does not require any condition and actions listed in it + will always be applied. + :vartype order: int + :ivar conditions: A list of conditions that must be matched for the actions to be executed. + :vartype conditions: list[~azure.mgmt.cdn.models.DeliveryRuleCondition] + :ivar actions: A list of actions that are executed when all the conditions of a rule are + satisfied. + :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". + :vartype match_processing_behavior: str or ~azure.mgmt.cdn.models.MatchProcessingBehavior + """ + + rule_set_name: Optional[str] = rest_field(name="ruleSetName", visibility=["read"]) + """The name of the rule set containing the rule.""" + order: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The order in which the rules are applied for the endpoint. Possible values {0,1,2,3,………}. A + rule with a lesser order will be applied before a rule with a greater order. Rule with order 0 + is a special rule. It does not require any condition and actions listed in it will always be + applied.""" + conditions: Optional[list["_models.DeliveryRuleCondition"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """A list of conditions that must be matched for the actions to be executed.""" + actions: Optional[list["_models.DeliveryRuleAction"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """A list of actions that are executed when all the conditions of a rule are satisfied.""" + match_processing_behavior: Optional[Union[str, "_models.MatchProcessingBehavior"]] = rest_field( + name="matchProcessingBehavior", visibility=["read", "create", "update", "delete", "query"] + ) + """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\".""" + + @overload + def __init__( + self, + *, + order: Optional[int] = None, + conditions: Optional[list["_models.DeliveryRuleCondition"]] = None, + actions: Optional[list["_models.DeliveryRuleAction"]] = None, + match_processing_behavior: Optional[Union[str, "_models.MatchProcessingBehavior"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class Secret(ProxyResource): + """Friendly Secret name mapping to the any Secret or secret related information. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.cdn.models.SystemData + :ivar properties: The JSON object that contains the properties of the Secret to create. + :vartype properties: ~azure.mgmt.cdn.models.SecretProperties + """ + + properties: Optional["_models.SecretProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The JSON object that contains the properties of the Secret to create.""" + + __flattened_items = ["provisioning_state", "deployment_status", "profile_name", "parameters"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.SecretProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class SecretProperties(AFDStateProperties): + """The JSON object that contains the properties of the Secret to create. + + :ivar provisioning_state: Provisioning status. Known values are: "Succeeded", "Failed", + "Updating", "Deleting", and "Creating". + :vartype provisioning_state: str or ~azure.mgmt.cdn.models.AfdProvisioningState + :ivar deployment_status: Known values are: "NotStarted", "InProgress", "Succeeded", and + "Failed". + :vartype deployment_status: str or ~azure.mgmt.cdn.models.DeploymentStatus + :ivar profile_name: The name of the profile which holds the secret. + :vartype profile_name: str + :ivar parameters: object which contains secret parameters. + :vartype parameters: ~azure.mgmt.cdn.models.SecretParameters + """ + + profile_name: Optional[str] = rest_field(name="profileName", visibility=["read"]) + """The name of the profile which holds the secret.""" + parameters: Optional["_models.SecretParameters"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """object which contains secret parameters.""" + + @overload + def __init__( + self, + *, + parameters: Optional["_models.SecretParameters"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class SecurityPolicy(ProxyResource): + """SecurityPolicy association for AzureFrontDoor profile. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.cdn.models.SystemData + :ivar properties: The json object that contains properties required to create a security + policy. + :vartype properties: ~azure.mgmt.cdn.models.SecurityPolicyProperties + """ + + properties: Optional["_models.SecurityPolicyProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The json object that contains properties required to create a security policy.""" + + __flattened_items = ["provisioning_state", "deployment_status", "profile_name", "parameters"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.SecurityPolicyProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class SecurityPolicyProperties(AFDStateProperties): + """The json object that contains properties required to create a security policy. + + :ivar provisioning_state: Provisioning status. Known values are: "Succeeded", "Failed", + "Updating", "Deleting", and "Creating". + :vartype provisioning_state: str or ~azure.mgmt.cdn.models.AfdProvisioningState + :ivar deployment_status: Known values are: "NotStarted", "InProgress", "Succeeded", and + "Failed". + :vartype deployment_status: str or ~azure.mgmt.cdn.models.DeploymentStatus + :ivar profile_name: The name of the profile which holds the security policy. + :vartype profile_name: str + :ivar parameters: object which contains security policy parameters. + :vartype parameters: ~azure.mgmt.cdn.models.SecurityPolicyPropertiesParameters + """ + + profile_name: Optional[str] = rest_field(name="profileName", visibility=["read"]) + """The name of the profile which holds the security policy.""" + parameters: Optional["_models.SecurityPolicyPropertiesParameters"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """object which contains security policy parameters.""" + + @overload + def __init__( + self, + *, + parameters: Optional["_models.SecurityPolicyPropertiesParameters"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class SecurityPolicyPropertiesParameters(_Model): + """The json object containing security policy parameters. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + SecurityPolicyWebApplicationFirewallParameters + + :ivar type: The type of the Security policy to create. Required. "WebApplicationFirewall" + :vartype type: str or ~azure.mgmt.cdn.models.SecurityPolicyType + """ + + __mapping__: dict[str, _Model] = {} + type: str = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) + """The type of the Security policy to create. Required. \"WebApplicationFirewall\"""" + + @overload + def __init__( + self, + *, + type: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class SecurityPolicyUpdateParameters(_Model): + """The JSON object containing security policy update parameters. + + :ivar properties: The json object that contains properties required to update a security + policy. + :vartype properties: ~azure.mgmt.cdn.models.SecurityPolicyUpdateProperties + """ + + properties: Optional["_models.SecurityPolicyUpdateProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The json object that contains properties required to update a security policy.""" + + __flattened_items = ["parameters"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.SecurityPolicyUpdateProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class SecurityPolicyUpdateProperties(_Model): + """The json object that contains properties required to update a security policy. + + :ivar parameters: object which contains security policy parameters. + :vartype parameters: ~azure.mgmt.cdn.models.SecurityPolicyPropertiesParameters + """ + + parameters: Optional["_models.SecurityPolicyPropertiesParameters"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """object which contains security policy parameters.""" + + @overload + def __init__( + self, + *, + parameters: Optional["_models.SecurityPolicyPropertiesParameters"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class SecurityPolicyWebApplicationFirewallAssociation(_Model): # pylint: disable=name-too-long + """settings for security policy patterns to match. + + :ivar domains: List of domains. + :vartype domains: list[~azure.mgmt.cdn.models.ActivatedResourceReference] + :ivar patterns_to_match: List of paths. + :vartype patterns_to_match: list[str] + """ + + domains: Optional[list["_models.ActivatedResourceReference"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """List of domains.""" + patterns_to_match: Optional[list[str]] = rest_field( + name="patternsToMatch", visibility=["read", "create", "update", "delete", "query"] + ) + """List of paths.""" + + @overload + def __init__( + self, + *, + domains: Optional[list["_models.ActivatedResourceReference"]] = None, + patterns_to_match: Optional[list[str]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class SecurityPolicyWebApplicationFirewallParameters( + SecurityPolicyPropertiesParameters, discriminator="WebApplicationFirewall" +): # pylint: disable=name-too-long + """The json object containing security policy waf parameters. + + :ivar waf_policy: Resource ID. + :vartype waf_policy: ~azure.mgmt.cdn.models.ResourceReference + :ivar associations: Waf associations. + :vartype associations: + list[~azure.mgmt.cdn.models.SecurityPolicyWebApplicationFirewallAssociation] + :ivar type: The type of the Security policy to create. Required. WEB_APPLICATION_FIREWALL. + :vartype type: str or ~azure.mgmt.cdn.models.WEB_APPLICATION_FIREWALL + """ + + waf_policy: Optional["_models.ResourceReference"] = rest_field( + name="wafPolicy", visibility=["read", "create", "update", "delete", "query"] + ) + """Resource ID.""" + associations: Optional[list["_models.SecurityPolicyWebApplicationFirewallAssociation"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Waf associations.""" + type: Literal[SecurityPolicyType.WEB_APPLICATION_FIREWALL] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """The type of the Security policy to create. Required. WEB_APPLICATION_FIREWALL.""" + + @overload + def __init__( + self, + *, + waf_policy: Optional["_models.ResourceReference"] = None, + associations: Optional[list["_models.SecurityPolicyWebApplicationFirewallAssociation"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type = SecurityPolicyType.WEB_APPLICATION_FIREWALL # type: ignore + + +class ServerPortMatchConditionParameters( + DeliveryRuleConditionParameters, discriminator="DeliveryRuleServerPortConditionParameters" +): + """Defines the parameters for ServerPort match conditions. + + :ivar operator: Describes operator to be matched. Required. Known values are: "Any", "Equal", + "Contains", "BeginsWith", "EndsWith", "LessThan", "LessThanOrEqual", "GreaterThan", + "GreaterThanOrEqual", and "RegEx". + :vartype operator: str or ~azure.mgmt.cdn.models.ServerPortOperator + :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] + :ivar transforms: List of transforms. + :vartype transforms: list[str or ~azure.mgmt.cdn.models.Transform] + :ivar type_name: Required. DELIVERY_RULE_SERVER_PORT_CONDITION_PARAMETERS. + :vartype type_name: str or + ~azure.mgmt.cdn.models.DELIVERY_RULE_SERVER_PORT_CONDITION_PARAMETERS + """ + + operator: Union[str, "_models.ServerPortOperator"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Describes operator to be matched. Required. Known values are: \"Any\", \"Equal\", \"Contains\", + \"BeginsWith\", \"EndsWith\", \"LessThan\", \"LessThanOrEqual\", \"GreaterThan\", + \"GreaterThanOrEqual\", and \"RegEx\".""" + negate_condition: Optional[bool] = rest_field( + name="negateCondition", visibility=["read", "create", "update", "delete", "query"] + ) + """Describes if this is negate condition or not.""" + match_values: Optional[list[str]] = rest_field( + name="matchValues", visibility=["read", "create", "update", "delete", "query"] + ) + """The match value for the condition of the delivery rule.""" + transforms: Optional[list[Union[str, "_models.Transform"]]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """List of transforms.""" + type_name: Literal[DeliveryRuleConditionParametersType.DELIVERY_RULE_SERVER_PORT_CONDITION_PARAMETERS] = rest_discriminator(name="typeName", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Required. DELIVERY_RULE_SERVER_PORT_CONDITION_PARAMETERS.""" + + @overload + def __init__( + self, + *, + operator: Union[str, "_models.ServerPortOperator"], + negate_condition: Optional[bool] = None, + match_values: Optional[list[str]] = None, + transforms: Optional[list[Union[str, "_models.Transform"]]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type_name = DeliveryRuleConditionParametersType.DELIVERY_RULE_SERVER_PORT_CONDITION_PARAMETERS # type: ignore + + +class ServiceSpecification(_Model): + """One property of operation, include log specifications. + + :ivar log_specifications: Log specifications of operation. + :vartype log_specifications: list[~azure.mgmt.cdn.models.LogSpecification] + :ivar metric_specifications: Metric specifications of operation. + :vartype metric_specifications: list[~azure.mgmt.cdn.models.MetricSpecification] + """ + + log_specifications: Optional[list["_models.LogSpecification"]] = rest_field( + name="logSpecifications", visibility=["read", "create", "update", "delete", "query"] + ) + """Log specifications of operation.""" + metric_specifications: Optional[list["_models.MetricSpecification"]] = rest_field( + name="metricSpecifications", visibility=["read", "create", "update", "delete", "query"] + ) + """Metric specifications of operation.""" + + @overload + def __init__( + self, + *, + log_specifications: Optional[list["_models.LogSpecification"]] = None, + metric_specifications: Optional[list["_models.MetricSpecification"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class SharedPrivateLinkResourceProperties(_Model): + """Describes the properties of an existing Shared Private Link Resource to use when connecting to + a private origin. + + :ivar private_link: The resource id of the resource the shared private link resource is for. + :vartype private_link: ~azure.mgmt.cdn.models.ResourceReference + :ivar private_link_location: The location of the shared private link resource. + :vartype private_link_location: str + :ivar group_id: The group id from the provider of resource the shared private link resource is + for. + :vartype group_id: str + :ivar request_message: The request message for requesting approval of the shared private link + resource. + :vartype request_message: str + :ivar status: Status of the shared private link resource. Can be Pending, Approved, Rejected, + Disconnected, or Timeout. Known values are: "Pending", "Approved", "Rejected", "Disconnected", + and "Timeout". + :vartype status: str or ~azure.mgmt.cdn.models.SharedPrivateLinkResourceStatus + """ + + private_link: Optional["_models.ResourceReference"] = rest_field( + name="privateLink", visibility=["read", "create", "update", "delete", "query"] + ) + """The resource id of the resource the shared private link resource is for.""" + private_link_location: Optional[str] = rest_field( + name="privateLinkLocation", visibility=["read", "create", "update", "delete", "query"] + ) + """The location of the shared private link resource.""" + group_id: Optional[str] = rest_field(name="groupId", visibility=["read", "create", "update", "delete", "query"]) + """The group id from the provider of resource the shared private link resource is for.""" + request_message: Optional[str] = rest_field( + name="requestMessage", visibility=["read", "create", "update", "delete", "query"] + ) + """The request message for requesting approval of the shared private link resource.""" + status: Optional[Union[str, "_models.SharedPrivateLinkResourceStatus"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Status of the shared private link resource. Can be Pending, Approved, Rejected, Disconnected, + or Timeout. Known values are: \"Pending\", \"Approved\", \"Rejected\", \"Disconnected\", and + \"Timeout\".""" + + @overload + def __init__( + self, + *, + private_link: Optional["_models.ResourceReference"] = None, + private_link_location: Optional[str] = None, + group_id: Optional[str] = None, + request_message: Optional[str] = None, + status: Optional[Union[str, "_models.SharedPrivateLinkResourceStatus"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class Sku(_Model): + """Standard_Verizon = The SKU name for a Standard Verizon CDN profile. Premium_Verizon = The SKU + name for a Premium Verizon CDN profile. Custom_Verizon = The SKU name for a Custom Verizon CDN + profile. Standard_Akamai = The SKU name for an Akamai CDN profile. Standard_ChinaCdn = The SKU + name for a China CDN profile for VOD, Web and download scenarios using GB based billing model. + Standard_Microsoft = The SKU name for a Standard Microsoft CDN profile. Standard_AzureFrontDoor + = The SKU name for an Azure Front Door Standard profile. Premium_AzureFrontDoor = The SKU name + for an Azure Front Door Premium profile. Standard_955BandWidth_ChinaCdn = The SKU name for a + China CDN profile for VOD, Web and download scenarios using 95-5 peak bandwidth billing model. + Standard_AvgBandWidth_ChinaCdn = The SKU name for a China CDN profile for VOD, Web and download + scenarios using monthly average peak bandwidth billing model. StandardPlus_ChinaCdn = The SKU + name for a China CDN profile for live-streaming using GB based billing model. + StandardPlus_955BandWidth_ChinaCdn = The SKU name for a China CDN live-streaming profile using + 95-5 peak bandwidth billing model. StandardPlus_AvgBandWidth_ChinaCdn = The SKU name for a + China CDN live-streaming profile using monthly average peak bandwidth billing model. + + :ivar name: Name of the pricing tier. Known values are: "Standard_Verizon", "Premium_Verizon", + "Custom_Verizon", "Standard_Akamai", "Standard_ChinaCdn", "Standard_Microsoft", + "Standard_AzureFrontDoor", "Premium_AzureFrontDoor", "Standard_955BandWidth_ChinaCdn", + "Standard_AvgBandWidth_ChinaCdn", "StandardPlus_ChinaCdn", + "StandardPlus_955BandWidth_ChinaCdn", and "StandardPlus_AvgBandWidth_ChinaCdn". + :vartype name: str or ~azure.mgmt.cdn.models.SkuName + """ + + name: Optional[Union[str, "_models.SkuName"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Name of the pricing tier. Known values are: \"Standard_Verizon\", \"Premium_Verizon\", + \"Custom_Verizon\", \"Standard_Akamai\", \"Standard_ChinaCdn\", \"Standard_Microsoft\", + \"Standard_AzureFrontDoor\", \"Premium_AzureFrontDoor\", \"Standard_955BandWidth_ChinaCdn\", + \"Standard_AvgBandWidth_ChinaCdn\", \"StandardPlus_ChinaCdn\", + \"StandardPlus_955BandWidth_ChinaCdn\", and \"StandardPlus_AvgBandWidth_ChinaCdn\".""" + + @overload + def __init__( + self, + *, + name: Optional[Union[str, "_models.SkuName"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class SocketAddrMatchConditionParameters( + DeliveryRuleConditionParameters, discriminator="DeliveryRuleSocketAddrConditionParameters" +): + """Defines the parameters for SocketAddress match conditions. + + :ivar operator: Describes operator to be matched. Required. Known values are: "Any" and + "IPMatch". + :vartype operator: str or ~azure.mgmt.cdn.models.SocketAddrOperator + :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] + :ivar transforms: List of transforms. + :vartype transforms: list[str or ~azure.mgmt.cdn.models.Transform] + :ivar type_name: Required. DELIVERY_RULE_SOCKET_ADDR_CONDITION_PARAMETERS. + :vartype type_name: str or + ~azure.mgmt.cdn.models.DELIVERY_RULE_SOCKET_ADDR_CONDITION_PARAMETERS + """ + + operator: Union[str, "_models.SocketAddrOperator"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Describes operator to be matched. Required. Known values are: \"Any\" and \"IPMatch\".""" + negate_condition: Optional[bool] = rest_field( + name="negateCondition", visibility=["read", "create", "update", "delete", "query"] + ) + """Describes if this is negate condition or not.""" + match_values: Optional[list[str]] = rest_field( + name="matchValues", visibility=["read", "create", "update", "delete", "query"] + ) + """The match value for the condition of the delivery rule.""" + transforms: Optional[list[Union[str, "_models.Transform"]]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """List of transforms.""" + type_name: Literal[DeliveryRuleConditionParametersType.DELIVERY_RULE_SOCKET_ADDR_CONDITION_PARAMETERS] = rest_discriminator(name="typeName", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Required. DELIVERY_RULE_SOCKET_ADDR_CONDITION_PARAMETERS.""" + + @overload + def __init__( + self, + *, + operator: Union[str, "_models.SocketAddrOperator"], + negate_condition: Optional[bool] = None, + match_values: Optional[list[str]] = None, + transforms: Optional[list[Union[str, "_models.Transform"]]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type_name = DeliveryRuleConditionParametersType.DELIVERY_RULE_SOCKET_ADDR_CONDITION_PARAMETERS # type: ignore + + +class SslProtocolMatchConditionParameters( + DeliveryRuleConditionParameters, discriminator="DeliveryRuleSslProtocolConditionParameters" +): + """Defines the parameters for SslProtocol match conditions. + + :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. + :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.SslProtocol] + :ivar transforms: List of transforms. + :vartype transforms: list[str or ~azure.mgmt.cdn.models.Transform] + :ivar type_name: Required. DELIVERY_RULE_SSL_PROTOCOL_CONDITION_PARAMETERS. + :vartype type_name: str or + ~azure.mgmt.cdn.models.DELIVERY_RULE_SSL_PROTOCOL_CONDITION_PARAMETERS + """ + + operator: Union[str, "_models.SslProtocolOperator"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Describes operator to be matched. Required. \"Equal\"""" + negate_condition: Optional[bool] = rest_field( + name="negateCondition", visibility=["read", "create", "update", "delete", "query"] + ) + """Describes if this is negate condition or not.""" + match_values: Optional[list[Union[str, "_models.SslProtocol"]]] = rest_field( + name="matchValues", visibility=["read", "create", "update", "delete", "query"] + ) + """The match value for the condition of the delivery rule.""" + transforms: Optional[list[Union[str, "_models.Transform"]]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """List of transforms.""" + type_name: Literal[DeliveryRuleConditionParametersType.DELIVERY_RULE_SSL_PROTOCOL_CONDITION_PARAMETERS] = rest_discriminator(name="typeName", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Required. DELIVERY_RULE_SSL_PROTOCOL_CONDITION_PARAMETERS.""" + + @overload + def __init__( + self, + *, + operator: Union[str, "_models.SslProtocolOperator"], + negate_condition: Optional[bool] = None, + match_values: Optional[list[Union[str, "_models.SslProtocol"]]] = None, + transforms: Optional[list[Union[str, "_models.Transform"]]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type_name = DeliveryRuleConditionParametersType.DELIVERY_RULE_SSL_PROTOCOL_CONDITION_PARAMETERS # type: ignore + + +class SsoUri(_Model): + """The URI required to login to the supplemental portal from the Azure portal. + + :ivar sso_uri_value: The URI used to login to the supplemental portal. + :vartype sso_uri_value: str + """ + + sso_uri_value: Optional[str] = rest_field(name="ssoUriValue", visibility=["read"]) + """The URI used to login to the supplemental portal.""" + + +class SupportedOptimizationTypesListResult(_Model): + """The result of the GetSupportedOptimizationTypes API. + + :ivar supported_optimization_types: Supported optimization types for a profile. + :vartype supported_optimization_types: list[str or ~azure.mgmt.cdn.models.OptimizationType] + """ + + supported_optimization_types: Optional[list[Union[str, "_models.OptimizationType"]]] = rest_field( + name="supportedOptimizationTypes", visibility=["read"] + ) + """Supported optimization types for a profile.""" + + +class SystemData(_Model): + """Metadata pertaining to creation and last modification of the resource. + + :ivar created_by: The identity that created the resource. + :vartype created_by: str + :ivar created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". + :vartype created_by_type: str or ~azure.mgmt.cdn.models.CreatedByType + :ivar created_at: The timestamp of resource creation (UTC). + :vartype created_at: ~datetime.datetime + :ivar last_modified_by: The identity that last modified the resource. + :vartype last_modified_by: str + :ivar last_modified_by_type: The type of identity that last modified the resource. Known values + are: "User", "Application", "ManagedIdentity", and "Key". + :vartype last_modified_by_type: str or ~azure.mgmt.cdn.models.CreatedByType + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime + """ + + created_by: Optional[str] = rest_field(name="createdBy", visibility=["read", "create", "update", "delete", "query"]) + """The identity that created the resource.""" + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = rest_field( + name="createdByType", visibility=["read", "create", "update", "delete", "query"] + ) + """The type of identity that created the resource. Known values are: \"User\", \"Application\", + \"ManagedIdentity\", and \"Key\".""" + created_at: Optional[datetime.datetime] = rest_field( + name="createdAt", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) + """The timestamp of resource creation (UTC).""" + last_modified_by: Optional[str] = rest_field( + name="lastModifiedBy", visibility=["read", "create", "update", "delete", "query"] + ) + """The identity that last modified the resource.""" + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = rest_field( + name="lastModifiedByType", visibility=["read", "create", "update", "delete", "query"] + ) + """The type of identity that last modified the resource. Known values are: \"User\", + \"Application\", \"ManagedIdentity\", and \"Key\".""" + last_modified_at: Optional[datetime.datetime] = rest_field( + name="lastModifiedAt", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) + """The timestamp of resource last modification (UTC).""" + + @overload + def __init__( + self, + *, + created_by: Optional[str] = None, + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, + created_at: Optional[datetime.datetime] = None, + last_modified_by: Optional[str] = None, + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, + last_modified_at: Optional[datetime.datetime] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class UrlFileExtensionMatchConditionParameters( + DeliveryRuleConditionParameters, discriminator="DeliveryRuleUrlFileExtensionMatchConditionParameters" +): + """Defines the parameters for UrlFileExtension match conditions. + + :ivar operator: Describes operator to be matched. Required. Known values are: "Any", "Equal", + "Contains", "BeginsWith", "EndsWith", "LessThan", "LessThanOrEqual", "GreaterThan", + "GreaterThanOrEqual", and "RegEx". + :vartype operator: str or ~azure.mgmt.cdn.models.UrlFileExtensionOperator + :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] + :ivar transforms: List of transforms. + :vartype transforms: list[str or ~azure.mgmt.cdn.models.Transform] + :ivar type_name: Required. DELIVERY_RULE_URL_FILE_EXTENSION_MATCH_CONDITION_PARAMETERS. + :vartype type_name: str or + ~azure.mgmt.cdn.models.DELIVERY_RULE_URL_FILE_EXTENSION_MATCH_CONDITION_PARAMETERS + """ + + operator: Union[str, "_models.UrlFileExtensionOperator"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Describes operator to be matched. Required. Known values are: \"Any\", \"Equal\", \"Contains\", + \"BeginsWith\", \"EndsWith\", \"LessThan\", \"LessThanOrEqual\", \"GreaterThan\", + \"GreaterThanOrEqual\", and \"RegEx\".""" + negate_condition: Optional[bool] = rest_field( + name="negateCondition", visibility=["read", "create", "update", "delete", "query"] + ) + """Describes if this is negate condition or not.""" + match_values: Optional[list[str]] = rest_field( + name="matchValues", visibility=["read", "create", "update", "delete", "query"] + ) + """The match value for the condition of the delivery rule.""" + transforms: Optional[list[Union[str, "_models.Transform"]]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """List of transforms.""" + type_name: Literal[DeliveryRuleConditionParametersType.DELIVERY_RULE_URL_FILE_EXTENSION_MATCH_CONDITION_PARAMETERS] = rest_discriminator(name="typeName", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Required. DELIVERY_RULE_URL_FILE_EXTENSION_MATCH_CONDITION_PARAMETERS.""" + + @overload + def __init__( + self, + *, + operator: Union[str, "_models.UrlFileExtensionOperator"], + negate_condition: Optional[bool] = None, + match_values: Optional[list[str]] = None, + transforms: Optional[list[Union[str, "_models.Transform"]]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type_name = DeliveryRuleConditionParametersType.DELIVERY_RULE_URL_FILE_EXTENSION_MATCH_CONDITION_PARAMETERS # type: ignore + + +class UrlFileNameMatchConditionParameters( + DeliveryRuleConditionParameters, discriminator="DeliveryRuleUrlFilenameConditionParameters" +): + """Defines the parameters for UrlFilename match conditions. + + :ivar operator: Describes operator to be matched. Required. Known values are: "Any", "Equal", + "Contains", "BeginsWith", "EndsWith", "LessThan", "LessThanOrEqual", "GreaterThan", + "GreaterThanOrEqual", and "RegEx". + :vartype operator: str or ~azure.mgmt.cdn.models.UrlFileNameOperator + :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] + :ivar transforms: List of transforms. + :vartype transforms: list[str or ~azure.mgmt.cdn.models.Transform] + :ivar type_name: Required. DELIVERY_RULE_URL_FILENAME_CONDITION_PARAMETERS. + :vartype type_name: str or + ~azure.mgmt.cdn.models.DELIVERY_RULE_URL_FILENAME_CONDITION_PARAMETERS + """ + + operator: Union[str, "_models.UrlFileNameOperator"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Describes operator to be matched. Required. Known values are: \"Any\", \"Equal\", \"Contains\", + \"BeginsWith\", \"EndsWith\", \"LessThan\", \"LessThanOrEqual\", \"GreaterThan\", + \"GreaterThanOrEqual\", and \"RegEx\".""" + negate_condition: Optional[bool] = rest_field( + name="negateCondition", visibility=["read", "create", "update", "delete", "query"] + ) + """Describes if this is negate condition or not.""" + match_values: Optional[list[str]] = rest_field( + name="matchValues", visibility=["read", "create", "update", "delete", "query"] + ) + """The match value for the condition of the delivery rule.""" + transforms: Optional[list[Union[str, "_models.Transform"]]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """List of transforms.""" + type_name: Literal[DeliveryRuleConditionParametersType.DELIVERY_RULE_URL_FILENAME_CONDITION_PARAMETERS] = rest_discriminator(name="typeName", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Required. DELIVERY_RULE_URL_FILENAME_CONDITION_PARAMETERS.""" + + @overload + def __init__( + self, + *, + operator: Union[str, "_models.UrlFileNameOperator"], + negate_condition: Optional[bool] = None, + match_values: Optional[list[str]] = None, + transforms: Optional[list[Union[str, "_models.Transform"]]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type_name = DeliveryRuleConditionParametersType.DELIVERY_RULE_URL_FILENAME_CONDITION_PARAMETERS # type: ignore + + +class UrlPathMatchConditionParameters( + DeliveryRuleConditionParameters, discriminator="DeliveryRuleUrlPathMatchConditionParameters" +): + """Defines the parameters for UrlPath match conditions. + + :ivar operator: Describes operator to be matched. Required. Known values are: "Any", "Equal", + "Contains", "BeginsWith", "EndsWith", "LessThan", "LessThanOrEqual", "GreaterThan", + "GreaterThanOrEqual", "Wildcard", and "RegEx". + :vartype operator: str or ~azure.mgmt.cdn.models.UrlPathOperator + :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] + :ivar transforms: List of transforms. + :vartype transforms: list[str or ~azure.mgmt.cdn.models.Transform] + :ivar type_name: Required. DELIVERY_RULE_URL_PATH_MATCH_CONDITION_PARAMETERS. + :vartype type_name: str or + ~azure.mgmt.cdn.models.DELIVERY_RULE_URL_PATH_MATCH_CONDITION_PARAMETERS + """ + + operator: Union[str, "_models.UrlPathOperator"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Describes operator to be matched. Required. Known values are: \"Any\", \"Equal\", \"Contains\", + \"BeginsWith\", \"EndsWith\", \"LessThan\", \"LessThanOrEqual\", \"GreaterThan\", + \"GreaterThanOrEqual\", \"Wildcard\", and \"RegEx\".""" + negate_condition: Optional[bool] = rest_field( + name="negateCondition", visibility=["read", "create", "update", "delete", "query"] + ) + """Describes if this is negate condition or not.""" + match_values: Optional[list[str]] = rest_field( + name="matchValues", visibility=["read", "create", "update", "delete", "query"] + ) + """The match value for the condition of the delivery rule.""" + transforms: Optional[list[Union[str, "_models.Transform"]]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """List of transforms.""" + type_name: Literal[DeliveryRuleConditionParametersType.DELIVERY_RULE_URL_PATH_MATCH_CONDITION_PARAMETERS] = rest_discriminator(name="typeName", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Required. DELIVERY_RULE_URL_PATH_MATCH_CONDITION_PARAMETERS.""" + + @overload + def __init__( + self, + *, + operator: Union[str, "_models.UrlPathOperator"], + negate_condition: Optional[bool] = None, + match_values: Optional[list[str]] = None, + transforms: Optional[list[Union[str, "_models.Transform"]]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type_name = DeliveryRuleConditionParametersType.DELIVERY_RULE_URL_PATH_MATCH_CONDITION_PARAMETERS # type: ignore + + +class UrlRedirectAction(DeliveryRuleAction, discriminator="UrlRedirect"): + """Defines the url redirect action for the delivery rule. + + :ivar parameters: Defines the parameters for the action. Required. + :vartype parameters: ~azure.mgmt.cdn.models.UrlRedirectActionParameters + :ivar name: The name of the action for the delivery rule. Required. URL_REDIRECT. + :vartype name: str or ~azure.mgmt.cdn.models.URL_REDIRECT + """ + + parameters: "_models.UrlRedirectActionParameters" = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Defines the parameters for the action. Required.""" + name: Literal[DeliveryRuleActionName.URL_REDIRECT] = rest_discriminator(name="name", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """The name of the action for the delivery rule. Required. URL_REDIRECT.""" + + @overload + def __init__( + self, + *, + parameters: "_models.UrlRedirectActionParameters", + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.name = DeliveryRuleActionName.URL_REDIRECT # type: ignore + + +class UrlRedirectActionParameters( + DeliveryRuleActionParameters, discriminator="DeliveryRuleUrlRedirectActionParameters" +): + """Defines the parameters for the url redirect action. + + :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 + :ivar destination_protocol: Protocol to use for the redirect. The default value is + MatchRequest. Known values are: "MatchRequest", "Http", and "Https". + :vartype destination_protocol: str or ~azure.mgmt.cdn.models.DestinationProtocol + :ivar custom_path: The full path to redirect. Path cannot be empty and must start with /. Leave + empty to use the incoming path as destination path. + :vartype custom_path: str + :ivar custom_hostname: Host to redirect. Leave empty to use the incoming host as the + destination host. + :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 = 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 + that comes after #. Do not include the #. + :vartype custom_fragment: str + :ivar type_name: Required. DELIVERY_RULE_URL_REDIRECT_ACTION_PARAMETERS. + :vartype type_name: str or ~azure.mgmt.cdn.models.DELIVERY_RULE_URL_REDIRECT_ACTION_PARAMETERS + """ + + redirect_type: Union[str, "_models.RedirectType"] = rest_field( + name="redirectType", visibility=["read", "create", "update", "delete", "query"] + ) + """The redirect type the rule will use when redirecting traffic. Required. Known values are: + \"Moved\", \"Found\", \"TemporaryRedirect\", and \"PermanentRedirect\".""" + destination_protocol: Optional[Union[str, "_models.DestinationProtocol"]] = rest_field( + name="destinationProtocol", visibility=["read", "create", "update", "delete", "query"] + ) + """Protocol to use for the redirect. The default value is MatchRequest. Known values are: + \"MatchRequest\", \"Http\", and \"Https\".""" + custom_path: Optional[str] = rest_field( + name="customPath", visibility=["read", "create", "update", "delete", "query"] + ) + """The full path to redirect. Path cannot be empty and must start with /. Leave empty to use the + incoming path as destination path.""" + custom_hostname: Optional[str] = rest_field( + name="customHostname", visibility=["read", "create", "update", "delete", "query"] + ) + """Host to redirect. Leave empty to use the incoming host as the destination host.""" + custom_query_string: Optional[str] = rest_field( + name="customQueryString", visibility=["read", "create", "update", "delete", "query"] + ) + """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 = format. ? and & will be added automatically so do not include them.""" + custom_fragment: Optional[str] = rest_field( + name="customFragment", visibility=["read", "create", "update", "delete", "query"] + ) + """Fragment to add to the redirect URL. Fragment is the part of the URL that comes after #. Do not + include the #.""" + type_name: Literal[DeliveryRuleActionParametersType.DELIVERY_RULE_URL_REDIRECT_ACTION_PARAMETERS] = rest_discriminator(name="typeName", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Required. DELIVERY_RULE_URL_REDIRECT_ACTION_PARAMETERS.""" + + @overload + def __init__( + self, + *, + redirect_type: Union[str, "_models.RedirectType"], + destination_protocol: Optional[Union[str, "_models.DestinationProtocol"]] = None, + custom_path: Optional[str] = None, + custom_hostname: Optional[str] = None, + custom_query_string: Optional[str] = None, + custom_fragment: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type_name = DeliveryRuleActionParametersType.DELIVERY_RULE_URL_REDIRECT_ACTION_PARAMETERS # type: ignore + + +class UrlRewriteAction(DeliveryRuleAction, discriminator="UrlRewrite"): + """Defines the url rewrite action for the delivery rule. + + :ivar parameters: Defines the parameters for the action. Required. + :vartype parameters: ~azure.mgmt.cdn.models.UrlRewriteActionParameters + :ivar name: The name of the action for the delivery rule. Required. URL_REWRITE. + :vartype name: str or ~azure.mgmt.cdn.models.URL_REWRITE + """ + + parameters: "_models.UrlRewriteActionParameters" = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Defines the parameters for the action. Required.""" + name: Literal[DeliveryRuleActionName.URL_REWRITE] = rest_discriminator(name="name", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """The name of the action for the delivery rule. Required. URL_REWRITE.""" + + @overload + def __init__( + self, + *, + parameters: "_models.UrlRewriteActionParameters", + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.name = DeliveryRuleActionName.URL_REWRITE # type: ignore + + +class UrlRewriteActionParameters(DeliveryRuleActionParameters, discriminator="DeliveryRuleUrlRewriteActionParameters"): + """Defines the parameters for the url rewrite action. + + :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 + :ivar destination: Define the relative URL to which the above requests will be rewritten by. + Required. + :vartype destination: str + :ivar preserve_unmatched_path: Whether to preserve unmatched path. Default value is true. + :vartype preserve_unmatched_path: bool + :ivar type_name: Required. DELIVERY_RULE_URL_REWRITE_ACTION_PARAMETERS. + :vartype type_name: str or ~azure.mgmt.cdn.models.DELIVERY_RULE_URL_REWRITE_ACTION_PARAMETERS + """ + + source_pattern: str = rest_field(name="sourcePattern", visibility=["read", "create", "update", "delete", "query"]) + """define a request URI pattern that identifies the type of requests that may be rewritten. If + value is blank, all strings are matched. Required.""" + destination: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Define the relative URL to which the above requests will be rewritten by. Required.""" + preserve_unmatched_path: Optional[bool] = rest_field( + name="preserveUnmatchedPath", visibility=["read", "create", "update", "delete", "query"] + ) + """Whether to preserve unmatched path. Default value is true.""" + type_name: Literal[DeliveryRuleActionParametersType.DELIVERY_RULE_URL_REWRITE_ACTION_PARAMETERS] = rest_discriminator(name="typeName", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Required. DELIVERY_RULE_URL_REWRITE_ACTION_PARAMETERS.""" + + @overload + def __init__( + self, + *, + source_pattern: str, + destination: str, + preserve_unmatched_path: Optional[bool] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type_name = DeliveryRuleActionParametersType.DELIVERY_RULE_URL_REWRITE_ACTION_PARAMETERS # type: ignore + + +class UrlSigningAction(DeliveryRuleAction, discriminator="UrlSigning"): + """Defines the url signing action for the delivery rule. + + :ivar parameters: Defines the parameters for the action. Required. + :vartype parameters: ~azure.mgmt.cdn.models.UrlSigningActionParameters + :ivar name: The name of the action for the delivery rule. Required. URL_SIGNING. + :vartype name: str or ~azure.mgmt.cdn.models.URL_SIGNING + """ + + parameters: "_models.UrlSigningActionParameters" = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Defines the parameters for the action. Required.""" + name: Literal[DeliveryRuleActionName.URL_SIGNING] = rest_discriminator(name="name", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """The name of the action for the delivery rule. Required. URL_SIGNING.""" + + @overload + def __init__( + self, + *, + parameters: "_models.UrlSigningActionParameters", + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.name = DeliveryRuleActionName.URL_SIGNING # type: ignore + + +class UrlSigningActionParameters(DeliveryRuleActionParameters, discriminator="DeliveryRuleUrlSigningActionParameters"): + """Defines the parameters for the Url Signing action. + + :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 + considered for expires, key id etc. + :vartype parameter_name_override: list[~azure.mgmt.cdn.models.UrlSigningParamIdentifier] + :ivar type_name: Required. DELIVERY_RULE_URL_SIGNING_ACTION_PARAMETERS. + :vartype type_name: str or ~azure.mgmt.cdn.models.DELIVERY_RULE_URL_SIGNING_ACTION_PARAMETERS + """ + + algorithm: Optional[Union[str, "_models.Algorithm"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Algorithm to use for URL signing. \"SHA256\"""" + parameter_name_override: Optional[list["_models.UrlSigningParamIdentifier"]] = rest_field( + name="parameterNameOverride", visibility=["read", "create", "update", "delete", "query"] + ) + """Defines which query string parameters in the url to be considered for expires, key id etc.""" + type_name: Literal[DeliveryRuleActionParametersType.DELIVERY_RULE_URL_SIGNING_ACTION_PARAMETERS] = rest_discriminator(name="typeName", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Required. DELIVERY_RULE_URL_SIGNING_ACTION_PARAMETERS.""" + + @overload + def __init__( + self, + *, + algorithm: Optional[Union[str, "_models.Algorithm"]] = None, + parameter_name_override: Optional[list["_models.UrlSigningParamIdentifier"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type_name = DeliveryRuleActionParametersType.DELIVERY_RULE_URL_SIGNING_ACTION_PARAMETERS # type: ignore + + +class UrlSigningKey(_Model): + """Url signing key. + + :ivar key_id: Defines the customer defined key Id. This id will exist in the incoming request + to indicate the key used to form the hash. Required. + :vartype key_id: str + :ivar key_source_parameters: Defines the parameters for using customer key vault for Url + Signing Key. Required. + :vartype key_source_parameters: ~azure.mgmt.cdn.models.KeyVaultSigningKeyParameters + """ + + key_id: str = rest_field(name="keyId", visibility=["read", "create", "update", "delete", "query"]) + """Defines the customer defined key Id. This id will exist in the incoming request to indicate the + key used to form the hash. Required.""" + key_source_parameters: "_models.KeyVaultSigningKeyParameters" = rest_field( + name="keySourceParameters", visibility=["read", "create", "update", "delete", "query"] + ) + """Defines the parameters for using customer key vault for Url Signing Key. Required.""" + + @overload + def __init__( + self, + *, + key_id: str, + key_source_parameters: "_models.KeyVaultSigningKeyParameters", + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class UrlSigningKeyParameters(SecretParameters, discriminator="UrlSigningKey"): + """Url signing key parameters. + + :ivar key_id: Defines the customer defined key Id. This id will exist in the incoming request + to indicate the key used to form the hash. Required. + :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}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​. + Required. + :vartype secret_source: ~azure.mgmt.cdn.models.ResourceReference + :ivar secret_version: Version of the secret to be used. Required. + :vartype secret_version: str + :ivar type: The type of the secret resource. Required. URL_SIGNING_KEY. + :vartype type: str or ~azure.mgmt.cdn.models.URL_SIGNING_KEY + """ + + key_id: str = rest_field(name="keyId", visibility=["read", "create", "update", "delete", "query"]) + """Defines the customer defined key Id. This id will exist in the incoming request to indicate the + key used to form the hash. Required.""" + secret_source: "_models.ResourceReference" = rest_field( + name="secretSource", visibility=["read", "create", "update", "delete", "query"] + ) + """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}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​. + Required.""" + secret_version: str = rest_field(name="secretVersion", visibility=["read", "create", "update", "delete", "query"]) + """Version of the secret to be used. Required.""" + type: Literal[SecretType.URL_SIGNING_KEY] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """The type of the secret resource. Required. URL_SIGNING_KEY.""" + + @overload + def __init__( + self, + *, + key_id: str, + secret_source: "_models.ResourceReference", + secret_version: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.type = SecretType.URL_SIGNING_KEY # type: ignore + + +class UrlSigningParamIdentifier(_Model): + """Defines how to identify a parameter for a specific purpose e.g. expires. + + :ivar param_indicator: Indicates the purpose of the parameter. Required. Known values are: + "Expires", "KeyId", and "Signature". + :vartype param_indicator: str or ~azure.mgmt.cdn.models.ParamIndicator + :ivar param_name: Parameter name. Required. + :vartype param_name: str + """ + + param_indicator: Union[str, "_models.ParamIndicator"] = rest_field( + name="paramIndicator", visibility=["read", "create", "update", "delete", "query"] + ) + """Indicates the purpose of the parameter. Required. Known values are: \"Expires\", \"KeyId\", and + \"Signature\".""" + param_name: str = rest_field(name="paramName", visibility=["read", "create", "update", "delete", "query"]) + """Parameter name. Required.""" + + @overload + def __init__( + self, + *, + param_indicator: Union[str, "_models.ParamIndicator"], + param_name: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class Usage(_Model): + """Describes resource usage. + + :ivar id: Resource identifier. + :vartype id: str + :ivar unit: An enum describing the unit of measurement. Required. "Count" + :vartype unit: str or ~azure.mgmt.cdn.models.UsageUnit + :ivar current_value: The current value of the usage. Required. + :vartype current_value: int + :ivar limit: The limit of usage. Required. + :vartype limit: int + :ivar name: The name of the type of usage. Required. + :vartype name: ~azure.mgmt.cdn.models.UsageName + """ + + id: Optional[str] = rest_field(visibility=["read"]) + """Resource identifier.""" + unit: Union[str, "_models.UsageUnit"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """An enum describing the unit of measurement. Required. \"Count\"""" + current_value: int = rest_field(name="currentValue", visibility=["read", "create", "update", "delete", "query"]) + """The current value of the usage. Required.""" + limit: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The limit of usage. Required.""" + name: "_models.UsageName" = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The name of the type of usage. Required.""" + + @overload + def __init__( + self, + *, + unit: Union[str, "_models.UsageUnit"], + current_value: int, + limit: int, + name: "_models.UsageName", + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class UsageName(_Model): + """The usage names. + + :ivar value: A string describing the resource name. + :vartype value: str + :ivar localized_value: A localized string describing the resource name. + :vartype localized_value: str + """ + + value: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """A string describing the resource name.""" + localized_value: Optional[str] = rest_field( + name="localizedValue", visibility=["read", "create", "update", "delete", "query"] + ) + """A localized string describing the resource name.""" + + @overload + def __init__( + self, + *, + value: Optional[str] = None, + localized_value: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class UserAssignedIdentity(_Model): + """User assigned identity properties. + + :ivar principal_id: The principal ID of the assigned identity. + :vartype principal_id: str + :ivar client_id: The client ID of the assigned identity. + :vartype client_id: str + """ + + principal_id: Optional[str] = rest_field(name="principalId", visibility=["read"]) + """The principal ID of the assigned identity.""" + client_id: Optional[str] = rest_field(name="clientId", visibility=["read"]) + """The client ID of the assigned identity.""" + + +class UserManagedHttpsParameters(CustomDomainHttpsParameters, discriminator="AzureKeyVault"): + """Defines the certificate source parameters using user's keyvault certificate for enabling SSL. + + :ivar protocol_type: Defines the TLS extension protocol that is used for secure delivery. + Required. Known values are: "ServerNameIndication" and "IPBased". + :vartype protocol_type: str or ~azure.mgmt.cdn.models.ProtocolType + :ivar minimum_tls_version: TLS protocol version that will be used for Https. Known values are: + "None", "TLS10", and "TLS12". + :vartype minimum_tls_version: str or ~azure.mgmt.cdn.models.MinimumTlsVersion + :ivar certificate_source_parameters: Defines the certificate source parameters using user's + keyvault certificate for enabling SSL. Required. + :vartype certificate_source_parameters: + ~azure.mgmt.cdn.models.KeyVaultCertificateSourceParameters + :ivar certificate_source: Defines the source of the SSL certificate. Required. AZURE_KEY_VAULT. + :vartype certificate_source: str or ~azure.mgmt.cdn.models.AZURE_KEY_VAULT + """ + + certificate_source_parameters: "_models.KeyVaultCertificateSourceParameters" = rest_field( + name="certificateSourceParameters", visibility=["read", "create", "update", "delete", "query"] + ) + """Defines the certificate source parameters using user's keyvault certificate for enabling SSL. + Required.""" + certificate_source: Literal[CertificateSource.AZURE_KEY_VAULT] = rest_discriminator(name="certificateSource", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Defines the source of the SSL certificate. Required. AZURE_KEY_VAULT.""" + + @overload + def __init__( + self, + *, + protocol_type: Union[str, "_models.ProtocolType"], + certificate_source_parameters: "_models.KeyVaultCertificateSourceParameters", + minimum_tls_version: Optional[Union[str, "_models.MinimumTlsVersion"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + self.certificate_source = CertificateSource.AZURE_KEY_VAULT # type: ignore + + +class ValidateCustomDomainInput(_Model): + """Input of the custom domain to be validated for DNS mapping. + + :ivar host_name: The host name of the custom domain. Must be a domain name. Required. + :vartype host_name: str + """ + + host_name: str = rest_field(name="hostName", visibility=["read", "create", "update", "delete", "query"]) + """The host name of the custom domain. Must be a domain name. Required.""" + + @overload + def __init__( + self, + *, + host_name: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ValidateCustomDomainOutput(_Model): + """Output of custom domain validation. + + :ivar custom_domain_validated: Indicates whether the custom domain is valid or not. + :vartype custom_domain_validated: bool + :ivar reason: The reason why the custom domain is not valid. + :vartype reason: str + :ivar message: Error message describing why the custom domain is not valid. + :vartype message: str + """ + + custom_domain_validated: Optional[bool] = rest_field(name="customDomainValidated", visibility=["read"]) + """Indicates whether the custom domain is valid or not.""" + reason: Optional[str] = rest_field(visibility=["read"]) + """The reason why the custom domain is not valid.""" + message: Optional[str] = rest_field(visibility=["read"]) + """Error message describing why the custom domain is not valid.""" + + +class ValidateProbeInput(_Model): + """Input of the validate probe API. + + :ivar probe_url: The probe URL to validate. Required. + :vartype probe_url: str + """ + + probe_url: str = rest_field(name="probeURL", visibility=["read", "create", "update", "delete", "query"]) + """The probe URL to validate. Required.""" + + @overload + def __init__( + self, + *, + probe_url: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ValidateProbeOutput(_Model): + """Output of the validate probe API. + + :ivar is_valid: Indicates whether the probe URL is accepted or not. + :vartype is_valid: bool + :ivar error_code: Specifies the error code when the probe url is not accepted. + :vartype error_code: str + :ivar message: The detailed error message describing why the probe URL is not accepted. + :vartype message: str + """ + + is_valid: Optional[bool] = rest_field(name="isValid", visibility=["read"]) + """Indicates whether the probe URL is accepted or not.""" + error_code: Optional[str] = rest_field(name="errorCode", visibility=["read"]) + """Specifies the error code when the probe url is not accepted.""" + message: Optional[str] = rest_field(visibility=["read"]) + """The detailed error message describing why the probe URL is not accepted.""" + + +class ValidateSecretInput(_Model): + """Input of the secret to be validated. + + :ivar secret_type: The secret type. Required. Known values are: "UrlSigningKey", + "CustomerCertificate", "ManagedCertificate", and "AzureFirstPartyManagedCertificate". + :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}. + Required. + :vartype secret_source: ~azure.mgmt.cdn.models.ResourceReference + :ivar secret_version: Secret version, if customer is using a specific version. + :vartype secret_version: str + """ + + secret_type: Union[str, "_models.SecretType"] = rest_field( + name="secretType", visibility=["read", "create", "update", "delete", "query"] + ) + """The secret type. Required. Known values are: \"UrlSigningKey\", \"CustomerCertificate\", + \"ManagedCertificate\", and \"AzureFirstPartyManagedCertificate\".""" + secret_source: "_models.ResourceReference" = rest_field( + name="secretSource", visibility=["read", "create", "update", "delete", "query"] + ) + """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}. + Required.""" + secret_version: Optional[str] = rest_field( + name="secretVersion", visibility=["read", "create", "update", "delete", "query"] + ) + """Secret version, if customer is using a specific version.""" + + @overload + def __init__( + self, + *, + secret_type: Union[str, "_models.SecretType"], + secret_source: "_models.ResourceReference", + secret_version: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ValidateSecretOutput(_Model): + """Output of the validated secret. + + :ivar status: The validation status. Known values are: "Valid", "Invalid", "AccessDenied", and + "CertificateExpired". + :vartype status: str or ~azure.mgmt.cdn.models.Status + :ivar message: Detailed error message. + :vartype message: str + """ + + status: Optional[Union[str, "_models.Status"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The validation status. Known values are: \"Valid\", \"Invalid\", \"AccessDenied\", and + \"CertificateExpired\".""" + message: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Detailed error message.""" + + @overload + def __init__( + self, + *, + status: Optional[Union[str, "_models.Status"]] = None, + message: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class WafMetricsResponse(_Model): + """Waf Metrics Response. + + :ivar date_time_begin: + :vartype date_time_begin: ~datetime.datetime + :ivar date_time_end: + :vartype date_time_end: ~datetime.datetime + :ivar granularity: Known values are: "PT5M", "PT1H", and "P1D". + :vartype granularity: str or ~azure.mgmt.cdn.models.WafMetricsGranularity + :ivar series: + :vartype series: list[~azure.mgmt.cdn.models.WafMetricsResponseSeriesItem] + """ + + date_time_begin: Optional[datetime.datetime] = rest_field( + name="dateTimeBegin", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) + date_time_end: Optional[datetime.datetime] = rest_field( + name="dateTimeEnd", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) + granularity: Optional[Union[str, "_models.WafMetricsGranularity"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Known values are: \"PT5M\", \"PT1H\", and \"P1D\".""" + series: Optional[list["_models.WafMetricsResponseSeriesItem"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + + @overload + def __init__( + self, + *, + date_time_begin: Optional[datetime.datetime] = None, + date_time_end: Optional[datetime.datetime] = None, + granularity: Optional[Union[str, "_models.WafMetricsGranularity"]] = None, + series: Optional[list["_models.WafMetricsResponseSeriesItem"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class WafMetricsResponseSeriesItem(_Model): + """WafMetricsResponseSeriesItem. + + :ivar metric: + :vartype metric: str + :ivar unit: "count" + :vartype unit: str or ~azure.mgmt.cdn.models.WafMetricsSeriesUnit + :ivar groups: + :vartype groups: list[~azure.mgmt.cdn.models.WafMetricsResponseSeriesPropertiesItemsItem] + :ivar data: + :vartype data: + list[~azure.mgmt.cdn.models.Components18OrqelSchemasWafmetricsresponsePropertiesSeriesItemsPropertiesDataItems] + """ + + metric: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + unit: Optional[Union[str, "_models.WafMetricsSeriesUnit"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """\"count\"""" + groups: Optional[list["_models.WafMetricsResponseSeriesPropertiesItemsItem"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + data: Optional[ + list["_models.Components18OrqelSchemasWafmetricsresponsePropertiesSeriesItemsPropertiesDataItems"] + ] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + + @overload + def __init__( + self, + *, + metric: Optional[str] = None, + unit: Optional[Union[str, "_models.WafMetricsSeriesUnit"]] = None, + groups: Optional[list["_models.WafMetricsResponseSeriesPropertiesItemsItem"]] = None, + data: Optional[ + list["_models.Components18OrqelSchemasWafmetricsresponsePropertiesSeriesItemsPropertiesDataItems"] + ] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class WafMetricsResponseSeriesPropertiesItemsItem(_Model): # pylint: disable=name-too-long + """WafMetricsResponseSeriesPropertiesItemsItem. + + :ivar name: + :vartype name: str + :ivar value: + :vartype value: str + """ + + name: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + value: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + + @overload + def __init__( + self, + *, + name: Optional[str] = None, + value: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class WafRankingsResponse(_Model): + """Waf Rankings Response. + + :ivar date_time_begin: + :vartype date_time_begin: ~datetime.datetime + :ivar date_time_end: + :vartype date_time_end: ~datetime.datetime + :ivar groups: + :vartype groups: list[str] + :ivar data: + :vartype data: list[~azure.mgmt.cdn.models.WafRankingsResponseDataItem] + """ + + date_time_begin: Optional[datetime.datetime] = rest_field( + name="dateTimeBegin", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) + date_time_end: Optional[datetime.datetime] = rest_field( + name="dateTimeEnd", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) + groups: Optional[list[str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + data: Optional[list["_models.WafRankingsResponseDataItem"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + + @overload + def __init__( + self, + *, + date_time_begin: Optional[datetime.datetime] = None, + date_time_end: Optional[datetime.datetime] = None, + groups: Optional[list[str]] = None, + data: Optional[list["_models.WafRankingsResponseDataItem"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class WafRankingsResponseDataItem(_Model): + """WafRankingsResponseDataItem. + + :ivar group_values: + :vartype group_values: list[str] + :ivar metrics: + :vartype metrics: + list[~azure.mgmt.cdn.models.ComponentsKpo1PjSchemasWafrankingsresponsePropertiesDataItemsPropertiesMetricsItems] + """ + + group_values: Optional[list[str]] = rest_field( + name="groupValues", visibility=["read", "create", "update", "delete", "query"] + ) + metrics: Optional[ + list["_models.ComponentsKpo1PjSchemasWafrankingsresponsePropertiesDataItemsPropertiesMetricsItems"] + ] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + + @overload + def __init__( + self, + *, + group_values: Optional[list[str]] = None, + metrics: Optional[ + list["_models.ComponentsKpo1PjSchemasWafrankingsresponsePropertiesDataItemsPropertiesMetricsItems"] + ] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/models/_models_py3.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/models/_models_py3.py deleted file mode 100644 index e5fd01153680..000000000000 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/models/_models_py3.py +++ /dev/null @@ -1,13637 +0,0 @@ -# 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. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -import datetime -from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union - -from .. import _serialization - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models - - -class ActivatedResourceReference(_serialization.Model): - """Reference to another resource along with its state. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar is_active: Whether the resource is active or inactive. - :vartype is_active: bool - """ - - _validation = { - "is_active": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "is_active": {"key": "isActive", "type": "bool"}, - } - - def __init__(self, *, id: Optional[str] = None, **kwargs: Any) -> None: # pylint: disable=redefined-builtin - """ - :keyword id: Resource ID. - :paramtype id: str - """ - super().__init__(**kwargs) - self.id = id - self.is_active = None - - -class Resource(_serialization.Model): - """The core properties of ARM resources. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar system_data: Read only system data. - :vartype system_data: ~azure.mgmt.cdn.models.SystemData - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.system_data = None - - -class ProxyResource(Resource): - """The resource model definition for a ARM proxy resource. It will have everything other than - required location and tags. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar system_data: Read only system data. - :vartype system_data: ~azure.mgmt.cdn.models.SystemData - """ - - -class AFDDomain(ProxyResource): # pylint: disable=too-many-instance-attributes - """Friendly domain name mapping to the endpoint hostname that the customer provides for branding - purposes, e.g. www.contoso.com. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar system_data: Read only system data. - :vartype system_data: ~azure.mgmt.cdn.models.SystemData - :ivar profile_name: The name of the profile which holds the domain. - :vartype profile_name: str - :ivar tls_settings: The configuration specifying how to enable HTTPS for the domain - using - AzureFrontDoor managed certificate or user's own certificate. If not specified, enabling ssl - uses AzureFrontDoor managed certificate by default. - :vartype tls_settings: ~azure.mgmt.cdn.models.AFDDomainHttpsParameters - :ivar azure_dns_zone: Resource reference to the Azure DNS zone. - :vartype azure_dns_zone: ~azure.mgmt.cdn.models.ResourceReference - :ivar pre_validated_custom_domain_resource_id: Resource reference to the Azure resource where - custom domain ownership was prevalidated. - :vartype pre_validated_custom_domain_resource_id: ~azure.mgmt.cdn.models.ResourceReference - :ivar provisioning_state: Provisioning status. Known values are: "Succeeded", "Failed", - "Updating", "Deleting", and "Creating". - :vartype provisioning_state: str or ~azure.mgmt.cdn.models.AfdProvisioningState - :ivar deployment_status: Known values are: "NotStarted", "InProgress", "Succeeded", and - "Failed". - :vartype deployment_status: str or ~azure.mgmt.cdn.models.DeploymentStatus - :ivar domain_validation_state: Provisioning substate shows the progress of custom HTTPS - enabling/disabling process step by step. DCV stands for DomainControlValidation. Known values - are: "Unknown", "Submitting", "Pending", "Rejected", "TimedOut", "PendingRevalidation", - "Approved", "RefreshingValidationToken", and "InternalError". - :vartype domain_validation_state: str or ~azure.mgmt.cdn.models.DomainValidationState - :ivar host_name: The host name of the domain. Must be a domain name. - :vartype host_name: str - :ivar extended_properties: Key-Value pair representing migration properties for domains. - :vartype extended_properties: dict[str, str] - :ivar validation_properties: Values the customer needs to validate domain ownership. - :vartype validation_properties: ~azure.mgmt.cdn.models.DomainValidationProperties - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - "profile_name": {"readonly": True}, - "provisioning_state": {"readonly": True}, - "deployment_status": {"readonly": True}, - "domain_validation_state": {"readonly": True}, - "validation_properties": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "profile_name": {"key": "properties.profileName", "type": "str"}, - "tls_settings": {"key": "properties.tlsSettings", "type": "AFDDomainHttpsParameters"}, - "azure_dns_zone": {"key": "properties.azureDnsZone", "type": "ResourceReference"}, - "pre_validated_custom_domain_resource_id": { - "key": "properties.preValidatedCustomDomainResourceId", - "type": "ResourceReference", - }, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "deployment_status": {"key": "properties.deploymentStatus", "type": "str"}, - "domain_validation_state": {"key": "properties.domainValidationState", "type": "str"}, - "host_name": {"key": "properties.hostName", "type": "str"}, - "extended_properties": {"key": "properties.extendedProperties", "type": "{str}"}, - "validation_properties": {"key": "properties.validationProperties", "type": "DomainValidationProperties"}, - } - - def __init__( - self, - *, - tls_settings: Optional["_models.AFDDomainHttpsParameters"] = None, - azure_dns_zone: Optional["_models.ResourceReference"] = None, - pre_validated_custom_domain_resource_id: Optional["_models.ResourceReference"] = None, - host_name: Optional[str] = None, - extended_properties: Optional[Dict[str, str]] = None, - **kwargs: Any - ) -> None: - """ - :keyword tls_settings: The configuration specifying how to enable HTTPS for the domain - using - AzureFrontDoor managed certificate or user's own certificate. If not specified, enabling ssl - uses AzureFrontDoor managed certificate by default. - :paramtype tls_settings: ~azure.mgmt.cdn.models.AFDDomainHttpsParameters - :keyword azure_dns_zone: Resource reference to the Azure DNS zone. - :paramtype azure_dns_zone: ~azure.mgmt.cdn.models.ResourceReference - :keyword pre_validated_custom_domain_resource_id: Resource reference to the Azure resource - where custom domain ownership was prevalidated. - :paramtype pre_validated_custom_domain_resource_id: ~azure.mgmt.cdn.models.ResourceReference - :keyword host_name: The host name of the domain. Must be a domain name. - :paramtype host_name: str - :keyword extended_properties: Key-Value pair representing migration properties for domains. - :paramtype extended_properties: dict[str, str] - """ - super().__init__(**kwargs) - self.profile_name = 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.host_name = host_name - self.extended_properties = extended_properties - self.validation_properties = None - - -class AFDDomainHttpsParameters(_serialization.Model): - """The JSON object that contains the properties to secure a domain. - - All required parameters must be populated in order to send to server. - - :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". - :vartype minimum_tls_version: str or ~azure.mgmt.cdn.models.AfdMinimumTlsVersion - :ivar secret: Resource reference to the secret. ie. subs/rg/profile/secret. - :vartype secret: ~azure.mgmt.cdn.models.ResourceReference - """ - - _validation = { - "certificate_type": {"required": True}, - } - - _attribute_map = { - "certificate_type": {"key": "certificateType", "type": "str"}, - "minimum_tls_version": {"key": "minimumTlsVersion", "type": "str"}, - "secret": {"key": "secret", "type": "ResourceReference"}, - } - - def __init__( - self, - *, - certificate_type: Union[str, "_models.AfdCertificateType"], - minimum_tls_version: Optional[Union[str, "_models.AfdMinimumTlsVersion"]] = None, - secret: Optional["_models.ResourceReference"] = None, - **kwargs: Any - ) -> None: - """ - :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". - :paramtype minimum_tls_version: str or ~azure.mgmt.cdn.models.AfdMinimumTlsVersion - :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.minimum_tls_version = minimum_tls_version - self.secret = secret - - -class AFDDomainListResult(_serialization.Model): - """Result of the request to list domains. It contains a list of domain objects and a URL link to - get the next set of results. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: List of AzureFrontDoor domains within a profile. - :vartype value: list[~azure.mgmt.cdn.models.AFDDomain] - :ivar next_link: URL to get the next set of domain objects if there are any. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[AFDDomain]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword next_link: URL to get the next set of domain objects if there are any. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = None - self.next_link = next_link - - -class AFDStateProperties(_serialization.Model): - """The tracking states for afd resources. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar provisioning_state: Provisioning status. Known values are: "Succeeded", "Failed", - "Updating", "Deleting", and "Creating". - :vartype provisioning_state: str or ~azure.mgmt.cdn.models.AfdProvisioningState - :ivar deployment_status: Known values are: "NotStarted", "InProgress", "Succeeded", and - "Failed". - :vartype deployment_status: str or ~azure.mgmt.cdn.models.DeploymentStatus - """ - - _validation = { - "provisioning_state": {"readonly": True}, - "deployment_status": {"readonly": True}, - } - - _attribute_map = { - "provisioning_state": {"key": "provisioningState", "type": "str"}, - "deployment_status": {"key": "deploymentStatus", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.provisioning_state = None - self.deployment_status = None - - -class AFDDomainUpdatePropertiesParameters(_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. - - :ivar profile_name: The name of the profile which holds the domain. - :vartype profile_name: str - :ivar tls_settings: The configuration specifying how to enable HTTPS for the domain - using - AzureFrontDoor managed certificate or user's own certificate. If not specified, enabling ssl - uses AzureFrontDoor managed certificate by default. - :vartype tls_settings: ~azure.mgmt.cdn.models.AFDDomainHttpsParameters - :ivar azure_dns_zone: Resource reference to the Azure DNS zone. - :vartype azure_dns_zone: ~azure.mgmt.cdn.models.ResourceReference - :ivar pre_validated_custom_domain_resource_id: Resource reference to the Azure resource where - custom domain ownership was prevalidated. - :vartype pre_validated_custom_domain_resource_id: ~azure.mgmt.cdn.models.ResourceReference - """ - - _validation = { - "profile_name": {"readonly": True}, - } - - _attribute_map = { - "profile_name": {"key": "profileName", "type": "str"}, - "tls_settings": {"key": "tlsSettings", "type": "AFDDomainHttpsParameters"}, - "azure_dns_zone": {"key": "azureDnsZone", "type": "ResourceReference"}, - "pre_validated_custom_domain_resource_id": { - "key": "preValidatedCustomDomainResourceId", - "type": "ResourceReference", - }, - } - - def __init__( - self, - *, - tls_settings: Optional["_models.AFDDomainHttpsParameters"] = None, - azure_dns_zone: Optional["_models.ResourceReference"] = None, - pre_validated_custom_domain_resource_id: Optional["_models.ResourceReference"] = None, - **kwargs: Any - ) -> None: - """ - :keyword tls_settings: The configuration specifying how to enable HTTPS for the domain - using - AzureFrontDoor managed certificate or user's own certificate. If not specified, enabling ssl - uses AzureFrontDoor managed certificate by default. - :paramtype tls_settings: ~azure.mgmt.cdn.models.AFDDomainHttpsParameters - :keyword azure_dns_zone: Resource reference to the Azure DNS zone. - :paramtype azure_dns_zone: ~azure.mgmt.cdn.models.ResourceReference - :keyword pre_validated_custom_domain_resource_id: Resource reference to the Azure resource - where custom domain ownership was prevalidated. - :paramtype pre_validated_custom_domain_resource_id: ~azure.mgmt.cdn.models.ResourceReference - """ - super().__init__(**kwargs) - self.profile_name = 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 - - -class AFDDomainProperties(AFDDomainUpdatePropertiesParameters, AFDStateProperties): - """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. - - All required parameters must be populated in order to send to server. - - :ivar provisioning_state: Provisioning status. Known values are: "Succeeded", "Failed", - "Updating", "Deleting", and "Creating". - :vartype provisioning_state: str or ~azure.mgmt.cdn.models.AfdProvisioningState - :ivar deployment_status: Known values are: "NotStarted", "InProgress", "Succeeded", and - "Failed". - :vartype deployment_status: str or ~azure.mgmt.cdn.models.DeploymentStatus - :ivar profile_name: The name of the profile which holds the domain. - :vartype profile_name: str - :ivar tls_settings: The configuration specifying how to enable HTTPS for the domain - using - AzureFrontDoor managed certificate or user's own certificate. If not specified, enabling ssl - uses AzureFrontDoor managed certificate by default. - :vartype tls_settings: ~azure.mgmt.cdn.models.AFDDomainHttpsParameters - :ivar azure_dns_zone: Resource reference to the Azure DNS zone. - :vartype azure_dns_zone: ~azure.mgmt.cdn.models.ResourceReference - :ivar pre_validated_custom_domain_resource_id: Resource reference to the Azure resource where - custom domain ownership was prevalidated. - :vartype pre_validated_custom_domain_resource_id: ~azure.mgmt.cdn.models.ResourceReference - :ivar domain_validation_state: Provisioning substate shows the progress of custom HTTPS - enabling/disabling process step by step. DCV stands for DomainControlValidation. Known values - are: "Unknown", "Submitting", "Pending", "Rejected", "TimedOut", "PendingRevalidation", - "Approved", "RefreshingValidationToken", and "InternalError". - :vartype domain_validation_state: str or ~azure.mgmt.cdn.models.DomainValidationState - :ivar host_name: The host name of the domain. Must be a domain name. Required. - :vartype host_name: str - :ivar extended_properties: Key-Value pair representing migration properties for domains. - :vartype extended_properties: dict[str, str] - :ivar validation_properties: Values the customer needs to validate domain ownership. - :vartype validation_properties: ~azure.mgmt.cdn.models.DomainValidationProperties - """ - - _validation = { - "provisioning_state": {"readonly": True}, - "deployment_status": {"readonly": True}, - "profile_name": {"readonly": True}, - "domain_validation_state": {"readonly": True}, - "host_name": {"required": True}, - "validation_properties": {"readonly": True}, - } - - _attribute_map = { - "provisioning_state": {"key": "provisioningState", "type": "str"}, - "deployment_status": {"key": "deploymentStatus", "type": "str"}, - "profile_name": {"key": "profileName", "type": "str"}, - "tls_settings": {"key": "tlsSettings", "type": "AFDDomainHttpsParameters"}, - "azure_dns_zone": {"key": "azureDnsZone", "type": "ResourceReference"}, - "pre_validated_custom_domain_resource_id": { - "key": "preValidatedCustomDomainResourceId", - "type": "ResourceReference", - }, - "domain_validation_state": {"key": "domainValidationState", "type": "str"}, - "host_name": {"key": "hostName", "type": "str"}, - "extended_properties": {"key": "extendedProperties", "type": "{str}"}, - "validation_properties": {"key": "validationProperties", "type": "DomainValidationProperties"}, - } - - def __init__( - self, - *, - host_name: str, - tls_settings: Optional["_models.AFDDomainHttpsParameters"] = None, - azure_dns_zone: Optional["_models.ResourceReference"] = None, - pre_validated_custom_domain_resource_id: Optional["_models.ResourceReference"] = None, - extended_properties: Optional[Dict[str, str]] = None, - **kwargs: Any - ) -> None: - """ - :keyword tls_settings: The configuration specifying how to enable HTTPS for the domain - using - AzureFrontDoor managed certificate or user's own certificate. If not specified, enabling ssl - uses AzureFrontDoor managed certificate by default. - :paramtype tls_settings: ~azure.mgmt.cdn.models.AFDDomainHttpsParameters - :keyword azure_dns_zone: Resource reference to the Azure DNS zone. - :paramtype azure_dns_zone: ~azure.mgmt.cdn.models.ResourceReference - :keyword pre_validated_custom_domain_resource_id: Resource reference to the Azure resource - where custom domain ownership was prevalidated. - :paramtype pre_validated_custom_domain_resource_id: ~azure.mgmt.cdn.models.ResourceReference - :keyword host_name: The host name of the domain. Must be a domain name. Required. - :paramtype host_name: str - :keyword extended_properties: Key-Value pair representing migration properties for domains. - :paramtype extended_properties: dict[str, str] - """ - super().__init__( - tls_settings=tls_settings, - azure_dns_zone=azure_dns_zone, - 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.host_name = host_name - self.extended_properties = extended_properties - self.validation_properties = None - self.profile_name = 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 - - -class AFDDomainUpdateParameters(_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. - - :ivar profile_name: The name of the profile which holds the domain. - :vartype profile_name: str - :ivar tls_settings: The configuration specifying how to enable HTTPS for the domain - using - AzureFrontDoor managed certificate or user's own certificate. If not specified, enabling ssl - uses AzureFrontDoor managed certificate by default. - :vartype tls_settings: ~azure.mgmt.cdn.models.AFDDomainHttpsParameters - :ivar azure_dns_zone: Resource reference to the Azure DNS zone. - :vartype azure_dns_zone: ~azure.mgmt.cdn.models.ResourceReference - :ivar pre_validated_custom_domain_resource_id: Resource reference to the Azure resource where - custom domain ownership was prevalidated. - :vartype pre_validated_custom_domain_resource_id: ~azure.mgmt.cdn.models.ResourceReference - """ - - _validation = { - "profile_name": {"readonly": True}, - } - - _attribute_map = { - "profile_name": {"key": "properties.profileName", "type": "str"}, - "tls_settings": {"key": "properties.tlsSettings", "type": "AFDDomainHttpsParameters"}, - "azure_dns_zone": {"key": "properties.azureDnsZone", "type": "ResourceReference"}, - "pre_validated_custom_domain_resource_id": { - "key": "properties.preValidatedCustomDomainResourceId", - "type": "ResourceReference", - }, - } - - def __init__( - self, - *, - tls_settings: Optional["_models.AFDDomainHttpsParameters"] = None, - azure_dns_zone: Optional["_models.ResourceReference"] = None, - pre_validated_custom_domain_resource_id: Optional["_models.ResourceReference"] = None, - **kwargs: Any - ) -> None: - """ - :keyword tls_settings: The configuration specifying how to enable HTTPS for the domain - using - AzureFrontDoor managed certificate or user's own certificate. If not specified, enabling ssl - uses AzureFrontDoor managed certificate by default. - :paramtype tls_settings: ~azure.mgmt.cdn.models.AFDDomainHttpsParameters - :keyword azure_dns_zone: Resource reference to the Azure DNS zone. - :paramtype azure_dns_zone: ~azure.mgmt.cdn.models.ResourceReference - :keyword pre_validated_custom_domain_resource_id: Resource reference to the Azure resource - where custom domain ownership was prevalidated. - :paramtype pre_validated_custom_domain_resource_id: ~azure.mgmt.cdn.models.ResourceReference - """ - super().__init__(**kwargs) - self.profile_name = 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 - - -class TrackedResource(Resource): - """The resource model definition for a ARM tracked top level resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to server. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar system_data: Read only system data. - :vartype system_data: ~azure.mgmt.cdn.models.SystemData - :ivar location: Resource location. Required. - :vartype location: str - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - "location": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - } - - def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - """ - super().__init__(**kwargs) - self.location = location - self.tags = tags - - -class AFDEndpoint(TrackedResource): # pylint: disable=too-many-instance-attributes - """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. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to server. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar system_data: Read only system data. - :vartype system_data: ~azure.mgmt.cdn.models.SystemData - :ivar location: Resource location. Required. - :vartype location: str - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar profile_name: The name of the profile which holds the endpoint. - :vartype profile_name: str - :ivar enabled_state: Whether to enable use of this rule. Permitted values are 'Enabled' or - 'Disabled'. Known values are: "Enabled" and "Disabled". - :vartype enabled_state: str or ~azure.mgmt.cdn.models.EnabledState - :ivar provisioning_state: Provisioning status. Known values are: "Succeeded", "Failed", - "Updating", "Deleting", and "Creating". - :vartype provisioning_state: str or ~azure.mgmt.cdn.models.AfdProvisioningState - :ivar deployment_status: Known values are: "NotStarted", "InProgress", "Succeeded", and - "Failed". - :vartype deployment_status: str or ~azure.mgmt.cdn.models.DeploymentStatus - :ivar host_name: The host name of the endpoint structured as {endpointName}.{DNSZone}, e.g. - contoso.azureedge.net. - :vartype host_name: str - :ivar auto_generated_domain_name_label_scope: Indicates the endpoint name reuse scope. The - default value is TenantReuse. Known values are: "TenantReuse", "SubscriptionReuse", - "ResourceGroupReuse", and "NoReuse". - :vartype auto_generated_domain_name_label_scope: str or - ~azure.mgmt.cdn.models.AutoGeneratedDomainNameLabelScope - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - "location": {"required": True}, - "profile_name": {"readonly": True}, - "provisioning_state": {"readonly": True}, - "deployment_status": {"readonly": True}, - "host_name": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "profile_name": {"key": "properties.profileName", "type": "str"}, - "enabled_state": {"key": "properties.enabledState", "type": "str"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "deployment_status": {"key": "properties.deploymentStatus", "type": "str"}, - "host_name": {"key": "properties.hostName", "type": "str"}, - "auto_generated_domain_name_label_scope": { - "key": "properties.autoGeneratedDomainNameLabelScope", - "type": "str", - }, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - enabled_state: Optional[Union[str, "_models.EnabledState"]] = None, - auto_generated_domain_name_label_scope: Optional[ - Union[str, "_models.AutoGeneratedDomainNameLabelScope"] - ] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword enabled_state: Whether to enable use of this rule. Permitted values are 'Enabled' or - 'Disabled'. Known values are: "Enabled" and "Disabled". - :paramtype enabled_state: str or ~azure.mgmt.cdn.models.EnabledState - :keyword auto_generated_domain_name_label_scope: Indicates the endpoint name reuse scope. The - default value is TenantReuse. Known values are: "TenantReuse", "SubscriptionReuse", - "ResourceGroupReuse", and "NoReuse". - :paramtype auto_generated_domain_name_label_scope: str or - ~azure.mgmt.cdn.models.AutoGeneratedDomainNameLabelScope - """ - super().__init__(location=location, tags=tags, **kwargs) - self.profile_name = None - self.enabled_state = enabled_state - self.provisioning_state = None - self.deployment_status = None - self.host_name = None - self.auto_generated_domain_name_label_scope = auto_generated_domain_name_label_scope - - -class AFDEndpointListResult(_serialization.Model): - """Result of the request to list endpoints. It contains a list of endpoint objects and a URL link - to get the next set of results. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: List of AzureFrontDoor endpoints within a profile. - :vartype value: list[~azure.mgmt.cdn.models.AFDEndpoint] - :ivar next_link: URL to get the next set of endpoint objects if there is any. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[AFDEndpoint]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword next_link: URL to get the next set of endpoint objects if there is any. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = None - self.next_link = next_link - - -class AFDEndpointPropertiesUpdateParameters(_serialization.Model): - """The JSON object containing endpoint update parameters. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar profile_name: The name of the profile which holds the endpoint. - :vartype profile_name: str - :ivar enabled_state: Whether to enable use of this rule. Permitted values are 'Enabled' or - 'Disabled'. Known values are: "Enabled" and "Disabled". - :vartype enabled_state: str or ~azure.mgmt.cdn.models.EnabledState - """ - - _validation = { - "profile_name": {"readonly": True}, - } - - _attribute_map = { - "profile_name": {"key": "profileName", "type": "str"}, - "enabled_state": {"key": "enabledState", "type": "str"}, - } - - def __init__(self, *, enabled_state: Optional[Union[str, "_models.EnabledState"]] = None, **kwargs: Any) -> None: - """ - :keyword enabled_state: Whether to enable use of this rule. Permitted values are 'Enabled' or - 'Disabled'. Known values are: "Enabled" and "Disabled". - :paramtype enabled_state: str or ~azure.mgmt.cdn.models.EnabledState - """ - super().__init__(**kwargs) - self.profile_name = None - self.enabled_state = enabled_state - - -class AFDEndpointProperties(AFDEndpointPropertiesUpdateParameters, AFDStateProperties): - """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. - - :ivar provisioning_state: Provisioning status. Known values are: "Succeeded", "Failed", - "Updating", "Deleting", and "Creating". - :vartype provisioning_state: str or ~azure.mgmt.cdn.models.AfdProvisioningState - :ivar deployment_status: Known values are: "NotStarted", "InProgress", "Succeeded", and - "Failed". - :vartype deployment_status: str or ~azure.mgmt.cdn.models.DeploymentStatus - :ivar profile_name: The name of the profile which holds the endpoint. - :vartype profile_name: str - :ivar enabled_state: Whether to enable use of this rule. Permitted values are 'Enabled' or - 'Disabled'. Known values are: "Enabled" and "Disabled". - :vartype enabled_state: str or ~azure.mgmt.cdn.models.EnabledState - :ivar host_name: The host name of the endpoint structured as {endpointName}.{DNSZone}, e.g. - contoso.azureedge.net. - :vartype host_name: str - :ivar auto_generated_domain_name_label_scope: Indicates the endpoint name reuse scope. The - default value is TenantReuse. Known values are: "TenantReuse", "SubscriptionReuse", - "ResourceGroupReuse", and "NoReuse". - :vartype auto_generated_domain_name_label_scope: str or - ~azure.mgmt.cdn.models.AutoGeneratedDomainNameLabelScope - """ - - _validation = { - "provisioning_state": {"readonly": True}, - "deployment_status": {"readonly": True}, - "profile_name": {"readonly": True}, - "host_name": {"readonly": True}, - } - - _attribute_map = { - "provisioning_state": {"key": "provisioningState", "type": "str"}, - "deployment_status": {"key": "deploymentStatus", "type": "str"}, - "profile_name": {"key": "profileName", "type": "str"}, - "enabled_state": {"key": "enabledState", "type": "str"}, - "host_name": {"key": "hostName", "type": "str"}, - "auto_generated_domain_name_label_scope": {"key": "autoGeneratedDomainNameLabelScope", "type": "str"}, - } - - def __init__( - self, - *, - enabled_state: Optional[Union[str, "_models.EnabledState"]] = None, - auto_generated_domain_name_label_scope: Optional[ - Union[str, "_models.AutoGeneratedDomainNameLabelScope"] - ] = None, - **kwargs: Any - ) -> None: - """ - :keyword enabled_state: Whether to enable use of this rule. Permitted values are 'Enabled' or - 'Disabled'. Known values are: "Enabled" and "Disabled". - :paramtype enabled_state: str or ~azure.mgmt.cdn.models.EnabledState - :keyword auto_generated_domain_name_label_scope: Indicates the endpoint name reuse scope. The - default value is TenantReuse. Known values are: "TenantReuse", "SubscriptionReuse", - "ResourceGroupReuse", and "NoReuse". - :paramtype auto_generated_domain_name_label_scope: str or - ~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.auto_generated_domain_name_label_scope = auto_generated_domain_name_label_scope - self.profile_name = None - self.enabled_state = enabled_state - - -class AFDEndpointUpdateParameters(_serialization.Model): - """Properties required to create or update an endpoint. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar tags: Endpoint tags. - :vartype tags: dict[str, str] - :ivar profile_name: The name of the profile which holds the endpoint. - :vartype profile_name: str - :ivar enabled_state: Whether to enable use of this rule. Permitted values are 'Enabled' or - 'Disabled'. Known values are: "Enabled" and "Disabled". - :vartype enabled_state: str or ~azure.mgmt.cdn.models.EnabledState - """ - - _validation = { - "profile_name": {"readonly": True}, - } - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "profile_name": {"key": "properties.profileName", "type": "str"}, - "enabled_state": {"key": "properties.enabledState", "type": "str"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - enabled_state: Optional[Union[str, "_models.EnabledState"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Endpoint tags. - :paramtype tags: dict[str, str] - :keyword enabled_state: Whether to enable use of this rule. Permitted values are 'Enabled' or - 'Disabled'. Known values are: "Enabled" and "Disabled". - :paramtype enabled_state: str or ~azure.mgmt.cdn.models.EnabledState - """ - super().__init__(**kwargs) - self.tags = tags - self.profile_name = None - self.enabled_state = enabled_state - - -class AfdErrorResponse(_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 - """ - - _attribute_map = { - "error": {"key": "error", "type": "ErrorDetail"}, - } - - def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs: Any) -> None: - """ - :keyword error: The error object. - :paramtype error: ~azure.mgmt.cdn.models.ErrorDetail - """ - super().__init__(**kwargs) - self.error = error - - -class AFDOrigin(ProxyResource): # pylint: disable=too-many-instance-attributes - """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. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar system_data: Read only system data. - :vartype system_data: ~azure.mgmt.cdn.models.SystemData - :ivar origin_group_name: The name of the origin group which contains this origin. - :vartype origin_group_name: str - :ivar azure_origin: Resource reference to the Azure origin resource. - :vartype azure_origin: ~azure.mgmt.cdn.models.ResourceReference - :ivar host_name: The address of the origin. Domain names, IPv4 addresses, and IPv6 addresses - are supported.This should be unique across all origins in an endpoint. - :vartype host_name: str - :ivar http_port: The value of the HTTP port. Must be between 1 and 65535. - :vartype http_port: int - :ivar https_port: The value of the HTTPS port. Must be between 1 and 65535. - :vartype https_port: int - :ivar origin_host_header: The host header value sent to the origin with each request. If you - leave this blank, the request hostname determines this value. Azure Front Door origins, such as - Web Apps, Blob Storage, and Cloud Services require this host header value to match the origin - hostname by default. This overrides the host header defined at Endpoint. - :vartype origin_host_header: str - :ivar priority: Priority of origin in given origin group for load balancing. Higher priorities - will not be used for load balancing if any lower priority origin is healthy.Must be between 1 - and 5. - :vartype priority: int - :ivar weight: Weight of the origin in given origin group for load balancing. Must be between 1 - and 1000. - :vartype weight: int - :ivar shared_private_link_resource: The properties of the private link resource for private - origin. - :vartype shared_private_link_resource: - ~azure.mgmt.cdn.models.SharedPrivateLinkResourceProperties - :ivar enabled_state: Whether to enable health probes to be made against backends defined under - backendPools. Health probes can only be disabled if there is a single enabled backend in single - enabled backend pool. Known values are: "Enabled" and "Disabled". - :vartype enabled_state: str or ~azure.mgmt.cdn.models.EnabledState - :ivar enforce_certificate_name_check: Whether to enable certificate name check at origin level. - :vartype enforce_certificate_name_check: bool - :ivar provisioning_state: Provisioning status. Known values are: "Succeeded", "Failed", - "Updating", "Deleting", and "Creating". - :vartype provisioning_state: str or ~azure.mgmt.cdn.models.AfdProvisioningState - :ivar deployment_status: Known values are: "NotStarted", "InProgress", "Succeeded", and - "Failed". - :vartype deployment_status: str or ~azure.mgmt.cdn.models.DeploymentStatus - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - "origin_group_name": {"readonly": True}, - "http_port": {"maximum": 65535, "minimum": 1}, - "https_port": {"maximum": 65535, "minimum": 1}, - "priority": {"maximum": 5, "minimum": 1}, - "weight": {"maximum": 1000, "minimum": 1}, - "provisioning_state": {"readonly": True}, - "deployment_status": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "origin_group_name": {"key": "properties.originGroupName", "type": "str"}, - "azure_origin": {"key": "properties.azureOrigin", "type": "ResourceReference"}, - "host_name": {"key": "properties.hostName", "type": "str"}, - "http_port": {"key": "properties.httpPort", "type": "int"}, - "https_port": {"key": "properties.httpsPort", "type": "int"}, - "origin_host_header": {"key": "properties.originHostHeader", "type": "str"}, - "priority": {"key": "properties.priority", "type": "int"}, - "weight": {"key": "properties.weight", "type": "int"}, - "shared_private_link_resource": { - "key": "properties.sharedPrivateLinkResource", - "type": "SharedPrivateLinkResourceProperties", - }, - "enabled_state": {"key": "properties.enabledState", "type": "str"}, - "enforce_certificate_name_check": {"key": "properties.enforceCertificateNameCheck", "type": "bool"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "deployment_status": {"key": "properties.deploymentStatus", "type": "str"}, - } - - def __init__( - self, - *, - azure_origin: Optional["_models.ResourceReference"] = None, - host_name: Optional[str] = None, - http_port: int = 80, - https_port: int = 443, - origin_host_header: Optional[str] = None, - priority: Optional[int] = None, - weight: Optional[int] = None, - shared_private_link_resource: Optional["_models.SharedPrivateLinkResourceProperties"] = None, - enabled_state: Optional[Union[str, "_models.EnabledState"]] = None, - enforce_certificate_name_check: bool = True, - **kwargs: Any - ) -> None: - """ - :keyword azure_origin: Resource reference to the Azure origin resource. - :paramtype azure_origin: ~azure.mgmt.cdn.models.ResourceReference - :keyword host_name: The address of the origin. Domain names, IPv4 addresses, and IPv6 addresses - are supported.This should be unique across all origins in an endpoint. - :paramtype host_name: str - :keyword http_port: The value of the HTTP port. Must be between 1 and 65535. - :paramtype http_port: int - :keyword https_port: The value of the HTTPS port. Must be between 1 and 65535. - :paramtype https_port: int - :keyword origin_host_header: The host header value sent to the origin with each request. If you - leave this blank, the request hostname determines this value. Azure Front Door origins, such as - Web Apps, Blob Storage, and Cloud Services require this host header value to match the origin - hostname by default. This overrides the host header defined at Endpoint. - :paramtype origin_host_header: str - :keyword priority: Priority of origin in given origin group for load balancing. Higher - priorities will not be used for load balancing if any lower priority origin is healthy.Must be - between 1 and 5. - :paramtype priority: int - :keyword weight: Weight of the origin in given origin group for load balancing. Must be between - 1 and 1000. - :paramtype weight: int - :keyword shared_private_link_resource: The properties of the private link resource for private - origin. - :paramtype shared_private_link_resource: - ~azure.mgmt.cdn.models.SharedPrivateLinkResourceProperties - :keyword enabled_state: Whether to enable health probes to be made against backends defined - under backendPools. Health probes can only be disabled if there is a single enabled backend in - single enabled backend pool. Known values are: "Enabled" and "Disabled". - :paramtype enabled_state: str or ~azure.mgmt.cdn.models.EnabledState - :keyword enforce_certificate_name_check: Whether to enable certificate name check at origin - level. - :paramtype enforce_certificate_name_check: bool - """ - super().__init__(**kwargs) - self.origin_group_name = None - self.azure_origin = azure_origin - self.host_name = host_name - self.http_port = http_port - self.https_port = https_port - self.origin_host_header = origin_host_header - self.priority = priority - self.weight = weight - 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 - - -class AFDOriginGroup(ProxyResource): # pylint: disable=too-many-instance-attributes - """AFDOrigin group comprising of origins is used for load balancing to origins when the content - cannot be served from Azure Front Door. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar system_data: Read only system data. - :vartype system_data: ~azure.mgmt.cdn.models.SystemData - :ivar profile_name: The name of the profile which holds the origin group. - :vartype profile_name: str - :ivar load_balancing_settings: Load balancing settings for a backend pool. - :vartype load_balancing_settings: ~azure.mgmt.cdn.models.LoadBalancingSettingsParameters - :ivar health_probe_settings: Health probe settings to the origin that is used to determine the - health of the origin. - :vartype health_probe_settings: ~azure.mgmt.cdn.models.HealthProbeParameters - :ivar traffic_restoration_time_to_healed_or_new_endpoints_in_minutes: Time in minutes to shift - the traffic to the endpoint gradually when an unhealthy endpoint comes healthy or a new - endpoint is added. Default is 10 mins. This property is currently not supported. - :vartype traffic_restoration_time_to_healed_or_new_endpoints_in_minutes: int - :ivar session_affinity_state: Whether to allow session affinity on this host. Valid options are - 'Enabled' or 'Disabled'. Known values are: "Enabled" and "Disabled". - :vartype session_affinity_state: str or ~azure.mgmt.cdn.models.EnabledState - :ivar provisioning_state: Provisioning status. Known values are: "Succeeded", "Failed", - "Updating", "Deleting", and "Creating". - :vartype provisioning_state: str or ~azure.mgmt.cdn.models.AfdProvisioningState - :ivar deployment_status: Known values are: "NotStarted", "InProgress", "Succeeded", and - "Failed". - :vartype deployment_status: str or ~azure.mgmt.cdn.models.DeploymentStatus - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - "profile_name": {"readonly": True}, - "traffic_restoration_time_to_healed_or_new_endpoints_in_minutes": {"maximum": 50, "minimum": 0}, - "provisioning_state": {"readonly": True}, - "deployment_status": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "profile_name": {"key": "properties.profileName", "type": "str"}, - "load_balancing_settings": { - "key": "properties.loadBalancingSettings", - "type": "LoadBalancingSettingsParameters", - }, - "health_probe_settings": {"key": "properties.healthProbeSettings", "type": "HealthProbeParameters"}, - "traffic_restoration_time_to_healed_or_new_endpoints_in_minutes": { - "key": "properties.trafficRestorationTimeToHealedOrNewEndpointsInMinutes", - "type": "int", - }, - "session_affinity_state": {"key": "properties.sessionAffinityState", "type": "str"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "deployment_status": {"key": "properties.deploymentStatus", "type": "str"}, - } - - def __init__( - self, - *, - load_balancing_settings: Optional["_models.LoadBalancingSettingsParameters"] = None, - health_probe_settings: Optional["_models.HealthProbeParameters"] = None, - traffic_restoration_time_to_healed_or_new_endpoints_in_minutes: Optional[int] = None, - session_affinity_state: Optional[Union[str, "_models.EnabledState"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword load_balancing_settings: Load balancing settings for a backend pool. - :paramtype load_balancing_settings: ~azure.mgmt.cdn.models.LoadBalancingSettingsParameters - :keyword health_probe_settings: Health probe settings to the origin that is used to determine - the health of the origin. - :paramtype health_probe_settings: ~azure.mgmt.cdn.models.HealthProbeParameters - :keyword traffic_restoration_time_to_healed_or_new_endpoints_in_minutes: Time in minutes to - shift the traffic to the endpoint gradually when an unhealthy endpoint comes healthy or a new - endpoint is added. Default is 10 mins. This property is currently not supported. - :paramtype traffic_restoration_time_to_healed_or_new_endpoints_in_minutes: int - :keyword session_affinity_state: Whether to allow session affinity on this host. Valid options - are 'Enabled' or 'Disabled'. Known values are: "Enabled" and "Disabled". - :paramtype session_affinity_state: str or ~azure.mgmt.cdn.models.EnabledState - """ - super().__init__(**kwargs) - self.profile_name = 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 - - -class AFDOriginGroupListResult(_serialization.Model): - """Result of the request to list origin groups. It contains a list of origin groups objects and a - URL link to get the next set of results. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: List of Azure Front Door origin groups within an Azure Front Door endpoint. - :vartype value: list[~azure.mgmt.cdn.models.AFDOriginGroup] - :ivar next_link: URL to get the next set of origin objects if there are any. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[AFDOriginGroup]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword next_link: URL to get the next set of origin objects if there are any. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = None - self.next_link = next_link - - -class AFDOriginGroupUpdatePropertiesParameters(_serialization.Model): - """The JSON object that contains the properties of the origin group. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar profile_name: The name of the profile which holds the origin group. - :vartype profile_name: str - :ivar load_balancing_settings: Load balancing settings for a backend pool. - :vartype load_balancing_settings: ~azure.mgmt.cdn.models.LoadBalancingSettingsParameters - :ivar health_probe_settings: Health probe settings to the origin that is used to determine the - health of the origin. - :vartype health_probe_settings: ~azure.mgmt.cdn.models.HealthProbeParameters - :ivar traffic_restoration_time_to_healed_or_new_endpoints_in_minutes: Time in minutes to shift - the traffic to the endpoint gradually when an unhealthy endpoint comes healthy or a new - endpoint is added. Default is 10 mins. This property is currently not supported. - :vartype traffic_restoration_time_to_healed_or_new_endpoints_in_minutes: int - :ivar session_affinity_state: Whether to allow session affinity on this host. Valid options are - 'Enabled' or 'Disabled'. Known values are: "Enabled" and "Disabled". - :vartype session_affinity_state: str or ~azure.mgmt.cdn.models.EnabledState - """ - - _validation = { - "profile_name": {"readonly": True}, - "traffic_restoration_time_to_healed_or_new_endpoints_in_minutes": {"maximum": 50, "minimum": 0}, - } - - _attribute_map = { - "profile_name": {"key": "profileName", "type": "str"}, - "load_balancing_settings": {"key": "loadBalancingSettings", "type": "LoadBalancingSettingsParameters"}, - "health_probe_settings": {"key": "healthProbeSettings", "type": "HealthProbeParameters"}, - "traffic_restoration_time_to_healed_or_new_endpoints_in_minutes": { - "key": "trafficRestorationTimeToHealedOrNewEndpointsInMinutes", - "type": "int", - }, - "session_affinity_state": {"key": "sessionAffinityState", "type": "str"}, - } - - def __init__( - self, - *, - load_balancing_settings: Optional["_models.LoadBalancingSettingsParameters"] = None, - health_probe_settings: Optional["_models.HealthProbeParameters"] = None, - traffic_restoration_time_to_healed_or_new_endpoints_in_minutes: Optional[int] = None, - session_affinity_state: Optional[Union[str, "_models.EnabledState"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword load_balancing_settings: Load balancing settings for a backend pool. - :paramtype load_balancing_settings: ~azure.mgmt.cdn.models.LoadBalancingSettingsParameters - :keyword health_probe_settings: Health probe settings to the origin that is used to determine - the health of the origin. - :paramtype health_probe_settings: ~azure.mgmt.cdn.models.HealthProbeParameters - :keyword traffic_restoration_time_to_healed_or_new_endpoints_in_minutes: Time in minutes to - shift the traffic to the endpoint gradually when an unhealthy endpoint comes healthy or a new - endpoint is added. Default is 10 mins. This property is currently not supported. - :paramtype traffic_restoration_time_to_healed_or_new_endpoints_in_minutes: int - :keyword session_affinity_state: Whether to allow session affinity on this host. Valid options - are 'Enabled' or 'Disabled'. Known values are: "Enabled" and "Disabled". - :paramtype session_affinity_state: str or ~azure.mgmt.cdn.models.EnabledState - """ - super().__init__(**kwargs) - self.profile_name = 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 - - -class AFDOriginGroupProperties(AFDOriginGroupUpdatePropertiesParameters, AFDStateProperties): - """The JSON object that contains the properties of the origin group. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar provisioning_state: Provisioning status. Known values are: "Succeeded", "Failed", - "Updating", "Deleting", and "Creating". - :vartype provisioning_state: str or ~azure.mgmt.cdn.models.AfdProvisioningState - :ivar deployment_status: Known values are: "NotStarted", "InProgress", "Succeeded", and - "Failed". - :vartype deployment_status: str or ~azure.mgmt.cdn.models.DeploymentStatus - :ivar profile_name: The name of the profile which holds the origin group. - :vartype profile_name: str - :ivar load_balancing_settings: Load balancing settings for a backend pool. - :vartype load_balancing_settings: ~azure.mgmt.cdn.models.LoadBalancingSettingsParameters - :ivar health_probe_settings: Health probe settings to the origin that is used to determine the - health of the origin. - :vartype health_probe_settings: ~azure.mgmt.cdn.models.HealthProbeParameters - :ivar traffic_restoration_time_to_healed_or_new_endpoints_in_minutes: Time in minutes to shift - the traffic to the endpoint gradually when an unhealthy endpoint comes healthy or a new - endpoint is added. Default is 10 mins. This property is currently not supported. - :vartype traffic_restoration_time_to_healed_or_new_endpoints_in_minutes: int - :ivar session_affinity_state: Whether to allow session affinity on this host. Valid options are - 'Enabled' or 'Disabled'. Known values are: "Enabled" and "Disabled". - :vartype session_affinity_state: str or ~azure.mgmt.cdn.models.EnabledState - """ - - _validation = { - "provisioning_state": {"readonly": True}, - "deployment_status": {"readonly": True}, - "profile_name": {"readonly": True}, - "traffic_restoration_time_to_healed_or_new_endpoints_in_minutes": {"maximum": 50, "minimum": 0}, - } - - _attribute_map = { - "provisioning_state": {"key": "provisioningState", "type": "str"}, - "deployment_status": {"key": "deploymentStatus", "type": "str"}, - "profile_name": {"key": "profileName", "type": "str"}, - "load_balancing_settings": {"key": "loadBalancingSettings", "type": "LoadBalancingSettingsParameters"}, - "health_probe_settings": {"key": "healthProbeSettings", "type": "HealthProbeParameters"}, - "traffic_restoration_time_to_healed_or_new_endpoints_in_minutes": { - "key": "trafficRestorationTimeToHealedOrNewEndpointsInMinutes", - "type": "int", - }, - "session_affinity_state": {"key": "sessionAffinityState", "type": "str"}, - } - - def __init__( - self, - *, - load_balancing_settings: Optional["_models.LoadBalancingSettingsParameters"] = None, - health_probe_settings: Optional["_models.HealthProbeParameters"] = None, - traffic_restoration_time_to_healed_or_new_endpoints_in_minutes: Optional[int] = None, - session_affinity_state: Optional[Union[str, "_models.EnabledState"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword load_balancing_settings: Load balancing settings for a backend pool. - :paramtype load_balancing_settings: ~azure.mgmt.cdn.models.LoadBalancingSettingsParameters - :keyword health_probe_settings: Health probe settings to the origin that is used to determine - the health of the origin. - :paramtype health_probe_settings: ~azure.mgmt.cdn.models.HealthProbeParameters - :keyword traffic_restoration_time_to_healed_or_new_endpoints_in_minutes: Time in minutes to - shift the traffic to the endpoint gradually when an unhealthy endpoint comes healthy or a new - endpoint is added. Default is 10 mins. This property is currently not supported. - :paramtype traffic_restoration_time_to_healed_or_new_endpoints_in_minutes: int - :keyword session_affinity_state: Whether to allow session affinity on this host. Valid options - are 'Enabled' or 'Disabled'. Known values are: "Enabled" and "Disabled". - :paramtype session_affinity_state: str or ~azure.mgmt.cdn.models.EnabledState - """ - super().__init__( - load_balancing_settings=load_balancing_settings, - health_probe_settings=health_probe_settings, - traffic_restoration_time_to_healed_or_new_endpoints_in_minutes=traffic_restoration_time_to_healed_or_new_endpoints_in_minutes, - session_affinity_state=session_affinity_state, - **kwargs - ) - self.provisioning_state = None - self.deployment_status = None - self.profile_name = 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 - - -class AFDOriginGroupUpdateParameters(_serialization.Model): - """AFDOrigin group properties needed for origin group creation or update. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar profile_name: The name of the profile which holds the origin group. - :vartype profile_name: str - :ivar load_balancing_settings: Load balancing settings for a backend pool. - :vartype load_balancing_settings: ~azure.mgmt.cdn.models.LoadBalancingSettingsParameters - :ivar health_probe_settings: Health probe settings to the origin that is used to determine the - health of the origin. - :vartype health_probe_settings: ~azure.mgmt.cdn.models.HealthProbeParameters - :ivar traffic_restoration_time_to_healed_or_new_endpoints_in_minutes: Time in minutes to shift - the traffic to the endpoint gradually when an unhealthy endpoint comes healthy or a new - endpoint is added. Default is 10 mins. This property is currently not supported. - :vartype traffic_restoration_time_to_healed_or_new_endpoints_in_minutes: int - :ivar session_affinity_state: Whether to allow session affinity on this host. Valid options are - 'Enabled' or 'Disabled'. Known values are: "Enabled" and "Disabled". - :vartype session_affinity_state: str or ~azure.mgmt.cdn.models.EnabledState - """ - - _validation = { - "profile_name": {"readonly": True}, - "traffic_restoration_time_to_healed_or_new_endpoints_in_minutes": {"maximum": 50, "minimum": 0}, - } - - _attribute_map = { - "profile_name": {"key": "properties.profileName", "type": "str"}, - "load_balancing_settings": { - "key": "properties.loadBalancingSettings", - "type": "LoadBalancingSettingsParameters", - }, - "health_probe_settings": {"key": "properties.healthProbeSettings", "type": "HealthProbeParameters"}, - "traffic_restoration_time_to_healed_or_new_endpoints_in_minutes": { - "key": "properties.trafficRestorationTimeToHealedOrNewEndpointsInMinutes", - "type": "int", - }, - "session_affinity_state": {"key": "properties.sessionAffinityState", "type": "str"}, - } - - def __init__( - self, - *, - load_balancing_settings: Optional["_models.LoadBalancingSettingsParameters"] = None, - health_probe_settings: Optional["_models.HealthProbeParameters"] = None, - traffic_restoration_time_to_healed_or_new_endpoints_in_minutes: Optional[int] = None, - session_affinity_state: Optional[Union[str, "_models.EnabledState"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword load_balancing_settings: Load balancing settings for a backend pool. - :paramtype load_balancing_settings: ~azure.mgmt.cdn.models.LoadBalancingSettingsParameters - :keyword health_probe_settings: Health probe settings to the origin that is used to determine - the health of the origin. - :paramtype health_probe_settings: ~azure.mgmt.cdn.models.HealthProbeParameters - :keyword traffic_restoration_time_to_healed_or_new_endpoints_in_minutes: Time in minutes to - shift the traffic to the endpoint gradually when an unhealthy endpoint comes healthy or a new - endpoint is added. Default is 10 mins. This property is currently not supported. - :paramtype traffic_restoration_time_to_healed_or_new_endpoints_in_minutes: int - :keyword session_affinity_state: Whether to allow session affinity on this host. Valid options - are 'Enabled' or 'Disabled'. Known values are: "Enabled" and "Disabled". - :paramtype session_affinity_state: str or ~azure.mgmt.cdn.models.EnabledState - """ - super().__init__(**kwargs) - self.profile_name = 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 - - -class AFDOriginListResult(_serialization.Model): - """Result of the request to list origins. It contains a list of origin objects and a URL link to - get the next set of results. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: List of Azure Front Door origins within an Azure Front Door endpoint. - :vartype value: list[~azure.mgmt.cdn.models.AFDOrigin] - :ivar next_link: URL to get the next set of origin objects if there are any. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[AFDOrigin]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword next_link: URL to get the next set of origin objects if there are any. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = None - self.next_link = next_link - - -class AFDOriginUpdatePropertiesParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes - """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. - - :ivar origin_group_name: The name of the origin group which contains this origin. - :vartype origin_group_name: str - :ivar azure_origin: Resource reference to the Azure origin resource. - :vartype azure_origin: ~azure.mgmt.cdn.models.ResourceReference - :ivar host_name: The address of the origin. Domain names, IPv4 addresses, and IPv6 addresses - are supported.This should be unique across all origins in an endpoint. - :vartype host_name: str - :ivar http_port: The value of the HTTP port. Must be between 1 and 65535. - :vartype http_port: int - :ivar https_port: The value of the HTTPS port. Must be between 1 and 65535. - :vartype https_port: int - :ivar origin_host_header: The host header value sent to the origin with each request. If you - leave this blank, the request hostname determines this value. Azure Front Door origins, such as - Web Apps, Blob Storage, and Cloud Services require this host header value to match the origin - hostname by default. This overrides the host header defined at Endpoint. - :vartype origin_host_header: str - :ivar priority: Priority of origin in given origin group for load balancing. Higher priorities - will not be used for load balancing if any lower priority origin is healthy.Must be between 1 - and 5. - :vartype priority: int - :ivar weight: Weight of the origin in given origin group for load balancing. Must be between 1 - and 1000. - :vartype weight: int - :ivar shared_private_link_resource: The properties of the private link resource for private - origin. - :vartype shared_private_link_resource: - ~azure.mgmt.cdn.models.SharedPrivateLinkResourceProperties - :ivar enabled_state: Whether to enable health probes to be made against backends defined under - backendPools. Health probes can only be disabled if there is a single enabled backend in single - enabled backend pool. Known values are: "Enabled" and "Disabled". - :vartype enabled_state: str or ~azure.mgmt.cdn.models.EnabledState - :ivar enforce_certificate_name_check: Whether to enable certificate name check at origin level. - :vartype enforce_certificate_name_check: bool - """ - - _validation = { - "origin_group_name": {"readonly": True}, - "http_port": {"maximum": 65535, "minimum": 1}, - "https_port": {"maximum": 65535, "minimum": 1}, - "priority": {"maximum": 5, "minimum": 1}, - "weight": {"maximum": 1000, "minimum": 1}, - } - - _attribute_map = { - "origin_group_name": {"key": "originGroupName", "type": "str"}, - "azure_origin": {"key": "azureOrigin", "type": "ResourceReference"}, - "host_name": {"key": "hostName", "type": "str"}, - "http_port": {"key": "httpPort", "type": "int"}, - "https_port": {"key": "httpsPort", "type": "int"}, - "origin_host_header": {"key": "originHostHeader", "type": "str"}, - "priority": {"key": "priority", "type": "int"}, - "weight": {"key": "weight", "type": "int"}, - "shared_private_link_resource": { - "key": "sharedPrivateLinkResource", - "type": "SharedPrivateLinkResourceProperties", - }, - "enabled_state": {"key": "enabledState", "type": "str"}, - "enforce_certificate_name_check": {"key": "enforceCertificateNameCheck", "type": "bool"}, - } - - def __init__( - self, - *, - azure_origin: Optional["_models.ResourceReference"] = None, - host_name: Optional[str] = None, - http_port: int = 80, - https_port: int = 443, - origin_host_header: Optional[str] = None, - priority: Optional[int] = None, - weight: Optional[int] = None, - shared_private_link_resource: Optional["_models.SharedPrivateLinkResourceProperties"] = None, - enabled_state: Optional[Union[str, "_models.EnabledState"]] = None, - enforce_certificate_name_check: bool = True, - **kwargs: Any - ) -> None: - """ - :keyword azure_origin: Resource reference to the Azure origin resource. - :paramtype azure_origin: ~azure.mgmt.cdn.models.ResourceReference - :keyword host_name: The address of the origin. Domain names, IPv4 addresses, and IPv6 addresses - are supported.This should be unique across all origins in an endpoint. - :paramtype host_name: str - :keyword http_port: The value of the HTTP port. Must be between 1 and 65535. - :paramtype http_port: int - :keyword https_port: The value of the HTTPS port. Must be between 1 and 65535. - :paramtype https_port: int - :keyword origin_host_header: The host header value sent to the origin with each request. If you - leave this blank, the request hostname determines this value. Azure Front Door origins, such as - Web Apps, Blob Storage, and Cloud Services require this host header value to match the origin - hostname by default. This overrides the host header defined at Endpoint. - :paramtype origin_host_header: str - :keyword priority: Priority of origin in given origin group for load balancing. Higher - priorities will not be used for load balancing if any lower priority origin is healthy.Must be - between 1 and 5. - :paramtype priority: int - :keyword weight: Weight of the origin in given origin group for load balancing. Must be between - 1 and 1000. - :paramtype weight: int - :keyword shared_private_link_resource: The properties of the private link resource for private - origin. - :paramtype shared_private_link_resource: - ~azure.mgmt.cdn.models.SharedPrivateLinkResourceProperties - :keyword enabled_state: Whether to enable health probes to be made against backends defined - under backendPools. Health probes can only be disabled if there is a single enabled backend in - single enabled backend pool. Known values are: "Enabled" and "Disabled". - :paramtype enabled_state: str or ~azure.mgmt.cdn.models.EnabledState - :keyword enforce_certificate_name_check: Whether to enable certificate name check at origin - level. - :paramtype enforce_certificate_name_check: bool - """ - super().__init__(**kwargs) - self.origin_group_name = None - self.azure_origin = azure_origin - self.host_name = host_name - self.http_port = http_port - self.https_port = https_port - self.origin_host_header = origin_host_header - self.priority = priority - self.weight = weight - self.shared_private_link_resource = shared_private_link_resource - self.enabled_state = enabled_state - self.enforce_certificate_name_check = enforce_certificate_name_check - - -class AFDOriginProperties( - AFDOriginUpdatePropertiesParameters, AFDStateProperties -): # pylint: disable=too-many-instance-attributes - """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. - - :ivar provisioning_state: Provisioning status. Known values are: "Succeeded", "Failed", - "Updating", "Deleting", and "Creating". - :vartype provisioning_state: str or ~azure.mgmt.cdn.models.AfdProvisioningState - :ivar deployment_status: Known values are: "NotStarted", "InProgress", "Succeeded", and - "Failed". - :vartype deployment_status: str or ~azure.mgmt.cdn.models.DeploymentStatus - :ivar origin_group_name: The name of the origin group which contains this origin. - :vartype origin_group_name: str - :ivar azure_origin: Resource reference to the Azure origin resource. - :vartype azure_origin: ~azure.mgmt.cdn.models.ResourceReference - :ivar host_name: The address of the origin. Domain names, IPv4 addresses, and IPv6 addresses - are supported.This should be unique across all origins in an endpoint. - :vartype host_name: str - :ivar http_port: The value of the HTTP port. Must be between 1 and 65535. - :vartype http_port: int - :ivar https_port: The value of the HTTPS port. Must be between 1 and 65535. - :vartype https_port: int - :ivar origin_host_header: The host header value sent to the origin with each request. If you - leave this blank, the request hostname determines this value. Azure Front Door origins, such as - Web Apps, Blob Storage, and Cloud Services require this host header value to match the origin - hostname by default. This overrides the host header defined at Endpoint. - :vartype origin_host_header: str - :ivar priority: Priority of origin in given origin group for load balancing. Higher priorities - will not be used for load balancing if any lower priority origin is healthy.Must be between 1 - and 5. - :vartype priority: int - :ivar weight: Weight of the origin in given origin group for load balancing. Must be between 1 - and 1000. - :vartype weight: int - :ivar shared_private_link_resource: The properties of the private link resource for private - origin. - :vartype shared_private_link_resource: - ~azure.mgmt.cdn.models.SharedPrivateLinkResourceProperties - :ivar enabled_state: Whether to enable health probes to be made against backends defined under - backendPools. Health probes can only be disabled if there is a single enabled backend in single - enabled backend pool. Known values are: "Enabled" and "Disabled". - :vartype enabled_state: str or ~azure.mgmt.cdn.models.EnabledState - :ivar enforce_certificate_name_check: Whether to enable certificate name check at origin level. - :vartype enforce_certificate_name_check: bool - """ - - _validation = { - "provisioning_state": {"readonly": True}, - "deployment_status": {"readonly": True}, - "origin_group_name": {"readonly": True}, - "http_port": {"maximum": 65535, "minimum": 1}, - "https_port": {"maximum": 65535, "minimum": 1}, - "priority": {"maximum": 5, "minimum": 1}, - "weight": {"maximum": 1000, "minimum": 1}, - } - - _attribute_map = { - "provisioning_state": {"key": "provisioningState", "type": "str"}, - "deployment_status": {"key": "deploymentStatus", "type": "str"}, - "origin_group_name": {"key": "originGroupName", "type": "str"}, - "azure_origin": {"key": "azureOrigin", "type": "ResourceReference"}, - "host_name": {"key": "hostName", "type": "str"}, - "http_port": {"key": "httpPort", "type": "int"}, - "https_port": {"key": "httpsPort", "type": "int"}, - "origin_host_header": {"key": "originHostHeader", "type": "str"}, - "priority": {"key": "priority", "type": "int"}, - "weight": {"key": "weight", "type": "int"}, - "shared_private_link_resource": { - "key": "sharedPrivateLinkResource", - "type": "SharedPrivateLinkResourceProperties", - }, - "enabled_state": {"key": "enabledState", "type": "str"}, - "enforce_certificate_name_check": {"key": "enforceCertificateNameCheck", "type": "bool"}, - } - - def __init__( - self, - *, - azure_origin: Optional["_models.ResourceReference"] = None, - host_name: Optional[str] = None, - http_port: int = 80, - https_port: int = 443, - origin_host_header: Optional[str] = None, - priority: Optional[int] = None, - weight: Optional[int] = None, - shared_private_link_resource: Optional["_models.SharedPrivateLinkResourceProperties"] = None, - enabled_state: Optional[Union[str, "_models.EnabledState"]] = None, - enforce_certificate_name_check: bool = True, - **kwargs: Any - ) -> None: - """ - :keyword azure_origin: Resource reference to the Azure origin resource. - :paramtype azure_origin: ~azure.mgmt.cdn.models.ResourceReference - :keyword host_name: The address of the origin. Domain names, IPv4 addresses, and IPv6 addresses - are supported.This should be unique across all origins in an endpoint. - :paramtype host_name: str - :keyword http_port: The value of the HTTP port. Must be between 1 and 65535. - :paramtype http_port: int - :keyword https_port: The value of the HTTPS port. Must be between 1 and 65535. - :paramtype https_port: int - :keyword origin_host_header: The host header value sent to the origin with each request. If you - leave this blank, the request hostname determines this value. Azure Front Door origins, such as - Web Apps, Blob Storage, and Cloud Services require this host header value to match the origin - hostname by default. This overrides the host header defined at Endpoint. - :paramtype origin_host_header: str - :keyword priority: Priority of origin in given origin group for load balancing. Higher - priorities will not be used for load balancing if any lower priority origin is healthy.Must be - between 1 and 5. - :paramtype priority: int - :keyword weight: Weight of the origin in given origin group for load balancing. Must be between - 1 and 1000. - :paramtype weight: int - :keyword shared_private_link_resource: The properties of the private link resource for private - origin. - :paramtype shared_private_link_resource: - ~azure.mgmt.cdn.models.SharedPrivateLinkResourceProperties - :keyword enabled_state: Whether to enable health probes to be made against backends defined - under backendPools. Health probes can only be disabled if there is a single enabled backend in - single enabled backend pool. Known values are: "Enabled" and "Disabled". - :paramtype enabled_state: str or ~azure.mgmt.cdn.models.EnabledState - :keyword enforce_certificate_name_check: Whether to enable certificate name check at origin - level. - :paramtype enforce_certificate_name_check: bool - """ - super().__init__( - azure_origin=azure_origin, - host_name=host_name, - http_port=http_port, - https_port=https_port, - origin_host_header=origin_host_header, - priority=priority, - weight=weight, - shared_private_link_resource=shared_private_link_resource, - enabled_state=enabled_state, - enforce_certificate_name_check=enforce_certificate_name_check, - **kwargs - ) - self.provisioning_state = None - self.deployment_status = None - self.origin_group_name = None - self.azure_origin = azure_origin - self.host_name = host_name - self.http_port = http_port - self.https_port = https_port - self.origin_host_header = origin_host_header - self.priority = priority - self.weight = weight - self.shared_private_link_resource = shared_private_link_resource - self.enabled_state = enabled_state - self.enforce_certificate_name_check = enforce_certificate_name_check - - -class AFDOriginUpdateParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes - """AFDOrigin properties needed for origin update. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar origin_group_name: The name of the origin group which contains this origin. - :vartype origin_group_name: str - :ivar azure_origin: Resource reference to the Azure origin resource. - :vartype azure_origin: ~azure.mgmt.cdn.models.ResourceReference - :ivar host_name: The address of the origin. Domain names, IPv4 addresses, and IPv6 addresses - are supported.This should be unique across all origins in an endpoint. - :vartype host_name: str - :ivar http_port: The value of the HTTP port. Must be between 1 and 65535. - :vartype http_port: int - :ivar https_port: The value of the HTTPS port. Must be between 1 and 65535. - :vartype https_port: int - :ivar origin_host_header: The host header value sent to the origin with each request. If you - leave this blank, the request hostname determines this value. Azure Front Door origins, such as - Web Apps, Blob Storage, and Cloud Services require this host header value to match the origin - hostname by default. This overrides the host header defined at Endpoint. - :vartype origin_host_header: str - :ivar priority: Priority of origin in given origin group for load balancing. Higher priorities - will not be used for load balancing if any lower priority origin is healthy.Must be between 1 - and 5. - :vartype priority: int - :ivar weight: Weight of the origin in given origin group for load balancing. Must be between 1 - and 1000. - :vartype weight: int - :ivar shared_private_link_resource: The properties of the private link resource for private - origin. - :vartype shared_private_link_resource: - ~azure.mgmt.cdn.models.SharedPrivateLinkResourceProperties - :ivar enabled_state: Whether to enable health probes to be made against backends defined under - backendPools. Health probes can only be disabled if there is a single enabled backend in single - enabled backend pool. Known values are: "Enabled" and "Disabled". - :vartype enabled_state: str or ~azure.mgmt.cdn.models.EnabledState - :ivar enforce_certificate_name_check: Whether to enable certificate name check at origin level. - :vartype enforce_certificate_name_check: bool - """ - - _validation = { - "origin_group_name": {"readonly": True}, - "http_port": {"maximum": 65535, "minimum": 1}, - "https_port": {"maximum": 65535, "minimum": 1}, - "priority": {"maximum": 5, "minimum": 1}, - "weight": {"maximum": 1000, "minimum": 1}, - } - - _attribute_map = { - "origin_group_name": {"key": "properties.originGroupName", "type": "str"}, - "azure_origin": {"key": "properties.azureOrigin", "type": "ResourceReference"}, - "host_name": {"key": "properties.hostName", "type": "str"}, - "http_port": {"key": "properties.httpPort", "type": "int"}, - "https_port": {"key": "properties.httpsPort", "type": "int"}, - "origin_host_header": {"key": "properties.originHostHeader", "type": "str"}, - "priority": {"key": "properties.priority", "type": "int"}, - "weight": {"key": "properties.weight", "type": "int"}, - "shared_private_link_resource": { - "key": "properties.sharedPrivateLinkResource", - "type": "SharedPrivateLinkResourceProperties", - }, - "enabled_state": {"key": "properties.enabledState", "type": "str"}, - "enforce_certificate_name_check": {"key": "properties.enforceCertificateNameCheck", "type": "bool"}, - } - - def __init__( - self, - *, - azure_origin: Optional["_models.ResourceReference"] = None, - host_name: Optional[str] = None, - http_port: int = 80, - https_port: int = 443, - origin_host_header: Optional[str] = None, - priority: Optional[int] = None, - weight: Optional[int] = None, - shared_private_link_resource: Optional["_models.SharedPrivateLinkResourceProperties"] = None, - enabled_state: Optional[Union[str, "_models.EnabledState"]] = None, - enforce_certificate_name_check: bool = True, - **kwargs: Any - ) -> None: - """ - :keyword azure_origin: Resource reference to the Azure origin resource. - :paramtype azure_origin: ~azure.mgmt.cdn.models.ResourceReference - :keyword host_name: The address of the origin. Domain names, IPv4 addresses, and IPv6 addresses - are supported.This should be unique across all origins in an endpoint. - :paramtype host_name: str - :keyword http_port: The value of the HTTP port. Must be between 1 and 65535. - :paramtype http_port: int - :keyword https_port: The value of the HTTPS port. Must be between 1 and 65535. - :paramtype https_port: int - :keyword origin_host_header: The host header value sent to the origin with each request. If you - leave this blank, the request hostname determines this value. Azure Front Door origins, such as - Web Apps, Blob Storage, and Cloud Services require this host header value to match the origin - hostname by default. This overrides the host header defined at Endpoint. - :paramtype origin_host_header: str - :keyword priority: Priority of origin in given origin group for load balancing. Higher - priorities will not be used for load balancing if any lower priority origin is healthy.Must be - between 1 and 5. - :paramtype priority: int - :keyword weight: Weight of the origin in given origin group for load balancing. Must be between - 1 and 1000. - :paramtype weight: int - :keyword shared_private_link_resource: The properties of the private link resource for private - origin. - :paramtype shared_private_link_resource: - ~azure.mgmt.cdn.models.SharedPrivateLinkResourceProperties - :keyword enabled_state: Whether to enable health probes to be made against backends defined - under backendPools. Health probes can only be disabled if there is a single enabled backend in - single enabled backend pool. Known values are: "Enabled" and "Disabled". - :paramtype enabled_state: str or ~azure.mgmt.cdn.models.EnabledState - :keyword enforce_certificate_name_check: Whether to enable certificate name check at origin - level. - :paramtype enforce_certificate_name_check: bool - """ - super().__init__(**kwargs) - self.origin_group_name = None - self.azure_origin = azure_origin - self.host_name = host_name - self.http_port = http_port - self.https_port = https_port - self.origin_host_header = origin_host_header - self.priority = priority - self.weight = weight - self.shared_private_link_resource = shared_private_link_resource - self.enabled_state = enabled_state - self.enforce_certificate_name_check = enforce_certificate_name_check - - -class AfdPurgeParameters(_serialization.Model): - """Parameters required for content purge. - - All required parameters must be populated in order to send to server. - - :ivar content_paths: The path to the content to be purged. Can describe a file path or a wild - card directory. Required. - :vartype content_paths: list[str] - :ivar domains: List of domains. - :vartype domains: list[str] - """ - - _validation = { - "content_paths": {"required": True}, - } - - _attribute_map = { - "content_paths": {"key": "contentPaths", "type": "[str]"}, - "domains": {"key": "domains", "type": "[str]"}, - } - - def __init__(self, *, content_paths: List[str], domains: Optional[List[str]] = None, **kwargs: Any) -> None: - """ - :keyword content_paths: The path to the content to be purged. Can describe a file path or a - wild card directory. Required. - :paramtype content_paths: list[str] - :keyword domains: List of domains. - :paramtype domains: list[str] - """ - super().__init__(**kwargs) - self.content_paths = content_paths - self.domains = domains - - -class AfdRouteCacheConfiguration(_serialization.Model): - """Caching settings for a caching-type route. To disable caching, do not provide a - cacheConfiguration object. - - :ivar query_string_caching_behavior: Defines how Frontdoor caches requests that include query - strings. You can ignore any query strings when caching, ignore specific query strings, cache - every request with a unique URL, or cache specific query strings. Known values are: - "IgnoreQueryString", "UseQueryString", "IgnoreSpecifiedQueryStrings", and - "IncludeSpecifiedQueryStrings". - :vartype query_string_caching_behavior: str or - ~azure.mgmt.cdn.models.AfdQueryStringCachingBehavior - :ivar query_parameters: query parameters to include or exclude (comma separated). - :vartype query_parameters: str - :ivar compression_settings: compression settings. - :vartype compression_settings: ~azure.mgmt.cdn.models.CompressionSettings - """ - - _attribute_map = { - "query_string_caching_behavior": {"key": "queryStringCachingBehavior", "type": "str"}, - "query_parameters": {"key": "queryParameters", "type": "str"}, - "compression_settings": {"key": "compressionSettings", "type": "CompressionSettings"}, - } - - def __init__( - self, - *, - query_string_caching_behavior: Optional[Union[str, "_models.AfdQueryStringCachingBehavior"]] = None, - query_parameters: Optional[str] = None, - compression_settings: Optional["_models.CompressionSettings"] = None, - **kwargs: Any - ) -> None: - """ - :keyword query_string_caching_behavior: Defines how Frontdoor caches requests that include - query strings. You can ignore any query strings when caching, ignore specific query strings, - cache every request with a unique URL, or cache specific query strings. Known values are: - "IgnoreQueryString", "UseQueryString", "IgnoreSpecifiedQueryStrings", and - "IncludeSpecifiedQueryStrings". - :paramtype query_string_caching_behavior: str or - ~azure.mgmt.cdn.models.AfdQueryStringCachingBehavior - :keyword query_parameters: query parameters to include or exclude (comma separated). - :paramtype query_parameters: str - :keyword compression_settings: compression settings. - :paramtype compression_settings: ~azure.mgmt.cdn.models.CompressionSettings - """ - super().__init__(**kwargs) - self.query_string_caching_behavior = query_string_caching_behavior - self.query_parameters = query_parameters - self.compression_settings = compression_settings - - -class Certificate(_serialization.Model): - """Certificate used for https. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The type of the secret resource. Known values are: "UrlSigningKey", - "CustomerCertificate", "ManagedCertificate", and "AzureFirstPartyManagedCertificate". - :vartype type: str or ~azure.mgmt.cdn.models.SecretType - :ivar subject: Subject name in the certificate. - :vartype subject: str - :ivar expiration_date: Certificate expiration date. - :vartype expiration_date: str - """ - - _validation = { - "subject": {"readonly": True}, - "expiration_date": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "subject": {"key": "subject", "type": "str"}, - "expiration_date": {"key": "expirationDate", "type": "str"}, - } - - def __init__(self, *, type: Optional[Union[str, "_models.SecretType"]] = None, **kwargs: Any) -> None: - """ - :keyword type: The type of the secret resource. Known values are: "UrlSigningKey", - "CustomerCertificate", "ManagedCertificate", and "AzureFirstPartyManagedCertificate". - :paramtype type: str or ~azure.mgmt.cdn.models.SecretType - """ - super().__init__(**kwargs) - self.type = type - self.subject = None - self.expiration_date = None - - -class AzureFirstPartyManagedCertificate(Certificate): - """Azure FirstParty Managed Certificate provided by other first party resource providers to enable - HTTPS. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The type of the secret resource. Known values are: "UrlSigningKey", - "CustomerCertificate", "ManagedCertificate", and "AzureFirstPartyManagedCertificate". - :vartype type: str or ~azure.mgmt.cdn.models.SecretType - :ivar subject: Subject name in the certificate. - :vartype subject: str - :ivar expiration_date: Certificate expiration date. - :vartype expiration_date: str - """ - - -class SecretParameters(_serialization.Model): - """The json object containing secret parameters. - - You probably want to use the sub-classes and not this class directly. Known sub-classes are: - AzureFirstPartyManagedCertificateParameters, CustomerCertificateParameters, - ManagedCertificateParameters, UrlSigningKeyParameters - - All required parameters must be populated in order to send to server. - - :ivar type: The type of the secret resource. Required. Known values are: "UrlSigningKey", - "CustomerCertificate", "ManagedCertificate", and "AzureFirstPartyManagedCertificate". - :vartype type: str or ~azure.mgmt.cdn.models.SecretType - """ - - _validation = { - "type": {"required": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - } - - _subtype_map = { - "type": { - "AzureFirstPartyManagedCertificate": "AzureFirstPartyManagedCertificateParameters", - "CustomerCertificate": "CustomerCertificateParameters", - "ManagedCertificate": "ManagedCertificateParameters", - "UrlSigningKey": "UrlSigningKeyParameters", - } - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.type: Optional[str] = None - - -class AzureFirstPartyManagedCertificateParameters(SecretParameters): # pylint: disable=name-too-long - """Azure FirstParty Managed Certificate provided by other first party resource providers to enable - HTTPS. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to server. - - :ivar type: The type of the secret resource. Required. Known values are: "UrlSigningKey", - "CustomerCertificate", "ManagedCertificate", and "AzureFirstPartyManagedCertificate". - :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 - :vartype secret_source: ~azure.mgmt.cdn.models.ResourceReference - :ivar subject: Subject name in the certificate. - :vartype subject: str - :ivar expiration_date: Certificate expiration date. - :vartype expiration_date: str - :ivar certificate_authority: Certificate issuing authority. - :vartype certificate_authority: str - :ivar subject_alternative_names: The list of SANs. - :vartype subject_alternative_names: list[str] - :ivar thumbprint: Certificate thumbprint. - :vartype thumbprint: str - """ - - _validation = { - "type": {"required": True}, - "secret_source": {"readonly": True}, - "subject": {"readonly": True}, - "expiration_date": {"readonly": True}, - "certificate_authority": {"readonly": True}, - "thumbprint": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "secret_source": {"key": "secretSource", "type": "ResourceReference"}, - "subject": {"key": "subject", "type": "str"}, - "expiration_date": {"key": "expirationDate", "type": "str"}, - "certificate_authority": {"key": "certificateAuthority", "type": "str"}, - "subject_alternative_names": {"key": "subjectAlternativeNames", "type": "[str]"}, - "thumbprint": {"key": "thumbprint", "type": "str"}, - } - - def __init__(self, *, subject_alternative_names: Optional[List[str]] = None, **kwargs: Any) -> None: - """ - :keyword subject_alternative_names: The list of SANs. - :paramtype subject_alternative_names: list[str] - """ - super().__init__(**kwargs) - self.type: str = "AzureFirstPartyManagedCertificate" - self.secret_source = None - self.subject = None - self.expiration_date = None - self.certificate_authority = None - self.subject_alternative_names = subject_alternative_names - self.thumbprint = None - - -class CacheConfiguration(_serialization.Model): - """Caching settings for a caching-type route. To disable caching, do not provide a - cacheConfiguration object. - - :ivar query_string_caching_behavior: Defines how Frontdoor caches requests that include query - strings. You can ignore any query strings when caching, ignore specific query strings, cache - every request with a unique URL, or cache specific query strings. Known values are: - "IgnoreQueryString", "UseQueryString", "IgnoreSpecifiedQueryStrings", and - "IncludeSpecifiedQueryStrings". - :vartype query_string_caching_behavior: str or - ~azure.mgmt.cdn.models.RuleQueryStringCachingBehavior - :ivar query_parameters: query parameters to include or exclude (comma separated). - :vartype query_parameters: str - :ivar is_compression_enabled: Indicates whether content compression is enabled. If compression - is enabled, content will be served as compressed if user requests for a compressed version. - Content won't be compressed on AzureFrontDoor when requested content is smaller than 1 byte or - larger than 1 MB. Known values are: "Enabled" and "Disabled". - :vartype is_compression_enabled: str or ~azure.mgmt.cdn.models.RuleIsCompressionEnabled - :ivar cache_behavior: Caching behavior for the requests. Known values are: "HonorOrigin", - "OverrideAlways", and "OverrideIfOriginMissing". - :vartype cache_behavior: str or ~azure.mgmt.cdn.models.RuleCacheBehavior - :ivar cache_duration: The duration for which the content needs to be cached. Allowed format is - [d.]hh:mm:ss. - :vartype cache_duration: str - """ - - _attribute_map = { - "query_string_caching_behavior": {"key": "queryStringCachingBehavior", "type": "str"}, - "query_parameters": {"key": "queryParameters", "type": "str"}, - "is_compression_enabled": {"key": "isCompressionEnabled", "type": "str"}, - "cache_behavior": {"key": "cacheBehavior", "type": "str"}, - "cache_duration": {"key": "cacheDuration", "type": "str"}, - } - - def __init__( - self, - *, - query_string_caching_behavior: Optional[Union[str, "_models.RuleQueryStringCachingBehavior"]] = None, - query_parameters: Optional[str] = None, - is_compression_enabled: Optional[Union[str, "_models.RuleIsCompressionEnabled"]] = None, - cache_behavior: Optional[Union[str, "_models.RuleCacheBehavior"]] = None, - cache_duration: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword query_string_caching_behavior: Defines how Frontdoor caches requests that include - query strings. You can ignore any query strings when caching, ignore specific query strings, - cache every request with a unique URL, or cache specific query strings. Known values are: - "IgnoreQueryString", "UseQueryString", "IgnoreSpecifiedQueryStrings", and - "IncludeSpecifiedQueryStrings". - :paramtype query_string_caching_behavior: str or - ~azure.mgmt.cdn.models.RuleQueryStringCachingBehavior - :keyword query_parameters: query parameters to include or exclude (comma separated). - :paramtype query_parameters: str - :keyword is_compression_enabled: Indicates whether content compression is enabled. If - compression is enabled, content will be served as compressed if user requests for a compressed - version. Content won't be compressed on AzureFrontDoor when requested content is smaller than 1 - byte or larger than 1 MB. Known values are: "Enabled" and "Disabled". - :paramtype is_compression_enabled: str or ~azure.mgmt.cdn.models.RuleIsCompressionEnabled - :keyword cache_behavior: Caching behavior for the requests. Known values are: "HonorOrigin", - "OverrideAlways", and "OverrideIfOriginMissing". - :paramtype cache_behavior: str or ~azure.mgmt.cdn.models.RuleCacheBehavior - :keyword cache_duration: The duration for which the content needs to be cached. Allowed format - is [d.]hh:mm:ss. - :paramtype cache_duration: str - """ - super().__init__(**kwargs) - self.query_string_caching_behavior = query_string_caching_behavior - self.query_parameters = query_parameters - self.is_compression_enabled = is_compression_enabled - self.cache_behavior = cache_behavior - self.cache_duration = cache_duration - - -class CacheExpirationActionParameters(_serialization.Model): - """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 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 - :ivar cache_type: The level at which the content needs to be cached. Required. "All" - :vartype cache_type: str or ~azure.mgmt.cdn.models.CacheType - :ivar cache_duration: The duration for which the content needs to be cached. Allowed format is - [d.]hh:mm:ss. - :vartype cache_duration: str - """ - - _validation = { - "type_name": {"required": True}, - "cache_behavior": {"required": True}, - "cache_type": {"required": True}, - } - - _attribute_map = { - "type_name": {"key": "typeName", "type": "str"}, - "cache_behavior": {"key": "cacheBehavior", "type": "str"}, - "cache_type": {"key": "cacheType", "type": "str"}, - "cache_duration": {"key": "cacheDuration", "type": "str"}, - } - - 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 - :keyword cache_type: The level at which the content needs to be cached. Required. "All" - :paramtype cache_type: str or ~azure.mgmt.cdn.models.CacheType - :keyword cache_duration: The duration for which the content needs to be cached. Allowed format - is [d.]hh:mm:ss. - :paramtype cache_duration: str - """ - super().__init__(**kwargs) - self.type_name = type_name - self.cache_behavior = cache_behavior - self.cache_type = cache_type - self.cache_duration = cache_duration - - -class CacheKeyQueryStringActionParameters(_serialization.Model): - """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 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 - :ivar query_parameters: query parameters to include or exclude (comma separated). - :vartype query_parameters: str - """ - - _validation = { - "type_name": {"required": True}, - "query_string_behavior": {"required": True}, - } - - _attribute_map = { - "type_name": {"key": "typeName", "type": "str"}, - "query_string_behavior": {"key": "queryStringBehavior", "type": "str"}, - "query_parameters": {"key": "queryParameters", "type": "str"}, - } - - 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 - :keyword query_parameters: query parameters to include or exclude (comma separated). - :paramtype query_parameters: str - """ - super().__init__(**kwargs) - self.type_name = type_name - self.query_string_behavior = query_string_behavior - self.query_parameters = query_parameters - - -class CanMigrateParameters(_serialization.Model): - """Request body for CanMigrate operation. - - All required parameters must be populated in order to send to server. - - :ivar classic_resource_reference: Resource reference of the classic cdn profile or classic - frontdoor that need to be migrated. Required. - :vartype classic_resource_reference: ~azure.mgmt.cdn.models.ResourceReference - """ - - _validation = { - "classic_resource_reference": {"required": True}, - } - - _attribute_map = { - "classic_resource_reference": {"key": "classicResourceReference", "type": "ResourceReference"}, - } - - def __init__(self, *, classic_resource_reference: "_models.ResourceReference", **kwargs: Any) -> None: - """ - :keyword classic_resource_reference: Resource reference of the classic cdn profile or classic - frontdoor that need to be migrated. Required. - :paramtype classic_resource_reference: ~azure.mgmt.cdn.models.ResourceReference - """ - super().__init__(**kwargs) - self.classic_resource_reference = classic_resource_reference - - -class CanMigrateResult(_serialization.Model): - """Result for canMigrate operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar type: Resource type. - :vartype type: str - :ivar can_migrate: Flag that says if the profile can be migrated. - :vartype can_migrate: bool - :ivar default_sku: Recommended sku for the migration. Known values are: - "Standard_AzureFrontDoor" and "Premium_AzureFrontDoor". - :vartype default_sku: str or ~azure.mgmt.cdn.models.CanMigrateDefaultSku - :ivar errors: - :vartype errors: list[~azure.mgmt.cdn.models.MigrationErrorType] - """ - - _validation = { - "id": {"readonly": True}, - "type": {"readonly": True}, - "can_migrate": {"readonly": True}, - "default_sku": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "can_migrate": {"key": "properties.canMigrate", "type": "bool"}, - "default_sku": {"key": "properties.defaultSku", "type": "str"}, - "errors": {"key": "properties.errors", "type": "[MigrationErrorType]"}, - } - - def __init__(self, *, errors: Optional[List["_models.MigrationErrorType"]] = None, **kwargs: Any) -> None: - """ - :keyword errors: - :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.errors = errors - - -class CdnCertificateSourceParameters(_serialization.Model): - """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 certificate_type: Type of certificate used. Required. Known values are: "Shared" and - "Dedicated". - :vartype certificate_type: str or ~azure.mgmt.cdn.models.CertificateType - """ - - _validation = { - "type_name": {"required": True}, - "certificate_type": {"required": True}, - } - - _attribute_map = { - "type_name": {"key": "typeName", "type": "str"}, - "certificate_type": {"key": "certificateType", "type": "str"}, - } - - def __init__( - self, - *, - type_name: Union[str, "_models.CdnCertificateSourceParametersTypeName"], - 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.certificate_type = certificate_type - - -class CdnEndpoint(_serialization.Model): - """Defines the ARM Resource ID for the linked endpoints. - - :ivar id: ARM Resource ID string. - :vartype id: str - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - } - - def __init__(self, *, id: Optional[str] = None, **kwargs: Any) -> None: # pylint: disable=redefined-builtin - """ - :keyword id: ARM Resource ID string. - :paramtype id: str - """ - super().__init__(**kwargs) - self.id = id - - -class CustomDomainHttpsParameters(_serialization.Model): - """The JSON object that contains the properties to secure a custom domain. - - You probably want to use the sub-classes and not this class directly. Known sub-classes are: - UserManagedHttpsParameters, CdnManagedHttpsParameters - - All required parameters must be populated in order to send to server. - - :ivar certificate_source: Defines the source of the SSL certificate. Required. Known values - are: "AzureKeyVault" and "Cdn". - :vartype certificate_source: str or ~azure.mgmt.cdn.models.CertificateSource - :ivar protocol_type: Defines the TLS extension protocol that is used for secure delivery. - Required. Known values are: "ServerNameIndication" and "IPBased". - :vartype protocol_type: str or ~azure.mgmt.cdn.models.ProtocolType - :ivar minimum_tls_version: TLS protocol version that will be used for Https. Known values are: - "None", "TLS10", and "TLS12". - :vartype minimum_tls_version: str or ~azure.mgmt.cdn.models.MinimumTlsVersion - """ - - _validation = { - "certificate_source": {"required": True}, - "protocol_type": {"required": True}, - } - - _attribute_map = { - "certificate_source": {"key": "certificateSource", "type": "str"}, - "protocol_type": {"key": "protocolType", "type": "str"}, - "minimum_tls_version": {"key": "minimumTlsVersion", "type": "str"}, - } - - _subtype_map = { - "certificate_source": {"AzureKeyVault": "UserManagedHttpsParameters", "Cdn": "CdnManagedHttpsParameters"} - } - - def __init__( - self, - *, - protocol_type: Union[str, "_models.ProtocolType"], - minimum_tls_version: Optional[Union[str, "_models.MinimumTlsVersion"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword protocol_type: Defines the TLS extension protocol that is used for secure delivery. - Required. Known values are: "ServerNameIndication" and "IPBased". - :paramtype protocol_type: str or ~azure.mgmt.cdn.models.ProtocolType - :keyword minimum_tls_version: TLS protocol version that will be used for Https. Known values - are: "None", "TLS10", and "TLS12". - :paramtype minimum_tls_version: str or ~azure.mgmt.cdn.models.MinimumTlsVersion - """ - super().__init__(**kwargs) - self.certificate_source: Optional[str] = None - self.protocol_type = protocol_type - self.minimum_tls_version = minimum_tls_version - - -class CdnManagedHttpsParameters(CustomDomainHttpsParameters): - """Defines the certificate source parameters using CDN managed certificate for enabling SSL. - - All required parameters must be populated in order to send to server. - - :ivar certificate_source: Defines the source of the SSL certificate. Required. Known values - are: "AzureKeyVault" and "Cdn". - :vartype certificate_source: str or ~azure.mgmt.cdn.models.CertificateSource - :ivar protocol_type: Defines the TLS extension protocol that is used for secure delivery. - Required. Known values are: "ServerNameIndication" and "IPBased". - :vartype protocol_type: str or ~azure.mgmt.cdn.models.ProtocolType - :ivar minimum_tls_version: TLS protocol version that will be used for Https. Known values are: - "None", "TLS10", and "TLS12". - :vartype minimum_tls_version: str or ~azure.mgmt.cdn.models.MinimumTlsVersion - :ivar certificate_source_parameters: Defines the certificate source parameters using CDN - managed certificate for enabling SSL. Required. - :vartype certificate_source_parameters: ~azure.mgmt.cdn.models.CdnCertificateSourceParameters - """ - - _validation = { - "certificate_source": {"required": True}, - "protocol_type": {"required": True}, - "certificate_source_parameters": {"required": True}, - } - - _attribute_map = { - "certificate_source": {"key": "certificateSource", "type": "str"}, - "protocol_type": {"key": "protocolType", "type": "str"}, - "minimum_tls_version": {"key": "minimumTlsVersion", "type": "str"}, - "certificate_source_parameters": { - "key": "certificateSourceParameters", - "type": "CdnCertificateSourceParameters", - }, - } - - def __init__( - self, - *, - protocol_type: Union[str, "_models.ProtocolType"], - certificate_source_parameters: "_models.CdnCertificateSourceParameters", - minimum_tls_version: Optional[Union[str, "_models.MinimumTlsVersion"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword protocol_type: Defines the TLS extension protocol that is used for secure delivery. - Required. Known values are: "ServerNameIndication" and "IPBased". - :paramtype protocol_type: str or ~azure.mgmt.cdn.models.ProtocolType - :keyword minimum_tls_version: TLS protocol version that will be used for Https. Known values - are: "None", "TLS10", and "TLS12". - :paramtype minimum_tls_version: str or ~azure.mgmt.cdn.models.MinimumTlsVersion - :keyword certificate_source_parameters: Defines the certificate source parameters using CDN - managed certificate for enabling SSL. Required. - :paramtype certificate_source_parameters: ~azure.mgmt.cdn.models.CdnCertificateSourceParameters - """ - super().__init__(protocol_type=protocol_type, minimum_tls_version=minimum_tls_version, **kwargs) - self.certificate_source: str = "Cdn" - self.certificate_source_parameters = certificate_source_parameters - - -class CdnWebApplicationFirewallPolicy(TrackedResource): # pylint: disable=too-many-instance-attributes - """Defines web application firewall policy for Azure CDN. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to server. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar system_data: Read only system data. - :vartype system_data: ~azure.mgmt.cdn.models.SystemData - :ivar location: Resource location. Required. - :vartype location: str - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar etag: Gets a unique read-only string that changes whenever the resource is updated. - :vartype etag: str - :ivar sku: The pricing tier (defines a CDN provider, feature list and rate) of the - CdnWebApplicationFirewallPolicy. Required. - :vartype sku: ~azure.mgmt.cdn.models.Sku - :ivar policy_settings: Describes policySettings for policy. - :vartype policy_settings: ~azure.mgmt.cdn.models.PolicySettings - :ivar rate_limit_rules: Describes rate limit rules inside the policy. - :vartype rate_limit_rules: ~azure.mgmt.cdn.models.RateLimitRuleList - :ivar custom_rules: Describes custom rules inside the policy. - :vartype custom_rules: ~azure.mgmt.cdn.models.CustomRuleList - :ivar managed_rules: Describes managed rules inside the policy. - :vartype managed_rules: ~azure.mgmt.cdn.models.ManagedRuleSetList - :ivar endpoint_links: Describes Azure CDN endpoints associated with this Web Application - Firewall policy. - :vartype endpoint_links: list[~azure.mgmt.cdn.models.CdnEndpoint] - :ivar extended_properties: Key-Value pair representing additional properties for Web - Application Firewall policy. - :vartype extended_properties: dict[str, str] - :ivar provisioning_state: Provisioning state of the WebApplicationFirewallPolicy. Known values - are: "Creating", "Succeeded", and "Failed". - :vartype provisioning_state: str or ~azure.mgmt.cdn.models.ProvisioningState - :ivar resource_state: Resource status of the policy. Known values are: "Creating", "Enabling", - "Enabled", "Disabling", "Disabled", and "Deleting". - :vartype resource_state: str or ~azure.mgmt.cdn.models.PolicyResourceState - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - "location": {"required": True}, - "sku": {"required": True}, - "endpoint_links": {"readonly": True}, - "provisioning_state": {"readonly": True}, - "resource_state": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "etag": {"key": "etag", "type": "str"}, - "sku": {"key": "sku", "type": "Sku"}, - "policy_settings": {"key": "properties.policySettings", "type": "PolicySettings"}, - "rate_limit_rules": {"key": "properties.rateLimitRules", "type": "RateLimitRuleList"}, - "custom_rules": {"key": "properties.customRules", "type": "CustomRuleList"}, - "managed_rules": {"key": "properties.managedRules", "type": "ManagedRuleSetList"}, - "endpoint_links": {"key": "properties.endpointLinks", "type": "[CdnEndpoint]"}, - "extended_properties": {"key": "properties.extendedProperties", "type": "{str}"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "resource_state": {"key": "properties.resourceState", "type": "str"}, - } - - def __init__( - self, - *, - location: str, - sku: "_models.Sku", - tags: Optional[Dict[str, str]] = None, - etag: Optional[str] = None, - policy_settings: Optional["_models.PolicySettings"] = None, - rate_limit_rules: Optional["_models.RateLimitRuleList"] = None, - custom_rules: Optional["_models.CustomRuleList"] = None, - managed_rules: Optional["_models.ManagedRuleSetList"] = None, - extended_properties: Optional[Dict[str, str]] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword etag: Gets a unique read-only string that changes whenever the resource is updated. - :paramtype etag: str - :keyword sku: The pricing tier (defines a CDN provider, feature list and rate) of the - CdnWebApplicationFirewallPolicy. Required. - :paramtype sku: ~azure.mgmt.cdn.models.Sku - :keyword policy_settings: Describes policySettings for policy. - :paramtype policy_settings: ~azure.mgmt.cdn.models.PolicySettings - :keyword rate_limit_rules: Describes rate limit rules inside the policy. - :paramtype rate_limit_rules: ~azure.mgmt.cdn.models.RateLimitRuleList - :keyword custom_rules: Describes custom rules inside the policy. - :paramtype custom_rules: ~azure.mgmt.cdn.models.CustomRuleList - :keyword managed_rules: Describes managed rules inside the policy. - :paramtype managed_rules: ~azure.mgmt.cdn.models.ManagedRuleSetList - :keyword extended_properties: Key-Value pair representing additional properties for Web - Application Firewall policy. - :paramtype extended_properties: dict[str, str] - """ - super().__init__(location=location, tags=tags, **kwargs) - self.etag = etag - self.sku = sku - self.policy_settings = policy_settings - self.rate_limit_rules = rate_limit_rules - self.custom_rules = custom_rules - self.managed_rules = managed_rules - self.endpoint_links = None - self.extended_properties = extended_properties - self.provisioning_state = None - self.resource_state = None - - -class CdnWebApplicationFirewallPolicyList(_serialization.Model): - """Defines a list of WebApplicationFirewallPolicies for Azure CDN. It contains a list of - WebApplicationFirewallPolicy objects and a URL link to get the next set of results. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: List of Azure CDN WebApplicationFirewallPolicies within a resource group. - :vartype value: list[~azure.mgmt.cdn.models.CdnWebApplicationFirewallPolicy] - :ivar next_link: URL to get the next set of WebApplicationFirewallPolicy objects if there are - any. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[CdnWebApplicationFirewallPolicy]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword next_link: URL to get the next set of WebApplicationFirewallPolicy objects if there - are any. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = None - self.next_link = next_link - - -class CdnWebApplicationFirewallPolicyPatchParameters(_serialization.Model): # pylint: disable=name-too-long - """Properties required to update a CdnWebApplicationFirewallPolicy. - - :ivar tags: CdnWebApplicationFirewallPolicy tags. - :vartype tags: dict[str, str] - """ - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - } - - def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: - """ - :keyword tags: CdnWebApplicationFirewallPolicy tags. - :paramtype tags: dict[str, str] - """ - super().__init__(**kwargs) - self.tags = tags - - -class CheckEndpointNameAvailabilityInput(_serialization.Model): - """Input of CheckNameAvailability API. - - All required parameters must be populated in order to send to server. - - :ivar name: The resource name to validate. Required. - :vartype name: str - :ivar type: The type of the resource whose name is to be validated. Required. Known values are: - "Microsoft.Cdn/Profiles/Endpoints" and "Microsoft.Cdn/Profiles/AfdEndpoints". - :vartype type: str or ~azure.mgmt.cdn.models.ResourceType - :ivar auto_generated_domain_name_label_scope: Indicates the endpoint name reuse scope. The - default value is TenantReuse. Known values are: "TenantReuse", "SubscriptionReuse", - "ResourceGroupReuse", and "NoReuse". - :vartype auto_generated_domain_name_label_scope: str or - ~azure.mgmt.cdn.models.AutoGeneratedDomainNameLabelScope - """ - - _validation = { - "name": {"required": True}, - "type": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "auto_generated_domain_name_label_scope": {"key": "autoGeneratedDomainNameLabelScope", "type": "str"}, - } - - def __init__( - self, - *, - name: str, - type: Union[str, "_models.ResourceType"], - auto_generated_domain_name_label_scope: Optional[ - Union[str, "_models.AutoGeneratedDomainNameLabelScope"] - ] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The resource name to validate. Required. - :paramtype name: str - :keyword type: The type of the resource whose name is to be validated. Required. Known values - are: "Microsoft.Cdn/Profiles/Endpoints" and "Microsoft.Cdn/Profiles/AfdEndpoints". - :paramtype type: str or ~azure.mgmt.cdn.models.ResourceType - :keyword auto_generated_domain_name_label_scope: Indicates the endpoint name reuse scope. The - default value is TenantReuse. Known values are: "TenantReuse", "SubscriptionReuse", - "ResourceGroupReuse", and "NoReuse". - :paramtype auto_generated_domain_name_label_scope: str or - ~azure.mgmt.cdn.models.AutoGeneratedDomainNameLabelScope - """ - super().__init__(**kwargs) - self.name = name - self.type = type - self.auto_generated_domain_name_label_scope = auto_generated_domain_name_label_scope - - -class CheckEndpointNameAvailabilityOutput(_serialization.Model): - """Output of check name availability API. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name_available: Indicates whether the name is available. - :vartype name_available: bool - :ivar available_hostname: Returns the available hostname generated based on the - AutoGeneratedDomainNameLabelScope when the name is available, otherwise it returns empty - string. - :vartype available_hostname: str - :ivar reason: The reason why the name is not available. - :vartype reason: str - :ivar message: The detailed error message describing why the name is not available. - :vartype message: str - """ - - _validation = { - "name_available": {"readonly": True}, - "available_hostname": {"readonly": True}, - "reason": {"readonly": True}, - "message": {"readonly": True}, - } - - _attribute_map = { - "name_available": {"key": "nameAvailable", "type": "bool"}, - "available_hostname": {"key": "availableHostname", "type": "str"}, - "reason": {"key": "reason", "type": "str"}, - "message": {"key": "message", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.name_available = None - self.available_hostname = None - self.reason = None - self.message = None - - -class CheckHostNameAvailabilityInput(_serialization.Model): - """Input of CheckHostNameAvailability API. - - All required parameters must be populated in order to send to server. - - :ivar host_name: The host name to validate. Required. - :vartype host_name: str - """ - - _validation = { - "host_name": {"required": True}, - } - - _attribute_map = { - "host_name": {"key": "hostName", "type": "str"}, - } - - def __init__(self, *, host_name: str, **kwargs: Any) -> None: - """ - :keyword host_name: The host name to validate. Required. - :paramtype host_name: str - """ - super().__init__(**kwargs) - self.host_name = host_name - - -class CheckNameAvailabilityInput(_serialization.Model): - """Input of CheckNameAvailability API. - - All required parameters must be populated in order to send to server. - - :ivar name: The resource name to validate. Required. - :vartype name: str - :ivar type: The type of the resource whose name is to be validated. Required. Known values are: - "Microsoft.Cdn/Profiles/Endpoints" and "Microsoft.Cdn/Profiles/AfdEndpoints". - :vartype type: str or ~azure.mgmt.cdn.models.ResourceType - """ - - _validation = { - "name": {"required": True}, - "type": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - } - - def __init__(self, *, name: str, type: Union[str, "_models.ResourceType"], **kwargs: Any) -> None: - """ - :keyword name: The resource name to validate. Required. - :paramtype name: str - :keyword type: The type of the resource whose name is to be validated. Required. Known values - are: "Microsoft.Cdn/Profiles/Endpoints" and "Microsoft.Cdn/Profiles/AfdEndpoints". - :paramtype type: str or ~azure.mgmt.cdn.models.ResourceType - """ - super().__init__(**kwargs) - self.name = name - self.type = type - - -class CheckNameAvailabilityOutput(_serialization.Model): - """Output of check name availability API. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name_available: Indicates whether the name is available. - :vartype name_available: bool - :ivar reason: The reason why the name is not available. - :vartype reason: str - :ivar message: The detailed error message describing why the name is not available. - :vartype message: str - """ - - _validation = { - "name_available": {"readonly": True}, - "reason": {"readonly": True}, - "message": {"readonly": True}, - } - - _attribute_map = { - "name_available": {"key": "nameAvailable", "type": "bool"}, - "reason": {"key": "reason", "type": "str"}, - "message": {"key": "message", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.name_available = None - self.reason = None - self.message = None - - -class CidrIpAddress(_serialization.Model): - """CIDR Ip address. - - :ivar base_ip_address: Ip address itself. - :vartype base_ip_address: str - :ivar prefix_length: The length of the prefix of the ip address. - :vartype prefix_length: int - """ - - _attribute_map = { - "base_ip_address": {"key": "baseIpAddress", "type": "str"}, - "prefix_length": {"key": "prefixLength", "type": "int"}, - } - - def __init__( - self, *, base_ip_address: Optional[str] = None, prefix_length: Optional[int] = None, **kwargs: Any - ) -> None: - """ - :keyword base_ip_address: Ip address itself. - :paramtype base_ip_address: str - :keyword prefix_length: The length of the prefix of the ip address. - :paramtype prefix_length: int - """ - super().__init__(**kwargs) - self.base_ip_address = base_ip_address - self.prefix_length = prefix_length - - -class ClientPortMatchConditionParameters(_serialization.Model): - """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 operator: Describes operator to be matched. Required. Known values are: "Any", "Equal", - "Contains", "BeginsWith", "EndsWith", "LessThan", "LessThanOrEqual", "GreaterThan", - "GreaterThanOrEqual", and "RegEx". - :vartype operator: str or ~azure.mgmt.cdn.models.ClientPortOperator - :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] - :ivar transforms: List of transforms. - :vartype transforms: list[str or ~azure.mgmt.cdn.models.Transform] - """ - - _validation = { - "type_name": {"required": True}, - "operator": {"required": True}, - } - - _attribute_map = { - "type_name": {"key": "typeName", "type": "str"}, - "operator": {"key": "operator", "type": "str"}, - "negate_condition": {"key": "negateCondition", "type": "bool"}, - "match_values": {"key": "matchValues", "type": "[str]"}, - "transforms": {"key": "transforms", "type": "[str]"}, - } - - def __init__( - self, - *, - type_name: Union[str, "_models.ClientPortMatchConditionParametersTypeName"], - operator: Union[str, "_models.ClientPortOperator"], - negate_condition: bool = False, - match_values: Optional[List[str]] = None, - transforms: Optional[List[Union[str, "_models.Transform"]]] = None, - **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". - :paramtype operator: str or ~azure.mgmt.cdn.models.ClientPortOperator - :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] - :keyword transforms: List of transforms. - :paramtype transforms: list[str or ~azure.mgmt.cdn.models.Transform] - """ - super().__init__(**kwargs) - self.type_name = type_name - self.operator = operator - self.negate_condition = negate_condition - self.match_values = match_values - self.transforms = transforms - - -class Components18OrqelSchemasWafmetricsresponsePropertiesSeriesItemsPropertiesDataItems( - _serialization.Model -): # pylint: disable=name-too-long - """Components18OrqelSchemasWafmetricsresponsePropertiesSeriesItemsPropertiesDataItems. - - :ivar date_time: - :vartype date_time: ~datetime.datetime - :ivar value: - :vartype value: float - """ - - _attribute_map = { - "date_time": {"key": "dateTime", "type": "iso-8601"}, - "value": {"key": "value", "type": "float"}, - } - - def __init__( - self, *, date_time: Optional[datetime.datetime] = None, value: Optional[float] = None, **kwargs: Any - ) -> None: - """ - :keyword date_time: - :paramtype date_time: ~datetime.datetime - :keyword value: - :paramtype value: float - """ - super().__init__(**kwargs) - self.date_time = date_time - self.value = value - - -class Components1Gs0LlpSchemasMetricsresponsePropertiesSeriesItemsPropertiesDataItems( - _serialization.Model -): # pylint: disable=name-too-long - """Components1Gs0LlpSchemasMetricsresponsePropertiesSeriesItemsPropertiesDataItems. - - :ivar date_time: - :vartype date_time: ~datetime.datetime - :ivar value: - :vartype value: float - """ - - _attribute_map = { - "date_time": {"key": "dateTime", "type": "iso-8601"}, - "value": {"key": "value", "type": "float"}, - } - - def __init__( - self, *, date_time: Optional[datetime.datetime] = None, value: Optional[float] = None, **kwargs: Any - ) -> None: - """ - :keyword date_time: - :paramtype date_time: ~datetime.datetime - :keyword value: - :paramtype value: float - """ - super().__init__(**kwargs) - self.date_time = date_time - self.value = value - - -class ComponentsKpo1PjSchemasWafrankingsresponsePropertiesDataItemsPropertiesMetricsItems( - _serialization.Model -): # pylint: disable=name-too-long - """ComponentsKpo1PjSchemasWafrankingsresponsePropertiesDataItemsPropertiesMetricsItems. - - :ivar metric: - :vartype metric: str - :ivar value: - :vartype value: int - :ivar percentage: - :vartype percentage: float - """ - - _attribute_map = { - "metric": {"key": "metric", "type": "str"}, - "value": {"key": "value", "type": "int"}, - "percentage": {"key": "percentage", "type": "float"}, - } - - def __init__( - self, - *, - metric: Optional[str] = None, - value: Optional[int] = None, - percentage: Optional[float] = None, - **kwargs: Any - ) -> None: - """ - :keyword metric: - :paramtype metric: str - :keyword value: - :paramtype value: int - :keyword percentage: - :paramtype percentage: float - """ - super().__init__(**kwargs) - self.metric = metric - self.value = value - self.percentage = percentage - - -class CompressionSettings(_serialization.Model): - """settings for compression. - - :ivar content_types_to_compress: List of content types on which compression applies. The value - should be a valid MIME type. - :vartype content_types_to_compress: list[str] - :ivar is_compression_enabled: Indicates whether content compression is enabled on - AzureFrontDoor. Default value is false. If compression is enabled, content will be served as - compressed if user requests for a compressed version. Content won't be compressed on - AzureFrontDoor when requested content is smaller than 1 byte or larger than 1 MB. - :vartype is_compression_enabled: bool - """ - - _attribute_map = { - "content_types_to_compress": {"key": "contentTypesToCompress", "type": "[str]"}, - "is_compression_enabled": {"key": "isCompressionEnabled", "type": "bool"}, - } - - def __init__( - self, - *, - content_types_to_compress: Optional[List[str]] = None, - is_compression_enabled: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword content_types_to_compress: List of content types on which compression applies. The - value should be a valid MIME type. - :paramtype content_types_to_compress: list[str] - :keyword is_compression_enabled: Indicates whether content compression is enabled on - AzureFrontDoor. Default value is false. If compression is enabled, content will be served as - compressed if user requests for a compressed version. Content won't be compressed on - AzureFrontDoor when requested content is smaller than 1 byte or larger than 1 MB. - :paramtype is_compression_enabled: bool - """ - super().__init__(**kwargs) - self.content_types_to_compress = content_types_to_compress - self.is_compression_enabled = is_compression_enabled - - -class ContinentsResponse(_serialization.Model): - """Continents Response. - - :ivar continents: - :vartype continents: list[~azure.mgmt.cdn.models.ContinentsResponseContinentsItem] - :ivar country_or_regions: - :vartype country_or_regions: - list[~azure.mgmt.cdn.models.ContinentsResponseCountryOrRegionsItem] - """ - - _attribute_map = { - "continents": {"key": "continents", "type": "[ContinentsResponseContinentsItem]"}, - "country_or_regions": {"key": "countryOrRegions", "type": "[ContinentsResponseCountryOrRegionsItem]"}, - } - - def __init__( - self, - *, - continents: Optional[List["_models.ContinentsResponseContinentsItem"]] = None, - country_or_regions: Optional[List["_models.ContinentsResponseCountryOrRegionsItem"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword continents: - :paramtype continents: list[~azure.mgmt.cdn.models.ContinentsResponseContinentsItem] - :keyword country_or_regions: - :paramtype country_or_regions: - list[~azure.mgmt.cdn.models.ContinentsResponseCountryOrRegionsItem] - """ - super().__init__(**kwargs) - self.continents = continents - self.country_or_regions = country_or_regions - - -class ContinentsResponseContinentsItem(_serialization.Model): - """ContinentsResponseContinentsItem. - - :ivar id: - :vartype id: str - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - } - - def __init__(self, *, id: Optional[str] = None, **kwargs: Any) -> None: # pylint: disable=redefined-builtin - """ - :keyword id: - :paramtype id: str - """ - super().__init__(**kwargs) - self.id = id - - -class ContinentsResponseCountryOrRegionsItem(_serialization.Model): - """ContinentsResponseCountryOrRegionsItem. - - :ivar id: - :vartype id: str - :ivar continent_id: - :vartype continent_id: str - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "continent_id": {"key": "continentId", "type": "str"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - continent_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: - :paramtype id: str - :keyword continent_id: - :paramtype continent_id: str - """ - super().__init__(**kwargs) - self.id = id - self.continent_id = continent_id - - -class CookiesMatchConditionParameters(_serialization.Model): - """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 selector: Name of Cookies to be matched. - :vartype selector: str - :ivar operator: Describes operator to be matched. Required. Known values are: "Any", "Equal", - "Contains", "BeginsWith", "EndsWith", "LessThan", "LessThanOrEqual", "GreaterThan", - "GreaterThanOrEqual", and "RegEx". - :vartype operator: str or ~azure.mgmt.cdn.models.CookiesOperator - :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] - :ivar transforms: List of transforms. - :vartype transforms: list[str or ~azure.mgmt.cdn.models.Transform] - """ - - _validation = { - "type_name": {"required": True}, - "operator": {"required": True}, - } - - _attribute_map = { - "type_name": {"key": "typeName", "type": "str"}, - "selector": {"key": "selector", "type": "str"}, - "operator": {"key": "operator", "type": "str"}, - "negate_condition": {"key": "negateCondition", "type": "bool"}, - "match_values": {"key": "matchValues", "type": "[str]"}, - "transforms": {"key": "transforms", "type": "[str]"}, - } - - def __init__( - self, - *, - type_name: Union[str, "_models.CookiesMatchConditionParametersTypeName"], - operator: Union[str, "_models.CookiesOperator"], - selector: Optional[str] = None, - negate_condition: bool = False, - match_values: Optional[List[str]] = None, - transforms: Optional[List[Union[str, "_models.Transform"]]] = None, - **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", - "Equal", "Contains", "BeginsWith", "EndsWith", "LessThan", "LessThanOrEqual", "GreaterThan", - "GreaterThanOrEqual", and "RegEx". - :paramtype operator: str or ~azure.mgmt.cdn.models.CookiesOperator - :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] - :keyword transforms: List of transforms. - :paramtype transforms: list[str or ~azure.mgmt.cdn.models.Transform] - """ - super().__init__(**kwargs) - self.type_name = type_name - self.selector = selector - self.operator = operator - self.negate_condition = negate_condition - self.match_values = match_values - self.transforms = transforms - - -class CustomDomain(ProxyResource): # pylint: disable=too-many-instance-attributes - """Friendly domain name mapping to the endpoint hostname that the customer provides for branding - purposes, e.g. www.contoso.com. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar system_data: Read only system data. - :vartype system_data: ~azure.mgmt.cdn.models.SystemData - :ivar host_name: The host name of the custom domain. Must be a domain name. - :vartype host_name: str - :ivar resource_state: Resource status of the custom domain. Known values are: "Creating", - "Active", and "Deleting". - :vartype resource_state: str or ~azure.mgmt.cdn.models.CustomDomainResourceState - :ivar custom_https_provisioning_state: Provisioning status of the custom domain. Known values - are: "Enabling", "Enabled", "Disabling", "Disabled", and "Failed". - :vartype custom_https_provisioning_state: str or - ~azure.mgmt.cdn.models.CustomHttpsProvisioningState - :ivar custom_https_provisioning_substate: Provisioning substate shows the progress of custom - HTTPS enabling/disabling process step by step. Known values are: - "SubmittingDomainControlValidationRequest", "PendingDomainControlValidationREquestApproval", - "DomainControlValidationRequestApproved", "DomainControlValidationRequestRejected", - "DomainControlValidationRequestTimedOut", "IssuingCertificate", "DeployingCertificate", - "CertificateDeployed", "DeletingCertificate", and "CertificateDeleted". - :vartype custom_https_provisioning_substate: str or - ~azure.mgmt.cdn.models.CustomHttpsProvisioningSubstate - :ivar custom_https_parameters: Certificate parameters for securing custom HTTPS. - :vartype custom_https_parameters: ~azure.mgmt.cdn.models.CustomDomainHttpsParameters - :ivar validation_data: Special validation or data may be required when delivering CDN to some - regions due to local compliance reasons. E.g. ICP license number of a custom domain is required - to deliver content in China. - :vartype validation_data: str - :ivar provisioning_state: Provisioning status of Custom Https of the custom domain. Known - values are: "Enabling", "Enabled", "Disabling", "Disabled", and "Failed". - :vartype provisioning_state: str or ~azure.mgmt.cdn.models.CustomHttpsProvisioningState - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - "resource_state": {"readonly": True}, - "custom_https_provisioning_state": {"readonly": True}, - "custom_https_provisioning_substate": {"readonly": True}, - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "host_name": {"key": "properties.hostName", "type": "str"}, - "resource_state": {"key": "properties.resourceState", "type": "str"}, - "custom_https_provisioning_state": {"key": "properties.customHttpsProvisioningState", "type": "str"}, - "custom_https_provisioning_substate": {"key": "properties.customHttpsProvisioningSubstate", "type": "str"}, - "custom_https_parameters": {"key": "properties.customHttpsParameters", "type": "CustomDomainHttpsParameters"}, - "validation_data": {"key": "properties.validationData", "type": "str"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - } - - def __init__( - self, - *, - host_name: Optional[str] = None, - custom_https_parameters: Optional["_models.CustomDomainHttpsParameters"] = None, - validation_data: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword host_name: The host name of the custom domain. Must be a domain name. - :paramtype host_name: str - :keyword custom_https_parameters: Certificate parameters for securing custom HTTPS. - :paramtype custom_https_parameters: ~azure.mgmt.cdn.models.CustomDomainHttpsParameters - :keyword validation_data: Special validation or data may be required when delivering CDN to - some regions due to local compliance reasons. E.g. ICP license number of a custom domain is - required to deliver content in China. - :paramtype validation_data: str - """ - 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.custom_https_parameters = custom_https_parameters - self.validation_data = validation_data - self.provisioning_state = None - - -class CustomDomainListResult(_serialization.Model): - """Result of the request to list custom domains. It contains a list of custom domain objects and a - URL link to get the next set of results. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: List of CDN CustomDomains within an endpoint. - :vartype value: list[~azure.mgmt.cdn.models.CustomDomain] - :ivar next_link: URL to get the next set of custom domain objects if there are any. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[CustomDomain]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword next_link: URL to get the next set of custom domain objects if there are any. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = None - self.next_link = next_link - - -class CustomDomainParameters(_serialization.Model): - """The customDomain JSON object required for custom domain creation or update. - - :ivar host_name: The host name of the custom domain. Must be a domain name. - :vartype host_name: str - """ - - _attribute_map = { - "host_name": {"key": "properties.hostName", "type": "str"}, - } - - def __init__(self, *, host_name: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword host_name: The host name of the custom domain. Must be a domain name. - :paramtype host_name: str - """ - super().__init__(**kwargs) - self.host_name = host_name - - -class CustomerCertificate(Certificate): - """Customer Certificate used for https. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The type of the secret resource. Known values are: "UrlSigningKey", - "CustomerCertificate", "ManagedCertificate", and "AzureFirstPartyManagedCertificate". - :vartype type: str or ~azure.mgmt.cdn.models.SecretType - :ivar subject: Subject name in the certificate. - :vartype subject: str - :ivar expiration_date: Certificate expiration date. - :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 - :vartype secret_source: ~azure.mgmt.cdn.models.ResourceReference - :ivar secret_version: Certificate version. - :vartype secret_version: str - :ivar certificate_authority: Certificate issuing authority. - :vartype certificate_authority: str - :ivar use_latest_version: Whether to use the latest version for the certificate. - :vartype use_latest_version: bool - :ivar subject_alternative_names: The list of SANs. - :vartype subject_alternative_names: list[str] - :ivar thumbprint: Certificate thumbprint. - :vartype thumbprint: str - """ - - _validation = { - "subject": {"readonly": True}, - "expiration_date": {"readonly": True}, - "certificate_authority": {"readonly": True}, - "thumbprint": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "subject": {"key": "subject", "type": "str"}, - "expiration_date": {"key": "expirationDate", "type": "str"}, - "secret_source": {"key": "secretSource", "type": "ResourceReference"}, - "secret_version": {"key": "secretVersion", "type": "str"}, - "certificate_authority": {"key": "certificateAuthority", "type": "str"}, - "use_latest_version": {"key": "useLatestVersion", "type": "bool"}, - "subject_alternative_names": {"key": "subjectAlternativeNames", "type": "[str]"}, - "thumbprint": {"key": "thumbprint", "type": "str"}, - } - - def __init__( - self, - *, - type: Optional[Union[str, "_models.SecretType"]] = None, - secret_source: Optional["_models.ResourceReference"] = None, - secret_version: Optional[str] = None, - use_latest_version: Optional[bool] = None, - subject_alternative_names: Optional[List[str]] = None, - **kwargs: Any - ) -> None: - """ - :keyword type: The type of the secret resource. Known values are: "UrlSigningKey", - "CustomerCertificate", "ManagedCertificate", and "AzureFirstPartyManagedCertificate". - :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 - :paramtype secret_source: ~azure.mgmt.cdn.models.ResourceReference - :keyword secret_version: Certificate version. - :paramtype secret_version: str - :keyword use_latest_version: Whether to use the latest version for the certificate. - :paramtype use_latest_version: bool - :keyword subject_alternative_names: The list of SANs. - :paramtype subject_alternative_names: list[str] - """ - super().__init__(type=type, **kwargs) - self.secret_source = secret_source - self.secret_version = secret_version - self.certificate_authority = None - self.use_latest_version = use_latest_version - self.subject_alternative_names = subject_alternative_names - self.thumbprint = None - - -class CustomerCertificateParameters(SecretParameters): - """Customer Certificate used for https. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to server. - - :ivar type: The type of the secret resource. Required. Known values are: "UrlSigningKey", - "CustomerCertificate", "ManagedCertificate", and "AzureFirstPartyManagedCertificate". - :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 - Required. - :vartype secret_source: ~azure.mgmt.cdn.models.ResourceReference - :ivar secret_version: Version of the secret to be used. - :vartype secret_version: str - :ivar use_latest_version: Whether to use the latest version for the certificate. - :vartype use_latest_version: bool - :ivar subject: Subject name in the certificate. - :vartype subject: str - :ivar expiration_date: Certificate expiration date. - :vartype expiration_date: str - :ivar certificate_authority: Certificate issuing authority. - :vartype certificate_authority: str - :ivar subject_alternative_names: The list of SANs. - :vartype subject_alternative_names: list[str] - :ivar thumbprint: Certificate thumbprint. - :vartype thumbprint: str - """ - - _validation = { - "type": {"required": True}, - "secret_source": {"required": True}, - "subject": {"readonly": True}, - "expiration_date": {"readonly": True}, - "certificate_authority": {"readonly": True}, - "thumbprint": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "secret_source": {"key": "secretSource", "type": "ResourceReference"}, - "secret_version": {"key": "secretVersion", "type": "str"}, - "use_latest_version": {"key": "useLatestVersion", "type": "bool"}, - "subject": {"key": "subject", "type": "str"}, - "expiration_date": {"key": "expirationDate", "type": "str"}, - "certificate_authority": {"key": "certificateAuthority", "type": "str"}, - "subject_alternative_names": {"key": "subjectAlternativeNames", "type": "[str]"}, - "thumbprint": {"key": "thumbprint", "type": "str"}, - } - - def __init__( - self, - *, - secret_source: "_models.ResourceReference", - secret_version: Optional[str] = None, - use_latest_version: Optional[bool] = None, - subject_alternative_names: Optional[List[str]] = None, - **kwargs: Any - ) -> None: - """ - :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 - Required. - :paramtype secret_source: ~azure.mgmt.cdn.models.ResourceReference - :keyword secret_version: Version of the secret to be used. - :paramtype secret_version: str - :keyword use_latest_version: Whether to use the latest version for the certificate. - :paramtype use_latest_version: bool - :keyword subject_alternative_names: The list of SANs. - :paramtype subject_alternative_names: list[str] - """ - super().__init__(**kwargs) - self.type: str = "CustomerCertificate" - 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_alternative_names = subject_alternative_names - self.thumbprint = None - - -class CustomRule(_serialization.Model): - """Defines the common attributes for a custom rule that can be included in a waf policy. - - All required parameters must be populated in order to send to server. - - :ivar name: Defines the name of the custom rule. Required. - :vartype name: str - :ivar enabled_state: Describes if the custom rule is in enabled or disabled state. Defaults to - Enabled if not specified. Known values are: "Disabled" and "Enabled". - :vartype enabled_state: str or ~azure.mgmt.cdn.models.CustomRuleEnabledState - :ivar priority: Defines in what order this rule be evaluated in the overall list of custom - rules. Required. - :vartype priority: int - :ivar match_conditions: List of match conditions. Required. - :vartype match_conditions: list[~azure.mgmt.cdn.models.MatchCondition] - :ivar action: Describes what action to be applied when rule matches. Required. Known values - are: "Allow", "Block", "Log", and "Redirect". - :vartype action: str or ~azure.mgmt.cdn.models.ActionType - """ - - _validation = { - "name": {"required": True}, - "priority": {"required": True, "maximum": 1000, "minimum": 0}, - "match_conditions": {"required": True}, - "action": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "enabled_state": {"key": "enabledState", "type": "str"}, - "priority": {"key": "priority", "type": "int"}, - "match_conditions": {"key": "matchConditions", "type": "[MatchCondition]"}, - "action": {"key": "action", "type": "str"}, - } - - def __init__( - self, - *, - name: str, - priority: int, - match_conditions: List["_models.MatchCondition"], - action: Union[str, "_models.ActionType"], - enabled_state: Optional[Union[str, "_models.CustomRuleEnabledState"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: Defines the name of the custom rule. Required. - :paramtype name: str - :keyword enabled_state: Describes if the custom rule is in enabled or disabled state. Defaults - to Enabled if not specified. Known values are: "Disabled" and "Enabled". - :paramtype enabled_state: str or ~azure.mgmt.cdn.models.CustomRuleEnabledState - :keyword priority: Defines in what order this rule be evaluated in the overall list of custom - rules. Required. - :paramtype priority: int - :keyword match_conditions: List of match conditions. Required. - :paramtype match_conditions: list[~azure.mgmt.cdn.models.MatchCondition] - :keyword action: Describes what action to be applied when rule matches. Required. Known values - are: "Allow", "Block", "Log", and "Redirect". - :paramtype action: str or ~azure.mgmt.cdn.models.ActionType - """ - super().__init__(**kwargs) - self.name = name - self.enabled_state = enabled_state - self.priority = priority - self.match_conditions = match_conditions - self.action = action - - -class CustomRuleList(_serialization.Model): - """Defines contents of custom rules. - - :ivar rules: List of rules. - :vartype rules: list[~azure.mgmt.cdn.models.CustomRule] - """ - - _attribute_map = { - "rules": {"key": "rules", "type": "[CustomRule]"}, - } - - def __init__(self, *, rules: Optional[List["_models.CustomRule"]] = None, **kwargs: Any) -> None: - """ - :keyword rules: List of rules. - :paramtype rules: list[~azure.mgmt.cdn.models.CustomRule] - """ - super().__init__(**kwargs) - self.rules = rules - - -class DeepCreatedCustomDomain(_serialization.Model): - """Custom domains created on the CDN endpoint. - - All required parameters must be populated in order to send to server. - - :ivar name: Custom domain name. Required. - :vartype name: str - :ivar host_name: The host name of the custom domain. Must be a domain name. - :vartype host_name: str - :ivar validation_data: Special validation or data may be required when delivering CDN to some - regions due to local compliance reasons. E.g. ICP license number of a custom domain is required - to deliver content in China. - :vartype validation_data: str - """ - - _validation = { - "name": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "host_name": {"key": "properties.hostName", "type": "str"}, - "validation_data": {"key": "properties.validationData", "type": "str"}, - } - - def __init__( - self, *, name: str, host_name: Optional[str] = None, validation_data: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword name: Custom domain name. Required. - :paramtype name: str - :keyword host_name: The host name of the custom domain. Must be a domain name. - :paramtype host_name: str - :keyword validation_data: Special validation or data may be required when delivering CDN to - some regions due to local compliance reasons. E.g. ICP license number of a custom domain is - required to deliver content in China. - :paramtype validation_data: str - """ - super().__init__(**kwargs) - self.name = name - self.host_name = host_name - self.validation_data = validation_data - - -class DeepCreatedOrigin(_serialization.Model): # pylint: disable=too-many-instance-attributes - """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. - - All required parameters must be populated in order to send to server. - - :ivar name: Origin name which must be unique within the endpoint. Required. - :vartype name: str - :ivar host_name: The address of the origin. It can be a domain name, IPv4 address, or IPv6 - address. This should be unique across all origins in an endpoint. - :vartype host_name: str - :ivar http_port: The value of the HTTP port. Must be between 1 and 65535. - :vartype http_port: int - :ivar https_port: The value of the HTTPS port. Must be between 1 and 65535. - :vartype https_port: int - :ivar origin_host_header: The host header value sent to the origin with each request. If you - leave this blank, the request hostname determines this value. Azure CDN origins, such as Web - Apps, Blob Storage, and Cloud Services require this host header value to match the origin - hostname by default. - :vartype origin_host_header: str - :ivar priority: Priority of origin in given origin group for load balancing. Higher priorities - will not be used for load balancing if any lower priority origin is healthy.Must be between 1 - and 5. - :vartype priority: int - :ivar weight: Weight of the origin in given origin group for load balancing. Must be between 1 - and 1000. - :vartype weight: int - :ivar enabled: Origin is enabled for load balancing or not. By default, origin is always - enabled. - :vartype enabled: bool - :ivar private_link_alias: The Alias of the Private Link resource. Populating this optional - field indicates that this origin is 'Private'. - :vartype private_link_alias: str - :ivar private_link_resource_id: The Resource Id of the Private Link resource. Populating this - optional field indicates that this backend is 'Private'. - :vartype private_link_resource_id: str - :ivar private_link_location: The location of the Private Link resource. Required only if - 'privateLinkResourceId' is populated. - :vartype private_link_location: str - :ivar private_link_approval_message: A custom message to be included in the approval request to - connect to the Private Link. - :vartype private_link_approval_message: str - :ivar private_endpoint_status: The approval status for the connection to the Private Link. - Known values are: "Pending", "Approved", "Rejected", "Disconnected", and "Timeout". - :vartype private_endpoint_status: str or ~azure.mgmt.cdn.models.PrivateEndpointStatus - """ - - _validation = { - "name": {"required": True}, - "http_port": {"maximum": 65535, "minimum": 1}, - "https_port": {"maximum": 65535, "minimum": 1}, - "priority": {"maximum": 5, "minimum": 1}, - "weight": {"maximum": 1000, "minimum": 1}, - "private_endpoint_status": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "host_name": {"key": "properties.hostName", "type": "str"}, - "http_port": {"key": "properties.httpPort", "type": "int"}, - "https_port": {"key": "properties.httpsPort", "type": "int"}, - "origin_host_header": {"key": "properties.originHostHeader", "type": "str"}, - "priority": {"key": "properties.priority", "type": "int"}, - "weight": {"key": "properties.weight", "type": "int"}, - "enabled": {"key": "properties.enabled", "type": "bool"}, - "private_link_alias": {"key": "properties.privateLinkAlias", "type": "str"}, - "private_link_resource_id": {"key": "properties.privateLinkResourceId", "type": "str"}, - "private_link_location": {"key": "properties.privateLinkLocation", "type": "str"}, - "private_link_approval_message": {"key": "properties.privateLinkApprovalMessage", "type": "str"}, - "private_endpoint_status": {"key": "properties.privateEndpointStatus", "type": "str"}, - } - - def __init__( - self, - *, - name: str, - host_name: Optional[str] = None, - http_port: Optional[int] = None, - https_port: Optional[int] = None, - origin_host_header: Optional[str] = None, - priority: Optional[int] = None, - weight: Optional[int] = None, - enabled: Optional[bool] = None, - private_link_alias: Optional[str] = None, - private_link_resource_id: Optional[str] = None, - private_link_location: Optional[str] = None, - private_link_approval_message: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: Origin name which must be unique within the endpoint. Required. - :paramtype name: str - :keyword host_name: The address of the origin. It can be a domain name, IPv4 address, or IPv6 - address. This should be unique across all origins in an endpoint. - :paramtype host_name: str - :keyword http_port: The value of the HTTP port. Must be between 1 and 65535. - :paramtype http_port: int - :keyword https_port: The value of the HTTPS port. Must be between 1 and 65535. - :paramtype https_port: int - :keyword origin_host_header: The host header value sent to the origin with each request. If you - leave this blank, the request hostname determines this value. Azure CDN origins, such as Web - Apps, Blob Storage, and Cloud Services require this host header value to match the origin - hostname by default. - :paramtype origin_host_header: str - :keyword priority: Priority of origin in given origin group for load balancing. Higher - priorities will not be used for load balancing if any lower priority origin is healthy.Must be - between 1 and 5. - :paramtype priority: int - :keyword weight: Weight of the origin in given origin group for load balancing. Must be between - 1 and 1000. - :paramtype weight: int - :keyword enabled: Origin is enabled for load balancing or not. By default, origin is always - enabled. - :paramtype enabled: bool - :keyword private_link_alias: The Alias of the Private Link resource. Populating this optional - field indicates that this origin is 'Private'. - :paramtype private_link_alias: str - :keyword private_link_resource_id: The Resource Id of the Private Link resource. Populating - this optional field indicates that this backend is 'Private'. - :paramtype private_link_resource_id: str - :keyword private_link_location: The location of the Private Link resource. Required only if - 'privateLinkResourceId' is populated. - :paramtype private_link_location: str - :keyword private_link_approval_message: A custom message to be included in the approval request - to connect to the Private Link. - :paramtype private_link_approval_message: str - """ - super().__init__(**kwargs) - self.name = name - self.host_name = host_name - self.http_port = http_port - self.https_port = https_port - self.origin_host_header = origin_host_header - self.priority = priority - self.weight = weight - self.enabled = enabled - self.private_link_alias = private_link_alias - 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 - - -class DeepCreatedOriginGroup(_serialization.Model): - """The origin group for CDN content which is added when creating a CDN endpoint. Traffic is sent - to the origins within the origin group based on origin health. - - All required parameters must be populated in order to send to server. - - :ivar name: Origin group name which must be unique within the endpoint. Required. - :vartype name: str - :ivar health_probe_settings: Health probe settings to the origin that is used to determine the - health of the origin. - :vartype health_probe_settings: ~azure.mgmt.cdn.models.HealthProbeParameters - :ivar origins: The source of the content being delivered via CDN within given origin group. - :vartype origins: list[~azure.mgmt.cdn.models.ResourceReference] - :ivar traffic_restoration_time_to_healed_or_new_endpoints_in_minutes: Time in minutes to shift - the traffic to the endpoint gradually when an unhealthy endpoint comes healthy or a new - endpoint is added. Default is 10 mins. This property is currently not supported. - :vartype traffic_restoration_time_to_healed_or_new_endpoints_in_minutes: int - :ivar response_based_origin_error_detection_settings: The JSON object that contains the - properties to determine origin health using real requests/responses.This property is currently - not supported. - :vartype response_based_origin_error_detection_settings: - ~azure.mgmt.cdn.models.ResponseBasedOriginErrorDetectionParameters - """ - - _validation = { - "name": {"required": True}, - "traffic_restoration_time_to_healed_or_new_endpoints_in_minutes": {"maximum": 50, "minimum": 0}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "health_probe_settings": {"key": "properties.healthProbeSettings", "type": "HealthProbeParameters"}, - "origins": {"key": "properties.origins", "type": "[ResourceReference]"}, - "traffic_restoration_time_to_healed_or_new_endpoints_in_minutes": { - "key": "properties.trafficRestorationTimeToHealedOrNewEndpointsInMinutes", - "type": "int", - }, - "response_based_origin_error_detection_settings": { - "key": "properties.responseBasedOriginErrorDetectionSettings", - "type": "ResponseBasedOriginErrorDetectionParameters", - }, - } - - def __init__( - self, - *, - name: str, - health_probe_settings: Optional["_models.HealthProbeParameters"] = None, - origins: Optional[List["_models.ResourceReference"]] = None, - traffic_restoration_time_to_healed_or_new_endpoints_in_minutes: Optional[int] = None, - response_based_origin_error_detection_settings: Optional[ - "_models.ResponseBasedOriginErrorDetectionParameters" - ] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: Origin group name which must be unique within the endpoint. Required. - :paramtype name: str - :keyword health_probe_settings: Health probe settings to the origin that is used to determine - the health of the origin. - :paramtype health_probe_settings: ~azure.mgmt.cdn.models.HealthProbeParameters - :keyword origins: The source of the content being delivered via CDN within given origin group. - :paramtype origins: list[~azure.mgmt.cdn.models.ResourceReference] - :keyword traffic_restoration_time_to_healed_or_new_endpoints_in_minutes: Time in minutes to - shift the traffic to the endpoint gradually when an unhealthy endpoint comes healthy or a new - endpoint is added. Default is 10 mins. This property is currently not supported. - :paramtype traffic_restoration_time_to_healed_or_new_endpoints_in_minutes: int - :keyword response_based_origin_error_detection_settings: The JSON object that contains the - properties to determine origin health using real requests/responses.This property is currently - not supported. - :paramtype response_based_origin_error_detection_settings: - ~azure.mgmt.cdn.models.ResponseBasedOriginErrorDetectionParameters - """ - super().__init__(**kwargs) - self.name = name - self.health_probe_settings = health_probe_settings - self.origins = origins - self.traffic_restoration_time_to_healed_or_new_endpoints_in_minutes = ( - traffic_restoration_time_to_healed_or_new_endpoints_in_minutes - ) - self.response_based_origin_error_detection_settings = response_based_origin_error_detection_settings - - -class DeliveryRule(_serialization.Model): - """A rule that specifies a set of actions and conditions. - - All required parameters must be populated in order to send to server. - - :ivar name: Name of the rule. - :vartype name: str - :ivar order: The order in which the rules are applied for the endpoint. Possible values - {0,1,2,3,………}. A rule with a lesser order will be applied before a rule with a greater order. - Rule with order 0 is a special rule. It does not require any condition and actions listed in it - will always be applied. Required. - :vartype order: int - :ivar conditions: A list of conditions that must be matched for the actions to be executed. - :vartype conditions: list[~azure.mgmt.cdn.models.DeliveryRuleCondition] - :ivar actions: A list of actions that are executed when all the conditions of a rule are - satisfied. Required. - :vartype actions: list[~azure.mgmt.cdn.models.DeliveryRuleAction] - """ - - _validation = { - "order": {"required": True}, - "actions": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "order": {"key": "order", "type": "int"}, - "conditions": {"key": "conditions", "type": "[DeliveryRuleCondition]"}, - "actions": {"key": "actions", "type": "[DeliveryRuleAction]"}, - } - - def __init__( - self, - *, - order: int, - actions: List["_models.DeliveryRuleAction"], - name: Optional[str] = None, - conditions: Optional[List["_models.DeliveryRuleCondition"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: Name of the rule. - :paramtype name: str - :keyword order: The order in which the rules are applied for the endpoint. Possible values - {0,1,2,3,………}. A rule with a lesser order will be applied before a rule with a greater order. - Rule with order 0 is a special rule. It does not require any condition and actions listed in it - will always be applied. Required. - :paramtype order: int - :keyword conditions: A list of conditions that must be matched for the actions to be executed. - :paramtype conditions: list[~azure.mgmt.cdn.models.DeliveryRuleCondition] - :keyword actions: A list of actions that are executed when all the conditions of a rule are - satisfied. Required. - :paramtype actions: list[~azure.mgmt.cdn.models.DeliveryRuleAction] - """ - super().__init__(**kwargs) - self.name = name - self.order = order - self.conditions = conditions - self.actions = actions - - -class DeliveryRuleAction(_serialization.Model): - """An action for the delivery rule. - - You probably want to use the sub-classes and not this class directly. Known sub-classes are: - DeliveryRuleCacheExpirationAction, DeliveryRuleCacheKeyQueryStringAction, - DeliveryRuleRequestHeaderAction, DeliveryRuleResponseHeaderAction, OriginGroupOverrideAction, - DeliveryRuleRouteConfigurationOverrideAction, UrlRedirectAction, UrlRewriteAction, - UrlSigningAction - - All required parameters must be populated in order to send to server. - - :ivar name: The name of the action for the delivery rule. Required. Known values are: - "CacheExpiration", "CacheKeyQueryString", "ModifyRequestHeader", "ModifyResponseHeader", - "UrlRedirect", "UrlRewrite", "UrlSigning", "OriginGroupOverride", and - "RouteConfigurationOverride". - :vartype name: str or ~azure.mgmt.cdn.models.DeliveryRuleActionEnum - """ - - _validation = { - "name": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - } - - _subtype_map = { - "name": { - "CacheExpiration": "DeliveryRuleCacheExpirationAction", - "CacheKeyQueryString": "DeliveryRuleCacheKeyQueryStringAction", - "ModifyRequestHeader": "DeliveryRuleRequestHeaderAction", - "ModifyResponseHeader": "DeliveryRuleResponseHeaderAction", - "OriginGroupOverride": "OriginGroupOverrideAction", - "RouteConfigurationOverride": "DeliveryRuleRouteConfigurationOverrideAction", - "UrlRedirect": "UrlRedirectAction", - "UrlRewrite": "UrlRewriteAction", - "UrlSigning": "UrlSigningAction", - } - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.name: Optional[str] = None - - -class DeliveryRuleCacheExpirationAction(DeliveryRuleAction): - """Defines the cache expiration action for the delivery rule. - - All required parameters must be populated in order to send to server. - - :ivar name: The name of the action for the delivery rule. Required. Known values are: - "CacheExpiration", "CacheKeyQueryString", "ModifyRequestHeader", "ModifyResponseHeader", - "UrlRedirect", "UrlRewrite", "UrlSigning", "OriginGroupOverride", and - "RouteConfigurationOverride". - :vartype name: str or ~azure.mgmt.cdn.models.DeliveryRuleActionEnum - :ivar parameters: Defines the parameters for the action. Required. - :vartype parameters: ~azure.mgmt.cdn.models.CacheExpirationActionParameters - """ - - _validation = { - "name": {"required": True}, - "parameters": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "parameters": {"key": "parameters", "type": "CacheExpirationActionParameters"}, - } - - def __init__(self, *, parameters: "_models.CacheExpirationActionParameters", **kwargs: Any) -> None: - """ - :keyword parameters: Defines the parameters for the action. Required. - :paramtype parameters: ~azure.mgmt.cdn.models.CacheExpirationActionParameters - """ - super().__init__(**kwargs) - self.name: str = "CacheExpiration" - self.parameters = parameters - - -class DeliveryRuleCacheKeyQueryStringAction(DeliveryRuleAction): - """Defines the cache-key query string action for the delivery rule. - - All required parameters must be populated in order to send to server. - - :ivar name: The name of the action for the delivery rule. Required. Known values are: - "CacheExpiration", "CacheKeyQueryString", "ModifyRequestHeader", "ModifyResponseHeader", - "UrlRedirect", "UrlRewrite", "UrlSigning", "OriginGroupOverride", and - "RouteConfigurationOverride". - :vartype name: str or ~azure.mgmt.cdn.models.DeliveryRuleActionEnum - :ivar parameters: Defines the parameters for the action. Required. - :vartype parameters: ~azure.mgmt.cdn.models.CacheKeyQueryStringActionParameters - """ - - _validation = { - "name": {"required": True}, - "parameters": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "parameters": {"key": "parameters", "type": "CacheKeyQueryStringActionParameters"}, - } - - def __init__(self, *, parameters: "_models.CacheKeyQueryStringActionParameters", **kwargs: Any) -> None: - """ - :keyword parameters: Defines the parameters for the action. Required. - :paramtype parameters: ~azure.mgmt.cdn.models.CacheKeyQueryStringActionParameters - """ - super().__init__(**kwargs) - self.name: str = "CacheKeyQueryString" - self.parameters = parameters - - -class DeliveryRuleCondition(_serialization.Model): - """A condition for the delivery rule. - - You probably want to use the sub-classes and not this class directly. Known sub-classes are: - DeliveryRuleClientPortCondition, DeliveryRuleCookiesCondition, DeliveryRuleHostNameCondition, - DeliveryRuleHttpVersionCondition, DeliveryRuleIsDeviceCondition, DeliveryRulePostArgsCondition, - DeliveryRuleQueryStringCondition, DeliveryRuleRemoteAddressCondition, - DeliveryRuleRequestBodyCondition, DeliveryRuleRequestHeaderCondition, - DeliveryRuleRequestMethodCondition, DeliveryRuleRequestSchemeCondition, - DeliveryRuleRequestUriCondition, DeliveryRuleServerPortCondition, - DeliveryRuleSocketAddrCondition, DeliveryRuleSslProtocolCondition, - DeliveryRuleUrlFileExtensionCondition, DeliveryRuleUrlFileNameCondition, - DeliveryRuleUrlPathCondition - - All required parameters must be populated in order to send to server. - - :ivar name: The name of the condition for the delivery rule. Required. Known values are: - "RemoteAddress", "RequestMethod", "QueryString", "PostArgs", "RequestUri", "RequestHeader", - "RequestBody", "RequestScheme", "UrlPath", "UrlFileExtension", "UrlFileName", "HttpVersion", - "Cookies", "IsDevice", "SocketAddr", "ClientPort", "ServerPort", "HostName", and "SslProtocol". - :vartype name: str or ~azure.mgmt.cdn.models.MatchVariable - """ - - _validation = { - "name": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - } - - _subtype_map = { - "name": { - "ClientPort": "DeliveryRuleClientPortCondition", - "Cookies": "DeliveryRuleCookiesCondition", - "HostName": "DeliveryRuleHostNameCondition", - "HttpVersion": "DeliveryRuleHttpVersionCondition", - "IsDevice": "DeliveryRuleIsDeviceCondition", - "PostArgs": "DeliveryRulePostArgsCondition", - "QueryString": "DeliveryRuleQueryStringCondition", - "RemoteAddress": "DeliveryRuleRemoteAddressCondition", - "RequestBody": "DeliveryRuleRequestBodyCondition", - "RequestHeader": "DeliveryRuleRequestHeaderCondition", - "RequestMethod": "DeliveryRuleRequestMethodCondition", - "RequestScheme": "DeliveryRuleRequestSchemeCondition", - "RequestUri": "DeliveryRuleRequestUriCondition", - "ServerPort": "DeliveryRuleServerPortCondition", - "SocketAddr": "DeliveryRuleSocketAddrCondition", - "SslProtocol": "DeliveryRuleSslProtocolCondition", - "UrlFileExtension": "DeliveryRuleUrlFileExtensionCondition", - "UrlFileName": "DeliveryRuleUrlFileNameCondition", - "UrlPath": "DeliveryRuleUrlPathCondition", - } - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.name: Optional[str] = None - - -class DeliveryRuleClientPortCondition(DeliveryRuleCondition): - """Defines the ClientPort condition for the delivery rule. - - All required parameters must be populated in order to send to server. - - :ivar name: The name of the condition for the delivery rule. Required. Known values are: - "RemoteAddress", "RequestMethod", "QueryString", "PostArgs", "RequestUri", "RequestHeader", - "RequestBody", "RequestScheme", "UrlPath", "UrlFileExtension", "UrlFileName", "HttpVersion", - "Cookies", "IsDevice", "SocketAddr", "ClientPort", "ServerPort", "HostName", and "SslProtocol". - :vartype name: str or ~azure.mgmt.cdn.models.MatchVariable - :ivar parameters: Defines the parameters for the condition. Required. - :vartype parameters: ~azure.mgmt.cdn.models.ClientPortMatchConditionParameters - """ - - _validation = { - "name": {"required": True}, - "parameters": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "parameters": {"key": "parameters", "type": "ClientPortMatchConditionParameters"}, - } - - def __init__(self, *, parameters: "_models.ClientPortMatchConditionParameters", **kwargs: Any) -> None: - """ - :keyword parameters: Defines the parameters for the condition. Required. - :paramtype parameters: ~azure.mgmt.cdn.models.ClientPortMatchConditionParameters - """ - super().__init__(**kwargs) - self.name: str = "ClientPort" - self.parameters = parameters - - -class DeliveryRuleCookiesCondition(DeliveryRuleCondition): - """Defines the Cookies condition for the delivery rule. - - All required parameters must be populated in order to send to server. - - :ivar name: The name of the condition for the delivery rule. Required. Known values are: - "RemoteAddress", "RequestMethod", "QueryString", "PostArgs", "RequestUri", "RequestHeader", - "RequestBody", "RequestScheme", "UrlPath", "UrlFileExtension", "UrlFileName", "HttpVersion", - "Cookies", "IsDevice", "SocketAddr", "ClientPort", "ServerPort", "HostName", and "SslProtocol". - :vartype name: str or ~azure.mgmt.cdn.models.MatchVariable - :ivar parameters: Defines the parameters for the condition. Required. - :vartype parameters: ~azure.mgmt.cdn.models.CookiesMatchConditionParameters - """ - - _validation = { - "name": {"required": True}, - "parameters": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "parameters": {"key": "parameters", "type": "CookiesMatchConditionParameters"}, - } - - def __init__(self, *, parameters: "_models.CookiesMatchConditionParameters", **kwargs: Any) -> None: - """ - :keyword parameters: Defines the parameters for the condition. Required. - :paramtype parameters: ~azure.mgmt.cdn.models.CookiesMatchConditionParameters - """ - super().__init__(**kwargs) - self.name: str = "Cookies" - self.parameters = parameters - - -class DeliveryRuleHostNameCondition(DeliveryRuleCondition): - """Defines the HostName condition for the delivery rule. - - All required parameters must be populated in order to send to server. - - :ivar name: The name of the condition for the delivery rule. Required. Known values are: - "RemoteAddress", "RequestMethod", "QueryString", "PostArgs", "RequestUri", "RequestHeader", - "RequestBody", "RequestScheme", "UrlPath", "UrlFileExtension", "UrlFileName", "HttpVersion", - "Cookies", "IsDevice", "SocketAddr", "ClientPort", "ServerPort", "HostName", and "SslProtocol". - :vartype name: str or ~azure.mgmt.cdn.models.MatchVariable - :ivar parameters: Defines the parameters for the condition. Required. - :vartype parameters: ~azure.mgmt.cdn.models.HostNameMatchConditionParameters - """ - - _validation = { - "name": {"required": True}, - "parameters": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "parameters": {"key": "parameters", "type": "HostNameMatchConditionParameters"}, - } - - def __init__(self, *, parameters: "_models.HostNameMatchConditionParameters", **kwargs: Any) -> None: - """ - :keyword parameters: Defines the parameters for the condition. Required. - :paramtype parameters: ~azure.mgmt.cdn.models.HostNameMatchConditionParameters - """ - super().__init__(**kwargs) - self.name: str = "HostName" - self.parameters = parameters - - -class DeliveryRuleHttpVersionCondition(DeliveryRuleCondition): - """Defines the HttpVersion condition for the delivery rule. - - All required parameters must be populated in order to send to server. - - :ivar name: The name of the condition for the delivery rule. Required. Known values are: - "RemoteAddress", "RequestMethod", "QueryString", "PostArgs", "RequestUri", "RequestHeader", - "RequestBody", "RequestScheme", "UrlPath", "UrlFileExtension", "UrlFileName", "HttpVersion", - "Cookies", "IsDevice", "SocketAddr", "ClientPort", "ServerPort", "HostName", and "SslProtocol". - :vartype name: str or ~azure.mgmt.cdn.models.MatchVariable - :ivar parameters: Defines the parameters for the condition. Required. - :vartype parameters: ~azure.mgmt.cdn.models.HttpVersionMatchConditionParameters - """ - - _validation = { - "name": {"required": True}, - "parameters": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "parameters": {"key": "parameters", "type": "HttpVersionMatchConditionParameters"}, - } - - def __init__(self, *, parameters: "_models.HttpVersionMatchConditionParameters", **kwargs: Any) -> None: - """ - :keyword parameters: Defines the parameters for the condition. Required. - :paramtype parameters: ~azure.mgmt.cdn.models.HttpVersionMatchConditionParameters - """ - super().__init__(**kwargs) - self.name: str = "HttpVersion" - self.parameters = parameters - - -class DeliveryRuleIsDeviceCondition(DeliveryRuleCondition): - """Defines the IsDevice condition for the delivery rule. - - All required parameters must be populated in order to send to server. - - :ivar name: The name of the condition for the delivery rule. Required. Known values are: - "RemoteAddress", "RequestMethod", "QueryString", "PostArgs", "RequestUri", "RequestHeader", - "RequestBody", "RequestScheme", "UrlPath", "UrlFileExtension", "UrlFileName", "HttpVersion", - "Cookies", "IsDevice", "SocketAddr", "ClientPort", "ServerPort", "HostName", and "SslProtocol". - :vartype name: str or ~azure.mgmt.cdn.models.MatchVariable - :ivar parameters: Defines the parameters for the condition. Required. - :vartype parameters: ~azure.mgmt.cdn.models.IsDeviceMatchConditionParameters - """ - - _validation = { - "name": {"required": True}, - "parameters": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "parameters": {"key": "parameters", "type": "IsDeviceMatchConditionParameters"}, - } - - def __init__(self, *, parameters: "_models.IsDeviceMatchConditionParameters", **kwargs: Any) -> None: - """ - :keyword parameters: Defines the parameters for the condition. Required. - :paramtype parameters: ~azure.mgmt.cdn.models.IsDeviceMatchConditionParameters - """ - super().__init__(**kwargs) - self.name: str = "IsDevice" - self.parameters = parameters - - -class DeliveryRulePostArgsCondition(DeliveryRuleCondition): - """Defines the PostArgs condition for the delivery rule. - - All required parameters must be populated in order to send to server. - - :ivar name: The name of the condition for the delivery rule. Required. Known values are: - "RemoteAddress", "RequestMethod", "QueryString", "PostArgs", "RequestUri", "RequestHeader", - "RequestBody", "RequestScheme", "UrlPath", "UrlFileExtension", "UrlFileName", "HttpVersion", - "Cookies", "IsDevice", "SocketAddr", "ClientPort", "ServerPort", "HostName", and "SslProtocol". - :vartype name: str or ~azure.mgmt.cdn.models.MatchVariable - :ivar parameters: Defines the parameters for the condition. Required. - :vartype parameters: ~azure.mgmt.cdn.models.PostArgsMatchConditionParameters - """ - - _validation = { - "name": {"required": True}, - "parameters": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "parameters": {"key": "parameters", "type": "PostArgsMatchConditionParameters"}, - } - - def __init__(self, *, parameters: "_models.PostArgsMatchConditionParameters", **kwargs: Any) -> None: - """ - :keyword parameters: Defines the parameters for the condition. Required. - :paramtype parameters: ~azure.mgmt.cdn.models.PostArgsMatchConditionParameters - """ - super().__init__(**kwargs) - self.name: str = "PostArgs" - self.parameters = parameters - - -class DeliveryRuleQueryStringCondition(DeliveryRuleCondition): - """Defines the QueryString condition for the delivery rule. - - All required parameters must be populated in order to send to server. - - :ivar name: The name of the condition for the delivery rule. Required. Known values are: - "RemoteAddress", "RequestMethod", "QueryString", "PostArgs", "RequestUri", "RequestHeader", - "RequestBody", "RequestScheme", "UrlPath", "UrlFileExtension", "UrlFileName", "HttpVersion", - "Cookies", "IsDevice", "SocketAddr", "ClientPort", "ServerPort", "HostName", and "SslProtocol". - :vartype name: str or ~azure.mgmt.cdn.models.MatchVariable - :ivar parameters: Defines the parameters for the condition. Required. - :vartype parameters: ~azure.mgmt.cdn.models.QueryStringMatchConditionParameters - """ - - _validation = { - "name": {"required": True}, - "parameters": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "parameters": {"key": "parameters", "type": "QueryStringMatchConditionParameters"}, - } - - def __init__(self, *, parameters: "_models.QueryStringMatchConditionParameters", **kwargs: Any) -> None: - """ - :keyword parameters: Defines the parameters for the condition. Required. - :paramtype parameters: ~azure.mgmt.cdn.models.QueryStringMatchConditionParameters - """ - super().__init__(**kwargs) - self.name: str = "QueryString" - self.parameters = parameters - - -class DeliveryRuleRemoteAddressCondition(DeliveryRuleCondition): - """Defines the RemoteAddress condition for the delivery rule. - - All required parameters must be populated in order to send to server. - - :ivar name: The name of the condition for the delivery rule. Required. Known values are: - "RemoteAddress", "RequestMethod", "QueryString", "PostArgs", "RequestUri", "RequestHeader", - "RequestBody", "RequestScheme", "UrlPath", "UrlFileExtension", "UrlFileName", "HttpVersion", - "Cookies", "IsDevice", "SocketAddr", "ClientPort", "ServerPort", "HostName", and "SslProtocol". - :vartype name: str or ~azure.mgmt.cdn.models.MatchVariable - :ivar parameters: Defines the parameters for the condition. Required. - :vartype parameters: ~azure.mgmt.cdn.models.RemoteAddressMatchConditionParameters - """ - - _validation = { - "name": {"required": True}, - "parameters": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "parameters": {"key": "parameters", "type": "RemoteAddressMatchConditionParameters"}, - } - - def __init__(self, *, parameters: "_models.RemoteAddressMatchConditionParameters", **kwargs: Any) -> None: - """ - :keyword parameters: Defines the parameters for the condition. Required. - :paramtype parameters: ~azure.mgmt.cdn.models.RemoteAddressMatchConditionParameters - """ - super().__init__(**kwargs) - self.name: str = "RemoteAddress" - self.parameters = parameters - - -class DeliveryRuleRequestBodyCondition(DeliveryRuleCondition): - """Defines the RequestBody condition for the delivery rule. - - All required parameters must be populated in order to send to server. - - :ivar name: The name of the condition for the delivery rule. Required. Known values are: - "RemoteAddress", "RequestMethod", "QueryString", "PostArgs", "RequestUri", "RequestHeader", - "RequestBody", "RequestScheme", "UrlPath", "UrlFileExtension", "UrlFileName", "HttpVersion", - "Cookies", "IsDevice", "SocketAddr", "ClientPort", "ServerPort", "HostName", and "SslProtocol". - :vartype name: str or ~azure.mgmt.cdn.models.MatchVariable - :ivar parameters: Defines the parameters for the condition. Required. - :vartype parameters: ~azure.mgmt.cdn.models.RequestBodyMatchConditionParameters - """ - - _validation = { - "name": {"required": True}, - "parameters": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "parameters": {"key": "parameters", "type": "RequestBodyMatchConditionParameters"}, - } - - def __init__(self, *, parameters: "_models.RequestBodyMatchConditionParameters", **kwargs: Any) -> None: - """ - :keyword parameters: Defines the parameters for the condition. Required. - :paramtype parameters: ~azure.mgmt.cdn.models.RequestBodyMatchConditionParameters - """ - super().__init__(**kwargs) - self.name: str = "RequestBody" - self.parameters = parameters - - -class DeliveryRuleRequestHeaderAction(DeliveryRuleAction): - """Defines the request header action for the delivery rule. - - All required parameters must be populated in order to send to server. - - :ivar name: The name of the action for the delivery rule. Required. Known values are: - "CacheExpiration", "CacheKeyQueryString", "ModifyRequestHeader", "ModifyResponseHeader", - "UrlRedirect", "UrlRewrite", "UrlSigning", "OriginGroupOverride", and - "RouteConfigurationOverride". - :vartype name: str or ~azure.mgmt.cdn.models.DeliveryRuleActionEnum - :ivar parameters: Defines the parameters for the action. Required. - :vartype parameters: ~azure.mgmt.cdn.models.HeaderActionParameters - """ - - _validation = { - "name": {"required": True}, - "parameters": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "parameters": {"key": "parameters", "type": "HeaderActionParameters"}, - } - - def __init__(self, *, parameters: "_models.HeaderActionParameters", **kwargs: Any) -> None: - """ - :keyword parameters: Defines the parameters for the action. Required. - :paramtype parameters: ~azure.mgmt.cdn.models.HeaderActionParameters - """ - super().__init__(**kwargs) - self.name: str = "ModifyRequestHeader" - self.parameters = parameters - - -class DeliveryRuleRequestHeaderCondition(DeliveryRuleCondition): - """Defines the RequestHeader condition for the delivery rule. - - All required parameters must be populated in order to send to server. - - :ivar name: The name of the condition for the delivery rule. Required. Known values are: - "RemoteAddress", "RequestMethod", "QueryString", "PostArgs", "RequestUri", "RequestHeader", - "RequestBody", "RequestScheme", "UrlPath", "UrlFileExtension", "UrlFileName", "HttpVersion", - "Cookies", "IsDevice", "SocketAddr", "ClientPort", "ServerPort", "HostName", and "SslProtocol". - :vartype name: str or ~azure.mgmt.cdn.models.MatchVariable - :ivar parameters: Defines the parameters for the condition. Required. - :vartype parameters: ~azure.mgmt.cdn.models.RequestHeaderMatchConditionParameters - """ - - _validation = { - "name": {"required": True}, - "parameters": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "parameters": {"key": "parameters", "type": "RequestHeaderMatchConditionParameters"}, - } - - def __init__(self, *, parameters: "_models.RequestHeaderMatchConditionParameters", **kwargs: Any) -> None: - """ - :keyword parameters: Defines the parameters for the condition. Required. - :paramtype parameters: ~azure.mgmt.cdn.models.RequestHeaderMatchConditionParameters - """ - super().__init__(**kwargs) - self.name: str = "RequestHeader" - self.parameters = parameters - - -class DeliveryRuleRequestMethodCondition(DeliveryRuleCondition): - """Defines the RequestMethod condition for the delivery rule. - - All required parameters must be populated in order to send to server. - - :ivar name: The name of the condition for the delivery rule. Required. Known values are: - "RemoteAddress", "RequestMethod", "QueryString", "PostArgs", "RequestUri", "RequestHeader", - "RequestBody", "RequestScheme", "UrlPath", "UrlFileExtension", "UrlFileName", "HttpVersion", - "Cookies", "IsDevice", "SocketAddr", "ClientPort", "ServerPort", "HostName", and "SslProtocol". - :vartype name: str or ~azure.mgmt.cdn.models.MatchVariable - :ivar parameters: Defines the parameters for the condition. Required. - :vartype parameters: ~azure.mgmt.cdn.models.RequestMethodMatchConditionParameters - """ - - _validation = { - "name": {"required": True}, - "parameters": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "parameters": {"key": "parameters", "type": "RequestMethodMatchConditionParameters"}, - } - - def __init__(self, *, parameters: "_models.RequestMethodMatchConditionParameters", **kwargs: Any) -> None: - """ - :keyword parameters: Defines the parameters for the condition. Required. - :paramtype parameters: ~azure.mgmt.cdn.models.RequestMethodMatchConditionParameters - """ - super().__init__(**kwargs) - self.name: str = "RequestMethod" - self.parameters = parameters - - -class DeliveryRuleRequestSchemeCondition(DeliveryRuleCondition): - """Defines the RequestScheme condition for the delivery rule. - - All required parameters must be populated in order to send to server. - - :ivar name: The name of the condition for the delivery rule. Required. Known values are: - "RemoteAddress", "RequestMethod", "QueryString", "PostArgs", "RequestUri", "RequestHeader", - "RequestBody", "RequestScheme", "UrlPath", "UrlFileExtension", "UrlFileName", "HttpVersion", - "Cookies", "IsDevice", "SocketAddr", "ClientPort", "ServerPort", "HostName", and "SslProtocol". - :vartype name: str or ~azure.mgmt.cdn.models.MatchVariable - :ivar parameters: Defines the parameters for the condition. Required. - :vartype parameters: ~azure.mgmt.cdn.models.RequestSchemeMatchConditionParameters - """ - - _validation = { - "name": {"required": True}, - "parameters": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "parameters": {"key": "parameters", "type": "RequestSchemeMatchConditionParameters"}, - } - - def __init__(self, *, parameters: "_models.RequestSchemeMatchConditionParameters", **kwargs: Any) -> None: - """ - :keyword parameters: Defines the parameters for the condition. Required. - :paramtype parameters: ~azure.mgmt.cdn.models.RequestSchemeMatchConditionParameters - """ - super().__init__(**kwargs) - self.name: str = "RequestScheme" - self.parameters = parameters - - -class DeliveryRuleRequestUriCondition(DeliveryRuleCondition): - """Defines the RequestUri condition for the delivery rule. - - All required parameters must be populated in order to send to server. - - :ivar name: The name of the condition for the delivery rule. Required. Known values are: - "RemoteAddress", "RequestMethod", "QueryString", "PostArgs", "RequestUri", "RequestHeader", - "RequestBody", "RequestScheme", "UrlPath", "UrlFileExtension", "UrlFileName", "HttpVersion", - "Cookies", "IsDevice", "SocketAddr", "ClientPort", "ServerPort", "HostName", and "SslProtocol". - :vartype name: str or ~azure.mgmt.cdn.models.MatchVariable - :ivar parameters: Defines the parameters for the condition. Required. - :vartype parameters: ~azure.mgmt.cdn.models.RequestUriMatchConditionParameters - """ - - _validation = { - "name": {"required": True}, - "parameters": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "parameters": {"key": "parameters", "type": "RequestUriMatchConditionParameters"}, - } - - def __init__(self, *, parameters: "_models.RequestUriMatchConditionParameters", **kwargs: Any) -> None: - """ - :keyword parameters: Defines the parameters for the condition. Required. - :paramtype parameters: ~azure.mgmt.cdn.models.RequestUriMatchConditionParameters - """ - super().__init__(**kwargs) - self.name: str = "RequestUri" - self.parameters = parameters - - -class DeliveryRuleResponseHeaderAction(DeliveryRuleAction): - """Defines the response header action for the delivery rule. - - All required parameters must be populated in order to send to server. - - :ivar name: The name of the action for the delivery rule. Required. Known values are: - "CacheExpiration", "CacheKeyQueryString", "ModifyRequestHeader", "ModifyResponseHeader", - "UrlRedirect", "UrlRewrite", "UrlSigning", "OriginGroupOverride", and - "RouteConfigurationOverride". - :vartype name: str or ~azure.mgmt.cdn.models.DeliveryRuleActionEnum - :ivar parameters: Defines the parameters for the action. Required. - :vartype parameters: ~azure.mgmt.cdn.models.HeaderActionParameters - """ - - _validation = { - "name": {"required": True}, - "parameters": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "parameters": {"key": "parameters", "type": "HeaderActionParameters"}, - } - - def __init__(self, *, parameters: "_models.HeaderActionParameters", **kwargs: Any) -> None: - """ - :keyword parameters: Defines the parameters for the action. Required. - :paramtype parameters: ~azure.mgmt.cdn.models.HeaderActionParameters - """ - super().__init__(**kwargs) - self.name: str = "ModifyResponseHeader" - self.parameters = parameters - - -class DeliveryRuleRouteConfigurationOverrideAction(DeliveryRuleAction): # pylint: disable=name-too-long - """Defines the route configuration override action for the delivery rule. Only applicable to - Frontdoor Standard/Premium Profiles. - - All required parameters must be populated in order to send to server. - - :ivar name: The name of the action for the delivery rule. Required. Known values are: - "CacheExpiration", "CacheKeyQueryString", "ModifyRequestHeader", "ModifyResponseHeader", - "UrlRedirect", "UrlRewrite", "UrlSigning", "OriginGroupOverride", and - "RouteConfigurationOverride". - :vartype name: str or ~azure.mgmt.cdn.models.DeliveryRuleActionEnum - :ivar parameters: Defines the parameters for the action. Required. - :vartype parameters: ~azure.mgmt.cdn.models.RouteConfigurationOverrideActionParameters - """ - - _validation = { - "name": {"required": True}, - "parameters": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "parameters": {"key": "parameters", "type": "RouteConfigurationOverrideActionParameters"}, - } - - def __init__(self, *, parameters: "_models.RouteConfigurationOverrideActionParameters", **kwargs: Any) -> None: - """ - :keyword parameters: Defines the parameters for the action. Required. - :paramtype parameters: ~azure.mgmt.cdn.models.RouteConfigurationOverrideActionParameters - """ - super().__init__(**kwargs) - self.name: str = "RouteConfigurationOverride" - self.parameters = parameters - - -class DeliveryRuleServerPortCondition(DeliveryRuleCondition): - """Defines the ServerPort condition for the delivery rule. - - All required parameters must be populated in order to send to server. - - :ivar name: The name of the condition for the delivery rule. Required. Known values are: - "RemoteAddress", "RequestMethod", "QueryString", "PostArgs", "RequestUri", "RequestHeader", - "RequestBody", "RequestScheme", "UrlPath", "UrlFileExtension", "UrlFileName", "HttpVersion", - "Cookies", "IsDevice", "SocketAddr", "ClientPort", "ServerPort", "HostName", and "SslProtocol". - :vartype name: str or ~azure.mgmt.cdn.models.MatchVariable - :ivar parameters: Defines the parameters for the condition. Required. - :vartype parameters: ~azure.mgmt.cdn.models.ServerPortMatchConditionParameters - """ - - _validation = { - "name": {"required": True}, - "parameters": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "parameters": {"key": "parameters", "type": "ServerPortMatchConditionParameters"}, - } - - def __init__(self, *, parameters: "_models.ServerPortMatchConditionParameters", **kwargs: Any) -> None: - """ - :keyword parameters: Defines the parameters for the condition. Required. - :paramtype parameters: ~azure.mgmt.cdn.models.ServerPortMatchConditionParameters - """ - super().__init__(**kwargs) - self.name: str = "ServerPort" - self.parameters = parameters - - -class DeliveryRuleSocketAddrCondition(DeliveryRuleCondition): - """Defines the SocketAddress condition for the delivery rule. - - All required parameters must be populated in order to send to server. - - :ivar name: The name of the condition for the delivery rule. Required. Known values are: - "RemoteAddress", "RequestMethod", "QueryString", "PostArgs", "RequestUri", "RequestHeader", - "RequestBody", "RequestScheme", "UrlPath", "UrlFileExtension", "UrlFileName", "HttpVersion", - "Cookies", "IsDevice", "SocketAddr", "ClientPort", "ServerPort", "HostName", and "SslProtocol". - :vartype name: str or ~azure.mgmt.cdn.models.MatchVariable - :ivar parameters: Defines the parameters for the condition. Required. - :vartype parameters: ~azure.mgmt.cdn.models.SocketAddrMatchConditionParameters - """ - - _validation = { - "name": {"required": True}, - "parameters": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "parameters": {"key": "parameters", "type": "SocketAddrMatchConditionParameters"}, - } - - def __init__(self, *, parameters: "_models.SocketAddrMatchConditionParameters", **kwargs: Any) -> None: - """ - :keyword parameters: Defines the parameters for the condition. Required. - :paramtype parameters: ~azure.mgmt.cdn.models.SocketAddrMatchConditionParameters - """ - super().__init__(**kwargs) - self.name: str = "SocketAddr" - self.parameters = parameters - - -class DeliveryRuleSslProtocolCondition(DeliveryRuleCondition): - """Defines the SslProtocol condition for the delivery rule. - - All required parameters must be populated in order to send to server. - - :ivar name: The name of the condition for the delivery rule. Required. Known values are: - "RemoteAddress", "RequestMethod", "QueryString", "PostArgs", "RequestUri", "RequestHeader", - "RequestBody", "RequestScheme", "UrlPath", "UrlFileExtension", "UrlFileName", "HttpVersion", - "Cookies", "IsDevice", "SocketAddr", "ClientPort", "ServerPort", "HostName", and "SslProtocol". - :vartype name: str or ~azure.mgmt.cdn.models.MatchVariable - :ivar parameters: Defines the parameters for the condition. Required. - :vartype parameters: ~azure.mgmt.cdn.models.SslProtocolMatchConditionParameters - """ - - _validation = { - "name": {"required": True}, - "parameters": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "parameters": {"key": "parameters", "type": "SslProtocolMatchConditionParameters"}, - } - - def __init__(self, *, parameters: "_models.SslProtocolMatchConditionParameters", **kwargs: Any) -> None: - """ - :keyword parameters: Defines the parameters for the condition. Required. - :paramtype parameters: ~azure.mgmt.cdn.models.SslProtocolMatchConditionParameters - """ - super().__init__(**kwargs) - self.name: str = "SslProtocol" - self.parameters = parameters - - -class DeliveryRuleUrlFileExtensionCondition(DeliveryRuleCondition): - """Defines the UrlFileExtension condition for the delivery rule. - - All required parameters must be populated in order to send to server. - - :ivar name: The name of the condition for the delivery rule. Required. Known values are: - "RemoteAddress", "RequestMethod", "QueryString", "PostArgs", "RequestUri", "RequestHeader", - "RequestBody", "RequestScheme", "UrlPath", "UrlFileExtension", "UrlFileName", "HttpVersion", - "Cookies", "IsDevice", "SocketAddr", "ClientPort", "ServerPort", "HostName", and "SslProtocol". - :vartype name: str or ~azure.mgmt.cdn.models.MatchVariable - :ivar parameters: Defines the parameters for the condition. Required. - :vartype parameters: ~azure.mgmt.cdn.models.UrlFileExtensionMatchConditionParameters - """ - - _validation = { - "name": {"required": True}, - "parameters": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "parameters": {"key": "parameters", "type": "UrlFileExtensionMatchConditionParameters"}, - } - - def __init__(self, *, parameters: "_models.UrlFileExtensionMatchConditionParameters", **kwargs: Any) -> None: - """ - :keyword parameters: Defines the parameters for the condition. Required. - :paramtype parameters: ~azure.mgmt.cdn.models.UrlFileExtensionMatchConditionParameters - """ - super().__init__(**kwargs) - self.name: str = "UrlFileExtension" - self.parameters = parameters - - -class DeliveryRuleUrlFileNameCondition(DeliveryRuleCondition): - """Defines the UrlFileName condition for the delivery rule. - - All required parameters must be populated in order to send to server. - - :ivar name: The name of the condition for the delivery rule. Required. Known values are: - "RemoteAddress", "RequestMethod", "QueryString", "PostArgs", "RequestUri", "RequestHeader", - "RequestBody", "RequestScheme", "UrlPath", "UrlFileExtension", "UrlFileName", "HttpVersion", - "Cookies", "IsDevice", "SocketAddr", "ClientPort", "ServerPort", "HostName", and "SslProtocol". - :vartype name: str or ~azure.mgmt.cdn.models.MatchVariable - :ivar parameters: Defines the parameters for the condition. Required. - :vartype parameters: ~azure.mgmt.cdn.models.UrlFileNameMatchConditionParameters - """ - - _validation = { - "name": {"required": True}, - "parameters": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "parameters": {"key": "parameters", "type": "UrlFileNameMatchConditionParameters"}, - } - - def __init__(self, *, parameters: "_models.UrlFileNameMatchConditionParameters", **kwargs: Any) -> None: - """ - :keyword parameters: Defines the parameters for the condition. Required. - :paramtype parameters: ~azure.mgmt.cdn.models.UrlFileNameMatchConditionParameters - """ - super().__init__(**kwargs) - self.name: str = "UrlFileName" - self.parameters = parameters - - -class DeliveryRuleUrlPathCondition(DeliveryRuleCondition): - """Defines the UrlPath condition for the delivery rule. - - All required parameters must be populated in order to send to server. - - :ivar name: The name of the condition for the delivery rule. Required. Known values are: - "RemoteAddress", "RequestMethod", "QueryString", "PostArgs", "RequestUri", "RequestHeader", - "RequestBody", "RequestScheme", "UrlPath", "UrlFileExtension", "UrlFileName", "HttpVersion", - "Cookies", "IsDevice", "SocketAddr", "ClientPort", "ServerPort", "HostName", and "SslProtocol". - :vartype name: str or ~azure.mgmt.cdn.models.MatchVariable - :ivar parameters: Defines the parameters for the condition. Required. - :vartype parameters: ~azure.mgmt.cdn.models.UrlPathMatchConditionParameters - """ - - _validation = { - "name": {"required": True}, - "parameters": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "parameters": {"key": "parameters", "type": "UrlPathMatchConditionParameters"}, - } - - def __init__(self, *, parameters: "_models.UrlPathMatchConditionParameters", **kwargs: Any) -> None: - """ - :keyword parameters: Defines the parameters for the condition. Required. - :paramtype parameters: ~azure.mgmt.cdn.models.UrlPathMatchConditionParameters - """ - super().__init__(**kwargs) - self.name: str = "UrlPath" - self.parameters = parameters - - -class DimensionProperties(_serialization.Model): - """Type of operation: get, read, delete, etc. - - :ivar name: Name of dimension. - :vartype name: str - :ivar display_name: Display name of dimension. - :vartype display_name: str - :ivar internal_name: Internal name of dimension. - :vartype internal_name: str - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "display_name": {"key": "displayName", "type": "str"}, - "internal_name": {"key": "internalName", "type": "str"}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - display_name: Optional[str] = None, - internal_name: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: Name of dimension. - :paramtype name: str - :keyword display_name: Display name of dimension. - :paramtype display_name: str - :keyword internal_name: Internal name of dimension. - :paramtype internal_name: str - """ - super().__init__(**kwargs) - self.name = name - self.display_name = display_name - self.internal_name = internal_name - - -class DomainValidationProperties(_serialization.Model): - """The JSON object that contains the properties to validate a domain. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar validation_token: Challenge used for DNS TXT record or file based validation. - :vartype validation_token: str - :ivar expiration_date: The date time that the token expires. - :vartype expiration_date: str - """ - - _validation = { - "validation_token": {"readonly": True}, - "expiration_date": {"readonly": True}, - } - - _attribute_map = { - "validation_token": {"key": "validationToken", "type": "str"}, - "expiration_date": {"key": "expirationDate", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.validation_token = None - self.expiration_date = None - - -class EdgeNode(ProxyResource): - """Edgenode is a global Point of Presence (POP) location used to deliver CDN content to end users. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar system_data: Read only system data. - :vartype system_data: ~azure.mgmt.cdn.models.SystemData - :ivar ip_address_groups: List of ip address groups. - :vartype ip_address_groups: list[~azure.mgmt.cdn.models.IpAddressGroup] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "ip_address_groups": {"key": "properties.ipAddressGroups", "type": "[IpAddressGroup]"}, - } - - def __init__(self, *, ip_address_groups: Optional[List["_models.IpAddressGroup"]] = None, **kwargs: Any) -> None: - """ - :keyword ip_address_groups: List of ip address groups. - :paramtype ip_address_groups: list[~azure.mgmt.cdn.models.IpAddressGroup] - """ - super().__init__(**kwargs) - self.ip_address_groups = ip_address_groups - - -class EdgenodeResult(_serialization.Model): - """Result of the request to list CDN edgenodes. It contains a list of ip address group and a URL - link to get the next set of results. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Edge node of CDN service. - :vartype value: list[~azure.mgmt.cdn.models.EdgeNode] - :ivar next_link: URL to get the next set of edgenode list results if there are any. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[EdgeNode]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword next_link: URL to get the next set of edgenode list results if there are any. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = None - self.next_link = next_link - - -class Endpoint(TrackedResource): # pylint: disable=too-many-instance-attributes - """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. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to server. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar system_data: Read only system data. - :vartype system_data: ~azure.mgmt.cdn.models.SystemData - :ivar location: Resource location. Required. - :vartype location: str - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar origin_path: A directory path on the origin that CDN can use to retrieve content from, - e.g. contoso.cloudapp.net/originpath. - :vartype origin_path: str - :ivar content_types_to_compress: List of content types on which compression applies. The value - should be a valid MIME type. - :vartype content_types_to_compress: list[str] - :ivar origin_host_header: The host header value sent to the origin with each request. This - property at Endpoint is only allowed when endpoint uses single origin and can be overridden by - the same property specified at origin.If you leave this blank, the request hostname determines - this value. Azure CDN origins, such as Web Apps, Blob Storage, and Cloud Services require this - host header value to match the origin hostname by default. - :vartype origin_host_header: str - :ivar is_compression_enabled: Indicates whether content compression is enabled on CDN. Default - value is false. If compression is enabled, content will be served as compressed if user - requests for a compressed version. Content won't be compressed on CDN when requested content is - smaller than 1 byte or larger than 1 MB. - :vartype is_compression_enabled: bool - :ivar is_http_allowed: Indicates whether HTTP traffic is allowed on the endpoint. Default value - is true. At least one protocol (HTTP or HTTPS) must be allowed. - :vartype is_http_allowed: bool - :ivar is_https_allowed: Indicates whether HTTPS traffic is allowed on the endpoint. Default - value is true. At least one protocol (HTTP or HTTPS) must be allowed. - :vartype is_https_allowed: bool - :ivar query_string_caching_behavior: Defines how CDN caches requests that include query - strings. You can ignore any query strings when caching, bypass caching to prevent requests that - contain query strings from being cached, or cache every request with a unique URL. Known values - are: "IgnoreQueryString", "BypassCaching", "UseQueryString", and "NotSet". - :vartype query_string_caching_behavior: str or - ~azure.mgmt.cdn.models.QueryStringCachingBehavior - :ivar optimization_type: Specifies what scenario the customer wants this CDN endpoint to - optimize for, e.g. Download, Media services. With this information, CDN can apply scenario - driven optimization. Known values are: "GeneralWebDelivery", "GeneralMediaStreaming", - "VideoOnDemandMediaStreaming", "LargeFileDownload", and "DynamicSiteAcceleration". - :vartype optimization_type: str or ~azure.mgmt.cdn.models.OptimizationType - :ivar probe_path: Path to a file hosted on the origin which helps accelerate delivery of the - dynamic content and calculate the most optimal routes for the CDN. This is relative to the - origin path. This property is only relevant when using a single origin. - :vartype probe_path: str - :ivar geo_filters: List of rules defining the user's geo access within a CDN endpoint. Each geo - filter defines an access rule to a specified path or content, e.g. block APAC for path - /pictures/. - :vartype geo_filters: list[~azure.mgmt.cdn.models.GeoFilter] - :ivar default_origin_group: A reference to the origin group. - :vartype default_origin_group: ~azure.mgmt.cdn.models.ResourceReference - :ivar url_signing_keys: List of keys used to validate the signed URL hashes. - :vartype url_signing_keys: list[~azure.mgmt.cdn.models.UrlSigningKey] - :ivar delivery_policy: A policy that specifies the delivery rules to be used for an endpoint. - :vartype delivery_policy: - ~azure.mgmt.cdn.models.EndpointPropertiesUpdateParametersDeliveryPolicy - :ivar web_application_firewall_policy_link: Defines the Web Application Firewall policy for the - endpoint (if applicable). - :vartype web_application_firewall_policy_link: - ~azure.mgmt.cdn.models.EndpointPropertiesUpdateParametersWebApplicationFirewallPolicyLink - :ivar host_name: The host name of the endpoint structured as {endpointName}.{DNSZone}, e.g. - contoso.azureedge.net. - :vartype host_name: str - :ivar origins: The source of the content being delivered via CDN. - :vartype origins: list[~azure.mgmt.cdn.models.DeepCreatedOrigin] - :ivar origin_groups: The origin groups comprising of origins that are used for load balancing - the traffic based on availability. - :vartype origin_groups: list[~azure.mgmt.cdn.models.DeepCreatedOriginGroup] - :ivar custom_domains: The custom domains under the endpoint. - :vartype custom_domains: list[~azure.mgmt.cdn.models.DeepCreatedCustomDomain] - :ivar resource_state: Resource status of the endpoint. Known values are: "Creating", - "Deleting", "Running", "Starting", "Stopped", and "Stopping". - :vartype resource_state: str or ~azure.mgmt.cdn.models.EndpointResourceState - :ivar provisioning_state: Provisioning status of the endpoint. Known values are: "Succeeded", - "Failed", "Updating", "Deleting", and "Creating". - :vartype provisioning_state: str or ~azure.mgmt.cdn.models.EndpointProvisioningState - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - "location": {"required": True}, - "host_name": {"readonly": True}, - "custom_domains": {"readonly": True}, - "resource_state": {"readonly": True}, - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "origin_path": {"key": "properties.originPath", "type": "str"}, - "content_types_to_compress": {"key": "properties.contentTypesToCompress", "type": "[str]"}, - "origin_host_header": {"key": "properties.originHostHeader", "type": "str"}, - "is_compression_enabled": {"key": "properties.isCompressionEnabled", "type": "bool"}, - "is_http_allowed": {"key": "properties.isHttpAllowed", "type": "bool"}, - "is_https_allowed": {"key": "properties.isHttpsAllowed", "type": "bool"}, - "query_string_caching_behavior": {"key": "properties.queryStringCachingBehavior", "type": "str"}, - "optimization_type": {"key": "properties.optimizationType", "type": "str"}, - "probe_path": {"key": "properties.probePath", "type": "str"}, - "geo_filters": {"key": "properties.geoFilters", "type": "[GeoFilter]"}, - "default_origin_group": {"key": "properties.defaultOriginGroup", "type": "ResourceReference"}, - "url_signing_keys": {"key": "properties.urlSigningKeys", "type": "[UrlSigningKey]"}, - "delivery_policy": { - "key": "properties.deliveryPolicy", - "type": "EndpointPropertiesUpdateParametersDeliveryPolicy", - }, - "web_application_firewall_policy_link": { - "key": "properties.webApplicationFirewallPolicyLink", - "type": "EndpointPropertiesUpdateParametersWebApplicationFirewallPolicyLink", - }, - "host_name": {"key": "properties.hostName", "type": "str"}, - "origins": {"key": "properties.origins", "type": "[DeepCreatedOrigin]"}, - "origin_groups": {"key": "properties.originGroups", "type": "[DeepCreatedOriginGroup]"}, - "custom_domains": {"key": "properties.customDomains", "type": "[DeepCreatedCustomDomain]"}, - "resource_state": {"key": "properties.resourceState", "type": "str"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - } - - def __init__( # pylint: disable=too-many-locals - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - origin_path: Optional[str] = None, - content_types_to_compress: Optional[List[str]] = None, - origin_host_header: Optional[str] = None, - is_compression_enabled: Optional[bool] = None, - is_http_allowed: bool = True, - is_https_allowed: bool = True, - query_string_caching_behavior: Optional[Union[str, "_models.QueryStringCachingBehavior"]] = None, - optimization_type: Optional[Union[str, "_models.OptimizationType"]] = None, - probe_path: Optional[str] = None, - geo_filters: Optional[List["_models.GeoFilter"]] = None, - default_origin_group: Optional["_models.ResourceReference"] = None, - url_signing_keys: Optional[List["_models.UrlSigningKey"]] = None, - delivery_policy: Optional["_models.EndpointPropertiesUpdateParametersDeliveryPolicy"] = None, - web_application_firewall_policy_link: Optional[ - "_models.EndpointPropertiesUpdateParametersWebApplicationFirewallPolicyLink" - ] = None, - origins: Optional[List["_models.DeepCreatedOrigin"]] = None, - origin_groups: Optional[List["_models.DeepCreatedOriginGroup"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword origin_path: A directory path on the origin that CDN can use to retrieve content from, - e.g. contoso.cloudapp.net/originpath. - :paramtype origin_path: str - :keyword content_types_to_compress: List of content types on which compression applies. The - value should be a valid MIME type. - :paramtype content_types_to_compress: list[str] - :keyword origin_host_header: The host header value sent to the origin with each request. This - property at Endpoint is only allowed when endpoint uses single origin and can be overridden by - the same property specified at origin.If you leave this blank, the request hostname determines - this value. Azure CDN origins, such as Web Apps, Blob Storage, and Cloud Services require this - host header value to match the origin hostname by default. - :paramtype origin_host_header: str - :keyword is_compression_enabled: Indicates whether content compression is enabled on CDN. - Default value is false. If compression is enabled, content will be served as compressed if user - requests for a compressed version. Content won't be compressed on CDN when requested content is - smaller than 1 byte or larger than 1 MB. - :paramtype is_compression_enabled: bool - :keyword is_http_allowed: Indicates whether HTTP traffic is allowed on the endpoint. Default - value is true. At least one protocol (HTTP or HTTPS) must be allowed. - :paramtype is_http_allowed: bool - :keyword is_https_allowed: Indicates whether HTTPS traffic is allowed on the endpoint. Default - value is true. At least one protocol (HTTP or HTTPS) must be allowed. - :paramtype is_https_allowed: bool - :keyword query_string_caching_behavior: Defines how CDN caches requests that include query - strings. You can ignore any query strings when caching, bypass caching to prevent requests that - contain query strings from being cached, or cache every request with a unique URL. Known values - are: "IgnoreQueryString", "BypassCaching", "UseQueryString", and "NotSet". - :paramtype query_string_caching_behavior: str or - ~azure.mgmt.cdn.models.QueryStringCachingBehavior - :keyword optimization_type: Specifies what scenario the customer wants this CDN endpoint to - optimize for, e.g. Download, Media services. With this information, CDN can apply scenario - driven optimization. Known values are: "GeneralWebDelivery", "GeneralMediaStreaming", - "VideoOnDemandMediaStreaming", "LargeFileDownload", and "DynamicSiteAcceleration". - :paramtype optimization_type: str or ~azure.mgmt.cdn.models.OptimizationType - :keyword probe_path: Path to a file hosted on the origin which helps accelerate delivery of the - dynamic content and calculate the most optimal routes for the CDN. This is relative to the - origin path. This property is only relevant when using a single origin. - :paramtype probe_path: str - :keyword geo_filters: List of rules defining the user's geo access within a CDN endpoint. Each - geo filter defines an access rule to a specified path or content, e.g. block APAC for path - /pictures/. - :paramtype geo_filters: list[~azure.mgmt.cdn.models.GeoFilter] - :keyword default_origin_group: A reference to the origin group. - :paramtype default_origin_group: ~azure.mgmt.cdn.models.ResourceReference - :keyword url_signing_keys: List of keys used to validate the signed URL hashes. - :paramtype url_signing_keys: list[~azure.mgmt.cdn.models.UrlSigningKey] - :keyword delivery_policy: A policy that specifies the delivery rules to be used for an - endpoint. - :paramtype delivery_policy: - ~azure.mgmt.cdn.models.EndpointPropertiesUpdateParametersDeliveryPolicy - :keyword web_application_firewall_policy_link: Defines the Web Application Firewall policy for - the endpoint (if applicable). - :paramtype web_application_firewall_policy_link: - ~azure.mgmt.cdn.models.EndpointPropertiesUpdateParametersWebApplicationFirewallPolicyLink - :keyword origins: The source of the content being delivered via CDN. - :paramtype origins: list[~azure.mgmt.cdn.models.DeepCreatedOrigin] - :keyword origin_groups: The origin groups comprising of origins that are used for load - balancing the traffic based on availability. - :paramtype origin_groups: list[~azure.mgmt.cdn.models.DeepCreatedOriginGroup] - """ - super().__init__(location=location, tags=tags, **kwargs) - self.origin_path = origin_path - self.content_types_to_compress = content_types_to_compress - self.origin_host_header = origin_host_header - self.is_compression_enabled = is_compression_enabled - self.is_http_allowed = is_http_allowed - self.is_https_allowed = is_https_allowed - self.query_string_caching_behavior = query_string_caching_behavior - self.optimization_type = optimization_type - self.probe_path = probe_path - self.geo_filters = geo_filters - self.default_origin_group = default_origin_group - 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.origins = origins - self.origin_groups = origin_groups - self.custom_domains = None - self.resource_state = None - self.provisioning_state = None - - -class EndpointListResult(_serialization.Model): - """Result of the request to list endpoints. It contains a list of endpoint objects and a URL link - to get the next set of results. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: List of CDN endpoints within a profile. - :vartype value: list[~azure.mgmt.cdn.models.Endpoint] - :ivar next_link: URL to get the next set of endpoint objects if there is any. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[Endpoint]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword next_link: URL to get the next set of endpoint objects if there is any. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = None - self.next_link = next_link - - -class EndpointPropertiesUpdateParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes - """The JSON object containing endpoint update parameters. - - :ivar origin_path: A directory path on the origin that CDN can use to retrieve content from, - e.g. contoso.cloudapp.net/originpath. - :vartype origin_path: str - :ivar content_types_to_compress: List of content types on which compression applies. The value - should be a valid MIME type. - :vartype content_types_to_compress: list[str] - :ivar origin_host_header: The host header value sent to the origin with each request. This - property at Endpoint is only allowed when endpoint uses single origin and can be overridden by - the same property specified at origin.If you leave this blank, the request hostname determines - this value. Azure CDN origins, such as Web Apps, Blob Storage, and Cloud Services require this - host header value to match the origin hostname by default. - :vartype origin_host_header: str - :ivar is_compression_enabled: Indicates whether content compression is enabled on CDN. Default - value is false. If compression is enabled, content will be served as compressed if user - requests for a compressed version. Content won't be compressed on CDN when requested content is - smaller than 1 byte or larger than 1 MB. - :vartype is_compression_enabled: bool - :ivar is_http_allowed: Indicates whether HTTP traffic is allowed on the endpoint. Default value - is true. At least one protocol (HTTP or HTTPS) must be allowed. - :vartype is_http_allowed: bool - :ivar is_https_allowed: Indicates whether HTTPS traffic is allowed on the endpoint. Default - value is true. At least one protocol (HTTP or HTTPS) must be allowed. - :vartype is_https_allowed: bool - :ivar query_string_caching_behavior: Defines how CDN caches requests that include query - strings. You can ignore any query strings when caching, bypass caching to prevent requests that - contain query strings from being cached, or cache every request with a unique URL. Known values - are: "IgnoreQueryString", "BypassCaching", "UseQueryString", and "NotSet". - :vartype query_string_caching_behavior: str or - ~azure.mgmt.cdn.models.QueryStringCachingBehavior - :ivar optimization_type: Specifies what scenario the customer wants this CDN endpoint to - optimize for, e.g. Download, Media services. With this information, CDN can apply scenario - driven optimization. Known values are: "GeneralWebDelivery", "GeneralMediaStreaming", - "VideoOnDemandMediaStreaming", "LargeFileDownload", and "DynamicSiteAcceleration". - :vartype optimization_type: str or ~azure.mgmt.cdn.models.OptimizationType - :ivar probe_path: Path to a file hosted on the origin which helps accelerate delivery of the - dynamic content and calculate the most optimal routes for the CDN. This is relative to the - origin path. This property is only relevant when using a single origin. - :vartype probe_path: str - :ivar geo_filters: List of rules defining the user's geo access within a CDN endpoint. Each geo - filter defines an access rule to a specified path or content, e.g. block APAC for path - /pictures/. - :vartype geo_filters: list[~azure.mgmt.cdn.models.GeoFilter] - :ivar default_origin_group: A reference to the origin group. - :vartype default_origin_group: ~azure.mgmt.cdn.models.ResourceReference - :ivar url_signing_keys: List of keys used to validate the signed URL hashes. - :vartype url_signing_keys: list[~azure.mgmt.cdn.models.UrlSigningKey] - :ivar delivery_policy: A policy that specifies the delivery rules to be used for an endpoint. - :vartype delivery_policy: - ~azure.mgmt.cdn.models.EndpointPropertiesUpdateParametersDeliveryPolicy - :ivar web_application_firewall_policy_link: Defines the Web Application Firewall policy for the - endpoint (if applicable). - :vartype web_application_firewall_policy_link: - ~azure.mgmt.cdn.models.EndpointPropertiesUpdateParametersWebApplicationFirewallPolicyLink - """ - - _attribute_map = { - "origin_path": {"key": "originPath", "type": "str"}, - "content_types_to_compress": {"key": "contentTypesToCompress", "type": "[str]"}, - "origin_host_header": {"key": "originHostHeader", "type": "str"}, - "is_compression_enabled": {"key": "isCompressionEnabled", "type": "bool"}, - "is_http_allowed": {"key": "isHttpAllowed", "type": "bool"}, - "is_https_allowed": {"key": "isHttpsAllowed", "type": "bool"}, - "query_string_caching_behavior": {"key": "queryStringCachingBehavior", "type": "str"}, - "optimization_type": {"key": "optimizationType", "type": "str"}, - "probe_path": {"key": "probePath", "type": "str"}, - "geo_filters": {"key": "geoFilters", "type": "[GeoFilter]"}, - "default_origin_group": {"key": "defaultOriginGroup", "type": "ResourceReference"}, - "url_signing_keys": {"key": "urlSigningKeys", "type": "[UrlSigningKey]"}, - "delivery_policy": {"key": "deliveryPolicy", "type": "EndpointPropertiesUpdateParametersDeliveryPolicy"}, - "web_application_firewall_policy_link": { - "key": "webApplicationFirewallPolicyLink", - "type": "EndpointPropertiesUpdateParametersWebApplicationFirewallPolicyLink", - }, - } - - def __init__( - self, - *, - origin_path: Optional[str] = None, - content_types_to_compress: Optional[List[str]] = None, - origin_host_header: Optional[str] = None, - is_compression_enabled: Optional[bool] = None, - is_http_allowed: bool = True, - is_https_allowed: bool = True, - query_string_caching_behavior: Optional[Union[str, "_models.QueryStringCachingBehavior"]] = None, - optimization_type: Optional[Union[str, "_models.OptimizationType"]] = None, - probe_path: Optional[str] = None, - geo_filters: Optional[List["_models.GeoFilter"]] = None, - default_origin_group: Optional["_models.ResourceReference"] = None, - url_signing_keys: Optional[List["_models.UrlSigningKey"]] = None, - delivery_policy: Optional["_models.EndpointPropertiesUpdateParametersDeliveryPolicy"] = None, - web_application_firewall_policy_link: Optional[ - "_models.EndpointPropertiesUpdateParametersWebApplicationFirewallPolicyLink" - ] = None, - **kwargs: Any - ) -> None: - """ - :keyword origin_path: A directory path on the origin that CDN can use to retrieve content from, - e.g. contoso.cloudapp.net/originpath. - :paramtype origin_path: str - :keyword content_types_to_compress: List of content types on which compression applies. The - value should be a valid MIME type. - :paramtype content_types_to_compress: list[str] - :keyword origin_host_header: The host header value sent to the origin with each request. This - property at Endpoint is only allowed when endpoint uses single origin and can be overridden by - the same property specified at origin.If you leave this blank, the request hostname determines - this value. Azure CDN origins, such as Web Apps, Blob Storage, and Cloud Services require this - host header value to match the origin hostname by default. - :paramtype origin_host_header: str - :keyword is_compression_enabled: Indicates whether content compression is enabled on CDN. - Default value is false. If compression is enabled, content will be served as compressed if user - requests for a compressed version. Content won't be compressed on CDN when requested content is - smaller than 1 byte or larger than 1 MB. - :paramtype is_compression_enabled: bool - :keyword is_http_allowed: Indicates whether HTTP traffic is allowed on the endpoint. Default - value is true. At least one protocol (HTTP or HTTPS) must be allowed. - :paramtype is_http_allowed: bool - :keyword is_https_allowed: Indicates whether HTTPS traffic is allowed on the endpoint. Default - value is true. At least one protocol (HTTP or HTTPS) must be allowed. - :paramtype is_https_allowed: bool - :keyword query_string_caching_behavior: Defines how CDN caches requests that include query - strings. You can ignore any query strings when caching, bypass caching to prevent requests that - contain query strings from being cached, or cache every request with a unique URL. Known values - are: "IgnoreQueryString", "BypassCaching", "UseQueryString", and "NotSet". - :paramtype query_string_caching_behavior: str or - ~azure.mgmt.cdn.models.QueryStringCachingBehavior - :keyword optimization_type: Specifies what scenario the customer wants this CDN endpoint to - optimize for, e.g. Download, Media services. With this information, CDN can apply scenario - driven optimization. Known values are: "GeneralWebDelivery", "GeneralMediaStreaming", - "VideoOnDemandMediaStreaming", "LargeFileDownload", and "DynamicSiteAcceleration". - :paramtype optimization_type: str or ~azure.mgmt.cdn.models.OptimizationType - :keyword probe_path: Path to a file hosted on the origin which helps accelerate delivery of the - dynamic content and calculate the most optimal routes for the CDN. This is relative to the - origin path. This property is only relevant when using a single origin. - :paramtype probe_path: str - :keyword geo_filters: List of rules defining the user's geo access within a CDN endpoint. Each - geo filter defines an access rule to a specified path or content, e.g. block APAC for path - /pictures/. - :paramtype geo_filters: list[~azure.mgmt.cdn.models.GeoFilter] - :keyword default_origin_group: A reference to the origin group. - :paramtype default_origin_group: ~azure.mgmt.cdn.models.ResourceReference - :keyword url_signing_keys: List of keys used to validate the signed URL hashes. - :paramtype url_signing_keys: list[~azure.mgmt.cdn.models.UrlSigningKey] - :keyword delivery_policy: A policy that specifies the delivery rules to be used for an - endpoint. - :paramtype delivery_policy: - ~azure.mgmt.cdn.models.EndpointPropertiesUpdateParametersDeliveryPolicy - :keyword web_application_firewall_policy_link: Defines the Web Application Firewall policy for - the endpoint (if applicable). - :paramtype web_application_firewall_policy_link: - ~azure.mgmt.cdn.models.EndpointPropertiesUpdateParametersWebApplicationFirewallPolicyLink - """ - super().__init__(**kwargs) - self.origin_path = origin_path - self.content_types_to_compress = content_types_to_compress - self.origin_host_header = origin_host_header - self.is_compression_enabled = is_compression_enabled - self.is_http_allowed = is_http_allowed - self.is_https_allowed = is_https_allowed - self.query_string_caching_behavior = query_string_caching_behavior - self.optimization_type = optimization_type - self.probe_path = probe_path - self.geo_filters = geo_filters - self.default_origin_group = default_origin_group - self.url_signing_keys = url_signing_keys - self.delivery_policy = delivery_policy - self.web_application_firewall_policy_link = web_application_firewall_policy_link - - -class EndpointProperties(EndpointPropertiesUpdateParameters): # pylint: disable=too-many-instance-attributes - """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. - - All required parameters must be populated in order to send to server. - - :ivar origin_path: A directory path on the origin that CDN can use to retrieve content from, - e.g. contoso.cloudapp.net/originpath. - :vartype origin_path: str - :ivar content_types_to_compress: List of content types on which compression applies. The value - should be a valid MIME type. - :vartype content_types_to_compress: list[str] - :ivar origin_host_header: The host header value sent to the origin with each request. This - property at Endpoint is only allowed when endpoint uses single origin and can be overridden by - the same property specified at origin.If you leave this blank, the request hostname determines - this value. Azure CDN origins, such as Web Apps, Blob Storage, and Cloud Services require this - host header value to match the origin hostname by default. - :vartype origin_host_header: str - :ivar is_compression_enabled: Indicates whether content compression is enabled on CDN. Default - value is false. If compression is enabled, content will be served as compressed if user - requests for a compressed version. Content won't be compressed on CDN when requested content is - smaller than 1 byte or larger than 1 MB. - :vartype is_compression_enabled: bool - :ivar is_http_allowed: Indicates whether HTTP traffic is allowed on the endpoint. Default value - is true. At least one protocol (HTTP or HTTPS) must be allowed. - :vartype is_http_allowed: bool - :ivar is_https_allowed: Indicates whether HTTPS traffic is allowed on the endpoint. Default - value is true. At least one protocol (HTTP or HTTPS) must be allowed. - :vartype is_https_allowed: bool - :ivar query_string_caching_behavior: Defines how CDN caches requests that include query - strings. You can ignore any query strings when caching, bypass caching to prevent requests that - contain query strings from being cached, or cache every request with a unique URL. Known values - are: "IgnoreQueryString", "BypassCaching", "UseQueryString", and "NotSet". - :vartype query_string_caching_behavior: str or - ~azure.mgmt.cdn.models.QueryStringCachingBehavior - :ivar optimization_type: Specifies what scenario the customer wants this CDN endpoint to - optimize for, e.g. Download, Media services. With this information, CDN can apply scenario - driven optimization. Known values are: "GeneralWebDelivery", "GeneralMediaStreaming", - "VideoOnDemandMediaStreaming", "LargeFileDownload", and "DynamicSiteAcceleration". - :vartype optimization_type: str or ~azure.mgmt.cdn.models.OptimizationType - :ivar probe_path: Path to a file hosted on the origin which helps accelerate delivery of the - dynamic content and calculate the most optimal routes for the CDN. This is relative to the - origin path. This property is only relevant when using a single origin. - :vartype probe_path: str - :ivar geo_filters: List of rules defining the user's geo access within a CDN endpoint. Each geo - filter defines an access rule to a specified path or content, e.g. block APAC for path - /pictures/. - :vartype geo_filters: list[~azure.mgmt.cdn.models.GeoFilter] - :ivar default_origin_group: A reference to the origin group. - :vartype default_origin_group: ~azure.mgmt.cdn.models.ResourceReference - :ivar url_signing_keys: List of keys used to validate the signed URL hashes. - :vartype url_signing_keys: list[~azure.mgmt.cdn.models.UrlSigningKey] - :ivar delivery_policy: A policy that specifies the delivery rules to be used for an endpoint. - :vartype delivery_policy: - ~azure.mgmt.cdn.models.EndpointPropertiesUpdateParametersDeliveryPolicy - :ivar web_application_firewall_policy_link: Defines the Web Application Firewall policy for the - endpoint (if applicable). - :vartype web_application_firewall_policy_link: - ~azure.mgmt.cdn.models.EndpointPropertiesUpdateParametersWebApplicationFirewallPolicyLink - :ivar host_name: The host name of the endpoint structured as {endpointName}.{DNSZone}, e.g. - contoso.azureedge.net. - :vartype host_name: str - :ivar origins: The source of the content being delivered via CDN. Required. - :vartype origins: list[~azure.mgmt.cdn.models.DeepCreatedOrigin] - :ivar origin_groups: The origin groups comprising of origins that are used for load balancing - the traffic based on availability. - :vartype origin_groups: list[~azure.mgmt.cdn.models.DeepCreatedOriginGroup] - :ivar custom_domains: The custom domains under the endpoint. - :vartype custom_domains: list[~azure.mgmt.cdn.models.DeepCreatedCustomDomain] - :ivar resource_state: Resource status of the endpoint. Known values are: "Creating", - "Deleting", "Running", "Starting", "Stopped", and "Stopping". - :vartype resource_state: str or ~azure.mgmt.cdn.models.EndpointResourceState - :ivar provisioning_state: Provisioning status of the endpoint. Known values are: "Succeeded", - "Failed", "Updating", "Deleting", and "Creating". - :vartype provisioning_state: str or ~azure.mgmt.cdn.models.EndpointProvisioningState - """ - - _validation = { - "host_name": {"readonly": True}, - "origins": {"required": True}, - "custom_domains": {"readonly": True}, - "resource_state": {"readonly": True}, - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "origin_path": {"key": "originPath", "type": "str"}, - "content_types_to_compress": {"key": "contentTypesToCompress", "type": "[str]"}, - "origin_host_header": {"key": "originHostHeader", "type": "str"}, - "is_compression_enabled": {"key": "isCompressionEnabled", "type": "bool"}, - "is_http_allowed": {"key": "isHttpAllowed", "type": "bool"}, - "is_https_allowed": {"key": "isHttpsAllowed", "type": "bool"}, - "query_string_caching_behavior": {"key": "queryStringCachingBehavior", "type": "str"}, - "optimization_type": {"key": "optimizationType", "type": "str"}, - "probe_path": {"key": "probePath", "type": "str"}, - "geo_filters": {"key": "geoFilters", "type": "[GeoFilter]"}, - "default_origin_group": {"key": "defaultOriginGroup", "type": "ResourceReference"}, - "url_signing_keys": {"key": "urlSigningKeys", "type": "[UrlSigningKey]"}, - "delivery_policy": {"key": "deliveryPolicy", "type": "EndpointPropertiesUpdateParametersDeliveryPolicy"}, - "web_application_firewall_policy_link": { - "key": "webApplicationFirewallPolicyLink", - "type": "EndpointPropertiesUpdateParametersWebApplicationFirewallPolicyLink", - }, - "host_name": {"key": "hostName", "type": "str"}, - "origins": {"key": "origins", "type": "[DeepCreatedOrigin]"}, - "origin_groups": {"key": "originGroups", "type": "[DeepCreatedOriginGroup]"}, - "custom_domains": {"key": "customDomains", "type": "[DeepCreatedCustomDomain]"}, - "resource_state": {"key": "resourceState", "type": "str"}, - "provisioning_state": {"key": "provisioningState", "type": "str"}, - } - - def __init__( - self, - *, - origins: List["_models.DeepCreatedOrigin"], - origin_path: Optional[str] = None, - content_types_to_compress: Optional[List[str]] = None, - origin_host_header: Optional[str] = None, - is_compression_enabled: Optional[bool] = None, - is_http_allowed: bool = True, - is_https_allowed: bool = True, - query_string_caching_behavior: Optional[Union[str, "_models.QueryStringCachingBehavior"]] = None, - optimization_type: Optional[Union[str, "_models.OptimizationType"]] = None, - probe_path: Optional[str] = None, - geo_filters: Optional[List["_models.GeoFilter"]] = None, - default_origin_group: Optional["_models.ResourceReference"] = None, - url_signing_keys: Optional[List["_models.UrlSigningKey"]] = None, - delivery_policy: Optional["_models.EndpointPropertiesUpdateParametersDeliveryPolicy"] = None, - web_application_firewall_policy_link: Optional[ - "_models.EndpointPropertiesUpdateParametersWebApplicationFirewallPolicyLink" - ] = None, - origin_groups: Optional[List["_models.DeepCreatedOriginGroup"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword origin_path: A directory path on the origin that CDN can use to retrieve content from, - e.g. contoso.cloudapp.net/originpath. - :paramtype origin_path: str - :keyword content_types_to_compress: List of content types on which compression applies. The - value should be a valid MIME type. - :paramtype content_types_to_compress: list[str] - :keyword origin_host_header: The host header value sent to the origin with each request. This - property at Endpoint is only allowed when endpoint uses single origin and can be overridden by - the same property specified at origin.If you leave this blank, the request hostname determines - this value. Azure CDN origins, such as Web Apps, Blob Storage, and Cloud Services require this - host header value to match the origin hostname by default. - :paramtype origin_host_header: str - :keyword is_compression_enabled: Indicates whether content compression is enabled on CDN. - Default value is false. If compression is enabled, content will be served as compressed if user - requests for a compressed version. Content won't be compressed on CDN when requested content is - smaller than 1 byte or larger than 1 MB. - :paramtype is_compression_enabled: bool - :keyword is_http_allowed: Indicates whether HTTP traffic is allowed on the endpoint. Default - value is true. At least one protocol (HTTP or HTTPS) must be allowed. - :paramtype is_http_allowed: bool - :keyword is_https_allowed: Indicates whether HTTPS traffic is allowed on the endpoint. Default - value is true. At least one protocol (HTTP or HTTPS) must be allowed. - :paramtype is_https_allowed: bool - :keyword query_string_caching_behavior: Defines how CDN caches requests that include query - strings. You can ignore any query strings when caching, bypass caching to prevent requests that - contain query strings from being cached, or cache every request with a unique URL. Known values - are: "IgnoreQueryString", "BypassCaching", "UseQueryString", and "NotSet". - :paramtype query_string_caching_behavior: str or - ~azure.mgmt.cdn.models.QueryStringCachingBehavior - :keyword optimization_type: Specifies what scenario the customer wants this CDN endpoint to - optimize for, e.g. Download, Media services. With this information, CDN can apply scenario - driven optimization. Known values are: "GeneralWebDelivery", "GeneralMediaStreaming", - "VideoOnDemandMediaStreaming", "LargeFileDownload", and "DynamicSiteAcceleration". - :paramtype optimization_type: str or ~azure.mgmt.cdn.models.OptimizationType - :keyword probe_path: Path to a file hosted on the origin which helps accelerate delivery of the - dynamic content and calculate the most optimal routes for the CDN. This is relative to the - origin path. This property is only relevant when using a single origin. - :paramtype probe_path: str - :keyword geo_filters: List of rules defining the user's geo access within a CDN endpoint. Each - geo filter defines an access rule to a specified path or content, e.g. block APAC for path - /pictures/. - :paramtype geo_filters: list[~azure.mgmt.cdn.models.GeoFilter] - :keyword default_origin_group: A reference to the origin group. - :paramtype default_origin_group: ~azure.mgmt.cdn.models.ResourceReference - :keyword url_signing_keys: List of keys used to validate the signed URL hashes. - :paramtype url_signing_keys: list[~azure.mgmt.cdn.models.UrlSigningKey] - :keyword delivery_policy: A policy that specifies the delivery rules to be used for an - endpoint. - :paramtype delivery_policy: - ~azure.mgmt.cdn.models.EndpointPropertiesUpdateParametersDeliveryPolicy - :keyword web_application_firewall_policy_link: Defines the Web Application Firewall policy for - the endpoint (if applicable). - :paramtype web_application_firewall_policy_link: - ~azure.mgmt.cdn.models.EndpointPropertiesUpdateParametersWebApplicationFirewallPolicyLink - :keyword origins: The source of the content being delivered via CDN. Required. - :paramtype origins: list[~azure.mgmt.cdn.models.DeepCreatedOrigin] - :keyword origin_groups: The origin groups comprising of origins that are used for load - balancing the traffic based on availability. - :paramtype origin_groups: list[~azure.mgmt.cdn.models.DeepCreatedOriginGroup] - """ - super().__init__( - origin_path=origin_path, - content_types_to_compress=content_types_to_compress, - origin_host_header=origin_host_header, - is_compression_enabled=is_compression_enabled, - is_http_allowed=is_http_allowed, - is_https_allowed=is_https_allowed, - query_string_caching_behavior=query_string_caching_behavior, - optimization_type=optimization_type, - probe_path=probe_path, - geo_filters=geo_filters, - default_origin_group=default_origin_group, - url_signing_keys=url_signing_keys, - delivery_policy=delivery_policy, - web_application_firewall_policy_link=web_application_firewall_policy_link, - **kwargs - ) - self.host_name = None - self.origins = origins - self.origin_groups = origin_groups - self.custom_domains = None - self.resource_state = None - self.provisioning_state = None - - -class EndpointPropertiesUpdateParametersDeliveryPolicy(_serialization.Model): # pylint: disable=name-too-long - """A policy that specifies the delivery rules to be used for an endpoint. - - All required parameters must be populated in order to send to server. - - :ivar description: User-friendly description of the policy. - :vartype description: str - :ivar rules: A list of the delivery rules. Required. - :vartype rules: list[~azure.mgmt.cdn.models.DeliveryRule] - """ - - _validation = { - "rules": {"required": True}, - } - - _attribute_map = { - "description": {"key": "description", "type": "str"}, - "rules": {"key": "rules", "type": "[DeliveryRule]"}, - } - - def __init__( - self, *, rules: List["_models.DeliveryRule"], description: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword description: User-friendly description of the policy. - :paramtype description: str - :keyword rules: A list of the delivery rules. Required. - :paramtype rules: list[~azure.mgmt.cdn.models.DeliveryRule] - """ - super().__init__(**kwargs) - self.description = description - self.rules = rules - - -class EndpointPropertiesUpdateParametersWebApplicationFirewallPolicyLink( - _serialization.Model -): # pylint: disable=name-too-long - """Defines the Web Application Firewall policy for the endpoint (if applicable). - - :ivar id: Resource ID. - :vartype id: str - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - } - - def __init__(self, *, id: Optional[str] = None, **kwargs: Any) -> None: # pylint: disable=redefined-builtin - """ - :keyword id: Resource ID. - :paramtype id: str - """ - super().__init__(**kwargs) - self.id = id - - -class EndpointUpdateParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes - """Properties required to create or update an endpoint. - - :ivar tags: Endpoint tags. - :vartype tags: dict[str, str] - :ivar origin_path: A directory path on the origin that CDN can use to retrieve content from, - e.g. contoso.cloudapp.net/originpath. - :vartype origin_path: str - :ivar content_types_to_compress: List of content types on which compression applies. The value - should be a valid MIME type. - :vartype content_types_to_compress: list[str] - :ivar origin_host_header: The host header value sent to the origin with each request. This - property at Endpoint is only allowed when endpoint uses single origin and can be overridden by - the same property specified at origin.If you leave this blank, the request hostname determines - this value. Azure CDN origins, such as Web Apps, Blob Storage, and Cloud Services require this - host header value to match the origin hostname by default. - :vartype origin_host_header: str - :ivar is_compression_enabled: Indicates whether content compression is enabled on CDN. Default - value is false. If compression is enabled, content will be served as compressed if user - requests for a compressed version. Content won't be compressed on CDN when requested content is - smaller than 1 byte or larger than 1 MB. - :vartype is_compression_enabled: bool - :ivar is_http_allowed: Indicates whether HTTP traffic is allowed on the endpoint. Default value - is true. At least one protocol (HTTP or HTTPS) must be allowed. - :vartype is_http_allowed: bool - :ivar is_https_allowed: Indicates whether HTTPS traffic is allowed on the endpoint. Default - value is true. At least one protocol (HTTP or HTTPS) must be allowed. - :vartype is_https_allowed: bool - :ivar query_string_caching_behavior: Defines how CDN caches requests that include query - strings. You can ignore any query strings when caching, bypass caching to prevent requests that - contain query strings from being cached, or cache every request with a unique URL. Known values - are: "IgnoreQueryString", "BypassCaching", "UseQueryString", and "NotSet". - :vartype query_string_caching_behavior: str or - ~azure.mgmt.cdn.models.QueryStringCachingBehavior - :ivar optimization_type: Specifies what scenario the customer wants this CDN endpoint to - optimize for, e.g. Download, Media services. With this information, CDN can apply scenario - driven optimization. Known values are: "GeneralWebDelivery", "GeneralMediaStreaming", - "VideoOnDemandMediaStreaming", "LargeFileDownload", and "DynamicSiteAcceleration". - :vartype optimization_type: str or ~azure.mgmt.cdn.models.OptimizationType - :ivar probe_path: Path to a file hosted on the origin which helps accelerate delivery of the - dynamic content and calculate the most optimal routes for the CDN. This is relative to the - origin path. This property is only relevant when using a single origin. - :vartype probe_path: str - :ivar geo_filters: List of rules defining the user's geo access within a CDN endpoint. Each geo - filter defines an access rule to a specified path or content, e.g. block APAC for path - /pictures/. - :vartype geo_filters: list[~azure.mgmt.cdn.models.GeoFilter] - :ivar default_origin_group: A reference to the origin group. - :vartype default_origin_group: ~azure.mgmt.cdn.models.ResourceReference - :ivar url_signing_keys: List of keys used to validate the signed URL hashes. - :vartype url_signing_keys: list[~azure.mgmt.cdn.models.UrlSigningKey] - :ivar delivery_policy: A policy that specifies the delivery rules to be used for an endpoint. - :vartype delivery_policy: - ~azure.mgmt.cdn.models.EndpointPropertiesUpdateParametersDeliveryPolicy - :ivar web_application_firewall_policy_link: Defines the Web Application Firewall policy for the - endpoint (if applicable). - :vartype web_application_firewall_policy_link: - ~azure.mgmt.cdn.models.EndpointPropertiesUpdateParametersWebApplicationFirewallPolicyLink - """ - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "origin_path": {"key": "properties.originPath", "type": "str"}, - "content_types_to_compress": {"key": "properties.contentTypesToCompress", "type": "[str]"}, - "origin_host_header": {"key": "properties.originHostHeader", "type": "str"}, - "is_compression_enabled": {"key": "properties.isCompressionEnabled", "type": "bool"}, - "is_http_allowed": {"key": "properties.isHttpAllowed", "type": "bool"}, - "is_https_allowed": {"key": "properties.isHttpsAllowed", "type": "bool"}, - "query_string_caching_behavior": {"key": "properties.queryStringCachingBehavior", "type": "str"}, - "optimization_type": {"key": "properties.optimizationType", "type": "str"}, - "probe_path": {"key": "properties.probePath", "type": "str"}, - "geo_filters": {"key": "properties.geoFilters", "type": "[GeoFilter]"}, - "default_origin_group": {"key": "properties.defaultOriginGroup", "type": "ResourceReference"}, - "url_signing_keys": {"key": "properties.urlSigningKeys", "type": "[UrlSigningKey]"}, - "delivery_policy": { - "key": "properties.deliveryPolicy", - "type": "EndpointPropertiesUpdateParametersDeliveryPolicy", - }, - "web_application_firewall_policy_link": { - "key": "properties.webApplicationFirewallPolicyLink", - "type": "EndpointPropertiesUpdateParametersWebApplicationFirewallPolicyLink", - }, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - origin_path: Optional[str] = None, - content_types_to_compress: Optional[List[str]] = None, - origin_host_header: Optional[str] = None, - is_compression_enabled: Optional[bool] = None, - is_http_allowed: bool = True, - is_https_allowed: bool = True, - query_string_caching_behavior: Optional[Union[str, "_models.QueryStringCachingBehavior"]] = None, - optimization_type: Optional[Union[str, "_models.OptimizationType"]] = None, - probe_path: Optional[str] = None, - geo_filters: Optional[List["_models.GeoFilter"]] = None, - default_origin_group: Optional["_models.ResourceReference"] = None, - url_signing_keys: Optional[List["_models.UrlSigningKey"]] = None, - delivery_policy: Optional["_models.EndpointPropertiesUpdateParametersDeliveryPolicy"] = None, - web_application_firewall_policy_link: Optional[ - "_models.EndpointPropertiesUpdateParametersWebApplicationFirewallPolicyLink" - ] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Endpoint tags. - :paramtype tags: dict[str, str] - :keyword origin_path: A directory path on the origin that CDN can use to retrieve content from, - e.g. contoso.cloudapp.net/originpath. - :paramtype origin_path: str - :keyword content_types_to_compress: List of content types on which compression applies. The - value should be a valid MIME type. - :paramtype content_types_to_compress: list[str] - :keyword origin_host_header: The host header value sent to the origin with each request. This - property at Endpoint is only allowed when endpoint uses single origin and can be overridden by - the same property specified at origin.If you leave this blank, the request hostname determines - this value. Azure CDN origins, such as Web Apps, Blob Storage, and Cloud Services require this - host header value to match the origin hostname by default. - :paramtype origin_host_header: str - :keyword is_compression_enabled: Indicates whether content compression is enabled on CDN. - Default value is false. If compression is enabled, content will be served as compressed if user - requests for a compressed version. Content won't be compressed on CDN when requested content is - smaller than 1 byte or larger than 1 MB. - :paramtype is_compression_enabled: bool - :keyword is_http_allowed: Indicates whether HTTP traffic is allowed on the endpoint. Default - value is true. At least one protocol (HTTP or HTTPS) must be allowed. - :paramtype is_http_allowed: bool - :keyword is_https_allowed: Indicates whether HTTPS traffic is allowed on the endpoint. Default - value is true. At least one protocol (HTTP or HTTPS) must be allowed. - :paramtype is_https_allowed: bool - :keyword query_string_caching_behavior: Defines how CDN caches requests that include query - strings. You can ignore any query strings when caching, bypass caching to prevent requests that - contain query strings from being cached, or cache every request with a unique URL. Known values - are: "IgnoreQueryString", "BypassCaching", "UseQueryString", and "NotSet". - :paramtype query_string_caching_behavior: str or - ~azure.mgmt.cdn.models.QueryStringCachingBehavior - :keyword optimization_type: Specifies what scenario the customer wants this CDN endpoint to - optimize for, e.g. Download, Media services. With this information, CDN can apply scenario - driven optimization. Known values are: "GeneralWebDelivery", "GeneralMediaStreaming", - "VideoOnDemandMediaStreaming", "LargeFileDownload", and "DynamicSiteAcceleration". - :paramtype optimization_type: str or ~azure.mgmt.cdn.models.OptimizationType - :keyword probe_path: Path to a file hosted on the origin which helps accelerate delivery of the - dynamic content and calculate the most optimal routes for the CDN. This is relative to the - origin path. This property is only relevant when using a single origin. - :paramtype probe_path: str - :keyword geo_filters: List of rules defining the user's geo access within a CDN endpoint. Each - geo filter defines an access rule to a specified path or content, e.g. block APAC for path - /pictures/. - :paramtype geo_filters: list[~azure.mgmt.cdn.models.GeoFilter] - :keyword default_origin_group: A reference to the origin group. - :paramtype default_origin_group: ~azure.mgmt.cdn.models.ResourceReference - :keyword url_signing_keys: List of keys used to validate the signed URL hashes. - :paramtype url_signing_keys: list[~azure.mgmt.cdn.models.UrlSigningKey] - :keyword delivery_policy: A policy that specifies the delivery rules to be used for an - endpoint. - :paramtype delivery_policy: - ~azure.mgmt.cdn.models.EndpointPropertiesUpdateParametersDeliveryPolicy - :keyword web_application_firewall_policy_link: Defines the Web Application Firewall policy for - the endpoint (if applicable). - :paramtype web_application_firewall_policy_link: - ~azure.mgmt.cdn.models.EndpointPropertiesUpdateParametersWebApplicationFirewallPolicyLink - """ - super().__init__(**kwargs) - self.tags = tags - self.origin_path = origin_path - self.content_types_to_compress = content_types_to_compress - self.origin_host_header = origin_host_header - self.is_compression_enabled = is_compression_enabled - self.is_http_allowed = is_http_allowed - self.is_https_allowed = is_https_allowed - self.query_string_caching_behavior = query_string_caching_behavior - self.optimization_type = optimization_type - self.probe_path = probe_path - self.geo_filters = geo_filters - self.default_origin_group = default_origin_group - self.url_signing_keys = url_signing_keys - self.delivery_policy = delivery_policy - self.web_application_firewall_policy_link = web_application_firewall_policy_link - - -class ErrorAdditionalInfo(_serialization.Model): - """The resource management error additional info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The additional info type. - :vartype type: str - :ivar info: The additional info. - :vartype info: JSON - """ - - _validation = { - "type": {"readonly": True}, - "info": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "info": {"key": "info", "type": "object"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.type = None - self.info = None - - -class ErrorDetail(_serialization.Model): - """The error detail. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: The error code. - :vartype code: str - :ivar message: The error message. - :vartype message: str - :ivar target: The error target. - :vartype target: str - :ivar details: The error details. - :vartype details: list[~azure.mgmt.cdn.models.ErrorDetail] - :ivar additional_info: The error additional info. - :vartype additional_info: list[~azure.mgmt.cdn.models.ErrorAdditionalInfo] - """ - - _validation = { - "code": {"readonly": True}, - "message": {"readonly": True}, - "target": {"readonly": True}, - "details": {"readonly": True}, - "additional_info": {"readonly": True}, - } - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "message": {"key": "message", "type": "str"}, - "target": {"key": "target", "type": "str"}, - "details": {"key": "details", "type": "[ErrorDetail]"}, - "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.code = None - self.message = None - self.target = None - self.details = None - self.additional_info = None - - -class ErrorResponse(_serialization.Model): - """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 object. - :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 object. - :paramtype error: ~azure.mgmt.cdn.models.ErrorDetail - """ - super().__init__(**kwargs) - self.error = error - - -class GeoFilter(_serialization.Model): - """Rules defining user's geo access within a CDN endpoint. - - All required parameters must be populated in order to send to server. - - :ivar relative_path: Relative path applicable to geo filter. (e.g. '/mypictures', - '/mypicture/kitty.jpg', and etc.). Required. - :vartype relative_path: str - :ivar action: Action of the geo filter, i.e. allow or block access. Required. Known values are: - "Block" and "Allow". - :vartype action: str or ~azure.mgmt.cdn.models.GeoFilterActions - :ivar country_codes: Two letter country or region codes defining user country or region access - in a geo filter, e.g. AU, MX, US. Required. - :vartype country_codes: list[str] - """ - - _validation = { - "relative_path": {"required": True}, - "action": {"required": True}, - "country_codes": {"required": True}, - } - - _attribute_map = { - "relative_path": {"key": "relativePath", "type": "str"}, - "action": {"key": "action", "type": "str"}, - "country_codes": {"key": "countryCodes", "type": "[str]"}, - } - - def __init__( - self, - *, - relative_path: str, - action: Union[str, "_models.GeoFilterActions"], - country_codes: List[str], - **kwargs: Any - ) -> None: - """ - :keyword relative_path: Relative path applicable to geo filter. (e.g. '/mypictures', - '/mypicture/kitty.jpg', and etc.). Required. - :paramtype relative_path: str - :keyword action: Action of the geo filter, i.e. allow or block access. Required. Known values - are: "Block" and "Allow". - :paramtype action: str or ~azure.mgmt.cdn.models.GeoFilterActions - :keyword country_codes: Two letter country or region codes defining user country or region - access in a geo filter, e.g. AU, MX, US. Required. - :paramtype country_codes: list[str] - """ - super().__init__(**kwargs) - self.relative_path = relative_path - self.action = action - self.country_codes = country_codes - - -class HeaderActionParameters(_serialization.Model): - """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 header_action: Action to perform. Required. Known values are: "Append", "Overwrite", and - "Delete". - :vartype header_action: str or ~azure.mgmt.cdn.models.HeaderAction - :ivar header_name: Name of the header to modify. Required. - :vartype header_name: str - :ivar value: Value for the specified action. - :vartype value: str - """ - - _validation = { - "type_name": {"required": True}, - "header_action": {"required": True}, - "header_name": {"required": True}, - } - - _attribute_map = { - "type_name": {"key": "typeName", "type": "str"}, - "header_action": {"key": "headerAction", "type": "str"}, - "header_name": {"key": "headerName", "type": "str"}, - "value": {"key": "value", "type": "str"}, - } - - 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 - :keyword header_name: Name of the header to modify. Required. - :paramtype header_name: str - :keyword value: Value for the specified action. - :paramtype value: str - """ - super().__init__(**kwargs) - self.type_name = type_name - self.header_action = header_action - self.header_name = header_name - self.value = value - - -class HealthProbeParameters(_serialization.Model): - """The JSON object that contains the properties to send health probes to origin. - - :ivar probe_path: The path relative to the origin that is used to determine the health of the - origin. - :vartype probe_path: str - :ivar probe_request_type: The type of health probe request that is made. Known values are: - "NotSet", "GET", and "HEAD". - :vartype probe_request_type: str or ~azure.mgmt.cdn.models.HealthProbeRequestType - :ivar probe_protocol: Protocol to use for health probe. Known values are: "NotSet", "Http", and - "Https". - :vartype probe_protocol: str or ~azure.mgmt.cdn.models.ProbeProtocol - :ivar probe_interval_in_seconds: The number of seconds between health probes.Default is 240sec. - :vartype probe_interval_in_seconds: int - """ - - _validation = { - "probe_interval_in_seconds": {"maximum": 255, "minimum": 1}, - } - - _attribute_map = { - "probe_path": {"key": "probePath", "type": "str"}, - "probe_request_type": {"key": "probeRequestType", "type": "str"}, - "probe_protocol": {"key": "probeProtocol", "type": "str"}, - "probe_interval_in_seconds": {"key": "probeIntervalInSeconds", "type": "int"}, - } - - def __init__( - self, - *, - probe_path: Optional[str] = None, - probe_request_type: Optional[Union[str, "_models.HealthProbeRequestType"]] = None, - probe_protocol: Optional[Union[str, "_models.ProbeProtocol"]] = None, - probe_interval_in_seconds: Optional[int] = None, - **kwargs: Any - ) -> None: - """ - :keyword probe_path: The path relative to the origin that is used to determine the health of - the origin. - :paramtype probe_path: str - :keyword probe_request_type: The type of health probe request that is made. Known values are: - "NotSet", "GET", and "HEAD". - :paramtype probe_request_type: str or ~azure.mgmt.cdn.models.HealthProbeRequestType - :keyword probe_protocol: Protocol to use for health probe. Known values are: "NotSet", "Http", - and "Https". - :paramtype probe_protocol: str or ~azure.mgmt.cdn.models.ProbeProtocol - :keyword probe_interval_in_seconds: The number of seconds between health probes.Default is - 240sec. - :paramtype probe_interval_in_seconds: int - """ - super().__init__(**kwargs) - self.probe_path = probe_path - self.probe_request_type = probe_request_type - self.probe_protocol = probe_protocol - self.probe_interval_in_seconds = probe_interval_in_seconds - - -class HostNameMatchConditionParameters(_serialization.Model): - """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 operator: Describes operator to be matched. Required. Known values are: "Any", "Equal", - "Contains", "BeginsWith", "EndsWith", "LessThan", "LessThanOrEqual", "GreaterThan", - "GreaterThanOrEqual", and "RegEx". - :vartype operator: str or ~azure.mgmt.cdn.models.HostNameOperator - :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] - :ivar transforms: List of transforms. - :vartype transforms: list[str or ~azure.mgmt.cdn.models.Transform] - """ - - _validation = { - "type_name": {"required": True}, - "operator": {"required": True}, - } - - _attribute_map = { - "type_name": {"key": "typeName", "type": "str"}, - "operator": {"key": "operator", "type": "str"}, - "negate_condition": {"key": "negateCondition", "type": "bool"}, - "match_values": {"key": "matchValues", "type": "[str]"}, - "transforms": {"key": "transforms", "type": "[str]"}, - } - - def __init__( - self, - *, - type_name: Union[str, "_models.HostNameMatchConditionParametersTypeName"], - operator: Union[str, "_models.HostNameOperator"], - negate_condition: bool = False, - match_values: Optional[List[str]] = None, - transforms: Optional[List[Union[str, "_models.Transform"]]] = None, - **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". - :paramtype operator: str or ~azure.mgmt.cdn.models.HostNameOperator - :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] - :keyword transforms: List of transforms. - :paramtype transforms: list[str or ~azure.mgmt.cdn.models.Transform] - """ - super().__init__(**kwargs) - self.type_name = type_name - self.operator = operator - self.negate_condition = negate_condition - self.match_values = match_values - self.transforms = transforms - - -class HttpErrorRangeParameters(_serialization.Model): - """The JSON object that represents the range for http status codes. - - :ivar begin: The inclusive start of the http status code range. - :vartype begin: int - :ivar end: The inclusive end of the http status code range. - :vartype end: int - """ - - _validation = { - "begin": {"maximum": 999, "minimum": 100}, - "end": {"maximum": 999, "minimum": 100}, - } - - _attribute_map = { - "begin": {"key": "begin", "type": "int"}, - "end": {"key": "end", "type": "int"}, - } - - def __init__(self, *, begin: Optional[int] = None, end: Optional[int] = None, **kwargs: Any) -> None: - """ - :keyword begin: The inclusive start of the http status code range. - :paramtype begin: int - :keyword end: The inclusive end of the http status code range. - :paramtype end: int - """ - super().__init__(**kwargs) - self.begin = begin - self.end = end - - -class HttpVersionMatchConditionParameters(_serialization.Model): - """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 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. - :vartype negate_condition: bool - :ivar match_values: The match value for the condition of the delivery rule. - :vartype match_values: list[str] - :ivar transforms: List of transforms. - :vartype transforms: list[str or ~azure.mgmt.cdn.models.Transform] - """ - - _validation = { - "type_name": {"required": True}, - "operator": {"required": True}, - } - - _attribute_map = { - "type_name": {"key": "typeName", "type": "str"}, - "operator": {"key": "operator", "type": "str"}, - "negate_condition": {"key": "negateCondition", "type": "bool"}, - "match_values": {"key": "matchValues", "type": "[str]"}, - "transforms": {"key": "transforms", "type": "[str]"}, - } - - def __init__( - self, - *, - type_name: Union[str, "_models.HttpVersionMatchConditionParametersTypeName"], - operator: Union[str, "_models.HttpVersionOperator"], - negate_condition: bool = False, - match_values: Optional[List[str]] = None, - transforms: Optional[List[Union[str, "_models.Transform"]]] = None, - **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. - :paramtype negate_condition: bool - :keyword match_values: The match value for the condition of the delivery rule. - :paramtype match_values: list[str] - :keyword transforms: List of transforms. - :paramtype transforms: list[str or ~azure.mgmt.cdn.models.Transform] - """ - super().__init__(**kwargs) - self.type_name = type_name - self.operator = operator - self.negate_condition = negate_condition - self.match_values = match_values - self.transforms = transforms - - -class IpAddressGroup(_serialization.Model): - """CDN Ip address group. - - :ivar delivery_region: The delivery region of the ip address group. - :vartype delivery_region: str - :ivar ipv4_addresses: The list of ip v4 addresses. - :vartype ipv4_addresses: list[~azure.mgmt.cdn.models.CidrIpAddress] - :ivar ipv6_addresses: The list of ip v6 addresses. - :vartype ipv6_addresses: list[~azure.mgmt.cdn.models.CidrIpAddress] - """ - - _attribute_map = { - "delivery_region": {"key": "deliveryRegion", "type": "str"}, - "ipv4_addresses": {"key": "ipv4Addresses", "type": "[CidrIpAddress]"}, - "ipv6_addresses": {"key": "ipv6Addresses", "type": "[CidrIpAddress]"}, - } - - def __init__( - self, - *, - delivery_region: Optional[str] = None, - ipv4_addresses: Optional[List["_models.CidrIpAddress"]] = None, - ipv6_addresses: Optional[List["_models.CidrIpAddress"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword delivery_region: The delivery region of the ip address group. - :paramtype delivery_region: str - :keyword ipv4_addresses: The list of ip v4 addresses. - :paramtype ipv4_addresses: list[~azure.mgmt.cdn.models.CidrIpAddress] - :keyword ipv6_addresses: The list of ip v6 addresses. - :paramtype ipv6_addresses: list[~azure.mgmt.cdn.models.CidrIpAddress] - """ - super().__init__(**kwargs) - self.delivery_region = delivery_region - self.ipv4_addresses = ipv4_addresses - self.ipv6_addresses = ipv6_addresses - - -class IsDeviceMatchConditionParameters(_serialization.Model): - """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 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] - :ivar transforms: List of transforms. - :vartype transforms: list[str or ~azure.mgmt.cdn.models.Transform] - """ - - _validation = { - "type_name": {"required": True}, - "operator": {"required": True}, - } - - _attribute_map = { - "type_name": {"key": "typeName", "type": "str"}, - "operator": {"key": "operator", "type": "str"}, - "negate_condition": {"key": "negateCondition", "type": "bool"}, - "match_values": {"key": "matchValues", "type": "[str]"}, - "transforms": {"key": "transforms", "type": "[str]"}, - } - - 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, - 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] - :keyword transforms: List of transforms. - :paramtype transforms: list[str or ~azure.mgmt.cdn.models.Transform] - """ - super().__init__(**kwargs) - self.type_name = type_name - self.operator = operator - self.negate_condition = negate_condition - self.match_values = match_values - self.transforms = transforms - - -class KeyVaultCertificateSourceParameters(_serialization.Model): - """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 subscription_id: Subscription Id of the user's Key Vault containing the SSL certificate. - Required. - :vartype subscription_id: str - :ivar resource_group_name: Resource group of the user's Key Vault containing the SSL - certificate. Required. - :vartype resource_group_name: str - :ivar vault_name: The name of the user's Key Vault containing the SSL certificate. Required. - :vartype vault_name: str - :ivar secret_name: The name of Key Vault Secret (representing the full certificate PFX) in Key - Vault. Required. - :vartype secret_name: str - :ivar secret_version: The version(GUID) of Key Vault Secret in Key Vault. - :vartype secret_version: str - :ivar update_rule: Describes the action that shall be taken when the certificate is updated in - Key Vault. Required. "NoAction" - :vartype update_rule: str or ~azure.mgmt.cdn.models.UpdateRule - :ivar delete_rule: Describes the action that shall be taken when the certificate is removed - from Key Vault. Required. "NoAction" - :vartype delete_rule: str or ~azure.mgmt.cdn.models.DeleteRule - """ - - _validation = { - "type_name": {"required": True}, - "subscription_id": {"required": True}, - "resource_group_name": {"required": True}, - "vault_name": {"required": True}, - "secret_name": {"required": True}, - "update_rule": {"required": True}, - "delete_rule": {"required": True}, - } - - _attribute_map = { - "type_name": {"key": "typeName", "type": "str"}, - "subscription_id": {"key": "subscriptionId", "type": "str"}, - "resource_group_name": {"key": "resourceGroupName", "type": "str"}, - "vault_name": {"key": "vaultName", "type": "str"}, - "secret_name": {"key": "secretName", "type": "str"}, - "secret_version": {"key": "secretVersion", "type": "str"}, - "update_rule": {"key": "updateRule", "type": "str"}, - "delete_rule": {"key": "deleteRule", "type": "str"}, - } - - def __init__( - self, - *, - type_name: Union[str, "_models.KeyVaultCertificateSourceParametersTypeName"], - subscription_id: str, - resource_group_name: str, - vault_name: str, - secret_name: str, - update_rule: Union[str, "_models.UpdateRule"], - delete_rule: Union[str, "_models.DeleteRule"], - secret_version: Optional[str] = None, - **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 - :keyword resource_group_name: Resource group of the user's Key Vault containing the SSL - certificate. Required. - :paramtype resource_group_name: str - :keyword vault_name: The name of the user's Key Vault containing the SSL certificate. Required. - :paramtype vault_name: str - :keyword secret_name: The name of Key Vault Secret (representing the full certificate PFX) in - Key Vault. Required. - :paramtype secret_name: str - :keyword secret_version: The version(GUID) of Key Vault Secret in Key Vault. - :paramtype secret_version: str - :keyword update_rule: Describes the action that shall be taken when the certificate is updated - in Key Vault. Required. "NoAction" - :paramtype update_rule: str or ~azure.mgmt.cdn.models.UpdateRule - :keyword delete_rule: Describes the action that shall be taken when the certificate is removed - from Key Vault. Required. "NoAction" - :paramtype delete_rule: str or ~azure.mgmt.cdn.models.DeleteRule - """ - super().__init__(**kwargs) - self.type_name = type_name - self.subscription_id = subscription_id - self.resource_group_name = resource_group_name - self.vault_name = vault_name - self.secret_name = secret_name - self.secret_version = secret_version - self.update_rule = update_rule - self.delete_rule = delete_rule - - -class KeyVaultSigningKeyParameters(_serialization.Model): - """Describes the parameters for using a user's KeyVault for URL Signing Key. - - 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 - :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. - Required. - :vartype resource_group_name: str - :ivar vault_name: The name of the user's Key Vault containing the secret. Required. - :vartype vault_name: str - :ivar secret_name: The name of secret in Key Vault. Required. - :vartype secret_name: str - :ivar secret_version: The version(GUID) of secret in Key Vault. Required. - :vartype secret_version: str - """ - - _validation = { - "type_name": {"required": True}, - "subscription_id": {"required": True}, - "resource_group_name": {"required": True}, - "vault_name": {"required": True}, - "secret_name": {"required": True}, - "secret_version": {"required": True}, - } - - _attribute_map = { - "type_name": {"key": "typeName", "type": "str"}, - "subscription_id": {"key": "subscriptionId", "type": "str"}, - "resource_group_name": {"key": "resourceGroupName", "type": "str"}, - "vault_name": {"key": "vaultName", "type": "str"}, - "secret_name": {"key": "secretName", "type": "str"}, - "secret_version": {"key": "secretVersion", "type": "str"}, - } - - def __init__( - self, - *, - type_name: Union[str, "_models.KeyVaultSigningKeyParametersTypeName"], - subscription_id: str, - resource_group_name: str, - vault_name: str, - secret_name: str, - secret_version: str, - **kwargs: Any - ) -> None: - """ - :keyword type_name: Required. "KeyVaultSigningKeyParameters" - :paramtype type_name: str or ~azure.mgmt.cdn.models.KeyVaultSigningKeyParametersTypeName - :keyword subscription_id: Subscription Id of the user's Key Vault containing the secret. - Required. - :paramtype subscription_id: str - :keyword resource_group_name: Resource group of the user's Key Vault containing the secret. - Required. - :paramtype resource_group_name: str - :keyword vault_name: The name of the user's Key Vault containing the secret. Required. - :paramtype vault_name: str - :keyword secret_name: The name of secret in Key Vault. Required. - :paramtype secret_name: str - :keyword secret_version: The version(GUID) of secret in Key Vault. Required. - :paramtype secret_version: str - """ - super().__init__(**kwargs) - self.type_name = type_name - self.subscription_id = subscription_id - self.resource_group_name = resource_group_name - self.vault_name = vault_name - self.secret_name = secret_name - self.secret_version = secret_version - - -class LoadBalancingSettingsParameters(_serialization.Model): - """Round-Robin load balancing settings for a backend pool. - - :ivar sample_size: The number of samples to consider for load balancing decisions. - :vartype sample_size: int - :ivar successful_samples_required: The number of samples within the sample period that must - succeed. - :vartype successful_samples_required: int - :ivar additional_latency_in_milliseconds: The additional latency in milliseconds for probes to - fall into the lowest latency bucket. - :vartype additional_latency_in_milliseconds: int - """ - - _attribute_map = { - "sample_size": {"key": "sampleSize", "type": "int"}, - "successful_samples_required": {"key": "successfulSamplesRequired", "type": "int"}, - "additional_latency_in_milliseconds": {"key": "additionalLatencyInMilliseconds", "type": "int"}, - } - - def __init__( - self, - *, - sample_size: Optional[int] = None, - successful_samples_required: Optional[int] = None, - additional_latency_in_milliseconds: Optional[int] = None, - **kwargs: Any - ) -> None: - """ - :keyword sample_size: The number of samples to consider for load balancing decisions. - :paramtype sample_size: int - :keyword successful_samples_required: The number of samples within the sample period that must - succeed. - :paramtype successful_samples_required: int - :keyword additional_latency_in_milliseconds: The additional latency in milliseconds for probes - to fall into the lowest latency bucket. - :paramtype additional_latency_in_milliseconds: int - """ - super().__init__(**kwargs) - self.sample_size = sample_size - self.successful_samples_required = successful_samples_required - self.additional_latency_in_milliseconds = additional_latency_in_milliseconds - - -class LoadParameters(_serialization.Model): - """Parameters required for content load. - - All required parameters must be populated in order to send to server. - - :ivar content_paths: The path to the content to be loaded. Path should be a relative file URL - of the origin. Required. - :vartype content_paths: list[str] - """ - - _validation = { - "content_paths": {"required": True}, - } - - _attribute_map = { - "content_paths": {"key": "contentPaths", "type": "[str]"}, - } - - def __init__(self, *, content_paths: List[str], **kwargs: Any) -> None: - """ - :keyword content_paths: The path to the content to be loaded. Path should be a relative file - URL of the origin. Required. - :paramtype content_paths: list[str] - """ - super().__init__(**kwargs) - self.content_paths = content_paths - - -class LogSpecification(_serialization.Model): - """Log specification of operation. - - :ivar name: Name of log specification. - :vartype name: str - :ivar display_name: Display name of log specification. - :vartype display_name: str - :ivar blob_duration: Blob duration of specification. - :vartype blob_duration: str - :ivar log_filter_pattern: Pattern to filter based on name. - :vartype log_filter_pattern: str - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "display_name": {"key": "displayName", "type": "str"}, - "blob_duration": {"key": "blobDuration", "type": "str"}, - "log_filter_pattern": {"key": "logFilterPattern", "type": "str"}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - display_name: Optional[str] = None, - blob_duration: Optional[str] = None, - log_filter_pattern: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: Name of log specification. - :paramtype name: str - :keyword display_name: Display name of log specification. - :paramtype display_name: str - :keyword blob_duration: Blob duration of specification. - :paramtype blob_duration: str - :keyword log_filter_pattern: Pattern to filter based on name. - :paramtype log_filter_pattern: str - """ - super().__init__(**kwargs) - self.name = name - self.display_name = display_name - self.blob_duration = blob_duration - self.log_filter_pattern = log_filter_pattern - - -class ManagedCertificate(Certificate): - """Managed Certificate used for https. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The type of the secret resource. Known values are: "UrlSigningKey", - "CustomerCertificate", "ManagedCertificate", and "AzureFirstPartyManagedCertificate". - :vartype type: str or ~azure.mgmt.cdn.models.SecretType - :ivar subject: Subject name in the certificate. - :vartype subject: str - :ivar expiration_date: Certificate expiration date. - :vartype expiration_date: str - """ - - -class ManagedCertificateParameters(SecretParameters): - """Managed Certificate used for https. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to server. - - :ivar type: The type of the secret resource. Required. Known values are: "UrlSigningKey", - "CustomerCertificate", "ManagedCertificate", and "AzureFirstPartyManagedCertificate". - :vartype type: str or ~azure.mgmt.cdn.models.SecretType - :ivar subject: Subject name in the certificate. - :vartype subject: str - :ivar expiration_date: Certificate expiration date. - :vartype expiration_date: str - """ - - _validation = { - "type": {"required": True}, - "subject": {"readonly": True}, - "expiration_date": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "subject": {"key": "subject", "type": "str"}, - "expiration_date": {"key": "expirationDate", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.type: str = "ManagedCertificate" - self.subject = None - self.expiration_date = None - - -class ManagedRuleDefinition(_serialization.Model): - """Describes a managed rule definition. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar rule_id: Identifier for the managed rule. - :vartype rule_id: str - :ivar description: Describes the functionality of the managed rule. - :vartype description: str - """ - - _validation = { - "rule_id": {"readonly": True}, - "description": {"readonly": True}, - } - - _attribute_map = { - "rule_id": {"key": "ruleId", "type": "str"}, - "description": {"key": "description", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.rule_id = None - self.description = None - - -class ManagedRuleGroupDefinition(_serialization.Model): - """Describes a managed rule group. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar rule_group_name: Name of the managed rule group. - :vartype rule_group_name: str - :ivar description: Description of the managed rule group. - :vartype description: str - :ivar rules: List of rules within the managed rule group. - :vartype rules: list[~azure.mgmt.cdn.models.ManagedRuleDefinition] - """ - - _validation = { - "rule_group_name": {"readonly": True}, - "description": {"readonly": True}, - "rules": {"readonly": True}, - } - - _attribute_map = { - "rule_group_name": {"key": "ruleGroupName", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "rules": {"key": "rules", "type": "[ManagedRuleDefinition]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.rule_group_name = None - self.description = None - self.rules = None - - -class ManagedRuleGroupOverride(_serialization.Model): - """Defines a managed rule group override setting. - - All required parameters must be populated in order to send to server. - - :ivar rule_group_name: Describes the managed rule group within the rule set to override. - Required. - :vartype rule_group_name: str - :ivar rules: List of rules that will be enabled. If none specified, all rules in the group will - be disabled. - :vartype rules: list[~azure.mgmt.cdn.models.ManagedRuleOverride] - """ - - _validation = { - "rule_group_name": {"required": True}, - } - - _attribute_map = { - "rule_group_name": {"key": "ruleGroupName", "type": "str"}, - "rules": {"key": "rules", "type": "[ManagedRuleOverride]"}, - } - - def __init__( - self, *, rule_group_name: str, rules: Optional[List["_models.ManagedRuleOverride"]] = None, **kwargs: Any - ) -> None: - """ - :keyword rule_group_name: Describes the managed rule group within the rule set to override. - Required. - :paramtype rule_group_name: str - :keyword rules: List of rules that will be enabled. If none specified, all rules in the group - will be disabled. - :paramtype rules: list[~azure.mgmt.cdn.models.ManagedRuleOverride] - """ - super().__init__(**kwargs) - self.rule_group_name = rule_group_name - self.rules = rules - - -class ManagedRuleOverride(_serialization.Model): - """Defines a managed rule group override setting. - - All required parameters must be populated in order to send to server. - - :ivar rule_id: Identifier for the managed rule. Required. - :vartype rule_id: str - :ivar enabled_state: Describes if the managed rule is in enabled or disabled state. Defaults to - Disabled if not specified. Known values are: "Disabled" and "Enabled". - :vartype enabled_state: str or ~azure.mgmt.cdn.models.ManagedRuleEnabledState - :ivar action: Describes the override action to be applied when rule matches. Known values are: - "Allow", "Block", "Log", and "Redirect". - :vartype action: str or ~azure.mgmt.cdn.models.ActionType - """ - - _validation = { - "rule_id": {"required": True}, - } - - _attribute_map = { - "rule_id": {"key": "ruleId", "type": "str"}, - "enabled_state": {"key": "enabledState", "type": "str"}, - "action": {"key": "action", "type": "str"}, - } - - def __init__( - self, - *, - rule_id: str, - enabled_state: Optional[Union[str, "_models.ManagedRuleEnabledState"]] = None, - action: Optional[Union[str, "_models.ActionType"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword rule_id: Identifier for the managed rule. Required. - :paramtype rule_id: str - :keyword enabled_state: Describes if the managed rule is in enabled or disabled state. Defaults - to Disabled if not specified. Known values are: "Disabled" and "Enabled". - :paramtype enabled_state: str or ~azure.mgmt.cdn.models.ManagedRuleEnabledState - :keyword action: Describes the override action to be applied when rule matches. Known values - are: "Allow", "Block", "Log", and "Redirect". - :paramtype action: str or ~azure.mgmt.cdn.models.ActionType - """ - super().__init__(**kwargs) - self.rule_id = rule_id - self.enabled_state = enabled_state - self.action = action - - -class ManagedRuleSet(_serialization.Model): - """Defines a managed rule set. - - All required parameters must be populated in order to send to server. - - :ivar rule_set_type: Defines the rule set type to use. Required. - :vartype rule_set_type: str - :ivar rule_set_version: Defines the version of the rule set to use. Required. - :vartype rule_set_version: str - :ivar anomaly_score: Verizon only : If the rule set supports anomaly detection mode, this - describes the threshold for blocking requests. - :vartype anomaly_score: int - :ivar rule_group_overrides: Defines the rule overrides to apply to the rule set. - :vartype rule_group_overrides: list[~azure.mgmt.cdn.models.ManagedRuleGroupOverride] - """ - - _validation = { - "rule_set_type": {"required": True}, - "rule_set_version": {"required": True}, - "anomaly_score": {"maximum": 20, "minimum": 0}, - } - - _attribute_map = { - "rule_set_type": {"key": "ruleSetType", "type": "str"}, - "rule_set_version": {"key": "ruleSetVersion", "type": "str"}, - "anomaly_score": {"key": "anomalyScore", "type": "int"}, - "rule_group_overrides": {"key": "ruleGroupOverrides", "type": "[ManagedRuleGroupOverride]"}, - } - - def __init__( - self, - *, - rule_set_type: str, - rule_set_version: str, - anomaly_score: Optional[int] = None, - rule_group_overrides: Optional[List["_models.ManagedRuleGroupOverride"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword rule_set_type: Defines the rule set type to use. Required. - :paramtype rule_set_type: str - :keyword rule_set_version: Defines the version of the rule set to use. Required. - :paramtype rule_set_version: str - :keyword anomaly_score: Verizon only : If the rule set supports anomaly detection mode, this - describes the threshold for blocking requests. - :paramtype anomaly_score: int - :keyword rule_group_overrides: Defines the rule overrides to apply to the rule set. - :paramtype rule_group_overrides: list[~azure.mgmt.cdn.models.ManagedRuleGroupOverride] - """ - super().__init__(**kwargs) - self.rule_set_type = rule_set_type - self.rule_set_version = rule_set_version - self.anomaly_score = anomaly_score - self.rule_group_overrides = rule_group_overrides - - -class ManagedRuleSetDefinition(Resource): - """Describes a managed rule set definition. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar system_data: Read only system data. - :vartype system_data: ~azure.mgmt.cdn.models.SystemData - :ivar sku: The pricing tier (defines a CDN provider, feature list and rate) of the - CdnWebApplicationFirewallPolicy. - :vartype sku: ~azure.mgmt.cdn.models.Sku - :ivar provisioning_state: Provisioning state of the managed rule set. - :vartype provisioning_state: str - :ivar rule_set_type: Type of the managed rule set. - :vartype rule_set_type: str - :ivar rule_set_version: Version of the managed rule set type. - :vartype rule_set_version: str - :ivar rule_groups: Rule groups of the managed rule set. - :vartype rule_groups: list[~azure.mgmt.cdn.models.ManagedRuleGroupDefinition] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - "provisioning_state": {"readonly": True}, - "rule_set_type": {"readonly": True}, - "rule_set_version": {"readonly": True}, - "rule_groups": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "sku": {"key": "sku", "type": "Sku"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "rule_set_type": {"key": "properties.ruleSetType", "type": "str"}, - "rule_set_version": {"key": "properties.ruleSetVersion", "type": "str"}, - "rule_groups": {"key": "properties.ruleGroups", "type": "[ManagedRuleGroupDefinition]"}, - } - - def __init__(self, *, sku: Optional["_models.Sku"] = None, **kwargs: Any) -> None: - """ - :keyword sku: The pricing tier (defines a CDN provider, feature list and rate) of the - CdnWebApplicationFirewallPolicy. - :paramtype sku: ~azure.mgmt.cdn.models.Sku - """ - super().__init__(**kwargs) - self.sku = sku - self.provisioning_state = None - self.rule_set_type = None - self.rule_set_version = None - self.rule_groups = None - - -class ManagedRuleSetDefinitionList(_serialization.Model): - """List of managed rule set definitions available for use in a policy. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: List of managed rule set definitions. - :vartype value: list[~azure.mgmt.cdn.models.ManagedRuleSetDefinition] - :ivar next_link: URL to retrieve next set of managed rule set definitions. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[ManagedRuleSetDefinition]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword next_link: URL to retrieve next set of managed rule set definitions. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = None - self.next_link = next_link - - -class ManagedRuleSetList(_serialization.Model): - """Defines the list of managed rule sets for the policy. - - :ivar managed_rule_sets: List of rule sets. - :vartype managed_rule_sets: list[~azure.mgmt.cdn.models.ManagedRuleSet] - """ - - _attribute_map = { - "managed_rule_sets": {"key": "managedRuleSets", "type": "[ManagedRuleSet]"}, - } - - def __init__(self, *, managed_rule_sets: Optional[List["_models.ManagedRuleSet"]] = None, **kwargs: Any) -> None: - """ - :keyword managed_rule_sets: List of rule sets. - :paramtype managed_rule_sets: list[~azure.mgmt.cdn.models.ManagedRuleSet] - """ - super().__init__(**kwargs) - self.managed_rule_sets = managed_rule_sets - - -class ManagedServiceIdentity(_serialization.Model): - """Managed service identity (system assigned and/or user assigned identities). - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to server. - - :ivar principal_id: The service principal ID of the system assigned identity. This property - will only be provided for a system assigned identity. - :vartype principal_id: str - :ivar tenant_id: The tenant ID of the system assigned identity. This property will only be - provided for a system assigned identity. - :vartype tenant_id: str - :ivar type: Type of managed service identity (where both SystemAssigned and UserAssigned types - are allowed). Required. Known values are: "None", "SystemAssigned", "UserAssigned", and - "SystemAssigned, UserAssigned". - :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 - The dictionary values can be empty objects ({}) in requests. - :vartype user_assigned_identities: dict[str, ~azure.mgmt.cdn.models.UserAssignedIdentity] - """ - - _validation = { - "principal_id": {"readonly": True}, - "tenant_id": {"readonly": True}, - "type": {"required": True}, - } - - _attribute_map = { - "principal_id": {"key": "principalId", "type": "str"}, - "tenant_id": {"key": "tenantId", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "user_assigned_identities": {"key": "userAssignedIdentities", "type": "{UserAssignedIdentity}"}, - } - - def __init__( - self, - *, - type: Union[str, "_models.ManagedServiceIdentityType"], - user_assigned_identities: Optional[Dict[str, "_models.UserAssignedIdentity"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword type: Type of managed service identity (where both SystemAssigned and UserAssigned - types are allowed). Required. Known values are: "None", "SystemAssigned", "UserAssigned", and - "SystemAssigned, UserAssigned". - :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 - 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.type = type - self.user_assigned_identities = user_assigned_identities - - -class MatchCondition(_serialization.Model): - """Define match conditions. - - All required parameters must be populated in order to send to server. - - :ivar match_variable: Match variable to compare against. Required. Known values are: - "RemoteAddr", "SocketAddr", "RequestMethod", "RequestHeader", "RequestUri", "QueryString", - "RequestBody", "Cookies", and "PostArgs". - :vartype match_variable: str or ~azure.mgmt.cdn.models.WafMatchVariable - :ivar selector: Selector can used to match a specific key for QueryString, Cookies, - RequestHeader or PostArgs. - :vartype selector: str - :ivar operator: Describes operator to be matched. Required. Known values are: "Any", "IPMatch", - "GeoMatch", "Equal", "Contains", "LessThan", "GreaterThan", "LessThanOrEqual", - "GreaterThanOrEqual", "BeginsWith", "EndsWith", and "RegEx". - :vartype operator: str or ~azure.mgmt.cdn.models.Operator - :ivar negate_condition: Describes if the result of this condition should be negated. - :vartype negate_condition: bool - :ivar match_value: List of possible match values. Required. - :vartype match_value: list[str] - :ivar transforms: List of transforms. - :vartype transforms: list[str or ~azure.mgmt.cdn.models.TransformType] - """ - - _validation = { - "match_variable": {"required": True}, - "operator": {"required": True}, - "match_value": {"required": True}, - } - - _attribute_map = { - "match_variable": {"key": "matchVariable", "type": "str"}, - "selector": {"key": "selector", "type": "str"}, - "operator": {"key": "operator", "type": "str"}, - "negate_condition": {"key": "negateCondition", "type": "bool"}, - "match_value": {"key": "matchValue", "type": "[str]"}, - "transforms": {"key": "transforms", "type": "[str]"}, - } - - def __init__( - self, - *, - match_variable: Union[str, "_models.WafMatchVariable"], - operator: Union[str, "_models.Operator"], - match_value: List[str], - selector: Optional[str] = None, - negate_condition: Optional[bool] = None, - transforms: Optional[List[Union[str, "_models.TransformType"]]] = None, - **kwargs: Any - ) -> None: - """ - :keyword match_variable: Match variable to compare against. Required. Known values are: - "RemoteAddr", "SocketAddr", "RequestMethod", "RequestHeader", "RequestUri", "QueryString", - "RequestBody", "Cookies", and "PostArgs". - :paramtype match_variable: str or ~azure.mgmt.cdn.models.WafMatchVariable - :keyword selector: Selector can used to match a specific key for QueryString, Cookies, - RequestHeader or PostArgs. - :paramtype selector: str - :keyword operator: Describes operator to be matched. Required. Known values are: "Any", - "IPMatch", "GeoMatch", "Equal", "Contains", "LessThan", "GreaterThan", "LessThanOrEqual", - "GreaterThanOrEqual", "BeginsWith", "EndsWith", and "RegEx". - :paramtype operator: str or ~azure.mgmt.cdn.models.Operator - :keyword negate_condition: Describes if the result of this condition should be negated. - :paramtype negate_condition: bool - :keyword match_value: List of possible match values. Required. - :paramtype match_value: list[str] - :keyword transforms: List of transforms. - :paramtype transforms: list[str or ~azure.mgmt.cdn.models.TransformType] - """ - super().__init__(**kwargs) - self.match_variable = match_variable - self.selector = selector - self.operator = operator - self.negate_condition = negate_condition - self.match_value = match_value - self.transforms = transforms - - -class MetricAvailability(_serialization.Model): - """Retention policy of a resource metric. - - :ivar time_grain: - :vartype time_grain: str - :ivar blob_duration: - :vartype blob_duration: str - """ - - _attribute_map = { - "time_grain": {"key": "timeGrain", "type": "str"}, - "blob_duration": {"key": "blobDuration", "type": "str"}, - } - - def __init__(self, *, time_grain: Optional[str] = None, blob_duration: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword time_grain: - :paramtype time_grain: str - :keyword blob_duration: - :paramtype blob_duration: str - """ - super().__init__(**kwargs) - self.time_grain = time_grain - self.blob_duration = blob_duration - - -class MetricSpecification(_serialization.Model): # pylint: disable=too-many-instance-attributes - """Metric specification of operation. - - :ivar name: Name of metric specification. - :vartype name: str - :ivar display_name: Display name of metric specification. - :vartype display_name: str - :ivar display_description: Display description of metric specification. - :vartype display_description: str - :ivar unit: The metric unit. Possible values include: 'Bytes', 'Count', 'Milliseconds'. - :vartype unit: str - :ivar aggregation_type: The metric aggregation type. Possible values include: 'Average', - 'Count', 'Total'. - :vartype aggregation_type: str - :ivar availabilities: Retention policies of a resource metric. - :vartype availabilities: list[~azure.mgmt.cdn.models.MetricAvailability] - :ivar supported_time_grain_types: The supported time grain types for the metrics. - :vartype supported_time_grain_types: list[str] - :ivar dimensions: The dimensions of metric. - :vartype dimensions: list[~azure.mgmt.cdn.models.DimensionProperties] - :ivar fill_gap_with_zero: Property to specify whether to fill gap with zero. - :vartype fill_gap_with_zero: bool - :ivar metric_filter_pattern: Pattern to filter based on name. - :vartype metric_filter_pattern: str - :ivar is_internal: Property to specify metric is internal or not. - :vartype is_internal: bool - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "display_name": {"key": "displayName", "type": "str"}, - "display_description": {"key": "displayDescription", "type": "str"}, - "unit": {"key": "unit", "type": "str"}, - "aggregation_type": {"key": "aggregationType", "type": "str"}, - "availabilities": {"key": "availabilities", "type": "[MetricAvailability]"}, - "supported_time_grain_types": {"key": "supportedTimeGrainTypes", "type": "[str]"}, - "dimensions": {"key": "dimensions", "type": "[DimensionProperties]"}, - "fill_gap_with_zero": {"key": "fillGapWithZero", "type": "bool"}, - "metric_filter_pattern": {"key": "metricFilterPattern", "type": "str"}, - "is_internal": {"key": "isInternal", "type": "bool"}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - display_name: Optional[str] = None, - display_description: Optional[str] = None, - unit: Optional[str] = None, - aggregation_type: Optional[str] = None, - availabilities: Optional[List["_models.MetricAvailability"]] = None, - supported_time_grain_types: Optional[List[str]] = None, - dimensions: Optional[List["_models.DimensionProperties"]] = None, - fill_gap_with_zero: Optional[bool] = None, - metric_filter_pattern: Optional[str] = None, - is_internal: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: Name of metric specification. - :paramtype name: str - :keyword display_name: Display name of metric specification. - :paramtype display_name: str - :keyword display_description: Display description of metric specification. - :paramtype display_description: str - :keyword unit: The metric unit. Possible values include: 'Bytes', 'Count', 'Milliseconds'. - :paramtype unit: str - :keyword aggregation_type: The metric aggregation type. Possible values include: 'Average', - 'Count', 'Total'. - :paramtype aggregation_type: str - :keyword availabilities: Retention policies of a resource metric. - :paramtype availabilities: list[~azure.mgmt.cdn.models.MetricAvailability] - :keyword supported_time_grain_types: The supported time grain types for the metrics. - :paramtype supported_time_grain_types: list[str] - :keyword dimensions: The dimensions of metric. - :paramtype dimensions: list[~azure.mgmt.cdn.models.DimensionProperties] - :keyword fill_gap_with_zero: Property to specify whether to fill gap with zero. - :paramtype fill_gap_with_zero: bool - :keyword metric_filter_pattern: Pattern to filter based on name. - :paramtype metric_filter_pattern: str - :keyword is_internal: Property to specify metric is internal or not. - :paramtype is_internal: bool - """ - super().__init__(**kwargs) - self.name = name - self.display_name = display_name - self.display_description = display_description - self.unit = unit - self.aggregation_type = aggregation_type - self.availabilities = availabilities - self.supported_time_grain_types = supported_time_grain_types - self.dimensions = dimensions - self.fill_gap_with_zero = fill_gap_with_zero - self.metric_filter_pattern = metric_filter_pattern - self.is_internal = is_internal - - -class MetricsResponse(_serialization.Model): - """Metrics Response. - - :ivar date_time_begin: - :vartype date_time_begin: ~datetime.datetime - :ivar date_time_end: - :vartype date_time_end: ~datetime.datetime - :ivar granularity: Known values are: "PT5M", "PT1H", and "P1D". - :vartype granularity: str or ~azure.mgmt.cdn.models.MetricsGranularity - :ivar series: - :vartype series: list[~azure.mgmt.cdn.models.MetricsResponseSeriesItem] - """ - - _attribute_map = { - "date_time_begin": {"key": "dateTimeBegin", "type": "iso-8601"}, - "date_time_end": {"key": "dateTimeEnd", "type": "iso-8601"}, - "granularity": {"key": "granularity", "type": "str"}, - "series": {"key": "series", "type": "[MetricsResponseSeriesItem]"}, - } - - def __init__( - self, - *, - date_time_begin: Optional[datetime.datetime] = None, - date_time_end: Optional[datetime.datetime] = None, - granularity: Optional[Union[str, "_models.MetricsGranularity"]] = None, - series: Optional[List["_models.MetricsResponseSeriesItem"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword date_time_begin: - :paramtype date_time_begin: ~datetime.datetime - :keyword date_time_end: - :paramtype date_time_end: ~datetime.datetime - :keyword granularity: Known values are: "PT5M", "PT1H", and "P1D". - :paramtype granularity: str or ~azure.mgmt.cdn.models.MetricsGranularity - :keyword series: - :paramtype series: list[~azure.mgmt.cdn.models.MetricsResponseSeriesItem] - """ - super().__init__(**kwargs) - self.date_time_begin = date_time_begin - self.date_time_end = date_time_end - self.granularity = granularity - self.series = series - - -class MetricsResponseSeriesItem(_serialization.Model): - """MetricsResponseSeriesItem. - - :ivar metric: - :vartype metric: str - :ivar unit: Known values are: "count", "bytes", "bitsPerSecond", and "milliSeconds". - :vartype unit: str or ~azure.mgmt.cdn.models.MetricsSeriesUnit - :ivar groups: - :vartype groups: list[~azure.mgmt.cdn.models.MetricsResponseSeriesPropertiesItemsItem] - :ivar data: - :vartype data: - list[~azure.mgmt.cdn.models.Components1Gs0LlpSchemasMetricsresponsePropertiesSeriesItemsPropertiesDataItems] - """ - - _attribute_map = { - "metric": {"key": "metric", "type": "str"}, - "unit": {"key": "unit", "type": "str"}, - "groups": {"key": "groups", "type": "[MetricsResponseSeriesPropertiesItemsItem]"}, - "data": { - "key": "data", - "type": "[Components1Gs0LlpSchemasMetricsresponsePropertiesSeriesItemsPropertiesDataItems]", - }, - } - - def __init__( - self, - *, - metric: Optional[str] = None, - unit: Optional[Union[str, "_models.MetricsSeriesUnit"]] = None, - groups: Optional[List["_models.MetricsResponseSeriesPropertiesItemsItem"]] = None, - data: Optional[ - List["_models.Components1Gs0LlpSchemasMetricsresponsePropertiesSeriesItemsPropertiesDataItems"] - ] = None, - **kwargs: Any - ) -> None: - """ - :keyword metric: - :paramtype metric: str - :keyword unit: Known values are: "count", "bytes", "bitsPerSecond", and "milliSeconds". - :paramtype unit: str or ~azure.mgmt.cdn.models.MetricsSeriesUnit - :keyword groups: - :paramtype groups: list[~azure.mgmt.cdn.models.MetricsResponseSeriesPropertiesItemsItem] - :keyword data: - :paramtype data: - list[~azure.mgmt.cdn.models.Components1Gs0LlpSchemasMetricsresponsePropertiesSeriesItemsPropertiesDataItems] - """ - super().__init__(**kwargs) - self.metric = metric - self.unit = unit - self.groups = groups - self.data = data - - -class MetricsResponseSeriesPropertiesItemsItem(_serialization.Model): - """MetricsResponseSeriesPropertiesItemsItem. - - :ivar name: - :vartype name: str - :ivar value: - :vartype value: str - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "value": {"key": "value", "type": "str"}, - } - - def __init__(self, *, name: Optional[str] = None, value: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword name: - :paramtype name: str - :keyword value: - :paramtype value: str - """ - super().__init__(**kwargs) - self.name = name - self.value = value - - -class MigrateResult(_serialization.Model): - """Result for migrate operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar type: Resource type. - :vartype type: str - :ivar migrated_profile_resource_id: Arm resource id of the migrated profile. - :vartype migrated_profile_resource_id: ~azure.mgmt.cdn.models.ResourceReference - """ - - _validation = { - "id": {"readonly": True}, - "type": {"readonly": True}, - "migrated_profile_resource_id": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "migrated_profile_resource_id": {"key": "properties.migratedProfileResourceId", "type": "ResourceReference"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id = None - self.type = None - self.migrated_profile_resource_id = None - - -class MigrationErrorType(_serialization.Model): - """Error response indicates CDN service is not able to process the incoming request. The reason is - provided in the error message. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: Error code. - :vartype code: str - :ivar resource_name: Resource which has the problem. - :vartype resource_name: str - :ivar error_message: Error message indicating why the operation failed. - :vartype error_message: str - :ivar next_steps: Describes what needs to be done to fix the problem. - :vartype next_steps: str - """ - - _validation = { - "code": {"readonly": True}, - "resource_name": {"readonly": True}, - "error_message": {"readonly": True}, - "next_steps": {"readonly": True}, - } - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "resource_name": {"key": "resourceName", "type": "str"}, - "error_message": {"key": "errorMessage", "type": "str"}, - "next_steps": {"key": "nextSteps", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.code = None - self.resource_name = None - self.error_message = None - self.next_steps = None - - -class MigrationParameters(_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 classic_resource_reference: Resource reference of the classic cdn profile or classic - frontdoor that need to be migrated. Required. - :vartype classic_resource_reference: ~azure.mgmt.cdn.models.ResourceReference - :ivar profile_name: Name of the new profile that need to be created. Required. - :vartype profile_name: str - :ivar migration_web_application_firewall_mappings: Waf mapping for the migrated profile. - :vartype migration_web_application_firewall_mappings: - list[~azure.mgmt.cdn.models.MigrationWebApplicationFirewallMapping] - """ - - _validation = { - "sku": {"required": True}, - "classic_resource_reference": {"required": True}, - "profile_name": {"required": True}, - } - - _attribute_map = { - "sku": {"key": "sku", "type": "Sku"}, - "classic_resource_reference": {"key": "classicResourceReference", "type": "ResourceReference"}, - "profile_name": {"key": "profileName", "type": "str"}, - "migration_web_application_firewall_mappings": { - "key": "migrationWebApplicationFirewallMappings", - "type": "[MigrationWebApplicationFirewallMapping]", - }, - } - - def __init__( - self, - *, - sku: "_models.Sku", - classic_resource_reference: "_models.ResourceReference", - profile_name: str, - migration_web_application_firewall_mappings: Optional[ - List["_models.MigrationWebApplicationFirewallMapping"] - ] = None, - **kwargs: Any - ) -> None: - """ - :keyword sku: Sku for the migration. Required. - :paramtype sku: ~azure.mgmt.cdn.models.Sku - :keyword classic_resource_reference: Resource reference of the classic cdn profile or classic - frontdoor that need to be migrated. Required. - :paramtype classic_resource_reference: ~azure.mgmt.cdn.models.ResourceReference - :keyword profile_name: Name of the new profile that need to be created. Required. - :paramtype profile_name: str - :keyword migration_web_application_firewall_mappings: Waf mapping for the migrated profile. - :paramtype migration_web_application_firewall_mappings: - list[~azure.mgmt.cdn.models.MigrationWebApplicationFirewallMapping] - """ - super().__init__(**kwargs) - self.sku = sku - self.classic_resource_reference = classic_resource_reference - self.profile_name = profile_name - self.migration_web_application_firewall_mappings = migration_web_application_firewall_mappings - - -class MigrationWebApplicationFirewallMapping(_serialization.Model): - """Web Application Firewall Mapping. - - :ivar migrated_from: Migration From Waf policy. - :vartype migrated_from: ~azure.mgmt.cdn.models.ResourceReference - :ivar migrated_to: Migration to Waf policy. - :vartype migrated_to: ~azure.mgmt.cdn.models.ResourceReference - """ - - _attribute_map = { - "migrated_from": {"key": "migratedFrom", "type": "ResourceReference"}, - "migrated_to": {"key": "migratedTo", "type": "ResourceReference"}, - } - - def __init__( - self, - *, - migrated_from: Optional["_models.ResourceReference"] = None, - migrated_to: Optional["_models.ResourceReference"] = None, - **kwargs: Any - ) -> None: - """ - :keyword migrated_from: Migration From Waf policy. - :paramtype migrated_from: ~azure.mgmt.cdn.models.ResourceReference - :keyword migrated_to: Migration to Waf policy. - :paramtype migrated_to: ~azure.mgmt.cdn.models.ResourceReference - """ - super().__init__(**kwargs) - self.migrated_from = migrated_from - self.migrated_to = migrated_to - - -class Operation(_serialization.Model): - """CDN REST API operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: Operation name: {provider}/{resource}/{operation}. - :vartype name: str - :ivar is_data_action: Indicates whether the operation is a data action. - :vartype is_data_action: bool - :ivar display: The object that represents the operation. - :vartype display: ~azure.mgmt.cdn.models.OperationDisplay - :ivar origin: The origin of operations. - :vartype origin: str - :ivar service_specification: One property of operation, include metric specifications. - :vartype service_specification: ~azure.mgmt.cdn.models.ServiceSpecification - """ - - _validation = { - "name": {"readonly": True}, - "origin": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "is_data_action": {"key": "isDataAction", "type": "bool"}, - "display": {"key": "display", "type": "OperationDisplay"}, - "origin": {"key": "origin", "type": "str"}, - "service_specification": {"key": "properties.serviceSpecification", "type": "ServiceSpecification"}, - } - - def __init__( - self, - *, - is_data_action: Optional[bool] = None, - display: Optional["_models.OperationDisplay"] = None, - service_specification: Optional["_models.ServiceSpecification"] = None, - **kwargs: Any - ) -> None: - """ - :keyword is_data_action: Indicates whether the operation is a data action. - :paramtype is_data_action: bool - :keyword display: The object that represents the operation. - :paramtype display: ~azure.mgmt.cdn.models.OperationDisplay - :keyword service_specification: One property of operation, include metric specifications. - :paramtype service_specification: ~azure.mgmt.cdn.models.ServiceSpecification - """ - super().__init__(**kwargs) - self.name = None - self.is_data_action = is_data_action - self.display = display - self.origin = None - self.service_specification = service_specification - - -class OperationDisplay(_serialization.Model): - """The object that represents the operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar provider: Service provider: Microsoft.Cdn. - :vartype provider: str - :ivar resource: Resource on which the operation is performed: Profile, endpoint, etc. - :vartype resource: str - :ivar operation: Operation type: Read, write, delete, etc. - :vartype operation: str - :ivar description: Description of operation. - :vartype description: str - """ - - _validation = { - "provider": {"readonly": True}, - "resource": {"readonly": True}, - "operation": {"readonly": True}, - "description": {"readonly": True}, - } - - _attribute_map = { - "provider": {"key": "provider", "type": "str"}, - "resource": {"key": "resource", "type": "str"}, - "operation": {"key": "operation", "type": "str"}, - "description": {"key": "description", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.provider = None - self.resource = None - self.operation = None - self.description = None - - -class OperationsListResult(_serialization.Model): - """Result of the request to list CDN operations. It contains a list of operations and a URL link - to get the next set of results. - - :ivar value: List of CDN operations supported by the CDN resource provider. - :vartype value: list[~azure.mgmt.cdn.models.Operation] - :ivar next_link: URL to get the next set of operation list results if there are any. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[Operation]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: Optional[List["_models.Operation"]] = None, next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: List of CDN operations supported by the CDN resource provider. - :paramtype value: list[~azure.mgmt.cdn.models.Operation] - :keyword next_link: URL to get the next set of operation list results if there are any. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class Origin(ProxyResource): # pylint: disable=too-many-instance-attributes - """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. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar system_data: Read only system data. - :vartype system_data: ~azure.mgmt.cdn.models.SystemData - :ivar host_name: The address of the origin. Domain names, IPv4 addresses, and IPv6 addresses - are supported.This should be unique across all origins in an endpoint. - :vartype host_name: str - :ivar http_port: The value of the HTTP port. Must be between 1 and 65535. - :vartype http_port: int - :ivar https_port: The value of the HTTPS port. Must be between 1 and 65535. - :vartype https_port: int - :ivar origin_host_header: The host header value sent to the origin with each request. If you - leave this blank, the request hostname determines this value. Azure CDN origins, such as Web - Apps, Blob Storage, and Cloud Services require this host header value to match the origin - hostname by default. This overrides the host header defined at Endpoint. - :vartype origin_host_header: str - :ivar priority: Priority of origin in given origin group for load balancing. Higher priorities - will not be used for load balancing if any lower priority origin is healthy.Must be between 1 - and 5. - :vartype priority: int - :ivar weight: Weight of the origin in given origin group for load balancing. Must be between 1 - and 1000. - :vartype weight: int - :ivar enabled: Origin is enabled for load balancing or not. - :vartype enabled: bool - :ivar private_link_alias: The Alias of the Private Link resource. Populating this optional - field indicates that this origin is 'Private'. - :vartype private_link_alias: str - :ivar private_link_resource_id: The Resource Id of the Private Link resource. Populating this - optional field indicates that this backend is 'Private'. - :vartype private_link_resource_id: str - :ivar private_link_location: The location of the Private Link resource. Required only if - 'privateLinkResourceId' is populated. - :vartype private_link_location: str - :ivar private_link_approval_message: A custom message to be included in the approval request to - connect to the Private Link. - :vartype private_link_approval_message: str - :ivar resource_state: Resource status of the origin. Known values are: "Creating", "Active", - and "Deleting". - :vartype resource_state: str or ~azure.mgmt.cdn.models.OriginResourceState - :ivar provisioning_state: Provisioning status of the origin. Known values are: "Succeeded", - "Failed", "Updating", "Deleting", and "Creating". - :vartype provisioning_state: str or ~azure.mgmt.cdn.models.OriginProvisioningState - :ivar private_endpoint_status: The approval status for the connection to the Private Link. - Known values are: "Pending", "Approved", "Rejected", "Disconnected", and "Timeout". - :vartype private_endpoint_status: str or ~azure.mgmt.cdn.models.PrivateEndpointStatus - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - "http_port": {"maximum": 65535, "minimum": 1}, - "https_port": {"maximum": 65535, "minimum": 1}, - "priority": {"maximum": 5, "minimum": 1}, - "weight": {"maximum": 1000, "minimum": 1}, - "resource_state": {"readonly": True}, - "provisioning_state": {"readonly": True}, - "private_endpoint_status": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "host_name": {"key": "properties.hostName", "type": "str"}, - "http_port": {"key": "properties.httpPort", "type": "int"}, - "https_port": {"key": "properties.httpsPort", "type": "int"}, - "origin_host_header": {"key": "properties.originHostHeader", "type": "str"}, - "priority": {"key": "properties.priority", "type": "int"}, - "weight": {"key": "properties.weight", "type": "int"}, - "enabled": {"key": "properties.enabled", "type": "bool"}, - "private_link_alias": {"key": "properties.privateLinkAlias", "type": "str"}, - "private_link_resource_id": {"key": "properties.privateLinkResourceId", "type": "str"}, - "private_link_location": {"key": "properties.privateLinkLocation", "type": "str"}, - "private_link_approval_message": {"key": "properties.privateLinkApprovalMessage", "type": "str"}, - "resource_state": {"key": "properties.resourceState", "type": "str"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "private_endpoint_status": {"key": "properties.privateEndpointStatus", "type": "str"}, - } - - def __init__( - self, - *, - host_name: Optional[str] = None, - http_port: Optional[int] = None, - https_port: Optional[int] = None, - origin_host_header: Optional[str] = None, - priority: Optional[int] = None, - weight: Optional[int] = None, - enabled: Optional[bool] = None, - private_link_alias: Optional[str] = None, - private_link_resource_id: Optional[str] = None, - private_link_location: Optional[str] = None, - private_link_approval_message: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword host_name: The address of the origin. Domain names, IPv4 addresses, and IPv6 addresses - are supported.This should be unique across all origins in an endpoint. - :paramtype host_name: str - :keyword http_port: The value of the HTTP port. Must be between 1 and 65535. - :paramtype http_port: int - :keyword https_port: The value of the HTTPS port. Must be between 1 and 65535. - :paramtype https_port: int - :keyword origin_host_header: The host header value sent to the origin with each request. If you - leave this blank, the request hostname determines this value. Azure CDN origins, such as Web - Apps, Blob Storage, and Cloud Services require this host header value to match the origin - hostname by default. This overrides the host header defined at Endpoint. - :paramtype origin_host_header: str - :keyword priority: Priority of origin in given origin group for load balancing. Higher - priorities will not be used for load balancing if any lower priority origin is healthy.Must be - between 1 and 5. - :paramtype priority: int - :keyword weight: Weight of the origin in given origin group for load balancing. Must be between - 1 and 1000. - :paramtype weight: int - :keyword enabled: Origin is enabled for load balancing or not. - :paramtype enabled: bool - :keyword private_link_alias: The Alias of the Private Link resource. Populating this optional - field indicates that this origin is 'Private'. - :paramtype private_link_alias: str - :keyword private_link_resource_id: The Resource Id of the Private Link resource. Populating - this optional field indicates that this backend is 'Private'. - :paramtype private_link_resource_id: str - :keyword private_link_location: The location of the Private Link resource. Required only if - 'privateLinkResourceId' is populated. - :paramtype private_link_location: str - :keyword private_link_approval_message: A custom message to be included in the approval request - to connect to the Private Link. - :paramtype private_link_approval_message: str - """ - super().__init__(**kwargs) - self.host_name = host_name - self.http_port = http_port - self.https_port = https_port - self.origin_host_header = origin_host_header - self.priority = priority - self.weight = weight - self.enabled = enabled - self.private_link_alias = private_link_alias - 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 - - -class OriginGroup(ProxyResource): - """Origin group comprising of origins is used for load balancing to origins when the content - cannot be served from CDN. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar system_data: Read only system data. - :vartype system_data: ~azure.mgmt.cdn.models.SystemData - :ivar health_probe_settings: Health probe settings to the origin that is used to determine the - health of the origin. - :vartype health_probe_settings: ~azure.mgmt.cdn.models.HealthProbeParameters - :ivar origins: The source of the content being delivered via CDN within given origin group. - :vartype origins: list[~azure.mgmt.cdn.models.ResourceReference] - :ivar traffic_restoration_time_to_healed_or_new_endpoints_in_minutes: Time in minutes to shift - the traffic to the endpoint gradually when an unhealthy endpoint comes healthy or a new - endpoint is added. Default is 10 mins. This property is currently not supported. - :vartype traffic_restoration_time_to_healed_or_new_endpoints_in_minutes: int - :ivar response_based_origin_error_detection_settings: The JSON object that contains the - properties to determine origin health using real requests/responses. This property is currently - not supported. - :vartype response_based_origin_error_detection_settings: - ~azure.mgmt.cdn.models.ResponseBasedOriginErrorDetectionParameters - :ivar resource_state: Resource status of the origin group. Known values are: "Creating", - "Active", and "Deleting". - :vartype resource_state: str or ~azure.mgmt.cdn.models.OriginGroupResourceState - :ivar provisioning_state: Provisioning status of the origin group. Known values are: - "Succeeded", "Failed", "Updating", "Deleting", and "Creating". - :vartype provisioning_state: str or ~azure.mgmt.cdn.models.OriginGroupProvisioningState - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - "traffic_restoration_time_to_healed_or_new_endpoints_in_minutes": {"maximum": 50, "minimum": 0}, - "resource_state": {"readonly": True}, - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "health_probe_settings": {"key": "properties.healthProbeSettings", "type": "HealthProbeParameters"}, - "origins": {"key": "properties.origins", "type": "[ResourceReference]"}, - "traffic_restoration_time_to_healed_or_new_endpoints_in_minutes": { - "key": "properties.trafficRestorationTimeToHealedOrNewEndpointsInMinutes", - "type": "int", - }, - "response_based_origin_error_detection_settings": { - "key": "properties.responseBasedOriginErrorDetectionSettings", - "type": "ResponseBasedOriginErrorDetectionParameters", - }, - "resource_state": {"key": "properties.resourceState", "type": "str"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - } - - def __init__( - self, - *, - health_probe_settings: Optional["_models.HealthProbeParameters"] = None, - origins: Optional[List["_models.ResourceReference"]] = None, - traffic_restoration_time_to_healed_or_new_endpoints_in_minutes: Optional[int] = None, - response_based_origin_error_detection_settings: Optional[ - "_models.ResponseBasedOriginErrorDetectionParameters" - ] = None, - **kwargs: Any - ) -> None: - """ - :keyword health_probe_settings: Health probe settings to the origin that is used to determine - the health of the origin. - :paramtype health_probe_settings: ~azure.mgmt.cdn.models.HealthProbeParameters - :keyword origins: The source of the content being delivered via CDN within given origin group. - :paramtype origins: list[~azure.mgmt.cdn.models.ResourceReference] - :keyword traffic_restoration_time_to_healed_or_new_endpoints_in_minutes: Time in minutes to - shift the traffic to the endpoint gradually when an unhealthy endpoint comes healthy or a new - endpoint is added. Default is 10 mins. This property is currently not supported. - :paramtype traffic_restoration_time_to_healed_or_new_endpoints_in_minutes: int - :keyword response_based_origin_error_detection_settings: The JSON object that contains the - properties to determine origin health using real requests/responses. This property is currently - not supported. - :paramtype response_based_origin_error_detection_settings: - ~azure.mgmt.cdn.models.ResponseBasedOriginErrorDetectionParameters - """ - super().__init__(**kwargs) - self.health_probe_settings = health_probe_settings - self.origins = origins - self.traffic_restoration_time_to_healed_or_new_endpoints_in_minutes = ( - 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 - - -class OriginGroupListResult(_serialization.Model): - """Result of the request to list origin groups. It contains a list of origin groups objects and a - URL link to get the next set of results. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: List of CDN origin groups within an endpoint. - :vartype value: list[~azure.mgmt.cdn.models.OriginGroup] - :ivar next_link: URL to get the next set of origin objects if there are any. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[OriginGroup]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword next_link: URL to get the next set of origin objects if there are any. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = None - self.next_link = next_link - - -class OriginGroupOverride(_serialization.Model): - """Defines the parameters for the origin group override configuration. - - :ivar origin_group: defines the OriginGroup that would override the DefaultOriginGroup on - route. - :vartype origin_group: ~azure.mgmt.cdn.models.ResourceReference - :ivar forwarding_protocol: Protocol this rule will use when forwarding traffic to backends. - Known values are: "HttpOnly", "HttpsOnly", and "MatchRequest". - :vartype forwarding_protocol: str or ~azure.mgmt.cdn.models.ForwardingProtocol - """ - - _attribute_map = { - "origin_group": {"key": "originGroup", "type": "ResourceReference"}, - "forwarding_protocol": {"key": "forwardingProtocol", "type": "str"}, - } - - def __init__( - self, - *, - origin_group: Optional["_models.ResourceReference"] = None, - forwarding_protocol: Optional[Union[str, "_models.ForwardingProtocol"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword origin_group: defines the OriginGroup that would override the DefaultOriginGroup on - route. - :paramtype origin_group: ~azure.mgmt.cdn.models.ResourceReference - :keyword forwarding_protocol: Protocol this rule will use when forwarding traffic to backends. - Known values are: "HttpOnly", "HttpsOnly", and "MatchRequest". - :paramtype forwarding_protocol: str or ~azure.mgmt.cdn.models.ForwardingProtocol - """ - super().__init__(**kwargs) - self.origin_group = origin_group - self.forwarding_protocol = forwarding_protocol - - -class OriginGroupOverrideAction(DeliveryRuleAction): - """Defines the origin group override action for the delivery rule. - - All required parameters must be populated in order to send to server. - - :ivar name: The name of the action for the delivery rule. Required. Known values are: - "CacheExpiration", "CacheKeyQueryString", "ModifyRequestHeader", "ModifyResponseHeader", - "UrlRedirect", "UrlRewrite", "UrlSigning", "OriginGroupOverride", and - "RouteConfigurationOverride". - :vartype name: str or ~azure.mgmt.cdn.models.DeliveryRuleActionEnum - :ivar parameters: Defines the parameters for the action. Required. - :vartype parameters: ~azure.mgmt.cdn.models.OriginGroupOverrideActionParameters - """ - - _validation = { - "name": {"required": True}, - "parameters": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "parameters": {"key": "parameters", "type": "OriginGroupOverrideActionParameters"}, - } - - def __init__(self, *, parameters: "_models.OriginGroupOverrideActionParameters", **kwargs: Any) -> None: - """ - :keyword parameters: Defines the parameters for the action. Required. - :paramtype parameters: ~azure.mgmt.cdn.models.OriginGroupOverrideActionParameters - """ - super().__init__(**kwargs) - self.name: str = "OriginGroupOverride" - self.parameters = parameters - - -class OriginGroupOverrideActionParameters(_serialization.Model): - """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 origin_group: defines the OriginGroup that would override the DefaultOriginGroup. - Required. - :vartype origin_group: ~azure.mgmt.cdn.models.ResourceReference - """ - - _validation = { - "type_name": {"required": True}, - "origin_group": {"required": True}, - } - - _attribute_map = { - "type_name": {"key": "typeName", "type": "str"}, - "origin_group": {"key": "originGroup", "type": "ResourceReference"}, - } - - def __init__( - self, - *, - type_name: Union[str, "_models.OriginGroupOverrideActionParametersTypeName"], - 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.origin_group = origin_group - - -class OriginGroupUpdatePropertiesParameters(_serialization.Model): - """The JSON object that contains the properties of the origin group. - - :ivar health_probe_settings: Health probe settings to the origin that is used to determine the - health of the origin. - :vartype health_probe_settings: ~azure.mgmt.cdn.models.HealthProbeParameters - :ivar origins: The source of the content being delivered via CDN within given origin group. - :vartype origins: list[~azure.mgmt.cdn.models.ResourceReference] - :ivar traffic_restoration_time_to_healed_or_new_endpoints_in_minutes: Time in minutes to shift - the traffic to the endpoint gradually when an unhealthy endpoint comes healthy or a new - endpoint is added. Default is 10 mins. This property is currently not supported. - :vartype traffic_restoration_time_to_healed_or_new_endpoints_in_minutes: int - :ivar response_based_origin_error_detection_settings: The JSON object that contains the - properties to determine origin health using real requests/responses. This property is currently - not supported. - :vartype response_based_origin_error_detection_settings: - ~azure.mgmt.cdn.models.ResponseBasedOriginErrorDetectionParameters - """ - - _validation = { - "traffic_restoration_time_to_healed_or_new_endpoints_in_minutes": {"maximum": 50, "minimum": 0}, - } - - _attribute_map = { - "health_probe_settings": {"key": "healthProbeSettings", "type": "HealthProbeParameters"}, - "origins": {"key": "origins", "type": "[ResourceReference]"}, - "traffic_restoration_time_to_healed_or_new_endpoints_in_minutes": { - "key": "trafficRestorationTimeToHealedOrNewEndpointsInMinutes", - "type": "int", - }, - "response_based_origin_error_detection_settings": { - "key": "responseBasedOriginErrorDetectionSettings", - "type": "ResponseBasedOriginErrorDetectionParameters", - }, - } - - def __init__( - self, - *, - health_probe_settings: Optional["_models.HealthProbeParameters"] = None, - origins: Optional[List["_models.ResourceReference"]] = None, - traffic_restoration_time_to_healed_or_new_endpoints_in_minutes: Optional[int] = None, - response_based_origin_error_detection_settings: Optional[ - "_models.ResponseBasedOriginErrorDetectionParameters" - ] = None, - **kwargs: Any - ) -> None: - """ - :keyword health_probe_settings: Health probe settings to the origin that is used to determine - the health of the origin. - :paramtype health_probe_settings: ~azure.mgmt.cdn.models.HealthProbeParameters - :keyword origins: The source of the content being delivered via CDN within given origin group. - :paramtype origins: list[~azure.mgmt.cdn.models.ResourceReference] - :keyword traffic_restoration_time_to_healed_or_new_endpoints_in_minutes: Time in minutes to - shift the traffic to the endpoint gradually when an unhealthy endpoint comes healthy or a new - endpoint is added. Default is 10 mins. This property is currently not supported. - :paramtype traffic_restoration_time_to_healed_or_new_endpoints_in_minutes: int - :keyword response_based_origin_error_detection_settings: The JSON object that contains the - properties to determine origin health using real requests/responses. This property is currently - not supported. - :paramtype response_based_origin_error_detection_settings: - ~azure.mgmt.cdn.models.ResponseBasedOriginErrorDetectionParameters - """ - super().__init__(**kwargs) - self.health_probe_settings = health_probe_settings - self.origins = origins - self.traffic_restoration_time_to_healed_or_new_endpoints_in_minutes = ( - traffic_restoration_time_to_healed_or_new_endpoints_in_minutes - ) - self.response_based_origin_error_detection_settings = response_based_origin_error_detection_settings - - -class OriginGroupProperties(OriginGroupUpdatePropertiesParameters): - """The JSON object that contains the properties of the origin group. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar health_probe_settings: Health probe settings to the origin that is used to determine the - health of the origin. - :vartype health_probe_settings: ~azure.mgmt.cdn.models.HealthProbeParameters - :ivar origins: The source of the content being delivered via CDN within given origin group. - :vartype origins: list[~azure.mgmt.cdn.models.ResourceReference] - :ivar traffic_restoration_time_to_healed_or_new_endpoints_in_minutes: Time in minutes to shift - the traffic to the endpoint gradually when an unhealthy endpoint comes healthy or a new - endpoint is added. Default is 10 mins. This property is currently not supported. - :vartype traffic_restoration_time_to_healed_or_new_endpoints_in_minutes: int - :ivar response_based_origin_error_detection_settings: The JSON object that contains the - properties to determine origin health using real requests/responses. This property is currently - not supported. - :vartype response_based_origin_error_detection_settings: - ~azure.mgmt.cdn.models.ResponseBasedOriginErrorDetectionParameters - :ivar resource_state: Resource status of the origin group. Known values are: "Creating", - "Active", and "Deleting". - :vartype resource_state: str or ~azure.mgmt.cdn.models.OriginGroupResourceState - :ivar provisioning_state: Provisioning status of the origin group. Known values are: - "Succeeded", "Failed", "Updating", "Deleting", and "Creating". - :vartype provisioning_state: str or ~azure.mgmt.cdn.models.OriginGroupProvisioningState - """ - - _validation = { - "traffic_restoration_time_to_healed_or_new_endpoints_in_minutes": {"maximum": 50, "minimum": 0}, - "resource_state": {"readonly": True}, - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "health_probe_settings": {"key": "healthProbeSettings", "type": "HealthProbeParameters"}, - "origins": {"key": "origins", "type": "[ResourceReference]"}, - "traffic_restoration_time_to_healed_or_new_endpoints_in_minutes": { - "key": "trafficRestorationTimeToHealedOrNewEndpointsInMinutes", - "type": "int", - }, - "response_based_origin_error_detection_settings": { - "key": "responseBasedOriginErrorDetectionSettings", - "type": "ResponseBasedOriginErrorDetectionParameters", - }, - "resource_state": {"key": "resourceState", "type": "str"}, - "provisioning_state": {"key": "provisioningState", "type": "str"}, - } - - def __init__( - self, - *, - health_probe_settings: Optional["_models.HealthProbeParameters"] = None, - origins: Optional[List["_models.ResourceReference"]] = None, - traffic_restoration_time_to_healed_or_new_endpoints_in_minutes: Optional[int] = None, - response_based_origin_error_detection_settings: Optional[ - "_models.ResponseBasedOriginErrorDetectionParameters" - ] = None, - **kwargs: Any - ) -> None: - """ - :keyword health_probe_settings: Health probe settings to the origin that is used to determine - the health of the origin. - :paramtype health_probe_settings: ~azure.mgmt.cdn.models.HealthProbeParameters - :keyword origins: The source of the content being delivered via CDN within given origin group. - :paramtype origins: list[~azure.mgmt.cdn.models.ResourceReference] - :keyword traffic_restoration_time_to_healed_or_new_endpoints_in_minutes: Time in minutes to - shift the traffic to the endpoint gradually when an unhealthy endpoint comes healthy or a new - endpoint is added. Default is 10 mins. This property is currently not supported. - :paramtype traffic_restoration_time_to_healed_or_new_endpoints_in_minutes: int - :keyword response_based_origin_error_detection_settings: The JSON object that contains the - properties to determine origin health using real requests/responses. This property is currently - not supported. - :paramtype response_based_origin_error_detection_settings: - ~azure.mgmt.cdn.models.ResponseBasedOriginErrorDetectionParameters - """ - super().__init__( - health_probe_settings=health_probe_settings, - origins=origins, - traffic_restoration_time_to_healed_or_new_endpoints_in_minutes=traffic_restoration_time_to_healed_or_new_endpoints_in_minutes, - response_based_origin_error_detection_settings=response_based_origin_error_detection_settings, - **kwargs - ) - self.resource_state = None - self.provisioning_state = None - - -class OriginGroupUpdateParameters(_serialization.Model): - """Origin group properties needed for origin group creation or update. - - :ivar health_probe_settings: Health probe settings to the origin that is used to determine the - health of the origin. - :vartype health_probe_settings: ~azure.mgmt.cdn.models.HealthProbeParameters - :ivar origins: The source of the content being delivered via CDN within given origin group. - :vartype origins: list[~azure.mgmt.cdn.models.ResourceReference] - :ivar traffic_restoration_time_to_healed_or_new_endpoints_in_minutes: Time in minutes to shift - the traffic to the endpoint gradually when an unhealthy endpoint comes healthy or a new - endpoint is added. Default is 10 mins. This property is currently not supported. - :vartype traffic_restoration_time_to_healed_or_new_endpoints_in_minutes: int - :ivar response_based_origin_error_detection_settings: The JSON object that contains the - properties to determine origin health using real requests/responses. This property is currently - not supported. - :vartype response_based_origin_error_detection_settings: - ~azure.mgmt.cdn.models.ResponseBasedOriginErrorDetectionParameters - """ - - _validation = { - "traffic_restoration_time_to_healed_or_new_endpoints_in_minutes": {"maximum": 50, "minimum": 0}, - } - - _attribute_map = { - "health_probe_settings": {"key": "properties.healthProbeSettings", "type": "HealthProbeParameters"}, - "origins": {"key": "properties.origins", "type": "[ResourceReference]"}, - "traffic_restoration_time_to_healed_or_new_endpoints_in_minutes": { - "key": "properties.trafficRestorationTimeToHealedOrNewEndpointsInMinutes", - "type": "int", - }, - "response_based_origin_error_detection_settings": { - "key": "properties.responseBasedOriginErrorDetectionSettings", - "type": "ResponseBasedOriginErrorDetectionParameters", - }, - } - - def __init__( - self, - *, - health_probe_settings: Optional["_models.HealthProbeParameters"] = None, - origins: Optional[List["_models.ResourceReference"]] = None, - traffic_restoration_time_to_healed_or_new_endpoints_in_minutes: Optional[int] = None, - response_based_origin_error_detection_settings: Optional[ - "_models.ResponseBasedOriginErrorDetectionParameters" - ] = None, - **kwargs: Any - ) -> None: - """ - :keyword health_probe_settings: Health probe settings to the origin that is used to determine - the health of the origin. - :paramtype health_probe_settings: ~azure.mgmt.cdn.models.HealthProbeParameters - :keyword origins: The source of the content being delivered via CDN within given origin group. - :paramtype origins: list[~azure.mgmt.cdn.models.ResourceReference] - :keyword traffic_restoration_time_to_healed_or_new_endpoints_in_minutes: Time in minutes to - shift the traffic to the endpoint gradually when an unhealthy endpoint comes healthy or a new - endpoint is added. Default is 10 mins. This property is currently not supported. - :paramtype traffic_restoration_time_to_healed_or_new_endpoints_in_minutes: int - :keyword response_based_origin_error_detection_settings: The JSON object that contains the - properties to determine origin health using real requests/responses. This property is currently - not supported. - :paramtype response_based_origin_error_detection_settings: - ~azure.mgmt.cdn.models.ResponseBasedOriginErrorDetectionParameters - """ - super().__init__(**kwargs) - self.health_probe_settings = health_probe_settings - self.origins = origins - self.traffic_restoration_time_to_healed_or_new_endpoints_in_minutes = ( - traffic_restoration_time_to_healed_or_new_endpoints_in_minutes - ) - self.response_based_origin_error_detection_settings = response_based_origin_error_detection_settings - - -class OriginListResult(_serialization.Model): - """Result of the request to list origins. It contains a list of origin objects and a URL link to - get the next set of results. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: List of CDN origins within an endpoint. - :vartype value: list[~azure.mgmt.cdn.models.Origin] - :ivar next_link: URL to get the next set of origin objects if there are any. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[Origin]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword next_link: URL to get the next set of origin objects if there are any. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = None - self.next_link = next_link - - -class OriginUpdatePropertiesParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes - """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 - are supported.This should be unique across all origins in an endpoint. - :vartype host_name: str - :ivar http_port: The value of the HTTP port. Must be between 1 and 65535. - :vartype http_port: int - :ivar https_port: The value of the HTTPS port. Must be between 1 and 65535. - :vartype https_port: int - :ivar origin_host_header: The host header value sent to the origin with each request. If you - leave this blank, the request hostname determines this value. Azure CDN origins, such as Web - Apps, Blob Storage, and Cloud Services require this host header value to match the origin - hostname by default. This overrides the host header defined at Endpoint. - :vartype origin_host_header: str - :ivar priority: Priority of origin in given origin group for load balancing. Higher priorities - will not be used for load balancing if any lower priority origin is healthy.Must be between 1 - and 5. - :vartype priority: int - :ivar weight: Weight of the origin in given origin group for load balancing. Must be between 1 - and 1000. - :vartype weight: int - :ivar enabled: Origin is enabled for load balancing or not. - :vartype enabled: bool - :ivar private_link_alias: The Alias of the Private Link resource. Populating this optional - field indicates that this origin is 'Private'. - :vartype private_link_alias: str - :ivar private_link_resource_id: The Resource Id of the Private Link resource. Populating this - optional field indicates that this backend is 'Private'. - :vartype private_link_resource_id: str - :ivar private_link_location: The location of the Private Link resource. Required only if - 'privateLinkResourceId' is populated. - :vartype private_link_location: str - :ivar private_link_approval_message: A custom message to be included in the approval request to - connect to the Private Link. - :vartype private_link_approval_message: str - """ - - _validation = { - "http_port": {"maximum": 65535, "minimum": 1}, - "https_port": {"maximum": 65535, "minimum": 1}, - "priority": {"maximum": 5, "minimum": 1}, - "weight": {"maximum": 1000, "minimum": 1}, - } - - _attribute_map = { - "host_name": {"key": "hostName", "type": "str"}, - "http_port": {"key": "httpPort", "type": "int"}, - "https_port": {"key": "httpsPort", "type": "int"}, - "origin_host_header": {"key": "originHostHeader", "type": "str"}, - "priority": {"key": "priority", "type": "int"}, - "weight": {"key": "weight", "type": "int"}, - "enabled": {"key": "enabled", "type": "bool"}, - "private_link_alias": {"key": "privateLinkAlias", "type": "str"}, - "private_link_resource_id": {"key": "privateLinkResourceId", "type": "str"}, - "private_link_location": {"key": "privateLinkLocation", "type": "str"}, - "private_link_approval_message": {"key": "privateLinkApprovalMessage", "type": "str"}, - } - - def __init__( - self, - *, - host_name: Optional[str] = None, - http_port: Optional[int] = None, - https_port: Optional[int] = None, - origin_host_header: Optional[str] = None, - priority: Optional[int] = None, - weight: Optional[int] = None, - enabled: Optional[bool] = None, - private_link_alias: Optional[str] = None, - private_link_resource_id: Optional[str] = None, - private_link_location: Optional[str] = None, - private_link_approval_message: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword host_name: The address of the origin. Domain names, IPv4 addresses, and IPv6 addresses - are supported.This should be unique across all origins in an endpoint. - :paramtype host_name: str - :keyword http_port: The value of the HTTP port. Must be between 1 and 65535. - :paramtype http_port: int - :keyword https_port: The value of the HTTPS port. Must be between 1 and 65535. - :paramtype https_port: int - :keyword origin_host_header: The host header value sent to the origin with each request. If you - leave this blank, the request hostname determines this value. Azure CDN origins, such as Web - Apps, Blob Storage, and Cloud Services require this host header value to match the origin - hostname by default. This overrides the host header defined at Endpoint. - :paramtype origin_host_header: str - :keyword priority: Priority of origin in given origin group for load balancing. Higher - priorities will not be used for load balancing if any lower priority origin is healthy.Must be - between 1 and 5. - :paramtype priority: int - :keyword weight: Weight of the origin in given origin group for load balancing. Must be between - 1 and 1000. - :paramtype weight: int - :keyword enabled: Origin is enabled for load balancing or not. - :paramtype enabled: bool - :keyword private_link_alias: The Alias of the Private Link resource. Populating this optional - field indicates that this origin is 'Private'. - :paramtype private_link_alias: str - :keyword private_link_resource_id: The Resource Id of the Private Link resource. Populating - this optional field indicates that this backend is 'Private'. - :paramtype private_link_resource_id: str - :keyword private_link_location: The location of the Private Link resource. Required only if - 'privateLinkResourceId' is populated. - :paramtype private_link_location: str - :keyword private_link_approval_message: A custom message to be included in the approval request - to connect to the Private Link. - :paramtype private_link_approval_message: str - """ - super().__init__(**kwargs) - self.host_name = host_name - self.http_port = http_port - self.https_port = https_port - self.origin_host_header = origin_host_header - self.priority = priority - self.weight = weight - self.enabled = enabled - self.private_link_alias = private_link_alias - 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 - - -class OriginProperties(OriginUpdatePropertiesParameters): # pylint: disable=too-many-instance-attributes - """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. - - :ivar host_name: The address of the origin. Domain names, IPv4 addresses, and IPv6 addresses - are supported.This should be unique across all origins in an endpoint. - :vartype host_name: str - :ivar http_port: The value of the HTTP port. Must be between 1 and 65535. - :vartype http_port: int - :ivar https_port: The value of the HTTPS port. Must be between 1 and 65535. - :vartype https_port: int - :ivar origin_host_header: The host header value sent to the origin with each request. If you - leave this blank, the request hostname determines this value. Azure CDN origins, such as Web - Apps, Blob Storage, and Cloud Services require this host header value to match the origin - hostname by default. This overrides the host header defined at Endpoint. - :vartype origin_host_header: str - :ivar priority: Priority of origin in given origin group for load balancing. Higher priorities - will not be used for load balancing if any lower priority origin is healthy.Must be between 1 - and 5. - :vartype priority: int - :ivar weight: Weight of the origin in given origin group for load balancing. Must be between 1 - and 1000. - :vartype weight: int - :ivar enabled: Origin is enabled for load balancing or not. - :vartype enabled: bool - :ivar private_link_alias: The Alias of the Private Link resource. Populating this optional - field indicates that this origin is 'Private'. - :vartype private_link_alias: str - :ivar private_link_resource_id: The Resource Id of the Private Link resource. Populating this - optional field indicates that this backend is 'Private'. - :vartype private_link_resource_id: str - :ivar private_link_location: The location of the Private Link resource. Required only if - 'privateLinkResourceId' is populated. - :vartype private_link_location: str - :ivar private_link_approval_message: A custom message to be included in the approval request to - connect to the Private Link. - :vartype private_link_approval_message: str - :ivar resource_state: Resource status of the origin. Known values are: "Creating", "Active", - and "Deleting". - :vartype resource_state: str or ~azure.mgmt.cdn.models.OriginResourceState - :ivar provisioning_state: Provisioning status of the origin. Known values are: "Succeeded", - "Failed", "Updating", "Deleting", and "Creating". - :vartype provisioning_state: str or ~azure.mgmt.cdn.models.OriginProvisioningState - :ivar private_endpoint_status: The approval status for the connection to the Private Link. - Known values are: "Pending", "Approved", "Rejected", "Disconnected", and "Timeout". - :vartype private_endpoint_status: str or ~azure.mgmt.cdn.models.PrivateEndpointStatus - """ - - _validation = { - "http_port": {"maximum": 65535, "minimum": 1}, - "https_port": {"maximum": 65535, "minimum": 1}, - "priority": {"maximum": 5, "minimum": 1}, - "weight": {"maximum": 1000, "minimum": 1}, - "resource_state": {"readonly": True}, - "provisioning_state": {"readonly": True}, - "private_endpoint_status": {"readonly": True}, - } - - _attribute_map = { - "host_name": {"key": "hostName", "type": "str"}, - "http_port": {"key": "httpPort", "type": "int"}, - "https_port": {"key": "httpsPort", "type": "int"}, - "origin_host_header": {"key": "originHostHeader", "type": "str"}, - "priority": {"key": "priority", "type": "int"}, - "weight": {"key": "weight", "type": "int"}, - "enabled": {"key": "enabled", "type": "bool"}, - "private_link_alias": {"key": "privateLinkAlias", "type": "str"}, - "private_link_resource_id": {"key": "privateLinkResourceId", "type": "str"}, - "private_link_location": {"key": "privateLinkLocation", "type": "str"}, - "private_link_approval_message": {"key": "privateLinkApprovalMessage", "type": "str"}, - "resource_state": {"key": "resourceState", "type": "str"}, - "provisioning_state": {"key": "provisioningState", "type": "str"}, - "private_endpoint_status": {"key": "privateEndpointStatus", "type": "str"}, - } - - def __init__( - self, - *, - host_name: Optional[str] = None, - http_port: Optional[int] = None, - https_port: Optional[int] = None, - origin_host_header: Optional[str] = None, - priority: Optional[int] = None, - weight: Optional[int] = None, - enabled: Optional[bool] = None, - private_link_alias: Optional[str] = None, - private_link_resource_id: Optional[str] = None, - private_link_location: Optional[str] = None, - private_link_approval_message: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword host_name: The address of the origin. Domain names, IPv4 addresses, and IPv6 addresses - are supported.This should be unique across all origins in an endpoint. - :paramtype host_name: str - :keyword http_port: The value of the HTTP port. Must be between 1 and 65535. - :paramtype http_port: int - :keyword https_port: The value of the HTTPS port. Must be between 1 and 65535. - :paramtype https_port: int - :keyword origin_host_header: The host header value sent to the origin with each request. If you - leave this blank, the request hostname determines this value. Azure CDN origins, such as Web - Apps, Blob Storage, and Cloud Services require this host header value to match the origin - hostname by default. This overrides the host header defined at Endpoint. - :paramtype origin_host_header: str - :keyword priority: Priority of origin in given origin group for load balancing. Higher - priorities will not be used for load balancing if any lower priority origin is healthy.Must be - between 1 and 5. - :paramtype priority: int - :keyword weight: Weight of the origin in given origin group for load balancing. Must be between - 1 and 1000. - :paramtype weight: int - :keyword enabled: Origin is enabled for load balancing or not. - :paramtype enabled: bool - :keyword private_link_alias: The Alias of the Private Link resource. Populating this optional - field indicates that this origin is 'Private'. - :paramtype private_link_alias: str - :keyword private_link_resource_id: The Resource Id of the Private Link resource. Populating - this optional field indicates that this backend is 'Private'. - :paramtype private_link_resource_id: str - :keyword private_link_location: The location of the Private Link resource. Required only if - 'privateLinkResourceId' is populated. - :paramtype private_link_location: str - :keyword private_link_approval_message: A custom message to be included in the approval request - to connect to the Private Link. - :paramtype private_link_approval_message: str - """ - super().__init__( - host_name=host_name, - http_port=http_port, - https_port=https_port, - origin_host_header=origin_host_header, - priority=priority, - weight=weight, - enabled=enabled, - private_link_alias=private_link_alias, - private_link_resource_id=private_link_resource_id, - private_link_location=private_link_location, - private_link_approval_message=private_link_approval_message, - **kwargs - ) - self.resource_state = None - self.provisioning_state = None - self.private_endpoint_status = None - - -class OriginUpdateParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes - """Origin properties needed for origin update. - - :ivar host_name: The address of the origin. Domain names, IPv4 addresses, and IPv6 addresses - are supported.This should be unique across all origins in an endpoint. - :vartype host_name: str - :ivar http_port: The value of the HTTP port. Must be between 1 and 65535. - :vartype http_port: int - :ivar https_port: The value of the HTTPS port. Must be between 1 and 65535. - :vartype https_port: int - :ivar origin_host_header: The host header value sent to the origin with each request. If you - leave this blank, the request hostname determines this value. Azure CDN origins, such as Web - Apps, Blob Storage, and Cloud Services require this host header value to match the origin - hostname by default. This overrides the host header defined at Endpoint. - :vartype origin_host_header: str - :ivar priority: Priority of origin in given origin group for load balancing. Higher priorities - will not be used for load balancing if any lower priority origin is healthy.Must be between 1 - and 5. - :vartype priority: int - :ivar weight: Weight of the origin in given origin group for load balancing. Must be between 1 - and 1000. - :vartype weight: int - :ivar enabled: Origin is enabled for load balancing or not. - :vartype enabled: bool - :ivar private_link_alias: The Alias of the Private Link resource. Populating this optional - field indicates that this origin is 'Private'. - :vartype private_link_alias: str - :ivar private_link_resource_id: The Resource Id of the Private Link resource. Populating this - optional field indicates that this backend is 'Private'. - :vartype private_link_resource_id: str - :ivar private_link_location: The location of the Private Link resource. Required only if - 'privateLinkResourceId' is populated. - :vartype private_link_location: str - :ivar private_link_approval_message: A custom message to be included in the approval request to - connect to the Private Link. - :vartype private_link_approval_message: str - """ - - _validation = { - "http_port": {"maximum": 65535, "minimum": 1}, - "https_port": {"maximum": 65535, "minimum": 1}, - "priority": {"maximum": 5, "minimum": 1}, - "weight": {"maximum": 1000, "minimum": 1}, - } - - _attribute_map = { - "host_name": {"key": "properties.hostName", "type": "str"}, - "http_port": {"key": "properties.httpPort", "type": "int"}, - "https_port": {"key": "properties.httpsPort", "type": "int"}, - "origin_host_header": {"key": "properties.originHostHeader", "type": "str"}, - "priority": {"key": "properties.priority", "type": "int"}, - "weight": {"key": "properties.weight", "type": "int"}, - "enabled": {"key": "properties.enabled", "type": "bool"}, - "private_link_alias": {"key": "properties.privateLinkAlias", "type": "str"}, - "private_link_resource_id": {"key": "properties.privateLinkResourceId", "type": "str"}, - "private_link_location": {"key": "properties.privateLinkLocation", "type": "str"}, - "private_link_approval_message": {"key": "properties.privateLinkApprovalMessage", "type": "str"}, - } - - def __init__( - self, - *, - host_name: Optional[str] = None, - http_port: Optional[int] = None, - https_port: Optional[int] = None, - origin_host_header: Optional[str] = None, - priority: Optional[int] = None, - weight: Optional[int] = None, - enabled: Optional[bool] = None, - private_link_alias: Optional[str] = None, - private_link_resource_id: Optional[str] = None, - private_link_location: Optional[str] = None, - private_link_approval_message: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword host_name: The address of the origin. Domain names, IPv4 addresses, and IPv6 addresses - are supported.This should be unique across all origins in an endpoint. - :paramtype host_name: str - :keyword http_port: The value of the HTTP port. Must be between 1 and 65535. - :paramtype http_port: int - :keyword https_port: The value of the HTTPS port. Must be between 1 and 65535. - :paramtype https_port: int - :keyword origin_host_header: The host header value sent to the origin with each request. If you - leave this blank, the request hostname determines this value. Azure CDN origins, such as Web - Apps, Blob Storage, and Cloud Services require this host header value to match the origin - hostname by default. This overrides the host header defined at Endpoint. - :paramtype origin_host_header: str - :keyword priority: Priority of origin in given origin group for load balancing. Higher - priorities will not be used for load balancing if any lower priority origin is healthy.Must be - between 1 and 5. - :paramtype priority: int - :keyword weight: Weight of the origin in given origin group for load balancing. Must be between - 1 and 1000. - :paramtype weight: int - :keyword enabled: Origin is enabled for load balancing or not. - :paramtype enabled: bool - :keyword private_link_alias: The Alias of the Private Link resource. Populating this optional - field indicates that this origin is 'Private'. - :paramtype private_link_alias: str - :keyword private_link_resource_id: The Resource Id of the Private Link resource. Populating - this optional field indicates that this backend is 'Private'. - :paramtype private_link_resource_id: str - :keyword private_link_location: The location of the Private Link resource. Required only if - 'privateLinkResourceId' is populated. - :paramtype private_link_location: str - :keyword private_link_approval_message: A custom message to be included in the approval request - to connect to the Private Link. - :paramtype private_link_approval_message: str - """ - super().__init__(**kwargs) - self.host_name = host_name - self.http_port = http_port - self.https_port = https_port - self.origin_host_header = origin_host_header - self.priority = priority - self.weight = weight - self.enabled = enabled - self.private_link_alias = private_link_alias - 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 - - -class PolicySettings(_serialization.Model): - """Defines contents of a web application firewall global configuration. - - :ivar enabled_state: describes if the policy is in enabled state or disabled state. Known - values are: "Disabled" and "Enabled". - :vartype enabled_state: str or ~azure.mgmt.cdn.models.PolicyEnabledState - :ivar mode: Describes if it is in detection mode or prevention mode at policy level. Known - values are: "Prevention" and "Detection". - :vartype mode: str or ~azure.mgmt.cdn.models.PolicyMode - :ivar default_redirect_url: If action type is redirect, this field represents the default - redirect URL for the client. - :vartype default_redirect_url: str - :ivar default_custom_block_response_status_code: If the action type is block, this field - defines the default customer overridable http response status code. Known values are: 200, 403, - 405, 406, and 429. - :vartype default_custom_block_response_status_code: int or - ~azure.mgmt.cdn.models.PolicySettingsDefaultCustomBlockResponseStatusCode - :ivar default_custom_block_response_body: If the action type is block, customer can override - the response body. The body must be specified in base64 encoding. - :vartype default_custom_block_response_body: str - """ - - _validation = { - "default_custom_block_response_body": { - "pattern": r"^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{4})$" - }, - } - - _attribute_map = { - "enabled_state": {"key": "enabledState", "type": "str"}, - "mode": {"key": "mode", "type": "str"}, - "default_redirect_url": {"key": "defaultRedirectUrl", "type": "str"}, - "default_custom_block_response_status_code": {"key": "defaultCustomBlockResponseStatusCode", "type": "int"}, - "default_custom_block_response_body": {"key": "defaultCustomBlockResponseBody", "type": "str"}, - } - - def __init__( - self, - *, - enabled_state: Optional[Union[str, "_models.PolicyEnabledState"]] = None, - mode: Optional[Union[str, "_models.PolicyMode"]] = None, - default_redirect_url: Optional[str] = None, - default_custom_block_response_status_code: Optional[ - Union[int, "_models.PolicySettingsDefaultCustomBlockResponseStatusCode"] - ] = None, - default_custom_block_response_body: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword enabled_state: describes if the policy is in enabled state or disabled state. Known - values are: "Disabled" and "Enabled". - :paramtype enabled_state: str or ~azure.mgmt.cdn.models.PolicyEnabledState - :keyword mode: Describes if it is in detection mode or prevention mode at policy level. Known - values are: "Prevention" and "Detection". - :paramtype mode: str or ~azure.mgmt.cdn.models.PolicyMode - :keyword default_redirect_url: If action type is redirect, this field represents the default - redirect URL for the client. - :paramtype default_redirect_url: str - :keyword default_custom_block_response_status_code: If the action type is block, this field - defines the default customer overridable http response status code. Known values are: 200, 403, - 405, 406, and 429. - :paramtype default_custom_block_response_status_code: int or - ~azure.mgmt.cdn.models.PolicySettingsDefaultCustomBlockResponseStatusCode - :keyword default_custom_block_response_body: If the action type is block, customer can override - the response body. The body must be specified in base64 encoding. - :paramtype default_custom_block_response_body: str - """ - super().__init__(**kwargs) - self.enabled_state = enabled_state - self.mode = mode - self.default_redirect_url = default_redirect_url - self.default_custom_block_response_status_code = default_custom_block_response_status_code - self.default_custom_block_response_body = default_custom_block_response_body - - -class PostArgsMatchConditionParameters(_serialization.Model): - """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 selector: Name of PostArg to be matched. - :vartype selector: str - :ivar operator: Describes operator to be matched. Required. Known values are: "Any", "Equal", - "Contains", "BeginsWith", "EndsWith", "LessThan", "LessThanOrEqual", "GreaterThan", - "GreaterThanOrEqual", and "RegEx". - :vartype operator: str or ~azure.mgmt.cdn.models.PostArgsOperator - :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] - :ivar transforms: List of transforms. - :vartype transforms: list[str or ~azure.mgmt.cdn.models.Transform] - """ - - _validation = { - "type_name": {"required": True}, - "operator": {"required": True}, - } - - _attribute_map = { - "type_name": {"key": "typeName", "type": "str"}, - "selector": {"key": "selector", "type": "str"}, - "operator": {"key": "operator", "type": "str"}, - "negate_condition": {"key": "negateCondition", "type": "bool"}, - "match_values": {"key": "matchValues", "type": "[str]"}, - "transforms": {"key": "transforms", "type": "[str]"}, - } - - def __init__( - self, - *, - type_name: Union[str, "_models.PostArgsMatchConditionParametersTypeName"], - operator: Union[str, "_models.PostArgsOperator"], - selector: Optional[str] = None, - negate_condition: bool = False, - match_values: Optional[List[str]] = None, - transforms: Optional[List[Union[str, "_models.Transform"]]] = None, - **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", - "Equal", "Contains", "BeginsWith", "EndsWith", "LessThan", "LessThanOrEqual", "GreaterThan", - "GreaterThanOrEqual", and "RegEx". - :paramtype operator: str or ~azure.mgmt.cdn.models.PostArgsOperator - :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] - :keyword transforms: List of transforms. - :paramtype transforms: list[str or ~azure.mgmt.cdn.models.Transform] - """ - super().__init__(**kwargs) - self.type_name = type_name - self.selector = selector - self.operator = operator - self.negate_condition = negate_condition - self.match_values = match_values - self.transforms = transforms - - -class Profile(TrackedResource): # pylint: disable=too-many-instance-attributes - """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. - - All required parameters must be populated in order to send to server. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar system_data: Read only system data. - :vartype system_data: ~azure.mgmt.cdn.models.SystemData - :ivar location: Resource location. Required. - :vartype location: str - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar sku: The pricing tier (defines Azure Front Door Standard or Premium or a CDN provider, - feature list and rate) of the profile. Required. - :vartype sku: ~azure.mgmt.cdn.models.Sku - :ivar kind: Kind of the profile. Used by portal to differentiate traditional CDN profile and - new AFD profile. - :vartype kind: str - :ivar identity: Managed service identity (system assigned and/or user assigned identities). - :vartype identity: ~azure.mgmt.cdn.models.ManagedServiceIdentity - :ivar resource_state: Resource status of the profile. Known values are: "Creating", "Active", - "Deleting", "Disabled", "Migrating", "Migrated", "PendingMigrationCommit", - "CommittingMigration", and "AbortingMigration". - :vartype resource_state: str or ~azure.mgmt.cdn.models.ProfileResourceState - :ivar provisioning_state: Provisioning status of the profile. Known values are: "Succeeded", - "Failed", "Updating", "Deleting", and "Creating". - :vartype provisioning_state: str or ~azure.mgmt.cdn.models.ProfileProvisioningState - :ivar extended_properties: Key-Value pair representing additional properties for profiles. - :vartype extended_properties: dict[str, str] - :ivar front_door_id: The Id of the frontdoor. - :vartype front_door_id: str - :ivar origin_response_timeout_seconds: Send and receive timeout on forwarding request to the - origin. When timeout is reached, the request fails and returns. - :vartype origin_response_timeout_seconds: int - :ivar log_scrubbing: Defines rules that scrub sensitive fields in the Azure Front Door profile - logs. - :vartype log_scrubbing: ~azure.mgmt.cdn.models.ProfileLogScrubbing - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - "location": {"required": True}, - "sku": {"required": True}, - "kind": {"readonly": True}, - "resource_state": {"readonly": True}, - "provisioning_state": {"readonly": True}, - "extended_properties": {"readonly": True}, - "front_door_id": {"readonly": True}, - "origin_response_timeout_seconds": {"minimum": 16}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "sku": {"key": "sku", "type": "Sku"}, - "kind": {"key": "kind", "type": "str"}, - "identity": {"key": "identity", "type": "ManagedServiceIdentity"}, - "resource_state": {"key": "properties.resourceState", "type": "str"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "extended_properties": {"key": "properties.extendedProperties", "type": "{str}"}, - "front_door_id": {"key": "properties.frontDoorId", "type": "str"}, - "origin_response_timeout_seconds": {"key": "properties.originResponseTimeoutSeconds", "type": "int"}, - "log_scrubbing": {"key": "properties.logScrubbing", "type": "ProfileLogScrubbing"}, - } - - def __init__( - self, - *, - location: str, - sku: "_models.Sku", - tags: Optional[Dict[str, str]] = None, - identity: Optional["_models.ManagedServiceIdentity"] = None, - origin_response_timeout_seconds: Optional[int] = None, - log_scrubbing: Optional["_models.ProfileLogScrubbing"] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Resource location. Required. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword sku: The pricing tier (defines Azure Front Door Standard or Premium or a CDN provider, - feature list and rate) of the profile. Required. - :paramtype sku: ~azure.mgmt.cdn.models.Sku - :keyword identity: Managed service identity (system assigned and/or user assigned identities). - :paramtype identity: ~azure.mgmt.cdn.models.ManagedServiceIdentity - :keyword origin_response_timeout_seconds: Send and receive timeout on forwarding request to the - origin. When timeout is reached, the request fails and returns. - :paramtype origin_response_timeout_seconds: int - :keyword log_scrubbing: Defines rules that scrub sensitive fields in the Azure Front Door - profile logs. - :paramtype log_scrubbing: ~azure.mgmt.cdn.models.ProfileLogScrubbing - """ - super().__init__(location=location, tags=tags, **kwargs) - self.sku = sku - self.kind = None - self.identity = identity - self.resource_state = None - self.provisioning_state = None - self.extended_properties = None - self.front_door_id = None - self.origin_response_timeout_seconds = origin_response_timeout_seconds - self.log_scrubbing = log_scrubbing - - -class ProfileChangeSkuWafMapping(_serialization.Model): - """Parameters required for profile upgrade. - - All required parameters must be populated in order to send to server. - - :ivar security_policy_name: The security policy name. Required. - :vartype security_policy_name: str - :ivar change_to_waf_policy: The new waf resource for the security policy to use. Required. - :vartype change_to_waf_policy: ~azure.mgmt.cdn.models.ResourceReference - """ - - _validation = { - "security_policy_name": {"required": True}, - "change_to_waf_policy": {"required": True}, - } - - _attribute_map = { - "security_policy_name": {"key": "securityPolicyName", "type": "str"}, - "change_to_waf_policy": {"key": "changeToWafPolicy", "type": "ResourceReference"}, - } - - def __init__( - self, *, security_policy_name: str, change_to_waf_policy: "_models.ResourceReference", **kwargs: Any - ) -> None: - """ - :keyword security_policy_name: The security policy name. Required. - :paramtype security_policy_name: str - :keyword change_to_waf_policy: The new waf resource for the security policy to use. Required. - :paramtype change_to_waf_policy: ~azure.mgmt.cdn.models.ResourceReference - """ - super().__init__(**kwargs) - self.security_policy_name = security_policy_name - self.change_to_waf_policy = change_to_waf_policy - - -class ProfileListResult(_serialization.Model): - """Result of the request to list profiles. It contains a list of profile objects and a URL link to - get the next set of results. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: List of CDN profiles within a resource group. - :vartype value: list[~azure.mgmt.cdn.models.Profile] - :ivar next_link: URL to get the next set of profile objects if there are any. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[Profile]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword next_link: URL to get the next set of profile objects if there are any. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = None - self.next_link = next_link - - -class ProfileLogScrubbing(_serialization.Model): - """Defines rules that scrub sensitive fields in the Azure Front Door profile logs. - - :ivar state: State of the log scrubbing config. Default value is Enabled. Known values are: - "Enabled" and "Disabled". - :vartype state: str or ~azure.mgmt.cdn.models.ProfileScrubbingState - :ivar scrubbing_rules: List of log scrubbing rules applied to the Azure Front Door profile - logs. - :vartype scrubbing_rules: list[~azure.mgmt.cdn.models.ProfileScrubbingRules] - """ - - _attribute_map = { - "state": {"key": "state", "type": "str"}, - "scrubbing_rules": {"key": "scrubbingRules", "type": "[ProfileScrubbingRules]"}, - } - - def __init__( - self, - *, - state: Optional[Union[str, "_models.ProfileScrubbingState"]] = None, - scrubbing_rules: Optional[List["_models.ProfileScrubbingRules"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword state: State of the log scrubbing config. Default value is Enabled. Known values are: - "Enabled" and "Disabled". - :paramtype state: str or ~azure.mgmt.cdn.models.ProfileScrubbingState - :keyword scrubbing_rules: List of log scrubbing rules applied to the Azure Front Door profile - logs. - :paramtype scrubbing_rules: list[~azure.mgmt.cdn.models.ProfileScrubbingRules] - """ - super().__init__(**kwargs) - self.state = state - self.scrubbing_rules = scrubbing_rules - - -class ProfileScrubbingRules(_serialization.Model): - """Defines the contents of the log scrubbing rules. - - All required parameters must be populated in order to send to server. - - :ivar match_variable: The variable to be scrubbed from the logs. Required. Known values are: - "RequestIPAddress", "RequestUri", and "QueryStringArgNames". - :vartype match_variable: str or ~azure.mgmt.cdn.models.ScrubbingRuleEntryMatchVariable - :ivar selector_match_operator: When matchVariable is a collection, operate on the selector to - specify which elements in the collection this rule applies to. Required. "EqualsAny" - :vartype selector_match_operator: str or ~azure.mgmt.cdn.models.ScrubbingRuleEntryMatchOperator - :ivar selector: When matchVariable is a collection, operator used to specify which elements in - the collection this rule applies to. - :vartype selector: str - :ivar state: Defines the state of a log scrubbing rule. Default value is enabled. Known values - are: "Enabled" and "Disabled". - :vartype state: str or ~azure.mgmt.cdn.models.ScrubbingRuleEntryState - """ - - _validation = { - "match_variable": {"required": True}, - "selector_match_operator": {"required": True}, - } - - _attribute_map = { - "match_variable": {"key": "matchVariable", "type": "str"}, - "selector_match_operator": {"key": "selectorMatchOperator", "type": "str"}, - "selector": {"key": "selector", "type": "str"}, - "state": {"key": "state", "type": "str"}, - } - - def __init__( - self, - *, - match_variable: Union[str, "_models.ScrubbingRuleEntryMatchVariable"], - selector_match_operator: Union[str, "_models.ScrubbingRuleEntryMatchOperator"], - selector: Optional[str] = None, - state: Optional[Union[str, "_models.ScrubbingRuleEntryState"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword match_variable: The variable to be scrubbed from the logs. Required. Known values are: - "RequestIPAddress", "RequestUri", and "QueryStringArgNames". - :paramtype match_variable: str or ~azure.mgmt.cdn.models.ScrubbingRuleEntryMatchVariable - :keyword selector_match_operator: When matchVariable is a collection, operate on the selector - to specify which elements in the collection this rule applies to. Required. "EqualsAny" - :paramtype selector_match_operator: str or - ~azure.mgmt.cdn.models.ScrubbingRuleEntryMatchOperator - :keyword selector: When matchVariable is a collection, operator used to specify which elements - in the collection this rule applies to. - :paramtype selector: str - :keyword state: Defines the state of a log scrubbing rule. Default value is enabled. Known - values are: "Enabled" and "Disabled". - :paramtype state: str or ~azure.mgmt.cdn.models.ScrubbingRuleEntryState - """ - super().__init__(**kwargs) - self.match_variable = match_variable - self.selector_match_operator = selector_match_operator - self.selector = selector - self.state = state - - -class ProfileUpdateParameters(_serialization.Model): - """Properties required to update a profile. - - :ivar tags: Profile tags. - :vartype tags: dict[str, str] - :ivar identity: Managed service identity (system assigned and/or user assigned identities). - :vartype identity: ~azure.mgmt.cdn.models.ManagedServiceIdentity - :ivar origin_response_timeout_seconds: Send and receive timeout on forwarding request to the - origin. When timeout is reached, the request fails and returns. - :vartype origin_response_timeout_seconds: int - :ivar log_scrubbing: Defines rules to scrub sensitive fields in logs. - :vartype log_scrubbing: ~azure.mgmt.cdn.models.ProfileLogScrubbing - """ - - _validation = { - "origin_response_timeout_seconds": {"minimum": 16}, - } - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "identity": {"key": "identity", "type": "ManagedServiceIdentity"}, - "origin_response_timeout_seconds": {"key": "properties.originResponseTimeoutSeconds", "type": "int"}, - "log_scrubbing": {"key": "properties.logScrubbing", "type": "ProfileLogScrubbing"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - identity: Optional["_models.ManagedServiceIdentity"] = None, - origin_response_timeout_seconds: Optional[int] = None, - log_scrubbing: Optional["_models.ProfileLogScrubbing"] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Profile tags. - :paramtype tags: dict[str, str] - :keyword identity: Managed service identity (system assigned and/or user assigned identities). - :paramtype identity: ~azure.mgmt.cdn.models.ManagedServiceIdentity - :keyword origin_response_timeout_seconds: Send and receive timeout on forwarding request to the - origin. When timeout is reached, the request fails and returns. - :paramtype origin_response_timeout_seconds: int - :keyword log_scrubbing: Defines rules to scrub sensitive fields in logs. - :paramtype log_scrubbing: ~azure.mgmt.cdn.models.ProfileLogScrubbing - """ - super().__init__(**kwargs) - self.tags = tags - self.identity = identity - self.origin_response_timeout_seconds = origin_response_timeout_seconds - self.log_scrubbing = log_scrubbing - - -class ProfileUpgradeParameters(_serialization.Model): - """Parameters required for profile upgrade. - - All required parameters must be populated in order to send to server. - - :ivar waf_mapping_list: Web Application Firewall (WAF) and security policy mapping for the - profile upgrade. Required. - :vartype waf_mapping_list: list[~azure.mgmt.cdn.models.ProfileChangeSkuWafMapping] - """ - - _validation = { - "waf_mapping_list": {"required": True}, - } - - _attribute_map = { - "waf_mapping_list": {"key": "wafMappingList", "type": "[ProfileChangeSkuWafMapping]"}, - } - - def __init__(self, *, waf_mapping_list: List["_models.ProfileChangeSkuWafMapping"], **kwargs: Any) -> None: - """ - :keyword waf_mapping_list: Web Application Firewall (WAF) and security policy mapping for the - profile upgrade. Required. - :paramtype waf_mapping_list: list[~azure.mgmt.cdn.models.ProfileChangeSkuWafMapping] - """ - super().__init__(**kwargs) - self.waf_mapping_list = waf_mapping_list - - -class PurgeParameters(_serialization.Model): - """Parameters required for content purge. - - All required parameters must be populated in order to send to server. - - :ivar content_paths: The path to the content to be purged. Can describe a file path or a wild - card directory. Required. - :vartype content_paths: list[str] - """ - - _validation = { - "content_paths": {"required": True}, - } - - _attribute_map = { - "content_paths": {"key": "contentPaths", "type": "[str]"}, - } - - def __init__(self, *, content_paths: List[str], **kwargs: Any) -> None: - """ - :keyword content_paths: The path to the content to be purged. Can describe a file path or a - wild card directory. Required. - :paramtype content_paths: list[str] - """ - super().__init__(**kwargs) - self.content_paths = content_paths - - -class QueryStringMatchConditionParameters(_serialization.Model): - """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 operator: Describes operator to be matched. Required. Known values are: "Any", "Equal", - "Contains", "BeginsWith", "EndsWith", "LessThan", "LessThanOrEqual", "GreaterThan", - "GreaterThanOrEqual", and "RegEx". - :vartype operator: str or ~azure.mgmt.cdn.models.QueryStringOperator - :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] - :ivar transforms: List of transforms. - :vartype transforms: list[str or ~azure.mgmt.cdn.models.Transform] - """ - - _validation = { - "type_name": {"required": True}, - "operator": {"required": True}, - } - - _attribute_map = { - "type_name": {"key": "typeName", "type": "str"}, - "operator": {"key": "operator", "type": "str"}, - "negate_condition": {"key": "negateCondition", "type": "bool"}, - "match_values": {"key": "matchValues", "type": "[str]"}, - "transforms": {"key": "transforms", "type": "[str]"}, - } - - def __init__( - self, - *, - type_name: Union[str, "_models.QueryStringMatchConditionParametersTypeName"], - operator: Union[str, "_models.QueryStringOperator"], - negate_condition: bool = False, - match_values: Optional[List[str]] = None, - transforms: Optional[List[Union[str, "_models.Transform"]]] = None, - **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". - :paramtype operator: str or ~azure.mgmt.cdn.models.QueryStringOperator - :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] - :keyword transforms: List of transforms. - :paramtype transforms: list[str or ~azure.mgmt.cdn.models.Transform] - """ - super().__init__(**kwargs) - self.type_name = type_name - self.operator = operator - self.negate_condition = negate_condition - self.match_values = match_values - self.transforms = transforms - - -class RankingsResponse(_serialization.Model): - """Rankings Response. - - :ivar date_time_begin: - :vartype date_time_begin: ~datetime.datetime - :ivar date_time_end: - :vartype date_time_end: ~datetime.datetime - :ivar tables: - :vartype tables: list[~azure.mgmt.cdn.models.RankingsResponseTablesItem] - """ - - _attribute_map = { - "date_time_begin": {"key": "dateTimeBegin", "type": "iso-8601"}, - "date_time_end": {"key": "dateTimeEnd", "type": "iso-8601"}, - "tables": {"key": "tables", "type": "[RankingsResponseTablesItem]"}, - } - - def __init__( - self, - *, - date_time_begin: Optional[datetime.datetime] = None, - date_time_end: Optional[datetime.datetime] = None, - tables: Optional[List["_models.RankingsResponseTablesItem"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword date_time_begin: - :paramtype date_time_begin: ~datetime.datetime - :keyword date_time_end: - :paramtype date_time_end: ~datetime.datetime - :keyword tables: - :paramtype tables: list[~azure.mgmt.cdn.models.RankingsResponseTablesItem] - """ - super().__init__(**kwargs) - self.date_time_begin = date_time_begin - self.date_time_end = date_time_end - self.tables = tables - - -class RankingsResponseTablesItem(_serialization.Model): - """RankingsResponseTablesItem. - - :ivar ranking: - :vartype ranking: str - :ivar data: - :vartype data: list[~azure.mgmt.cdn.models.RankingsResponseTablesPropertiesItemsItem] - """ - - _attribute_map = { - "ranking": {"key": "ranking", "type": "str"}, - "data": {"key": "data", "type": "[RankingsResponseTablesPropertiesItemsItem]"}, - } - - def __init__( - self, - *, - ranking: Optional[str] = None, - data: Optional[List["_models.RankingsResponseTablesPropertiesItemsItem"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword ranking: - :paramtype ranking: str - :keyword data: - :paramtype data: list[~azure.mgmt.cdn.models.RankingsResponseTablesPropertiesItemsItem] - """ - super().__init__(**kwargs) - self.ranking = ranking - self.data = data - - -class RankingsResponseTablesPropertiesItemsItem(_serialization.Model): # pylint: disable=name-too-long - """RankingsResponseTablesPropertiesItemsItem. - - :ivar name: - :vartype name: str - :ivar metrics: - :vartype metrics: list[~azure.mgmt.cdn.models.RankingsResponseTablesPropertiesItemsMetricsItem] - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "metrics": {"key": "metrics", "type": "[RankingsResponseTablesPropertiesItemsMetricsItem]"}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - metrics: Optional[List["_models.RankingsResponseTablesPropertiesItemsMetricsItem"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: - :paramtype name: str - :keyword metrics: - :paramtype metrics: - list[~azure.mgmt.cdn.models.RankingsResponseTablesPropertiesItemsMetricsItem] - """ - super().__init__(**kwargs) - self.name = name - self.metrics = metrics - - -class RankingsResponseTablesPropertiesItemsMetricsItem(_serialization.Model): # pylint: disable=name-too-long - """RankingsResponseTablesPropertiesItemsMetricsItem. - - :ivar metric: - :vartype metric: str - :ivar value: - :vartype value: int - :ivar percentage: - :vartype percentage: float - """ - - _attribute_map = { - "metric": {"key": "metric", "type": "str"}, - "value": {"key": "value", "type": "int"}, - "percentage": {"key": "percentage", "type": "float"}, - } - - def __init__( - self, - *, - metric: Optional[str] = None, - value: Optional[int] = None, - percentage: Optional[float] = None, - **kwargs: Any - ) -> None: - """ - :keyword metric: - :paramtype metric: str - :keyword value: - :paramtype value: int - :keyword percentage: - :paramtype percentage: float - """ - super().__init__(**kwargs) - self.metric = metric - self.value = value - self.percentage = percentage - - -class RateLimitRule(CustomRule): - """Defines a rate limiting rule that can be included in a waf policy. - - All required parameters must be populated in order to send to server. - - :ivar name: Defines the name of the custom rule. Required. - :vartype name: str - :ivar enabled_state: Describes if the custom rule is in enabled or disabled state. Defaults to - Enabled if not specified. Known values are: "Disabled" and "Enabled". - :vartype enabled_state: str or ~azure.mgmt.cdn.models.CustomRuleEnabledState - :ivar priority: Defines in what order this rule be evaluated in the overall list of custom - rules. Required. - :vartype priority: int - :ivar match_conditions: List of match conditions. Required. - :vartype match_conditions: list[~azure.mgmt.cdn.models.MatchCondition] - :ivar action: Describes what action to be applied when rule matches. Required. Known values - are: "Allow", "Block", "Log", and "Redirect". - :vartype action: str or ~azure.mgmt.cdn.models.ActionType - :ivar rate_limit_threshold: Defines rate limit threshold. Required. - :vartype rate_limit_threshold: int - :ivar rate_limit_duration_in_minutes: Defines rate limit duration. Default is 1 minute. - Required. - :vartype rate_limit_duration_in_minutes: int - """ - - _validation = { - "name": {"required": True}, - "priority": {"required": True, "maximum": 1000, "minimum": 0}, - "match_conditions": {"required": True}, - "action": {"required": True}, - "rate_limit_threshold": {"required": True, "minimum": 0}, - "rate_limit_duration_in_minutes": {"required": True, "maximum": 60, "minimum": 0}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "enabled_state": {"key": "enabledState", "type": "str"}, - "priority": {"key": "priority", "type": "int"}, - "match_conditions": {"key": "matchConditions", "type": "[MatchCondition]"}, - "action": {"key": "action", "type": "str"}, - "rate_limit_threshold": {"key": "rateLimitThreshold", "type": "int"}, - "rate_limit_duration_in_minutes": {"key": "rateLimitDurationInMinutes", "type": "int"}, - } - - def __init__( - self, - *, - name: str, - priority: int, - match_conditions: List["_models.MatchCondition"], - action: Union[str, "_models.ActionType"], - rate_limit_threshold: int, - rate_limit_duration_in_minutes: int, - enabled_state: Optional[Union[str, "_models.CustomRuleEnabledState"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: Defines the name of the custom rule. Required. - :paramtype name: str - :keyword enabled_state: Describes if the custom rule is in enabled or disabled state. Defaults - to Enabled if not specified. Known values are: "Disabled" and "Enabled". - :paramtype enabled_state: str or ~azure.mgmt.cdn.models.CustomRuleEnabledState - :keyword priority: Defines in what order this rule be evaluated in the overall list of custom - rules. Required. - :paramtype priority: int - :keyword match_conditions: List of match conditions. Required. - :paramtype match_conditions: list[~azure.mgmt.cdn.models.MatchCondition] - :keyword action: Describes what action to be applied when rule matches. Required. Known values - are: "Allow", "Block", "Log", and "Redirect". - :paramtype action: str or ~azure.mgmt.cdn.models.ActionType - :keyword rate_limit_threshold: Defines rate limit threshold. Required. - :paramtype rate_limit_threshold: int - :keyword rate_limit_duration_in_minutes: Defines rate limit duration. Default is 1 minute. - Required. - :paramtype rate_limit_duration_in_minutes: int - """ - super().__init__( - name=name, - enabled_state=enabled_state, - priority=priority, - match_conditions=match_conditions, - action=action, - **kwargs - ) - self.rate_limit_threshold = rate_limit_threshold - self.rate_limit_duration_in_minutes = rate_limit_duration_in_minutes - - -class RateLimitRuleList(_serialization.Model): - """Defines contents of rate limit rules. - - :ivar rules: List of rules. - :vartype rules: list[~azure.mgmt.cdn.models.RateLimitRule] - """ - - _attribute_map = { - "rules": {"key": "rules", "type": "[RateLimitRule]"}, - } - - def __init__(self, *, rules: Optional[List["_models.RateLimitRule"]] = None, **kwargs: Any) -> None: - """ - :keyword rules: List of rules. - :paramtype rules: list[~azure.mgmt.cdn.models.RateLimitRule] - """ - super().__init__(**kwargs) - self.rules = rules - - -class RemoteAddressMatchConditionParameters(_serialization.Model): - """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 operator: Describes operator to be matched. Required. Known values are: "Any", "IPMatch", - and "GeoMatch". - :vartype operator: str or ~azure.mgmt.cdn.models.RemoteAddressOperator - :ivar negate_condition: Describes if this is negate condition or not. - :vartype negate_condition: bool - :ivar match_values: Match values to match against. The operator will apply to each value in - here with OR semantics. If any of them match the variable with the given operator this match - condition is considered a match. - :vartype match_values: list[str] - :ivar transforms: List of transforms. - :vartype transforms: list[str or ~azure.mgmt.cdn.models.Transform] - """ - - _validation = { - "type_name": {"required": True}, - "operator": {"required": True}, - } - - _attribute_map = { - "type_name": {"key": "typeName", "type": "str"}, - "operator": {"key": "operator", "type": "str"}, - "negate_condition": {"key": "negateCondition", "type": "bool"}, - "match_values": {"key": "matchValues", "type": "[str]"}, - "transforms": {"key": "transforms", "type": "[str]"}, - } - - def __init__( - self, - *, - type_name: Union[str, "_models.RemoteAddressMatchConditionParametersTypeName"], - operator: Union[str, "_models.RemoteAddressOperator"], - negate_condition: bool = False, - match_values: Optional[List[str]] = None, - transforms: Optional[List[Union[str, "_models.Transform"]]] = None, - **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 - :keyword negate_condition: Describes if this is negate condition or not. - :paramtype negate_condition: bool - :keyword match_values: Match values to match against. The operator will apply to each value in - here with OR semantics. If any of them match the variable with the given operator this match - condition is considered a match. - :paramtype match_values: list[str] - :keyword transforms: List of transforms. - :paramtype transforms: list[str or ~azure.mgmt.cdn.models.Transform] - """ - super().__init__(**kwargs) - self.type_name = type_name - self.operator = operator - self.negate_condition = negate_condition - self.match_values = match_values - self.transforms = transforms - - -class RequestBodyMatchConditionParameters(_serialization.Model): - """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 operator: Describes operator to be matched. Required. Known values are: "Any", "Equal", - "Contains", "BeginsWith", "EndsWith", "LessThan", "LessThanOrEqual", "GreaterThan", - "GreaterThanOrEqual", and "RegEx". - :vartype operator: str or ~azure.mgmt.cdn.models.RequestBodyOperator - :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] - :ivar transforms: List of transforms. - :vartype transforms: list[str or ~azure.mgmt.cdn.models.Transform] - """ - - _validation = { - "type_name": {"required": True}, - "operator": {"required": True}, - } - - _attribute_map = { - "type_name": {"key": "typeName", "type": "str"}, - "operator": {"key": "operator", "type": "str"}, - "negate_condition": {"key": "negateCondition", "type": "bool"}, - "match_values": {"key": "matchValues", "type": "[str]"}, - "transforms": {"key": "transforms", "type": "[str]"}, - } - - def __init__( - self, - *, - type_name: Union[str, "_models.RequestBodyMatchConditionParametersTypeName"], - operator: Union[str, "_models.RequestBodyOperator"], - negate_condition: bool = False, - match_values: Optional[List[str]] = None, - transforms: Optional[List[Union[str, "_models.Transform"]]] = None, - **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". - :paramtype operator: str or ~azure.mgmt.cdn.models.RequestBodyOperator - :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] - :keyword transforms: List of transforms. - :paramtype transforms: list[str or ~azure.mgmt.cdn.models.Transform] - """ - super().__init__(**kwargs) - self.type_name = type_name - self.operator = operator - self.negate_condition = negate_condition - self.match_values = match_values - self.transforms = transforms - - -class RequestHeaderMatchConditionParameters(_serialization.Model): - """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 selector: Name of Header to be matched. - :vartype selector: str - :ivar operator: Describes operator to be matched. Required. Known values are: "Any", "Equal", - "Contains", "BeginsWith", "EndsWith", "LessThan", "LessThanOrEqual", "GreaterThan", - "GreaterThanOrEqual", and "RegEx". - :vartype operator: str or ~azure.mgmt.cdn.models.RequestHeaderOperator - :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] - :ivar transforms: List of transforms. - :vartype transforms: list[str or ~azure.mgmt.cdn.models.Transform] - """ - - _validation = { - "type_name": {"required": True}, - "operator": {"required": True}, - } - - _attribute_map = { - "type_name": {"key": "typeName", "type": "str"}, - "selector": {"key": "selector", "type": "str"}, - "operator": {"key": "operator", "type": "str"}, - "negate_condition": {"key": "negateCondition", "type": "bool"}, - "match_values": {"key": "matchValues", "type": "[str]"}, - "transforms": {"key": "transforms", "type": "[str]"}, - } - - def __init__( - self, - *, - type_name: Union[str, "_models.RequestHeaderMatchConditionParametersTypeName"], - operator: Union[str, "_models.RequestHeaderOperator"], - selector: Optional[str] = None, - negate_condition: bool = False, - match_values: Optional[List[str]] = None, - transforms: Optional[List[Union[str, "_models.Transform"]]] = None, - **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", - "Equal", "Contains", "BeginsWith", "EndsWith", "LessThan", "LessThanOrEqual", "GreaterThan", - "GreaterThanOrEqual", and "RegEx". - :paramtype operator: str or ~azure.mgmt.cdn.models.RequestHeaderOperator - :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] - :keyword transforms: List of transforms. - :paramtype transforms: list[str or ~azure.mgmt.cdn.models.Transform] - """ - super().__init__(**kwargs) - self.type_name = type_name - self.selector = selector - self.operator = operator - self.negate_condition = negate_condition - self.match_values = match_values - self.transforms = transforms - - -class RequestMethodMatchConditionParameters(_serialization.Model): - """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 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. - :vartype negate_condition: bool - :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] - """ - - _validation = { - "type_name": {"required": True}, - "operator": {"required": True}, - } - - _attribute_map = { - "type_name": {"key": "typeName", "type": "str"}, - "operator": {"key": "operator", "type": "str"}, - "negate_condition": {"key": "negateCondition", "type": "bool"}, - "transforms": {"key": "transforms", "type": "[str]"}, - "match_values": {"key": "matchValues", "type": "[str]"}, - } - - 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, - **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. - :paramtype negate_condition: bool - :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] - """ - super().__init__(**kwargs) - self.type_name = type_name - self.operator = operator - self.negate_condition = negate_condition - self.transforms = transforms - self.match_values = match_values - - -class RequestSchemeMatchConditionParameters(_serialization.Model): - """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 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. - :vartype negate_condition: bool - :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] - """ - - _validation = { - "type_name": {"required": True}, - "operator": {"required": True}, - } - - _attribute_map = { - "type_name": {"key": "typeName", "type": "str"}, - "operator": {"key": "operator", "type": "str"}, - "negate_condition": {"key": "negateCondition", "type": "bool"}, - "transforms": {"key": "transforms", "type": "[str]"}, - "match_values": {"key": "matchValues", "type": "[str]"}, - } - - 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, - **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 - :keyword negate_condition: Describes if this is negate condition or not. - :paramtype negate_condition: bool - :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] - """ - super().__init__(**kwargs) - self.type_name = type_name - self.operator = operator - self.negate_condition = negate_condition - self.transforms = transforms - self.match_values = match_values - - -class RequestUriMatchConditionParameters(_serialization.Model): - """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 operator: Describes operator to be matched. Required. Known values are: "Any", "Equal", - "Contains", "BeginsWith", "EndsWith", "LessThan", "LessThanOrEqual", "GreaterThan", - "GreaterThanOrEqual", and "RegEx". - :vartype operator: str or ~azure.mgmt.cdn.models.RequestUriOperator - :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] - :ivar transforms: List of transforms. - :vartype transforms: list[str or ~azure.mgmt.cdn.models.Transform] - """ - - _validation = { - "type_name": {"required": True}, - "operator": {"required": True}, - } - - _attribute_map = { - "type_name": {"key": "typeName", "type": "str"}, - "operator": {"key": "operator", "type": "str"}, - "negate_condition": {"key": "negateCondition", "type": "bool"}, - "match_values": {"key": "matchValues", "type": "[str]"}, - "transforms": {"key": "transforms", "type": "[str]"}, - } - - def __init__( - self, - *, - type_name: Union[str, "_models.RequestUriMatchConditionParametersTypeName"], - operator: Union[str, "_models.RequestUriOperator"], - negate_condition: bool = False, - match_values: Optional[List[str]] = None, - transforms: Optional[List[Union[str, "_models.Transform"]]] = None, - **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". - :paramtype operator: str or ~azure.mgmt.cdn.models.RequestUriOperator - :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] - :keyword transforms: List of transforms. - :paramtype transforms: list[str or ~azure.mgmt.cdn.models.Transform] - """ - super().__init__(**kwargs) - self.type_name = type_name - self.operator = operator - self.negate_condition = negate_condition - self.match_values = match_values - self.transforms = transforms - - -class ResourceReference(_serialization.Model): - """Reference to another resource. - - :ivar id: Resource ID. - :vartype id: str - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - } - - def __init__(self, *, id: Optional[str] = None, **kwargs: Any) -> None: # pylint: disable=redefined-builtin - """ - :keyword id: Resource ID. - :paramtype id: str - """ - super().__init__(**kwargs) - self.id = id - - -class ResourcesResponse(_serialization.Model): - """Resources Response. - - :ivar endpoints: - :vartype endpoints: list[~azure.mgmt.cdn.models.ResourcesResponseEndpointsItem] - :ivar custom_domains: - :vartype custom_domains: list[~azure.mgmt.cdn.models.ResourcesResponseCustomDomainsItem] - """ - - _attribute_map = { - "endpoints": {"key": "endpoints", "type": "[ResourcesResponseEndpointsItem]"}, - "custom_domains": {"key": "customDomains", "type": "[ResourcesResponseCustomDomainsItem]"}, - } - - def __init__( - self, - *, - endpoints: Optional[List["_models.ResourcesResponseEndpointsItem"]] = None, - custom_domains: Optional[List["_models.ResourcesResponseCustomDomainsItem"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword endpoints: - :paramtype endpoints: list[~azure.mgmt.cdn.models.ResourcesResponseEndpointsItem] - :keyword custom_domains: - :paramtype custom_domains: list[~azure.mgmt.cdn.models.ResourcesResponseCustomDomainsItem] - """ - super().__init__(**kwargs) - self.endpoints = endpoints - self.custom_domains = custom_domains - - -class ResourcesResponseCustomDomainsItem(_serialization.Model): - """ResourcesResponseCustomDomainsItem. - - :ivar id: - :vartype id: str - :ivar name: - :vartype name: str - :ivar endpoint_id: - :vartype endpoint_id: str - :ivar history: - :vartype history: bool - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "endpoint_id": {"key": "endpointId", "type": "str"}, - "history": {"key": "history", "type": "bool"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - name: Optional[str] = None, - endpoint_id: Optional[str] = None, - history: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: - :paramtype id: str - :keyword name: - :paramtype name: str - :keyword endpoint_id: - :paramtype endpoint_id: str - :keyword history: - :paramtype history: bool - """ - super().__init__(**kwargs) - self.id = id - self.name = name - self.endpoint_id = endpoint_id - self.history = history - - -class ResourcesResponseEndpointsItem(_serialization.Model): - """ResourcesResponseEndpointsItem. - - :ivar id: - :vartype id: str - :ivar name: - :vartype name: str - :ivar history: - :vartype history: bool - :ivar custom_domains: - :vartype custom_domains: - list[~azure.mgmt.cdn.models.ResourcesResponseEndpointsPropertiesItemsItem] - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "history": {"key": "history", "type": "bool"}, - "custom_domains": {"key": "customDomains", "type": "[ResourcesResponseEndpointsPropertiesItemsItem]"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - name: Optional[str] = None, - history: Optional[bool] = None, - custom_domains: Optional[List["_models.ResourcesResponseEndpointsPropertiesItemsItem"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: - :paramtype id: str - :keyword name: - :paramtype name: str - :keyword history: - :paramtype history: bool - :keyword custom_domains: - :paramtype custom_domains: - list[~azure.mgmt.cdn.models.ResourcesResponseEndpointsPropertiesItemsItem] - """ - super().__init__(**kwargs) - self.id = id - self.name = name - self.history = history - self.custom_domains = custom_domains - - -class ResourcesResponseEndpointsPropertiesItemsItem(_serialization.Model): # pylint: disable=name-too-long - """ResourcesResponseEndpointsPropertiesItemsItem. - - :ivar id: - :vartype id: str - :ivar name: - :vartype name: str - :ivar endpoint_id: - :vartype endpoint_id: str - :ivar history: - :vartype history: bool - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "endpoint_id": {"key": "endpointId", "type": "str"}, - "history": {"key": "history", "type": "bool"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - name: Optional[str] = None, - endpoint_id: Optional[str] = None, - history: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: - :paramtype id: str - :keyword name: - :paramtype name: str - :keyword endpoint_id: - :paramtype endpoint_id: str - :keyword history: - :paramtype history: bool - """ - super().__init__(**kwargs) - self.id = id - self.name = name - self.endpoint_id = endpoint_id - self.history = history - - -class ResourceUsage(_serialization.Model): - """Output of check resource usage API. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar resource_type: Resource type for which the usage is provided. - :vartype resource_type: str - :ivar unit: Unit of the usage. e.g. count. "count" - :vartype unit: str or ~azure.mgmt.cdn.models.ResourceUsageUnit - :ivar current_value: Actual value of usage on the specified resource type. - :vartype current_value: int - :ivar limit: Quota of the specified resource type. - :vartype limit: int - """ - - _validation = { - "resource_type": {"readonly": True}, - "unit": {"readonly": True}, - "current_value": {"readonly": True}, - "limit": {"readonly": True}, - } - - _attribute_map = { - "resource_type": {"key": "resourceType", "type": "str"}, - "unit": {"key": "unit", "type": "str"}, - "current_value": {"key": "currentValue", "type": "int"}, - "limit": {"key": "limit", "type": "int"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.resource_type = None - self.unit = None - self.current_value = None - self.limit = None - - -class ResourceUsageListResult(_serialization.Model): - """Output of check resource usage API. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: List of resource usages. - :vartype value: list[~azure.mgmt.cdn.models.ResourceUsage] - :ivar next_link: URL to get the next set of custom domain objects if there are any. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[ResourceUsage]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword next_link: URL to get the next set of custom domain objects if there are any. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = None - self.next_link = next_link - - -class ResponseBasedOriginErrorDetectionParameters(_serialization.Model): # pylint: disable=name-too-long - """The JSON object that contains the properties to determine origin health using real - requests/responses. - - :ivar response_based_detected_error_types: Type of response errors for real user requests for - which origin will be deemed unhealthy. Known values are: "None", "TcpErrorsOnly", and - "TcpAndHttpErrors". - :vartype response_based_detected_error_types: str or - ~azure.mgmt.cdn.models.ResponseBasedDetectedErrorTypes - :ivar response_based_failover_threshold_percentage: The percentage of failed requests in the - sample where failover should trigger. - :vartype response_based_failover_threshold_percentage: int - :ivar http_error_ranges: The list of Http status code ranges that are considered as server - errors for origin and it is marked as unhealthy. - :vartype http_error_ranges: list[~azure.mgmt.cdn.models.HttpErrorRangeParameters] - """ - - _validation = { - "response_based_failover_threshold_percentage": {"maximum": 100, "minimum": 0}, - } - - _attribute_map = { - "response_based_detected_error_types": {"key": "responseBasedDetectedErrorTypes", "type": "str"}, - "response_based_failover_threshold_percentage": { - "key": "responseBasedFailoverThresholdPercentage", - "type": "int", - }, - "http_error_ranges": {"key": "httpErrorRanges", "type": "[HttpErrorRangeParameters]"}, - } - - def __init__( - self, - *, - response_based_detected_error_types: Optional[Union[str, "_models.ResponseBasedDetectedErrorTypes"]] = None, - response_based_failover_threshold_percentage: Optional[int] = None, - http_error_ranges: Optional[List["_models.HttpErrorRangeParameters"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword response_based_detected_error_types: Type of response errors for real user requests - for which origin will be deemed unhealthy. Known values are: "None", "TcpErrorsOnly", and - "TcpAndHttpErrors". - :paramtype response_based_detected_error_types: str or - ~azure.mgmt.cdn.models.ResponseBasedDetectedErrorTypes - :keyword response_based_failover_threshold_percentage: The percentage of failed requests in the - sample where failover should trigger. - :paramtype response_based_failover_threshold_percentage: int - :keyword http_error_ranges: The list of Http status code ranges that are considered as server - errors for origin and it is marked as unhealthy. - :paramtype http_error_ranges: list[~azure.mgmt.cdn.models.HttpErrorRangeParameters] - """ - super().__init__(**kwargs) - self.response_based_detected_error_types = response_based_detected_error_types - self.response_based_failover_threshold_percentage = response_based_failover_threshold_percentage - self.http_error_ranges = http_error_ranges - - -class Route(ProxyResource): # pylint: disable=too-many-instance-attributes - """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. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar system_data: Read only system data. - :vartype system_data: ~azure.mgmt.cdn.models.SystemData - :ivar endpoint_name: The name of the endpoint which holds the route. - :vartype endpoint_name: str - :ivar custom_domains: Domains referenced by this endpoint. - :vartype custom_domains: list[~azure.mgmt.cdn.models.ActivatedResourceReference] - :ivar origin_group: A reference to the origin group. - :vartype origin_group: ~azure.mgmt.cdn.models.ResourceReference - :ivar origin_path: A directory path on the origin that AzureFrontDoor can use to retrieve - content from, e.g. contoso.cloudapp.net/originpath. - :vartype origin_path: str - :ivar rule_sets: rule sets referenced by this endpoint. - :vartype rule_sets: list[~azure.mgmt.cdn.models.ResourceReference] - :ivar supported_protocols: List of supported protocols for this route. - :vartype supported_protocols: list[str or ~azure.mgmt.cdn.models.AFDEndpointProtocols] - :ivar patterns_to_match: The route patterns of the rule. - :vartype patterns_to_match: list[str] - :ivar cache_configuration: The caching configuration for this route. To disable caching, do not - provide a cacheConfiguration object. - :vartype cache_configuration: ~azure.mgmt.cdn.models.AfdRouteCacheConfiguration - :ivar forwarding_protocol: Protocol this rule will use when forwarding traffic to backends. - Known values are: "HttpOnly", "HttpsOnly", and "MatchRequest". - :vartype forwarding_protocol: str or ~azure.mgmt.cdn.models.ForwardingProtocol - :ivar link_to_default_domain: whether this route will be linked to the default endpoint domain. - Known values are: "Enabled" and "Disabled". - :vartype link_to_default_domain: str or ~azure.mgmt.cdn.models.LinkToDefaultDomain - :ivar https_redirect: Whether to automatically redirect HTTP traffic to HTTPS traffic. Note - that this is a easy way to set up this rule and it will be the first rule that gets executed. - Known values are: "Enabled" and "Disabled". - :vartype https_redirect: str or ~azure.mgmt.cdn.models.HttpsRedirect - :ivar enabled_state: Whether to enable use of this rule. Permitted values are 'Enabled' or - 'Disabled'. Known values are: "Enabled" and "Disabled". - :vartype enabled_state: str or ~azure.mgmt.cdn.models.EnabledState - :ivar provisioning_state: Provisioning status. Known values are: "Succeeded", "Failed", - "Updating", "Deleting", and "Creating". - :vartype provisioning_state: str or ~azure.mgmt.cdn.models.AfdProvisioningState - :ivar deployment_status: Known values are: "NotStarted", "InProgress", "Succeeded", and - "Failed". - :vartype deployment_status: str or ~azure.mgmt.cdn.models.DeploymentStatus - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - "endpoint_name": {"readonly": True}, - "provisioning_state": {"readonly": True}, - "deployment_status": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "endpoint_name": {"key": "properties.endpointName", "type": "str"}, - "custom_domains": {"key": "properties.customDomains", "type": "[ActivatedResourceReference]"}, - "origin_group": {"key": "properties.originGroup", "type": "ResourceReference"}, - "origin_path": {"key": "properties.originPath", "type": "str"}, - "rule_sets": {"key": "properties.ruleSets", "type": "[ResourceReference]"}, - "supported_protocols": {"key": "properties.supportedProtocols", "type": "[str]"}, - "patterns_to_match": {"key": "properties.patternsToMatch", "type": "[str]"}, - "cache_configuration": {"key": "properties.cacheConfiguration", "type": "AfdRouteCacheConfiguration"}, - "forwarding_protocol": {"key": "properties.forwardingProtocol", "type": "str"}, - "link_to_default_domain": {"key": "properties.linkToDefaultDomain", "type": "str"}, - "https_redirect": {"key": "properties.httpsRedirect", "type": "str"}, - "enabled_state": {"key": "properties.enabledState", "type": "str"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "deployment_status": {"key": "properties.deploymentStatus", "type": "str"}, - } - - def __init__( - self, - *, - custom_domains: Optional[List["_models.ActivatedResourceReference"]] = None, - origin_group: Optional["_models.ResourceReference"] = None, - origin_path: Optional[str] = None, - rule_sets: Optional[List["_models.ResourceReference"]] = None, - supported_protocols: List[Union[str, "_models.AFDEndpointProtocols"]] = ["Http", "Https"], - patterns_to_match: Optional[List[str]] = None, - cache_configuration: Optional["_models.AfdRouteCacheConfiguration"] = None, - forwarding_protocol: Optional[Union[str, "_models.ForwardingProtocol"]] = None, - link_to_default_domain: Union[str, "_models.LinkToDefaultDomain"] = "Disabled", - https_redirect: Union[str, "_models.HttpsRedirect"] = "Disabled", - enabled_state: Optional[Union[str, "_models.EnabledState"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword custom_domains: Domains referenced by this endpoint. - :paramtype custom_domains: list[~azure.mgmt.cdn.models.ActivatedResourceReference] - :keyword origin_group: A reference to the origin group. - :paramtype origin_group: ~azure.mgmt.cdn.models.ResourceReference - :keyword origin_path: A directory path on the origin that AzureFrontDoor can use to retrieve - content from, e.g. contoso.cloudapp.net/originpath. - :paramtype origin_path: str - :keyword rule_sets: rule sets referenced by this endpoint. - :paramtype rule_sets: list[~azure.mgmt.cdn.models.ResourceReference] - :keyword supported_protocols: List of supported protocols for this route. - :paramtype supported_protocols: list[str or ~azure.mgmt.cdn.models.AFDEndpointProtocols] - :keyword patterns_to_match: The route patterns of the rule. - :paramtype patterns_to_match: list[str] - :keyword cache_configuration: The caching configuration for this route. To disable caching, do - not provide a cacheConfiguration object. - :paramtype cache_configuration: ~azure.mgmt.cdn.models.AfdRouteCacheConfiguration - :keyword forwarding_protocol: Protocol this rule will use when forwarding traffic to backends. - Known values are: "HttpOnly", "HttpsOnly", and "MatchRequest". - :paramtype forwarding_protocol: str or ~azure.mgmt.cdn.models.ForwardingProtocol - :keyword link_to_default_domain: whether this route will be linked to the default endpoint - domain. Known values are: "Enabled" and "Disabled". - :paramtype link_to_default_domain: str or ~azure.mgmt.cdn.models.LinkToDefaultDomain - :keyword https_redirect: Whether to automatically redirect HTTP traffic to HTTPS traffic. Note - that this is a easy way to set up this rule and it will be the first rule that gets executed. - Known values are: "Enabled" and "Disabled". - :paramtype https_redirect: str or ~azure.mgmt.cdn.models.HttpsRedirect - :keyword enabled_state: Whether to enable use of this rule. Permitted values are 'Enabled' or - 'Disabled'. Known values are: "Enabled" and "Disabled". - :paramtype enabled_state: str or ~azure.mgmt.cdn.models.EnabledState - """ - super().__init__(**kwargs) - self.endpoint_name = None - self.custom_domains = custom_domains - self.origin_group = origin_group - self.origin_path = origin_path - self.rule_sets = rule_sets - self.supported_protocols = supported_protocols - self.patterns_to_match = patterns_to_match - self.cache_configuration = cache_configuration - self.forwarding_protocol = forwarding_protocol - 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 - - -class RouteConfigurationOverrideActionParameters(_serialization.Model): # 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 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 - :ivar cache_configuration: The caching configuration associated with this rule. To disable - caching, do not provide a cacheConfiguration object. - :vartype cache_configuration: ~azure.mgmt.cdn.models.CacheConfiguration - """ - - _validation = { - "type_name": {"required": True}, - } - - _attribute_map = { - "type_name": {"key": "typeName", "type": "str"}, - "origin_group_override": {"key": "originGroupOverride", "type": "OriginGroupOverride"}, - "cache_configuration": {"key": "cacheConfiguration", "type": "CacheConfiguration"}, - } - - 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 - :keyword cache_configuration: The caching configuration associated with this rule. To disable - caching, do not provide a cacheConfiguration object. - :paramtype cache_configuration: ~azure.mgmt.cdn.models.CacheConfiguration - """ - super().__init__(**kwargs) - self.type_name = type_name - self.origin_group_override = origin_group_override - self.cache_configuration = cache_configuration - - -class RouteListResult(_serialization.Model): - """Result of the request to list routes. It contains a list of route objects and a URL link to get - the next set of results. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: List of AzureFrontDoor routes within a profile. - :vartype value: list[~azure.mgmt.cdn.models.Route] - :ivar next_link: URL to get the next set of route objects if there are any. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[Route]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword next_link: URL to get the next set of route objects if there are any. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = None - self.next_link = next_link - - -class RouteUpdatePropertiesParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes - """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. - - :ivar endpoint_name: The name of the endpoint which holds the route. - :vartype endpoint_name: str - :ivar custom_domains: Domains referenced by this endpoint. - :vartype custom_domains: list[~azure.mgmt.cdn.models.ActivatedResourceReference] - :ivar origin_group: A reference to the origin group. - :vartype origin_group: ~azure.mgmt.cdn.models.ResourceReference - :ivar origin_path: A directory path on the origin that AzureFrontDoor can use to retrieve - content from, e.g. contoso.cloudapp.net/originpath. - :vartype origin_path: str - :ivar rule_sets: rule sets referenced by this endpoint. - :vartype rule_sets: list[~azure.mgmt.cdn.models.ResourceReference] - :ivar supported_protocols: List of supported protocols for this route. - :vartype supported_protocols: list[str or ~azure.mgmt.cdn.models.AFDEndpointProtocols] - :ivar patterns_to_match: The route patterns of the rule. - :vartype patterns_to_match: list[str] - :ivar cache_configuration: The caching configuration for this route. To disable caching, do not - provide a cacheConfiguration object. - :vartype cache_configuration: ~azure.mgmt.cdn.models.AfdRouteCacheConfiguration - :ivar forwarding_protocol: Protocol this rule will use when forwarding traffic to backends. - Known values are: "HttpOnly", "HttpsOnly", and "MatchRequest". - :vartype forwarding_protocol: str or ~azure.mgmt.cdn.models.ForwardingProtocol - :ivar link_to_default_domain: whether this route will be linked to the default endpoint domain. - Known values are: "Enabled" and "Disabled". - :vartype link_to_default_domain: str or ~azure.mgmt.cdn.models.LinkToDefaultDomain - :ivar https_redirect: Whether to automatically redirect HTTP traffic to HTTPS traffic. Note - that this is a easy way to set up this rule and it will be the first rule that gets executed. - Known values are: "Enabled" and "Disabled". - :vartype https_redirect: str or ~azure.mgmt.cdn.models.HttpsRedirect - :ivar enabled_state: Whether to enable use of this rule. Permitted values are 'Enabled' or - 'Disabled'. Known values are: "Enabled" and "Disabled". - :vartype enabled_state: str or ~azure.mgmt.cdn.models.EnabledState - """ - - _validation = { - "endpoint_name": {"readonly": True}, - } - - _attribute_map = { - "endpoint_name": {"key": "endpointName", "type": "str"}, - "custom_domains": {"key": "customDomains", "type": "[ActivatedResourceReference]"}, - "origin_group": {"key": "originGroup", "type": "ResourceReference"}, - "origin_path": {"key": "originPath", "type": "str"}, - "rule_sets": {"key": "ruleSets", "type": "[ResourceReference]"}, - "supported_protocols": {"key": "supportedProtocols", "type": "[str]"}, - "patterns_to_match": {"key": "patternsToMatch", "type": "[str]"}, - "cache_configuration": {"key": "cacheConfiguration", "type": "AfdRouteCacheConfiguration"}, - "forwarding_protocol": {"key": "forwardingProtocol", "type": "str"}, - "link_to_default_domain": {"key": "linkToDefaultDomain", "type": "str"}, - "https_redirect": {"key": "httpsRedirect", "type": "str"}, - "enabled_state": {"key": "enabledState", "type": "str"}, - } - - def __init__( - self, - *, - custom_domains: Optional[List["_models.ActivatedResourceReference"]] = None, - origin_group: Optional["_models.ResourceReference"] = None, - origin_path: Optional[str] = None, - rule_sets: Optional[List["_models.ResourceReference"]] = None, - supported_protocols: List[Union[str, "_models.AFDEndpointProtocols"]] = ["Http", "Https"], - patterns_to_match: Optional[List[str]] = None, - cache_configuration: Optional["_models.AfdRouteCacheConfiguration"] = None, - forwarding_protocol: Optional[Union[str, "_models.ForwardingProtocol"]] = None, - link_to_default_domain: Union[str, "_models.LinkToDefaultDomain"] = "Disabled", - https_redirect: Union[str, "_models.HttpsRedirect"] = "Disabled", - enabled_state: Optional[Union[str, "_models.EnabledState"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword custom_domains: Domains referenced by this endpoint. - :paramtype custom_domains: list[~azure.mgmt.cdn.models.ActivatedResourceReference] - :keyword origin_group: A reference to the origin group. - :paramtype origin_group: ~azure.mgmt.cdn.models.ResourceReference - :keyword origin_path: A directory path on the origin that AzureFrontDoor can use to retrieve - content from, e.g. contoso.cloudapp.net/originpath. - :paramtype origin_path: str - :keyword rule_sets: rule sets referenced by this endpoint. - :paramtype rule_sets: list[~azure.mgmt.cdn.models.ResourceReference] - :keyword supported_protocols: List of supported protocols for this route. - :paramtype supported_protocols: list[str or ~azure.mgmt.cdn.models.AFDEndpointProtocols] - :keyword patterns_to_match: The route patterns of the rule. - :paramtype patterns_to_match: list[str] - :keyword cache_configuration: The caching configuration for this route. To disable caching, do - not provide a cacheConfiguration object. - :paramtype cache_configuration: ~azure.mgmt.cdn.models.AfdRouteCacheConfiguration - :keyword forwarding_protocol: Protocol this rule will use when forwarding traffic to backends. - Known values are: "HttpOnly", "HttpsOnly", and "MatchRequest". - :paramtype forwarding_protocol: str or ~azure.mgmt.cdn.models.ForwardingProtocol - :keyword link_to_default_domain: whether this route will be linked to the default endpoint - domain. Known values are: "Enabled" and "Disabled". - :paramtype link_to_default_domain: str or ~azure.mgmt.cdn.models.LinkToDefaultDomain - :keyword https_redirect: Whether to automatically redirect HTTP traffic to HTTPS traffic. Note - that this is a easy way to set up this rule and it will be the first rule that gets executed. - Known values are: "Enabled" and "Disabled". - :paramtype https_redirect: str or ~azure.mgmt.cdn.models.HttpsRedirect - :keyword enabled_state: Whether to enable use of this rule. Permitted values are 'Enabled' or - 'Disabled'. Known values are: "Enabled" and "Disabled". - :paramtype enabled_state: str or ~azure.mgmt.cdn.models.EnabledState - """ - super().__init__(**kwargs) - self.endpoint_name = None - self.custom_domains = custom_domains - self.origin_group = origin_group - self.origin_path = origin_path - self.rule_sets = rule_sets - self.supported_protocols = supported_protocols - self.patterns_to_match = patterns_to_match - self.cache_configuration = cache_configuration - self.forwarding_protocol = forwarding_protocol - self.link_to_default_domain = link_to_default_domain - self.https_redirect = https_redirect - self.enabled_state = enabled_state - - -class RouteProperties( - RouteUpdatePropertiesParameters, AFDStateProperties -): # pylint: disable=too-many-instance-attributes - """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. - - :ivar provisioning_state: Provisioning status. Known values are: "Succeeded", "Failed", - "Updating", "Deleting", and "Creating". - :vartype provisioning_state: str or ~azure.mgmt.cdn.models.AfdProvisioningState - :ivar deployment_status: Known values are: "NotStarted", "InProgress", "Succeeded", and - "Failed". - :vartype deployment_status: str or ~azure.mgmt.cdn.models.DeploymentStatus - :ivar endpoint_name: The name of the endpoint which holds the route. - :vartype endpoint_name: str - :ivar custom_domains: Domains referenced by this endpoint. - :vartype custom_domains: list[~azure.mgmt.cdn.models.ActivatedResourceReference] - :ivar origin_group: A reference to the origin group. - :vartype origin_group: ~azure.mgmt.cdn.models.ResourceReference - :ivar origin_path: A directory path on the origin that AzureFrontDoor can use to retrieve - content from, e.g. contoso.cloudapp.net/originpath. - :vartype origin_path: str - :ivar rule_sets: rule sets referenced by this endpoint. - :vartype rule_sets: list[~azure.mgmt.cdn.models.ResourceReference] - :ivar supported_protocols: List of supported protocols for this route. - :vartype supported_protocols: list[str or ~azure.mgmt.cdn.models.AFDEndpointProtocols] - :ivar patterns_to_match: The route patterns of the rule. - :vartype patterns_to_match: list[str] - :ivar cache_configuration: The caching configuration for this route. To disable caching, do not - provide a cacheConfiguration object. - :vartype cache_configuration: ~azure.mgmt.cdn.models.AfdRouteCacheConfiguration - :ivar forwarding_protocol: Protocol this rule will use when forwarding traffic to backends. - Known values are: "HttpOnly", "HttpsOnly", and "MatchRequest". - :vartype forwarding_protocol: str or ~azure.mgmt.cdn.models.ForwardingProtocol - :ivar link_to_default_domain: whether this route will be linked to the default endpoint domain. - Known values are: "Enabled" and "Disabled". - :vartype link_to_default_domain: str or ~azure.mgmt.cdn.models.LinkToDefaultDomain - :ivar https_redirect: Whether to automatically redirect HTTP traffic to HTTPS traffic. Note - that this is a easy way to set up this rule and it will be the first rule that gets executed. - Known values are: "Enabled" and "Disabled". - :vartype https_redirect: str or ~azure.mgmt.cdn.models.HttpsRedirect - :ivar enabled_state: Whether to enable use of this rule. Permitted values are 'Enabled' or - 'Disabled'. Known values are: "Enabled" and "Disabled". - :vartype enabled_state: str or ~azure.mgmt.cdn.models.EnabledState - """ - - _validation = { - "provisioning_state": {"readonly": True}, - "deployment_status": {"readonly": True}, - "endpoint_name": {"readonly": True}, - } - - _attribute_map = { - "provisioning_state": {"key": "provisioningState", "type": "str"}, - "deployment_status": {"key": "deploymentStatus", "type": "str"}, - "endpoint_name": {"key": "endpointName", "type": "str"}, - "custom_domains": {"key": "customDomains", "type": "[ActivatedResourceReference]"}, - "origin_group": {"key": "originGroup", "type": "ResourceReference"}, - "origin_path": {"key": "originPath", "type": "str"}, - "rule_sets": {"key": "ruleSets", "type": "[ResourceReference]"}, - "supported_protocols": {"key": "supportedProtocols", "type": "[str]"}, - "patterns_to_match": {"key": "patternsToMatch", "type": "[str]"}, - "cache_configuration": {"key": "cacheConfiguration", "type": "AfdRouteCacheConfiguration"}, - "forwarding_protocol": {"key": "forwardingProtocol", "type": "str"}, - "link_to_default_domain": {"key": "linkToDefaultDomain", "type": "str"}, - "https_redirect": {"key": "httpsRedirect", "type": "str"}, - "enabled_state": {"key": "enabledState", "type": "str"}, - } - - def __init__( - self, - *, - custom_domains: Optional[List["_models.ActivatedResourceReference"]] = None, - origin_group: Optional["_models.ResourceReference"] = None, - origin_path: Optional[str] = None, - rule_sets: Optional[List["_models.ResourceReference"]] = None, - supported_protocols: List[Union[str, "_models.AFDEndpointProtocols"]] = ["Http", "Https"], - patterns_to_match: Optional[List[str]] = None, - cache_configuration: Optional["_models.AfdRouteCacheConfiguration"] = None, - forwarding_protocol: Optional[Union[str, "_models.ForwardingProtocol"]] = None, - link_to_default_domain: Union[str, "_models.LinkToDefaultDomain"] = "Disabled", - https_redirect: Union[str, "_models.HttpsRedirect"] = "Disabled", - enabled_state: Optional[Union[str, "_models.EnabledState"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword custom_domains: Domains referenced by this endpoint. - :paramtype custom_domains: list[~azure.mgmt.cdn.models.ActivatedResourceReference] - :keyword origin_group: A reference to the origin group. - :paramtype origin_group: ~azure.mgmt.cdn.models.ResourceReference - :keyword origin_path: A directory path on the origin that AzureFrontDoor can use to retrieve - content from, e.g. contoso.cloudapp.net/originpath. - :paramtype origin_path: str - :keyword rule_sets: rule sets referenced by this endpoint. - :paramtype rule_sets: list[~azure.mgmt.cdn.models.ResourceReference] - :keyword supported_protocols: List of supported protocols for this route. - :paramtype supported_protocols: list[str or ~azure.mgmt.cdn.models.AFDEndpointProtocols] - :keyword patterns_to_match: The route patterns of the rule. - :paramtype patterns_to_match: list[str] - :keyword cache_configuration: The caching configuration for this route. To disable caching, do - not provide a cacheConfiguration object. - :paramtype cache_configuration: ~azure.mgmt.cdn.models.AfdRouteCacheConfiguration - :keyword forwarding_protocol: Protocol this rule will use when forwarding traffic to backends. - Known values are: "HttpOnly", "HttpsOnly", and "MatchRequest". - :paramtype forwarding_protocol: str or ~azure.mgmt.cdn.models.ForwardingProtocol - :keyword link_to_default_domain: whether this route will be linked to the default endpoint - domain. Known values are: "Enabled" and "Disabled". - :paramtype link_to_default_domain: str or ~azure.mgmt.cdn.models.LinkToDefaultDomain - :keyword https_redirect: Whether to automatically redirect HTTP traffic to HTTPS traffic. Note - that this is a easy way to set up this rule and it will be the first rule that gets executed. - Known values are: "Enabled" and "Disabled". - :paramtype https_redirect: str or ~azure.mgmt.cdn.models.HttpsRedirect - :keyword enabled_state: Whether to enable use of this rule. Permitted values are 'Enabled' or - 'Disabled'. Known values are: "Enabled" and "Disabled". - :paramtype enabled_state: str or ~azure.mgmt.cdn.models.EnabledState - """ - super().__init__( - custom_domains=custom_domains, - origin_group=origin_group, - origin_path=origin_path, - rule_sets=rule_sets, - supported_protocols=supported_protocols, - patterns_to_match=patterns_to_match, - cache_configuration=cache_configuration, - forwarding_protocol=forwarding_protocol, - link_to_default_domain=link_to_default_domain, - https_redirect=https_redirect, - enabled_state=enabled_state, - **kwargs - ) - self.provisioning_state = None - self.deployment_status = None - self.endpoint_name = None - self.custom_domains = custom_domains - self.origin_group = origin_group - self.origin_path = origin_path - self.rule_sets = rule_sets - self.supported_protocols = supported_protocols - self.patterns_to_match = patterns_to_match - self.cache_configuration = cache_configuration - self.forwarding_protocol = forwarding_protocol - self.link_to_default_domain = link_to_default_domain - self.https_redirect = https_redirect - self.enabled_state = enabled_state - - -class RouteUpdateParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes - """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. - - :ivar endpoint_name: The name of the endpoint which holds the route. - :vartype endpoint_name: str - :ivar custom_domains: Domains referenced by this endpoint. - :vartype custom_domains: list[~azure.mgmt.cdn.models.ActivatedResourceReference] - :ivar origin_group: A reference to the origin group. - :vartype origin_group: ~azure.mgmt.cdn.models.ResourceReference - :ivar origin_path: A directory path on the origin that AzureFrontDoor can use to retrieve - content from, e.g. contoso.cloudapp.net/originpath. - :vartype origin_path: str - :ivar rule_sets: rule sets referenced by this endpoint. - :vartype rule_sets: list[~azure.mgmt.cdn.models.ResourceReference] - :ivar supported_protocols: List of supported protocols for this route. - :vartype supported_protocols: list[str or ~azure.mgmt.cdn.models.AFDEndpointProtocols] - :ivar patterns_to_match: The route patterns of the rule. - :vartype patterns_to_match: list[str] - :ivar cache_configuration: The caching configuration for this route. To disable caching, do not - provide a cacheConfiguration object. - :vartype cache_configuration: ~azure.mgmt.cdn.models.AfdRouteCacheConfiguration - :ivar forwarding_protocol: Protocol this rule will use when forwarding traffic to backends. - Known values are: "HttpOnly", "HttpsOnly", and "MatchRequest". - :vartype forwarding_protocol: str or ~azure.mgmt.cdn.models.ForwardingProtocol - :ivar link_to_default_domain: whether this route will be linked to the default endpoint domain. - Known values are: "Enabled" and "Disabled". - :vartype link_to_default_domain: str or ~azure.mgmt.cdn.models.LinkToDefaultDomain - :ivar https_redirect: Whether to automatically redirect HTTP traffic to HTTPS traffic. Note - that this is a easy way to set up this rule and it will be the first rule that gets executed. - Known values are: "Enabled" and "Disabled". - :vartype https_redirect: str or ~azure.mgmt.cdn.models.HttpsRedirect - :ivar enabled_state: Whether to enable use of this rule. Permitted values are 'Enabled' or - 'Disabled'. Known values are: "Enabled" and "Disabled". - :vartype enabled_state: str or ~azure.mgmt.cdn.models.EnabledState - """ - - _validation = { - "endpoint_name": {"readonly": True}, - } - - _attribute_map = { - "endpoint_name": {"key": "properties.endpointName", "type": "str"}, - "custom_domains": {"key": "properties.customDomains", "type": "[ActivatedResourceReference]"}, - "origin_group": {"key": "properties.originGroup", "type": "ResourceReference"}, - "origin_path": {"key": "properties.originPath", "type": "str"}, - "rule_sets": {"key": "properties.ruleSets", "type": "[ResourceReference]"}, - "supported_protocols": {"key": "properties.supportedProtocols", "type": "[str]"}, - "patterns_to_match": {"key": "properties.patternsToMatch", "type": "[str]"}, - "cache_configuration": {"key": "properties.cacheConfiguration", "type": "AfdRouteCacheConfiguration"}, - "forwarding_protocol": {"key": "properties.forwardingProtocol", "type": "str"}, - "link_to_default_domain": {"key": "properties.linkToDefaultDomain", "type": "str"}, - "https_redirect": {"key": "properties.httpsRedirect", "type": "str"}, - "enabled_state": {"key": "properties.enabledState", "type": "str"}, - } - - def __init__( - self, - *, - custom_domains: Optional[List["_models.ActivatedResourceReference"]] = None, - origin_group: Optional["_models.ResourceReference"] = None, - origin_path: Optional[str] = None, - rule_sets: Optional[List["_models.ResourceReference"]] = None, - supported_protocols: List[Union[str, "_models.AFDEndpointProtocols"]] = ["Http", "Https"], - patterns_to_match: Optional[List[str]] = None, - cache_configuration: Optional["_models.AfdRouteCacheConfiguration"] = None, - forwarding_protocol: Optional[Union[str, "_models.ForwardingProtocol"]] = None, - link_to_default_domain: Union[str, "_models.LinkToDefaultDomain"] = "Disabled", - https_redirect: Union[str, "_models.HttpsRedirect"] = "Disabled", - enabled_state: Optional[Union[str, "_models.EnabledState"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword custom_domains: Domains referenced by this endpoint. - :paramtype custom_domains: list[~azure.mgmt.cdn.models.ActivatedResourceReference] - :keyword origin_group: A reference to the origin group. - :paramtype origin_group: ~azure.mgmt.cdn.models.ResourceReference - :keyword origin_path: A directory path on the origin that AzureFrontDoor can use to retrieve - content from, e.g. contoso.cloudapp.net/originpath. - :paramtype origin_path: str - :keyword rule_sets: rule sets referenced by this endpoint. - :paramtype rule_sets: list[~azure.mgmt.cdn.models.ResourceReference] - :keyword supported_protocols: List of supported protocols for this route. - :paramtype supported_protocols: list[str or ~azure.mgmt.cdn.models.AFDEndpointProtocols] - :keyword patterns_to_match: The route patterns of the rule. - :paramtype patterns_to_match: list[str] - :keyword cache_configuration: The caching configuration for this route. To disable caching, do - not provide a cacheConfiguration object. - :paramtype cache_configuration: ~azure.mgmt.cdn.models.AfdRouteCacheConfiguration - :keyword forwarding_protocol: Protocol this rule will use when forwarding traffic to backends. - Known values are: "HttpOnly", "HttpsOnly", and "MatchRequest". - :paramtype forwarding_protocol: str or ~azure.mgmt.cdn.models.ForwardingProtocol - :keyword link_to_default_domain: whether this route will be linked to the default endpoint - domain. Known values are: "Enabled" and "Disabled". - :paramtype link_to_default_domain: str or ~azure.mgmt.cdn.models.LinkToDefaultDomain - :keyword https_redirect: Whether to automatically redirect HTTP traffic to HTTPS traffic. Note - that this is a easy way to set up this rule and it will be the first rule that gets executed. - Known values are: "Enabled" and "Disabled". - :paramtype https_redirect: str or ~azure.mgmt.cdn.models.HttpsRedirect - :keyword enabled_state: Whether to enable use of this rule. Permitted values are 'Enabled' or - 'Disabled'. Known values are: "Enabled" and "Disabled". - :paramtype enabled_state: str or ~azure.mgmt.cdn.models.EnabledState - """ - super().__init__(**kwargs) - self.endpoint_name = None - self.custom_domains = custom_domains - self.origin_group = origin_group - self.origin_path = origin_path - self.rule_sets = rule_sets - self.supported_protocols = supported_protocols - self.patterns_to_match = patterns_to_match - self.cache_configuration = cache_configuration - self.forwarding_protocol = forwarding_protocol - self.link_to_default_domain = link_to_default_domain - self.https_redirect = https_redirect - self.enabled_state = enabled_state - - -class Rule(ProxyResource): # pylint: disable=too-many-instance-attributes - """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. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar system_data: Read only system data. - :vartype system_data: ~azure.mgmt.cdn.models.SystemData - :ivar rule_set_name: The name of the rule set containing the rule. - :vartype rule_set_name: str - :ivar order: The order in which the rules are applied for the endpoint. Possible values - {0,1,2,3,………}. A rule with a lesser order will be applied before a rule with a greater order. - Rule with order 0 is a special rule. It does not require any condition and actions listed in it - will always be applied. - :vartype order: int - :ivar conditions: A list of conditions that must be matched for the actions to be executed. - :vartype conditions: list[~azure.mgmt.cdn.models.DeliveryRuleCondition] - :ivar actions: A list of actions that are executed when all the conditions of a rule are - satisfied. - :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". - :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". - :vartype provisioning_state: str or ~azure.mgmt.cdn.models.AfdProvisioningState - :ivar deployment_status: Known values are: "NotStarted", "InProgress", "Succeeded", and - "Failed". - :vartype deployment_status: str or ~azure.mgmt.cdn.models.DeploymentStatus - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - "rule_set_name": {"readonly": True}, - "provisioning_state": {"readonly": True}, - "deployment_status": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "rule_set_name": {"key": "properties.ruleSetName", "type": "str"}, - "order": {"key": "properties.order", "type": "int"}, - "conditions": {"key": "properties.conditions", "type": "[DeliveryRuleCondition]"}, - "actions": {"key": "properties.actions", "type": "[DeliveryRuleAction]"}, - "match_processing_behavior": {"key": "properties.matchProcessingBehavior", "type": "str"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "deployment_status": {"key": "properties.deploymentStatus", "type": "str"}, - } - - def __init__( - self, - *, - order: Optional[int] = None, - conditions: Optional[List["_models.DeliveryRuleCondition"]] = None, - actions: Optional[List["_models.DeliveryRuleAction"]] = None, - match_processing_behavior: Union[str, "_models.MatchProcessingBehavior"] = "Continue", - **kwargs: Any - ) -> None: - """ - :keyword order: The order in which the rules are applied for the endpoint. Possible values - {0,1,2,3,………}. A rule with a lesser order will be applied before a rule with a greater order. - Rule with order 0 is a special rule. It does not require any condition and actions listed in it - will always be applied. - :paramtype order: int - :keyword conditions: A list of conditions that must be matched for the actions to be executed. - :paramtype conditions: list[~azure.mgmt.cdn.models.DeliveryRuleCondition] - :keyword actions: A list of actions that are executed when all the conditions of a rule are - satisfied. - :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". - :paramtype match_processing_behavior: str or ~azure.mgmt.cdn.models.MatchProcessingBehavior - """ - super().__init__(**kwargs) - self.rule_set_name = 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 - - -class RuleListResult(_serialization.Model): - """Result of the request to list rules. It contains a list of rule objects and a URL link to get - the next set of results. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: List of AzureFrontDoor rules within a rule set. - :vartype value: list[~azure.mgmt.cdn.models.Rule] - :ivar next_link: URL to get the next set of rule objects if there are any. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[Rule]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword next_link: URL to get the next set of rule objects if there are any. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = None - self.next_link = next_link - - -class RuleUpdatePropertiesParameters(_serialization.Model): - """The JSON object that contains the properties of the rule to update. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar rule_set_name: The name of the rule set containing the rule. - :vartype rule_set_name: str - :ivar order: The order in which the rules are applied for the endpoint. Possible values - {0,1,2,3,………}. A rule with a lesser order will be applied before a rule with a greater order. - Rule with order 0 is a special rule. It does not require any condition and actions listed in it - will always be applied. - :vartype order: int - :ivar conditions: A list of conditions that must be matched for the actions to be executed. - :vartype conditions: list[~azure.mgmt.cdn.models.DeliveryRuleCondition] - :ivar actions: A list of actions that are executed when all the conditions of a rule are - satisfied. - :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". - :vartype match_processing_behavior: str or ~azure.mgmt.cdn.models.MatchProcessingBehavior - """ - - _validation = { - "rule_set_name": {"readonly": True}, - } - - _attribute_map = { - "rule_set_name": {"key": "ruleSetName", "type": "str"}, - "order": {"key": "order", "type": "int"}, - "conditions": {"key": "conditions", "type": "[DeliveryRuleCondition]"}, - "actions": {"key": "actions", "type": "[DeliveryRuleAction]"}, - "match_processing_behavior": {"key": "matchProcessingBehavior", "type": "str"}, - } - - def __init__( - self, - *, - order: Optional[int] = None, - conditions: Optional[List["_models.DeliveryRuleCondition"]] = None, - actions: Optional[List["_models.DeliveryRuleAction"]] = None, - match_processing_behavior: Union[str, "_models.MatchProcessingBehavior"] = "Continue", - **kwargs: Any - ) -> None: - """ - :keyword order: The order in which the rules are applied for the endpoint. Possible values - {0,1,2,3,………}. A rule with a lesser order will be applied before a rule with a greater order. - Rule with order 0 is a special rule. It does not require any condition and actions listed in it - will always be applied. - :paramtype order: int - :keyword conditions: A list of conditions that must be matched for the actions to be executed. - :paramtype conditions: list[~azure.mgmt.cdn.models.DeliveryRuleCondition] - :keyword actions: A list of actions that are executed when all the conditions of a rule are - satisfied. - :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". - :paramtype match_processing_behavior: str or ~azure.mgmt.cdn.models.MatchProcessingBehavior - """ - super().__init__(**kwargs) - self.rule_set_name = None - self.order = order - self.conditions = conditions - self.actions = actions - self.match_processing_behavior = match_processing_behavior - - -class RuleProperties(RuleUpdatePropertiesParameters, AFDStateProperties): - """The JSON object that contains the properties of the Rules to create. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar provisioning_state: Provisioning status. Known values are: "Succeeded", "Failed", - "Updating", "Deleting", and "Creating". - :vartype provisioning_state: str or ~azure.mgmt.cdn.models.AfdProvisioningState - :ivar deployment_status: Known values are: "NotStarted", "InProgress", "Succeeded", and - "Failed". - :vartype deployment_status: str or ~azure.mgmt.cdn.models.DeploymentStatus - :ivar rule_set_name: The name of the rule set containing the rule. - :vartype rule_set_name: str - :ivar order: The order in which the rules are applied for the endpoint. Possible values - {0,1,2,3,………}. A rule with a lesser order will be applied before a rule with a greater order. - Rule with order 0 is a special rule. It does not require any condition and actions listed in it - will always be applied. - :vartype order: int - :ivar conditions: A list of conditions that must be matched for the actions to be executed. - :vartype conditions: list[~azure.mgmt.cdn.models.DeliveryRuleCondition] - :ivar actions: A list of actions that are executed when all the conditions of a rule are - satisfied. - :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". - :vartype match_processing_behavior: str or ~azure.mgmt.cdn.models.MatchProcessingBehavior - """ - - _validation = { - "provisioning_state": {"readonly": True}, - "deployment_status": {"readonly": True}, - "rule_set_name": {"readonly": True}, - } - - _attribute_map = { - "provisioning_state": {"key": "provisioningState", "type": "str"}, - "deployment_status": {"key": "deploymentStatus", "type": "str"}, - "rule_set_name": {"key": "ruleSetName", "type": "str"}, - "order": {"key": "order", "type": "int"}, - "conditions": {"key": "conditions", "type": "[DeliveryRuleCondition]"}, - "actions": {"key": "actions", "type": "[DeliveryRuleAction]"}, - "match_processing_behavior": {"key": "matchProcessingBehavior", "type": "str"}, - } - - def __init__( - self, - *, - order: Optional[int] = None, - conditions: Optional[List["_models.DeliveryRuleCondition"]] = None, - actions: Optional[List["_models.DeliveryRuleAction"]] = None, - match_processing_behavior: Union[str, "_models.MatchProcessingBehavior"] = "Continue", - **kwargs: Any - ) -> None: - """ - :keyword order: The order in which the rules are applied for the endpoint. Possible values - {0,1,2,3,………}. A rule with a lesser order will be applied before a rule with a greater order. - Rule with order 0 is a special rule. It does not require any condition and actions listed in it - will always be applied. - :paramtype order: int - :keyword conditions: A list of conditions that must be matched for the actions to be executed. - :paramtype conditions: list[~azure.mgmt.cdn.models.DeliveryRuleCondition] - :keyword actions: A list of actions that are executed when all the conditions of a rule are - satisfied. - :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". - :paramtype match_processing_behavior: str or ~azure.mgmt.cdn.models.MatchProcessingBehavior - """ - super().__init__( - order=order, - conditions=conditions, - actions=actions, - match_processing_behavior=match_processing_behavior, - **kwargs - ) - self.provisioning_state = None - self.deployment_status = None - self.rule_set_name = None - self.order = order - self.conditions = conditions - self.actions = actions - self.match_processing_behavior = match_processing_behavior - - -class RuleSet(ProxyResource): - """Friendly RuleSet name mapping to the any RuleSet or secret related information. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar system_data: Read only system data. - :vartype system_data: ~azure.mgmt.cdn.models.SystemData - :ivar provisioning_state: Provisioning status. Known values are: "Succeeded", "Failed", - "Updating", "Deleting", and "Creating". - :vartype provisioning_state: str or ~azure.mgmt.cdn.models.AfdProvisioningState - :ivar deployment_status: Known values are: "NotStarted", "InProgress", "Succeeded", and - "Failed". - :vartype deployment_status: str or ~azure.mgmt.cdn.models.DeploymentStatus - :ivar profile_name: The name of the profile which holds the rule set. - :vartype profile_name: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - "provisioning_state": {"readonly": True}, - "deployment_status": {"readonly": True}, - "profile_name": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "deployment_status": {"key": "properties.deploymentStatus", "type": "str"}, - "profile_name": {"key": "properties.profileName", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.provisioning_state = None - self.deployment_status = None - self.profile_name = None - - -class RuleSetListResult(_serialization.Model): - """Result of the request to list rule sets. It contains a list of rule set objects and a URL link - to get the next set of results. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: List of AzureFrontDoor rule sets within a profile. - :vartype value: list[~azure.mgmt.cdn.models.RuleSet] - :ivar next_link: URL to get the next set of rule set objects if there are any. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[RuleSet]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword next_link: URL to get the next set of rule set objects if there are any. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = None - self.next_link = next_link - - -class RuleSetProperties(AFDStateProperties): - """The JSON object that contains the properties of the Rule Set to create. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar provisioning_state: Provisioning status. Known values are: "Succeeded", "Failed", - "Updating", "Deleting", and "Creating". - :vartype provisioning_state: str or ~azure.mgmt.cdn.models.AfdProvisioningState - :ivar deployment_status: Known values are: "NotStarted", "InProgress", "Succeeded", and - "Failed". - :vartype deployment_status: str or ~azure.mgmt.cdn.models.DeploymentStatus - :ivar profile_name: The name of the profile which holds the rule set. - :vartype profile_name: str - """ - - _validation = { - "provisioning_state": {"readonly": True}, - "deployment_status": {"readonly": True}, - "profile_name": {"readonly": True}, - } - - _attribute_map = { - "provisioning_state": {"key": "provisioningState", "type": "str"}, - "deployment_status": {"key": "deploymentStatus", "type": "str"}, - "profile_name": {"key": "profileName", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.profile_name = None - - -class RuleUpdateParameters(_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. - - :ivar rule_set_name: The name of the rule set containing the rule. - :vartype rule_set_name: str - :ivar order: The order in which the rules are applied for the endpoint. Possible values - {0,1,2,3,………}. A rule with a lesser order will be applied before a rule with a greater order. - Rule with order 0 is a special rule. It does not require any condition and actions listed in it - will always be applied. - :vartype order: int - :ivar conditions: A list of conditions that must be matched for the actions to be executed. - :vartype conditions: list[~azure.mgmt.cdn.models.DeliveryRuleCondition] - :ivar actions: A list of actions that are executed when all the conditions of a rule are - satisfied. - :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". - :vartype match_processing_behavior: str or ~azure.mgmt.cdn.models.MatchProcessingBehavior - """ - - _validation = { - "rule_set_name": {"readonly": True}, - } - - _attribute_map = { - "rule_set_name": {"key": "properties.ruleSetName", "type": "str"}, - "order": {"key": "properties.order", "type": "int"}, - "conditions": {"key": "properties.conditions", "type": "[DeliveryRuleCondition]"}, - "actions": {"key": "properties.actions", "type": "[DeliveryRuleAction]"}, - "match_processing_behavior": {"key": "properties.matchProcessingBehavior", "type": "str"}, - } - - def __init__( - self, - *, - order: Optional[int] = None, - conditions: Optional[List["_models.DeliveryRuleCondition"]] = None, - actions: Optional[List["_models.DeliveryRuleAction"]] = None, - match_processing_behavior: Union[str, "_models.MatchProcessingBehavior"] = "Continue", - **kwargs: Any - ) -> None: - """ - :keyword order: The order in which the rules are applied for the endpoint. Possible values - {0,1,2,3,………}. A rule with a lesser order will be applied before a rule with a greater order. - Rule with order 0 is a special rule. It does not require any condition and actions listed in it - will always be applied. - :paramtype order: int - :keyword conditions: A list of conditions that must be matched for the actions to be executed. - :paramtype conditions: list[~azure.mgmt.cdn.models.DeliveryRuleCondition] - :keyword actions: A list of actions that are executed when all the conditions of a rule are - satisfied. - :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". - :paramtype match_processing_behavior: str or ~azure.mgmt.cdn.models.MatchProcessingBehavior - """ - super().__init__(**kwargs) - self.rule_set_name = None - self.order = order - self.conditions = conditions - self.actions = actions - self.match_processing_behavior = match_processing_behavior - - -class Secret(ProxyResource): - """Friendly Secret name mapping to the any Secret or secret related information. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar system_data: Read only system data. - :vartype system_data: ~azure.mgmt.cdn.models.SystemData - :ivar provisioning_state: Provisioning status. Known values are: "Succeeded", "Failed", - "Updating", "Deleting", and "Creating". - :vartype provisioning_state: str or ~azure.mgmt.cdn.models.AfdProvisioningState - :ivar deployment_status: Known values are: "NotStarted", "InProgress", "Succeeded", and - "Failed". - :vartype deployment_status: str or ~azure.mgmt.cdn.models.DeploymentStatus - :ivar profile_name: The name of the profile which holds the secret. - :vartype profile_name: str - :ivar parameters: object which contains secret parameters. - :vartype parameters: ~azure.mgmt.cdn.models.SecretParameters - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - "provisioning_state": {"readonly": True}, - "deployment_status": {"readonly": True}, - "profile_name": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "deployment_status": {"key": "properties.deploymentStatus", "type": "str"}, - "profile_name": {"key": "properties.profileName", "type": "str"}, - "parameters": {"key": "properties.parameters", "type": "SecretParameters"}, - } - - def __init__(self, *, parameters: Optional["_models.SecretParameters"] = None, **kwargs: Any) -> None: - """ - :keyword parameters: object which contains secret parameters. - :paramtype parameters: ~azure.mgmt.cdn.models.SecretParameters - """ - super().__init__(**kwargs) - self.provisioning_state = None - self.deployment_status = None - self.profile_name = None - self.parameters = parameters - - -class SecretListResult(_serialization.Model): - """Result of the request to list secrets. It contains a list of Secret objects and a URL link to - get the next set of results. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: List of AzureFrontDoor secrets within a profile. - :vartype value: list[~azure.mgmt.cdn.models.Secret] - :ivar next_link: URL to get the next set of Secret objects if there are any. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[Secret]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword next_link: URL to get the next set of Secret objects if there are any. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = None - self.next_link = next_link - - -class SecretProperties(AFDStateProperties): - """The JSON object that contains the properties of the Secret to create. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar provisioning_state: Provisioning status. Known values are: "Succeeded", "Failed", - "Updating", "Deleting", and "Creating". - :vartype provisioning_state: str or ~azure.mgmt.cdn.models.AfdProvisioningState - :ivar deployment_status: Known values are: "NotStarted", "InProgress", "Succeeded", and - "Failed". - :vartype deployment_status: str or ~azure.mgmt.cdn.models.DeploymentStatus - :ivar profile_name: The name of the profile which holds the secret. - :vartype profile_name: str - :ivar parameters: object which contains secret parameters. - :vartype parameters: ~azure.mgmt.cdn.models.SecretParameters - """ - - _validation = { - "provisioning_state": {"readonly": True}, - "deployment_status": {"readonly": True}, - "profile_name": {"readonly": True}, - } - - _attribute_map = { - "provisioning_state": {"key": "provisioningState", "type": "str"}, - "deployment_status": {"key": "deploymentStatus", "type": "str"}, - "profile_name": {"key": "profileName", "type": "str"}, - "parameters": {"key": "parameters", "type": "SecretParameters"}, - } - - def __init__(self, *, parameters: Optional["_models.SecretParameters"] = None, **kwargs: Any) -> None: - """ - :keyword parameters: object which contains secret parameters. - :paramtype parameters: ~azure.mgmt.cdn.models.SecretParameters - """ - super().__init__(**kwargs) - self.profile_name = None - self.parameters = parameters - - -class SecurityPolicy(ProxyResource): - """SecurityPolicy association for AzureFrontDoor profile. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar system_data: Read only system data. - :vartype system_data: ~azure.mgmt.cdn.models.SystemData - :ivar provisioning_state: Provisioning status. Known values are: "Succeeded", "Failed", - "Updating", "Deleting", and "Creating". - :vartype provisioning_state: str or ~azure.mgmt.cdn.models.AfdProvisioningState - :ivar deployment_status: Known values are: "NotStarted", "InProgress", "Succeeded", and - "Failed". - :vartype deployment_status: str or ~azure.mgmt.cdn.models.DeploymentStatus - :ivar profile_name: The name of the profile which holds the security policy. - :vartype profile_name: str - :ivar parameters: object which contains security policy parameters. - :vartype parameters: ~azure.mgmt.cdn.models.SecurityPolicyPropertiesParameters - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - "provisioning_state": {"readonly": True}, - "deployment_status": {"readonly": True}, - "profile_name": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "deployment_status": {"key": "properties.deploymentStatus", "type": "str"}, - "profile_name": {"key": "properties.profileName", "type": "str"}, - "parameters": {"key": "properties.parameters", "type": "SecurityPolicyPropertiesParameters"}, - } - - def __init__( - self, *, parameters: Optional["_models.SecurityPolicyPropertiesParameters"] = None, **kwargs: Any - ) -> None: - """ - :keyword parameters: object which contains security policy parameters. - :paramtype parameters: ~azure.mgmt.cdn.models.SecurityPolicyPropertiesParameters - """ - super().__init__(**kwargs) - self.provisioning_state = None - self.deployment_status = None - self.profile_name = None - self.parameters = parameters - - -class SecurityPolicyListResult(_serialization.Model): - """Result of the request to list security policies. It contains a list of security policy objects - and a URL link to get the next set of results. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: List of Security policies within a profile. - :vartype value: list[~azure.mgmt.cdn.models.SecurityPolicy] - :ivar next_link: URL to get the next set of security policy objects if there is any. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[SecurityPolicy]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword next_link: URL to get the next set of security policy objects if there is any. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = None - self.next_link = next_link - - -class SecurityPolicyProperties(AFDStateProperties): - """The json object that contains properties required to create a security policy. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar provisioning_state: Provisioning status. Known values are: "Succeeded", "Failed", - "Updating", "Deleting", and "Creating". - :vartype provisioning_state: str or ~azure.mgmt.cdn.models.AfdProvisioningState - :ivar deployment_status: Known values are: "NotStarted", "InProgress", "Succeeded", and - "Failed". - :vartype deployment_status: str or ~azure.mgmt.cdn.models.DeploymentStatus - :ivar profile_name: The name of the profile which holds the security policy. - :vartype profile_name: str - :ivar parameters: object which contains security policy parameters. - :vartype parameters: ~azure.mgmt.cdn.models.SecurityPolicyPropertiesParameters - """ - - _validation = { - "provisioning_state": {"readonly": True}, - "deployment_status": {"readonly": True}, - "profile_name": {"readonly": True}, - } - - _attribute_map = { - "provisioning_state": {"key": "provisioningState", "type": "str"}, - "deployment_status": {"key": "deploymentStatus", "type": "str"}, - "profile_name": {"key": "profileName", "type": "str"}, - "parameters": {"key": "parameters", "type": "SecurityPolicyPropertiesParameters"}, - } - - def __init__( - self, *, parameters: Optional["_models.SecurityPolicyPropertiesParameters"] = None, **kwargs: Any - ) -> None: - """ - :keyword parameters: object which contains security policy parameters. - :paramtype parameters: ~azure.mgmt.cdn.models.SecurityPolicyPropertiesParameters - """ - super().__init__(**kwargs) - self.profile_name = None - self.parameters = parameters - - -class SecurityPolicyPropertiesParameters(_serialization.Model): - """The json object containing security policy parameters. - - You probably want to use the sub-classes and not this class directly. Known sub-classes are: - SecurityPolicyWebApplicationFirewallParameters - - All required parameters must be populated in order to send to server. - - :ivar type: The type of the Security policy to create. Required. "WebApplicationFirewall" - :vartype type: str or ~azure.mgmt.cdn.models.SecurityPolicyType - """ - - _validation = { - "type": {"required": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - } - - _subtype_map = {"type": {"WebApplicationFirewall": "SecurityPolicyWebApplicationFirewallParameters"}} - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.type: Optional[str] = None - - -class SecurityPolicyUpdateParameters(_serialization.Model): - """The JSON object containing security policy update parameters. - - :ivar parameters: object which contains security policy parameters. - :vartype parameters: ~azure.mgmt.cdn.models.SecurityPolicyPropertiesParameters - """ - - _attribute_map = { - "parameters": {"key": "properties.parameters", "type": "SecurityPolicyPropertiesParameters"}, - } - - def __init__( - self, *, parameters: Optional["_models.SecurityPolicyPropertiesParameters"] = None, **kwargs: Any - ) -> None: - """ - :keyword parameters: object which contains security policy parameters. - :paramtype parameters: ~azure.mgmt.cdn.models.SecurityPolicyPropertiesParameters - """ - super().__init__(**kwargs) - self.parameters = parameters - - -class SecurityPolicyWebApplicationFirewallAssociation(_serialization.Model): # pylint: disable=name-too-long - """settings for security policy patterns to match. - - :ivar domains: List of domains. - :vartype domains: list[~azure.mgmt.cdn.models.ActivatedResourceReference] - :ivar patterns_to_match: List of paths. - :vartype patterns_to_match: list[str] - """ - - _attribute_map = { - "domains": {"key": "domains", "type": "[ActivatedResourceReference]"}, - "patterns_to_match": {"key": "patternsToMatch", "type": "[str]"}, - } - - def __init__( - self, - *, - domains: Optional[List["_models.ActivatedResourceReference"]] = None, - patterns_to_match: Optional[List[str]] = None, - **kwargs: Any - ) -> None: - """ - :keyword domains: List of domains. - :paramtype domains: list[~azure.mgmt.cdn.models.ActivatedResourceReference] - :keyword patterns_to_match: List of paths. - :paramtype patterns_to_match: list[str] - """ - super().__init__(**kwargs) - self.domains = domains - self.patterns_to_match = patterns_to_match - - -class SecurityPolicyWebApplicationFirewallParameters( - SecurityPolicyPropertiesParameters -): # pylint: disable=name-too-long - """The json object containing security policy waf parameters. - - All required parameters must be populated in order to send to server. - - :ivar type: The type of the Security policy to create. Required. "WebApplicationFirewall" - :vartype type: str or ~azure.mgmt.cdn.models.SecurityPolicyType - :ivar waf_policy: Resource ID. - :vartype waf_policy: ~azure.mgmt.cdn.models.ResourceReference - :ivar associations: Waf associations. - :vartype associations: - list[~azure.mgmt.cdn.models.SecurityPolicyWebApplicationFirewallAssociation] - """ - - _validation = { - "type": {"required": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "waf_policy": {"key": "wafPolicy", "type": "ResourceReference"}, - "associations": {"key": "associations", "type": "[SecurityPolicyWebApplicationFirewallAssociation]"}, - } - - def __init__( - self, - *, - waf_policy: Optional["_models.ResourceReference"] = None, - associations: Optional[List["_models.SecurityPolicyWebApplicationFirewallAssociation"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword waf_policy: Resource ID. - :paramtype waf_policy: ~azure.mgmt.cdn.models.ResourceReference - :keyword associations: Waf associations. - :paramtype associations: - list[~azure.mgmt.cdn.models.SecurityPolicyWebApplicationFirewallAssociation] - """ - super().__init__(**kwargs) - self.type: str = "WebApplicationFirewall" - self.waf_policy = waf_policy - self.associations = associations - - -class ServerPortMatchConditionParameters(_serialization.Model): - """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 operator: Describes operator to be matched. Required. Known values are: "Any", "Equal", - "Contains", "BeginsWith", "EndsWith", "LessThan", "LessThanOrEqual", "GreaterThan", - "GreaterThanOrEqual", and "RegEx". - :vartype operator: str or ~azure.mgmt.cdn.models.ServerPortOperator - :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] - :ivar transforms: List of transforms. - :vartype transforms: list[str or ~azure.mgmt.cdn.models.Transform] - """ - - _validation = { - "type_name": {"required": True}, - "operator": {"required": True}, - } - - _attribute_map = { - "type_name": {"key": "typeName", "type": "str"}, - "operator": {"key": "operator", "type": "str"}, - "negate_condition": {"key": "negateCondition", "type": "bool"}, - "match_values": {"key": "matchValues", "type": "[str]"}, - "transforms": {"key": "transforms", "type": "[str]"}, - } - - def __init__( - self, - *, - type_name: Union[str, "_models.ServerPortMatchConditionParametersTypeName"], - operator: Union[str, "_models.ServerPortOperator"], - negate_condition: bool = False, - match_values: Optional[List[str]] = None, - transforms: Optional[List[Union[str, "_models.Transform"]]] = None, - **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". - :paramtype operator: str or ~azure.mgmt.cdn.models.ServerPortOperator - :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] - :keyword transforms: List of transforms. - :paramtype transforms: list[str or ~azure.mgmt.cdn.models.Transform] - """ - super().__init__(**kwargs) - self.type_name = type_name - self.operator = operator - self.negate_condition = negate_condition - self.match_values = match_values - self.transforms = transforms - - -class ServiceSpecification(_serialization.Model): - """One property of operation, include log specifications. - - :ivar log_specifications: Log specifications of operation. - :vartype log_specifications: list[~azure.mgmt.cdn.models.LogSpecification] - :ivar metric_specifications: Metric specifications of operation. - :vartype metric_specifications: list[~azure.mgmt.cdn.models.MetricSpecification] - """ - - _attribute_map = { - "log_specifications": {"key": "logSpecifications", "type": "[LogSpecification]"}, - "metric_specifications": {"key": "metricSpecifications", "type": "[MetricSpecification]"}, - } - - def __init__( - self, - *, - log_specifications: Optional[List["_models.LogSpecification"]] = None, - metric_specifications: Optional[List["_models.MetricSpecification"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword log_specifications: Log specifications of operation. - :paramtype log_specifications: list[~azure.mgmt.cdn.models.LogSpecification] - :keyword metric_specifications: Metric specifications of operation. - :paramtype metric_specifications: list[~azure.mgmt.cdn.models.MetricSpecification] - """ - super().__init__(**kwargs) - self.log_specifications = log_specifications - self.metric_specifications = metric_specifications - - -class SharedPrivateLinkResourceProperties(_serialization.Model): - """Describes the properties of an existing Shared Private Link Resource to use when connecting to - a private origin. - - :ivar private_link: The resource id of the resource the shared private link resource is for. - :vartype private_link: ~azure.mgmt.cdn.models.ResourceReference - :ivar private_link_location: The location of the shared private link resource. - :vartype private_link_location: str - :ivar group_id: The group id from the provider of resource the shared private link resource is - for. - :vartype group_id: str - :ivar request_message: The request message for requesting approval of the shared private link - resource. - :vartype request_message: str - :ivar status: Status of the shared private link resource. Can be Pending, Approved, Rejected, - Disconnected, or Timeout. Known values are: "Pending", "Approved", "Rejected", "Disconnected", - and "Timeout". - :vartype status: str or ~azure.mgmt.cdn.models.SharedPrivateLinkResourceStatus - """ - - _attribute_map = { - "private_link": {"key": "privateLink", "type": "ResourceReference"}, - "private_link_location": {"key": "privateLinkLocation", "type": "str"}, - "group_id": {"key": "groupId", "type": "str"}, - "request_message": {"key": "requestMessage", "type": "str"}, - "status": {"key": "status", "type": "str"}, - } - - def __init__( - self, - *, - private_link: Optional["_models.ResourceReference"] = None, - private_link_location: Optional[str] = None, - group_id: Optional[str] = None, - request_message: Optional[str] = None, - status: Optional[Union[str, "_models.SharedPrivateLinkResourceStatus"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword private_link: The resource id of the resource the shared private link resource is for. - :paramtype private_link: ~azure.mgmt.cdn.models.ResourceReference - :keyword private_link_location: The location of the shared private link resource. - :paramtype private_link_location: str - :keyword group_id: The group id from the provider of resource the shared private link resource - is for. - :paramtype group_id: str - :keyword request_message: The request message for requesting approval of the shared private - link resource. - :paramtype request_message: str - :keyword status: Status of the shared private link resource. Can be Pending, Approved, - Rejected, Disconnected, or Timeout. Known values are: "Pending", "Approved", "Rejected", - "Disconnected", and "Timeout". - :paramtype status: str or ~azure.mgmt.cdn.models.SharedPrivateLinkResourceStatus - """ - super().__init__(**kwargs) - self.private_link = private_link - self.private_link_location = private_link_location - self.group_id = group_id - self.request_message = request_message - self.status = status - - -class Sku(_serialization.Model): - """Standard_Verizon = The SKU name for a Standard Verizon CDN profile. - Premium_Verizon = The SKU name for a Premium Verizon CDN profile. - Custom_Verizon = The SKU name for a Custom Verizon CDN profile. - Standard_Akamai = The SKU name for an Akamai CDN profile. - Standard_ChinaCdn = The SKU name for a China CDN profile for VOD, Web and download scenarios - using GB based billing model. - Standard_Microsoft = The SKU name for a Standard Microsoft CDN profile. - Standard_AzureFrontDoor = The SKU name for an Azure Front Door Standard profile. - Premium_AzureFrontDoor = The SKU name for an Azure Front Door Premium profile. - Standard_955BandWidth_ChinaCdn = The SKU name for a China CDN profile for VOD, Web and download - scenarios using 95-5 peak bandwidth billing model. - Standard_AvgBandWidth_ChinaCdn = The SKU name for a China CDN profile for VOD, Web and download - scenarios using monthly average peak bandwidth billing model. - StandardPlus_ChinaCdn = The SKU name for a China CDN profile for live-streaming using GB based - billing model. - StandardPlus_955BandWidth_ChinaCdn = The SKU name for a China CDN live-streaming profile using - 95-5 peak bandwidth billing model. - StandardPlus_AvgBandWidth_ChinaCdn = The SKU name for a China CDN live-streaming profile using - monthly average peak bandwidth billing model. - - :ivar name: Name of the pricing tier. Known values are: "Standard_Verizon", "Premium_Verizon", - "Custom_Verizon", "Standard_Akamai", "Standard_ChinaCdn", "Standard_Microsoft", - "Standard_AzureFrontDoor", "Premium_AzureFrontDoor", "Standard_955BandWidth_ChinaCdn", - "Standard_AvgBandWidth_ChinaCdn", "StandardPlus_ChinaCdn", - "StandardPlus_955BandWidth_ChinaCdn", and "StandardPlus_AvgBandWidth_ChinaCdn". - :vartype name: str or ~azure.mgmt.cdn.models.SkuName - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - } - - def __init__(self, *, name: Optional[Union[str, "_models.SkuName"]] = None, **kwargs: Any) -> None: - """ - :keyword name: Name of the pricing tier. Known values are: "Standard_Verizon", - "Premium_Verizon", "Custom_Verizon", "Standard_Akamai", "Standard_ChinaCdn", - "Standard_Microsoft", "Standard_AzureFrontDoor", "Premium_AzureFrontDoor", - "Standard_955BandWidth_ChinaCdn", "Standard_AvgBandWidth_ChinaCdn", "StandardPlus_ChinaCdn", - "StandardPlus_955BandWidth_ChinaCdn", and "StandardPlus_AvgBandWidth_ChinaCdn". - :paramtype name: str or ~azure.mgmt.cdn.models.SkuName - """ - super().__init__(**kwargs) - self.name = name - - -class SocketAddrMatchConditionParameters(_serialization.Model): - """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 operator: Describes operator to be matched. Required. Known values are: "Any" and - "IPMatch". - :vartype operator: str or ~azure.mgmt.cdn.models.SocketAddrOperator - :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] - :ivar transforms: List of transforms. - :vartype transforms: list[str or ~azure.mgmt.cdn.models.Transform] - """ - - _validation = { - "type_name": {"required": True}, - "operator": {"required": True}, - } - - _attribute_map = { - "type_name": {"key": "typeName", "type": "str"}, - "operator": {"key": "operator", "type": "str"}, - "negate_condition": {"key": "negateCondition", "type": "bool"}, - "match_values": {"key": "matchValues", "type": "[str]"}, - "transforms": {"key": "transforms", "type": "[str]"}, - } - - def __init__( - self, - *, - type_name: Union[str, "_models.SocketAddrMatchConditionParametersTypeName"], - operator: Union[str, "_models.SocketAddrOperator"], - negate_condition: bool = False, - match_values: Optional[List[str]] = None, - transforms: Optional[List[Union[str, "_models.Transform"]]] = None, - **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 - :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] - :keyword transforms: List of transforms. - :paramtype transforms: list[str or ~azure.mgmt.cdn.models.Transform] - """ - super().__init__(**kwargs) - self.type_name = type_name - self.operator = operator - self.negate_condition = negate_condition - self.match_values = match_values - self.transforms = transforms - - -class SslProtocolMatchConditionParameters(_serialization.Model): - """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 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. - :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.SslProtocol] - :ivar transforms: List of transforms. - :vartype transforms: list[str or ~azure.mgmt.cdn.models.Transform] - """ - - _validation = { - "type_name": {"required": True}, - "operator": {"required": True}, - } - - _attribute_map = { - "type_name": {"key": "typeName", "type": "str"}, - "operator": {"key": "operator", "type": "str"}, - "negate_condition": {"key": "negateCondition", "type": "bool"}, - "match_values": {"key": "matchValues", "type": "[str]"}, - "transforms": {"key": "transforms", "type": "[str]"}, - } - - 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, - transforms: Optional[List[Union[str, "_models.Transform"]]] = None, - **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. - :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.SslProtocol] - :keyword transforms: List of transforms. - :paramtype transforms: list[str or ~azure.mgmt.cdn.models.Transform] - """ - super().__init__(**kwargs) - self.type_name = type_name - self.operator = operator - self.negate_condition = negate_condition - self.match_values = match_values - self.transforms = transforms - - -class SsoUri(_serialization.Model): - """The URI required to login to the supplemental portal from the Azure portal. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar sso_uri_value: The URI used to login to the supplemental portal. - :vartype sso_uri_value: str - """ - - _validation = { - "sso_uri_value": {"readonly": True}, - } - - _attribute_map = { - "sso_uri_value": {"key": "ssoUriValue", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.sso_uri_value = None - - -class SupportedOptimizationTypesListResult(_serialization.Model): - """The result of the GetSupportedOptimizationTypes API. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar supported_optimization_types: Supported optimization types for a profile. - :vartype supported_optimization_types: list[str or ~azure.mgmt.cdn.models.OptimizationType] - """ - - _validation = { - "supported_optimization_types": {"readonly": True}, - } - - _attribute_map = { - "supported_optimization_types": {"key": "supportedOptimizationTypes", "type": "[str]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.supported_optimization_types = None - - -class SystemData(_serialization.Model): - """Read only system data. - - :ivar created_by: An identifier for the identity that created the resource. - :vartype created_by: str - :ivar created_by_type: The type of identity that created the resource. Known values are: - "user", "application", "managedIdentity", and "key". - :vartype created_by_type: str or ~azure.mgmt.cdn.models.IdentityType - :ivar created_at: The timestamp of resource creation (UTC). - :vartype created_at: ~datetime.datetime - :ivar last_modified_by: An identifier for the identity that last modified the resource. - :vartype last_modified_by: str - :ivar last_modified_by_type: The type of identity that last modified the resource. Known values - are: "user", "application", "managedIdentity", and "key". - :vartype last_modified_by_type: str or ~azure.mgmt.cdn.models.IdentityType - :ivar last_modified_at: The timestamp of resource last modification (UTC). - :vartype last_modified_at: ~datetime.datetime - """ - - _attribute_map = { - "created_by": {"key": "createdBy", "type": "str"}, - "created_by_type": {"key": "createdByType", "type": "str"}, - "created_at": {"key": "createdAt", "type": "iso-8601"}, - "last_modified_by": {"key": "lastModifiedBy", "type": "str"}, - "last_modified_by_type": {"key": "lastModifiedByType", "type": "str"}, - "last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"}, - } - - def __init__( - self, - *, - created_by: Optional[str] = None, - created_by_type: Optional[Union[str, "_models.IdentityType"]] = None, - created_at: Optional[datetime.datetime] = None, - last_modified_by: Optional[str] = None, - last_modified_by_type: Optional[Union[str, "_models.IdentityType"]] = None, - last_modified_at: Optional[datetime.datetime] = None, - **kwargs: Any - ) -> None: - """ - :keyword created_by: An identifier for the identity that created the resource. - :paramtype created_by: str - :keyword created_by_type: The type of identity that created the resource. Known values are: - "user", "application", "managedIdentity", and "key". - :paramtype created_by_type: str or ~azure.mgmt.cdn.models.IdentityType - :keyword created_at: The timestamp of resource creation (UTC). - :paramtype created_at: ~datetime.datetime - :keyword last_modified_by: An identifier for the identity that last modified the resource. - :paramtype last_modified_by: str - :keyword last_modified_by_type: The type of identity that last modified the resource. Known - values are: "user", "application", "managedIdentity", and "key". - :paramtype last_modified_by_type: str or ~azure.mgmt.cdn.models.IdentityType - :keyword last_modified_at: The timestamp of resource last modification (UTC). - :paramtype last_modified_at: ~datetime.datetime - """ - super().__init__(**kwargs) - self.created_by = created_by - self.created_by_type = created_by_type - self.created_at = created_at - self.last_modified_by = last_modified_by - self.last_modified_by_type = last_modified_by_type - self.last_modified_at = last_modified_at - - -class UrlFileExtensionMatchConditionParameters(_serialization.Model): - """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 operator: Describes operator to be matched. Required. Known values are: "Any", "Equal", - "Contains", "BeginsWith", "EndsWith", "LessThan", "LessThanOrEqual", "GreaterThan", - "GreaterThanOrEqual", and "RegEx". - :vartype operator: str or ~azure.mgmt.cdn.models.UrlFileExtensionOperator - :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] - :ivar transforms: List of transforms. - :vartype transforms: list[str or ~azure.mgmt.cdn.models.Transform] - """ - - _validation = { - "type_name": {"required": True}, - "operator": {"required": True}, - } - - _attribute_map = { - "type_name": {"key": "typeName", "type": "str"}, - "operator": {"key": "operator", "type": "str"}, - "negate_condition": {"key": "negateCondition", "type": "bool"}, - "match_values": {"key": "matchValues", "type": "[str]"}, - "transforms": {"key": "transforms", "type": "[str]"}, - } - - def __init__( - self, - *, - type_name: Union[str, "_models.UrlFileExtensionMatchConditionParametersTypeName"], - operator: Union[str, "_models.UrlFileExtensionOperator"], - negate_condition: bool = False, - match_values: Optional[List[str]] = None, - transforms: Optional[List[Union[str, "_models.Transform"]]] = None, - **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". - :paramtype operator: str or ~azure.mgmt.cdn.models.UrlFileExtensionOperator - :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] - :keyword transforms: List of transforms. - :paramtype transforms: list[str or ~azure.mgmt.cdn.models.Transform] - """ - super().__init__(**kwargs) - self.type_name = type_name - self.operator = operator - self.negate_condition = negate_condition - self.match_values = match_values - self.transforms = transforms - - -class UrlFileNameMatchConditionParameters(_serialization.Model): - """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 operator: Describes operator to be matched. Required. Known values are: "Any", "Equal", - "Contains", "BeginsWith", "EndsWith", "LessThan", "LessThanOrEqual", "GreaterThan", - "GreaterThanOrEqual", and "RegEx". - :vartype operator: str or ~azure.mgmt.cdn.models.UrlFileNameOperator - :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] - :ivar transforms: List of transforms. - :vartype transforms: list[str or ~azure.mgmt.cdn.models.Transform] - """ - - _validation = { - "type_name": {"required": True}, - "operator": {"required": True}, - } - - _attribute_map = { - "type_name": {"key": "typeName", "type": "str"}, - "operator": {"key": "operator", "type": "str"}, - "negate_condition": {"key": "negateCondition", "type": "bool"}, - "match_values": {"key": "matchValues", "type": "[str]"}, - "transforms": {"key": "transforms", "type": "[str]"}, - } - - def __init__( - self, - *, - type_name: Union[str, "_models.UrlFileNameMatchConditionParametersTypeName"], - operator: Union[str, "_models.UrlFileNameOperator"], - negate_condition: bool = False, - match_values: Optional[List[str]] = None, - transforms: Optional[List[Union[str, "_models.Transform"]]] = None, - **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". - :paramtype operator: str or ~azure.mgmt.cdn.models.UrlFileNameOperator - :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] - :keyword transforms: List of transforms. - :paramtype transforms: list[str or ~azure.mgmt.cdn.models.Transform] - """ - super().__init__(**kwargs) - self.type_name = type_name - self.operator = operator - self.negate_condition = negate_condition - self.match_values = match_values - self.transforms = transforms - - -class UrlPathMatchConditionParameters(_serialization.Model): - """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 operator: Describes operator to be matched. Required. Known values are: "Any", "Equal", - "Contains", "BeginsWith", "EndsWith", "LessThan", "LessThanOrEqual", "GreaterThan", - "GreaterThanOrEqual", "Wildcard", and "RegEx". - :vartype operator: str or ~azure.mgmt.cdn.models.UrlPathOperator - :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] - :ivar transforms: List of transforms. - :vartype transforms: list[str or ~azure.mgmt.cdn.models.Transform] - """ - - _validation = { - "type_name": {"required": True}, - "operator": {"required": True}, - } - - _attribute_map = { - "type_name": {"key": "typeName", "type": "str"}, - "operator": {"key": "operator", "type": "str"}, - "negate_condition": {"key": "negateCondition", "type": "bool"}, - "match_values": {"key": "matchValues", "type": "[str]"}, - "transforms": {"key": "transforms", "type": "[str]"}, - } - - def __init__( - self, - *, - type_name: Union[str, "_models.UrlPathMatchConditionParametersTypeName"], - operator: Union[str, "_models.UrlPathOperator"], - negate_condition: bool = False, - match_values: Optional[List[str]] = None, - transforms: Optional[List[Union[str, "_models.Transform"]]] = None, - **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". - :paramtype operator: str or ~azure.mgmt.cdn.models.UrlPathOperator - :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] - :keyword transforms: List of transforms. - :paramtype transforms: list[str or ~azure.mgmt.cdn.models.Transform] - """ - super().__init__(**kwargs) - self.type_name = type_name - self.operator = operator - self.negate_condition = negate_condition - self.match_values = match_values - self.transforms = transforms - - -class UrlRedirectAction(DeliveryRuleAction): - """Defines the url redirect action for the delivery rule. - - All required parameters must be populated in order to send to server. - - :ivar name: The name of the action for the delivery rule. Required. Known values are: - "CacheExpiration", "CacheKeyQueryString", "ModifyRequestHeader", "ModifyResponseHeader", - "UrlRedirect", "UrlRewrite", "UrlSigning", "OriginGroupOverride", and - "RouteConfigurationOverride". - :vartype name: str or ~azure.mgmt.cdn.models.DeliveryRuleActionEnum - :ivar parameters: Defines the parameters for the action. Required. - :vartype parameters: ~azure.mgmt.cdn.models.UrlRedirectActionParameters - """ - - _validation = { - "name": {"required": True}, - "parameters": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "parameters": {"key": "parameters", "type": "UrlRedirectActionParameters"}, - } - - def __init__(self, *, parameters: "_models.UrlRedirectActionParameters", **kwargs: Any) -> None: - """ - :keyword parameters: Defines the parameters for the action. Required. - :paramtype parameters: ~azure.mgmt.cdn.models.UrlRedirectActionParameters - """ - super().__init__(**kwargs) - self.name: str = "UrlRedirect" - self.parameters = parameters - - -class UrlRedirectActionParameters(_serialization.Model): - """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 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 - :ivar destination_protocol: Protocol to use for the redirect. The default value is - MatchRequest. Known values are: "MatchRequest", "Http", and "Https". - :vartype destination_protocol: str or ~azure.mgmt.cdn.models.DestinationProtocol - :ivar custom_path: The full path to redirect. Path cannot be empty and must start with /. Leave - empty to use the incoming path as destination path. - :vartype custom_path: str - :ivar custom_hostname: Host to redirect. Leave empty to use the incoming host as the - destination host. - :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 - 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 - that comes after #. Do not include the #. - :vartype custom_fragment: str - """ - - _validation = { - "type_name": {"required": True}, - "redirect_type": {"required": True}, - } - - _attribute_map = { - "type_name": {"key": "typeName", "type": "str"}, - "redirect_type": {"key": "redirectType", "type": "str"}, - "destination_protocol": {"key": "destinationProtocol", "type": "str"}, - "custom_path": {"key": "customPath", "type": "str"}, - "custom_hostname": {"key": "customHostname", "type": "str"}, - "custom_query_string": {"key": "customQueryString", "type": "str"}, - "custom_fragment": {"key": "customFragment", "type": "str"}, - } - - 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, - custom_hostname: Optional[str] = None, - custom_query_string: Optional[str] = None, - custom_fragment: Optional[str] = None, - **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 - :keyword destination_protocol: Protocol to use for the redirect. The default value is - MatchRequest. Known values are: "MatchRequest", "Http", and "Https". - :paramtype destination_protocol: str or ~azure.mgmt.cdn.models.DestinationProtocol - :keyword custom_path: The full path to redirect. Path cannot be empty and must start with /. - Leave empty to use the incoming path as destination path. - :paramtype custom_path: str - :keyword custom_hostname: Host to redirect. Leave empty to use the incoming host as the - destination host. - :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 & - 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 - that comes after #. Do not include the #. - :paramtype custom_fragment: str - """ - super().__init__(**kwargs) - self.type_name = type_name - self.redirect_type = redirect_type - self.destination_protocol = destination_protocol - self.custom_path = custom_path - self.custom_hostname = custom_hostname - self.custom_query_string = custom_query_string - self.custom_fragment = custom_fragment - - -class UrlRewriteAction(DeliveryRuleAction): - """Defines the url rewrite action for the delivery rule. - - All required parameters must be populated in order to send to server. - - :ivar name: The name of the action for the delivery rule. Required. Known values are: - "CacheExpiration", "CacheKeyQueryString", "ModifyRequestHeader", "ModifyResponseHeader", - "UrlRedirect", "UrlRewrite", "UrlSigning", "OriginGroupOverride", and - "RouteConfigurationOverride". - :vartype name: str or ~azure.mgmt.cdn.models.DeliveryRuleActionEnum - :ivar parameters: Defines the parameters for the action. Required. - :vartype parameters: ~azure.mgmt.cdn.models.UrlRewriteActionParameters - """ - - _validation = { - "name": {"required": True}, - "parameters": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "parameters": {"key": "parameters", "type": "UrlRewriteActionParameters"}, - } - - def __init__(self, *, parameters: "_models.UrlRewriteActionParameters", **kwargs: Any) -> None: - """ - :keyword parameters: Defines the parameters for the action. Required. - :paramtype parameters: ~azure.mgmt.cdn.models.UrlRewriteActionParameters - """ - super().__init__(**kwargs) - self.name: str = "UrlRewrite" - self.parameters = parameters - - -class UrlRewriteActionParameters(_serialization.Model): - """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 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 - :ivar destination: Define the relative URL to which the above requests will be rewritten by. - Required. - :vartype destination: str - :ivar preserve_unmatched_path: Whether to preserve unmatched path. Default value is true. - :vartype preserve_unmatched_path: bool - """ - - _validation = { - "type_name": {"required": True}, - "source_pattern": {"required": True}, - "destination": {"required": True}, - } - - _attribute_map = { - "type_name": {"key": "typeName", "type": "str"}, - "source_pattern": {"key": "sourcePattern", "type": "str"}, - "destination": {"key": "destination", "type": "str"}, - "preserve_unmatched_path": {"key": "preserveUnmatchedPath", "type": "bool"}, - } - - def __init__( - self, - *, - type_name: Union[str, "_models.UrlRewriteActionParametersTypeName"], - 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 - :keyword destination: Define the relative URL to which the above requests will be rewritten by. - Required. - :paramtype destination: str - :keyword preserve_unmatched_path: Whether to preserve unmatched path. Default value is true. - :paramtype preserve_unmatched_path: bool - """ - super().__init__(**kwargs) - self.type_name = type_name - self.source_pattern = source_pattern - self.destination = destination - self.preserve_unmatched_path = preserve_unmatched_path - - -class UrlSigningAction(DeliveryRuleAction): - """Defines the url signing action for the delivery rule. - - All required parameters must be populated in order to send to server. - - :ivar name: The name of the action for the delivery rule. Required. Known values are: - "CacheExpiration", "CacheKeyQueryString", "ModifyRequestHeader", "ModifyResponseHeader", - "UrlRedirect", "UrlRewrite", "UrlSigning", "OriginGroupOverride", and - "RouteConfigurationOverride". - :vartype name: str or ~azure.mgmt.cdn.models.DeliveryRuleActionEnum - :ivar parameters: Defines the parameters for the action. Required. - :vartype parameters: ~azure.mgmt.cdn.models.UrlSigningActionParameters - """ - - _validation = { - "name": {"required": True}, - "parameters": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "parameters": {"key": "parameters", "type": "UrlSigningActionParameters"}, - } - - def __init__(self, *, parameters: "_models.UrlSigningActionParameters", **kwargs: Any) -> None: - """ - :keyword parameters: Defines the parameters for the action. Required. - :paramtype parameters: ~azure.mgmt.cdn.models.UrlSigningActionParameters - """ - super().__init__(**kwargs) - self.name: str = "UrlSigning" - self.parameters = parameters - - -class UrlSigningActionParameters(_serialization.Model): - """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 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 - considered for expires, key id etc. - :vartype parameter_name_override: list[~azure.mgmt.cdn.models.UrlSigningParamIdentifier] - """ - - _validation = { - "type_name": {"required": True}, - } - - _attribute_map = { - "type_name": {"key": "typeName", "type": "str"}, - "algorithm": {"key": "algorithm", "type": "str"}, - "parameter_name_override": {"key": "parameterNameOverride", "type": "[UrlSigningParamIdentifier]"}, - } - - 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 - considered for expires, key id etc. - :paramtype parameter_name_override: list[~azure.mgmt.cdn.models.UrlSigningParamIdentifier] - """ - super().__init__(**kwargs) - self.type_name = type_name - self.algorithm = algorithm - self.parameter_name_override = parameter_name_override - - -class UrlSigningKey(_serialization.Model): - """Url signing key. - - All required parameters must be populated in order to send to server. - - :ivar key_id: Defines the customer defined key Id. This id will exist in the incoming request - to indicate the key used to form the hash. Required. - :vartype key_id: str - :ivar key_source_parameters: Defines the parameters for using customer key vault for Url - Signing Key. Required. - :vartype key_source_parameters: ~azure.mgmt.cdn.models.KeyVaultSigningKeyParameters - """ - - _validation = { - "key_id": {"required": True}, - "key_source_parameters": {"required": True}, - } - - _attribute_map = { - "key_id": {"key": "keyId", "type": "str"}, - "key_source_parameters": {"key": "keySourceParameters", "type": "KeyVaultSigningKeyParameters"}, - } - - def __init__( - self, *, key_id: str, key_source_parameters: "_models.KeyVaultSigningKeyParameters", **kwargs: Any - ) -> None: - """ - :keyword key_id: Defines the customer defined key Id. This id will exist in the incoming - request to indicate the key used to form the hash. Required. - :paramtype key_id: str - :keyword key_source_parameters: Defines the parameters for using customer key vault for Url - Signing Key. Required. - :paramtype key_source_parameters: ~azure.mgmt.cdn.models.KeyVaultSigningKeyParameters - """ - super().__init__(**kwargs) - self.key_id = key_id - self.key_source_parameters = key_source_parameters - - -class UrlSigningKeyParameters(SecretParameters): - """Url signing key parameters. - - All required parameters must be populated in order to send to server. - - :ivar type: The type of the secret resource. Required. Known values are: "UrlSigningKey", - "CustomerCertificate", "ManagedCertificate", and "AzureFirstPartyManagedCertificate". - :vartype type: str or ~azure.mgmt.cdn.models.SecretType - :ivar key_id: Defines the customer defined key Id. This id will exist in the incoming request - to indicate the key used to form the hash. Required. - :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 - Required. - :vartype secret_source: ~azure.mgmt.cdn.models.ResourceReference - :ivar secret_version: Version of the secret to be used. - :vartype secret_version: str - """ - - _validation = { - "type": {"required": True}, - "key_id": {"required": True}, - "secret_source": {"required": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "key_id": {"key": "keyId", "type": "str"}, - "secret_source": {"key": "secretSource", "type": "ResourceReference"}, - "secret_version": {"key": "secretVersion", "type": "str"}, - } - - def __init__( - self, - *, - key_id: str, - secret_source: "_models.ResourceReference", - secret_version: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword key_id: Defines the customer defined key Id. This id will exist in the incoming - request to indicate the key used to form the hash. Required. - :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 - Required. - :paramtype secret_source: ~azure.mgmt.cdn.models.ResourceReference - :keyword secret_version: Version of the secret to be used. - :paramtype secret_version: str - """ - super().__init__(**kwargs) - self.type: str = "UrlSigningKey" - self.key_id = key_id - self.secret_source = secret_source - self.secret_version = secret_version - - -class UrlSigningParamIdentifier(_serialization.Model): - """Defines how to identify a parameter for a specific purpose e.g. expires. - - All required parameters must be populated in order to send to server. - - :ivar param_indicator: Indicates the purpose of the parameter. Required. Known values are: - "Expires", "KeyId", and "Signature". - :vartype param_indicator: str or ~azure.mgmt.cdn.models.ParamIndicator - :ivar param_name: Parameter name. Required. - :vartype param_name: str - """ - - _validation = { - "param_indicator": {"required": True}, - "param_name": {"required": True}, - } - - _attribute_map = { - "param_indicator": {"key": "paramIndicator", "type": "str"}, - "param_name": {"key": "paramName", "type": "str"}, - } - - def __init__( - self, *, param_indicator: Union[str, "_models.ParamIndicator"], param_name: str, **kwargs: Any - ) -> None: - """ - :keyword param_indicator: Indicates the purpose of the parameter. Required. Known values are: - "Expires", "KeyId", and "Signature". - :paramtype param_indicator: str or ~azure.mgmt.cdn.models.ParamIndicator - :keyword param_name: Parameter name. Required. - :paramtype param_name: str - """ - super().__init__(**kwargs) - self.param_indicator = param_indicator - self.param_name = param_name - - -class Usage(_serialization.Model): - """Describes resource usage. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to server. - - :ivar id: Resource identifier. - :vartype id: str - :ivar unit: An enum describing the unit of measurement. Required. "Count" - :vartype unit: str or ~azure.mgmt.cdn.models.UsageUnit - :ivar current_value: The current value of the usage. Required. - :vartype current_value: int - :ivar limit: The limit of usage. Required. - :vartype limit: int - :ivar name: The name of the type of usage. Required. - :vartype name: ~azure.mgmt.cdn.models.UsageName - """ - - _validation = { - "id": {"readonly": True}, - "unit": {"required": True}, - "current_value": {"required": True}, - "limit": {"required": True}, - "name": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "unit": {"key": "unit", "type": "str"}, - "current_value": {"key": "currentValue", "type": "int"}, - "limit": {"key": "limit", "type": "int"}, - "name": {"key": "name", "type": "UsageName"}, - } - - def __init__( - self, - *, - unit: Union[str, "_models.UsageUnit"], - current_value: int, - limit: int, - name: "_models.UsageName", - **kwargs: Any - ) -> None: - """ - :keyword unit: An enum describing the unit of measurement. Required. "Count" - :paramtype unit: str or ~azure.mgmt.cdn.models.UsageUnit - :keyword current_value: The current value of the usage. Required. - :paramtype current_value: int - :keyword limit: The limit of usage. Required. - :paramtype limit: int - :keyword name: The name of the type of usage. Required. - :paramtype name: ~azure.mgmt.cdn.models.UsageName - """ - super().__init__(**kwargs) - self.id = None - self.unit = unit - self.current_value = current_value - self.limit = limit - self.name = name - - -class UsageName(_serialization.Model): - """The usage names. - - :ivar value: A string describing the resource name. - :vartype value: str - :ivar localized_value: A localized string describing the resource name. - :vartype localized_value: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "str"}, - "localized_value": {"key": "localizedValue", "type": "str"}, - } - - def __init__(self, *, value: Optional[str] = None, localized_value: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword value: A string describing the resource name. - :paramtype value: str - :keyword localized_value: A localized string describing the resource name. - :paramtype localized_value: str - """ - super().__init__(**kwargs) - self.value = value - self.localized_value = localized_value - - -class UsagesListResult(_serialization.Model): - """The list usages operation response. - - :ivar value: The list of resource usages. - :vartype value: list[~azure.mgmt.cdn.models.Usage] - :ivar next_link: URL to get the next set of results. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[Usage]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: Optional[List["_models.Usage"]] = None, next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The list of resource usages. - :paramtype value: list[~azure.mgmt.cdn.models.Usage] - :keyword next_link: URL to get the next set of results. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class UserAssignedIdentity(_serialization.Model): - """User assigned identity properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar principal_id: The principal ID of the assigned identity. - :vartype principal_id: str - :ivar client_id: The client ID of the assigned identity. - :vartype client_id: str - """ - - _validation = { - "principal_id": {"readonly": True}, - "client_id": {"readonly": True}, - } - - _attribute_map = { - "principal_id": {"key": "principalId", "type": "str"}, - "client_id": {"key": "clientId", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.principal_id = None - self.client_id = None - - -class UserManagedHttpsParameters(CustomDomainHttpsParameters): - """Defines the certificate source parameters using user's keyvault certificate for enabling SSL. - - All required parameters must be populated in order to send to server. - - :ivar certificate_source: Defines the source of the SSL certificate. Required. Known values - are: "AzureKeyVault" and "Cdn". - :vartype certificate_source: str or ~azure.mgmt.cdn.models.CertificateSource - :ivar protocol_type: Defines the TLS extension protocol that is used for secure delivery. - Required. Known values are: "ServerNameIndication" and "IPBased". - :vartype protocol_type: str or ~azure.mgmt.cdn.models.ProtocolType - :ivar minimum_tls_version: TLS protocol version that will be used for Https. Known values are: - "None", "TLS10", and "TLS12". - :vartype minimum_tls_version: str or ~azure.mgmt.cdn.models.MinimumTlsVersion - :ivar certificate_source_parameters: Defines the certificate source parameters using user's - keyvault certificate for enabling SSL. Required. - :vartype certificate_source_parameters: - ~azure.mgmt.cdn.models.KeyVaultCertificateSourceParameters - """ - - _validation = { - "certificate_source": {"required": True}, - "protocol_type": {"required": True}, - "certificate_source_parameters": {"required": True}, - } - - _attribute_map = { - "certificate_source": {"key": "certificateSource", "type": "str"}, - "protocol_type": {"key": "protocolType", "type": "str"}, - "minimum_tls_version": {"key": "minimumTlsVersion", "type": "str"}, - "certificate_source_parameters": { - "key": "certificateSourceParameters", - "type": "KeyVaultCertificateSourceParameters", - }, - } - - def __init__( - self, - *, - protocol_type: Union[str, "_models.ProtocolType"], - certificate_source_parameters: "_models.KeyVaultCertificateSourceParameters", - minimum_tls_version: Optional[Union[str, "_models.MinimumTlsVersion"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword protocol_type: Defines the TLS extension protocol that is used for secure delivery. - Required. Known values are: "ServerNameIndication" and "IPBased". - :paramtype protocol_type: str or ~azure.mgmt.cdn.models.ProtocolType - :keyword minimum_tls_version: TLS protocol version that will be used for Https. Known values - are: "None", "TLS10", and "TLS12". - :paramtype minimum_tls_version: str or ~azure.mgmt.cdn.models.MinimumTlsVersion - :keyword certificate_source_parameters: Defines the certificate source parameters using user's - keyvault certificate for enabling SSL. Required. - :paramtype certificate_source_parameters: - ~azure.mgmt.cdn.models.KeyVaultCertificateSourceParameters - """ - super().__init__(protocol_type=protocol_type, minimum_tls_version=minimum_tls_version, **kwargs) - self.certificate_source: str = "AzureKeyVault" - self.certificate_source_parameters = certificate_source_parameters - - -class ValidateCustomDomainInput(_serialization.Model): - """Input of the custom domain to be validated for DNS mapping. - - All required parameters must be populated in order to send to server. - - :ivar host_name: The host name of the custom domain. Must be a domain name. Required. - :vartype host_name: str - """ - - _validation = { - "host_name": {"required": True}, - } - - _attribute_map = { - "host_name": {"key": "hostName", "type": "str"}, - } - - def __init__(self, *, host_name: str, **kwargs: Any) -> None: - """ - :keyword host_name: The host name of the custom domain. Must be a domain name. Required. - :paramtype host_name: str - """ - super().__init__(**kwargs) - self.host_name = host_name - - -class ValidateCustomDomainOutput(_serialization.Model): - """Output of custom domain validation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar custom_domain_validated: Indicates whether the custom domain is valid or not. - :vartype custom_domain_validated: bool - :ivar reason: The reason why the custom domain is not valid. - :vartype reason: str - :ivar message: Error message describing why the custom domain is not valid. - :vartype message: str - """ - - _validation = { - "custom_domain_validated": {"readonly": True}, - "reason": {"readonly": True}, - "message": {"readonly": True}, - } - - _attribute_map = { - "custom_domain_validated": {"key": "customDomainValidated", "type": "bool"}, - "reason": {"key": "reason", "type": "str"}, - "message": {"key": "message", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.custom_domain_validated = None - self.reason = None - self.message = None - - -class ValidateProbeInput(_serialization.Model): - """Input of the validate probe API. - - All required parameters must be populated in order to send to server. - - :ivar probe_url: The probe URL to validate. Required. - :vartype probe_url: str - """ - - _validation = { - "probe_url": {"required": True}, - } - - _attribute_map = { - "probe_url": {"key": "probeURL", "type": "str"}, - } - - def __init__(self, *, probe_url: str, **kwargs: Any) -> None: - """ - :keyword probe_url: The probe URL to validate. Required. - :paramtype probe_url: str - """ - super().__init__(**kwargs) - self.probe_url = probe_url - - -class ValidateProbeOutput(_serialization.Model): - """Output of the validate probe API. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar is_valid: Indicates whether the probe URL is accepted or not. - :vartype is_valid: bool - :ivar error_code: Specifies the error code when the probe url is not accepted. - :vartype error_code: str - :ivar message: The detailed error message describing why the probe URL is not accepted. - :vartype message: str - """ - - _validation = { - "is_valid": {"readonly": True}, - "error_code": {"readonly": True}, - "message": {"readonly": True}, - } - - _attribute_map = { - "is_valid": {"key": "isValid", "type": "bool"}, - "error_code": {"key": "errorCode", "type": "str"}, - "message": {"key": "message", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.is_valid = None - self.error_code = None - self.message = None - - -class ValidateSecretInput(_serialization.Model): - """Input of the secret to be validated. - - All required parameters must be populated in order to send to server. - - :ivar secret_type: The secret type. Required. Known values are: "UrlSigningKey", - "CustomerCertificate", "ManagedCertificate", and "AzureFirstPartyManagedCertificate". - :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 - Required. - :vartype secret_source: ~azure.mgmt.cdn.models.ResourceReference - :ivar secret_version: Secret version, if customer is using a specific version. - :vartype secret_version: str - """ - - _validation = { - "secret_type": {"required": True}, - "secret_source": {"required": True}, - } - - _attribute_map = { - "secret_type": {"key": "secretType", "type": "str"}, - "secret_source": {"key": "secretSource", "type": "ResourceReference"}, - "secret_version": {"key": "secretVersion", "type": "str"}, - } - - def __init__( - self, - *, - secret_type: Union[str, "_models.SecretType"], - secret_source: "_models.ResourceReference", - secret_version: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword secret_type: The secret type. Required. Known values are: "UrlSigningKey", - "CustomerCertificate", "ManagedCertificate", and "AzureFirstPartyManagedCertificate". - :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 - Required. - :paramtype secret_source: ~azure.mgmt.cdn.models.ResourceReference - :keyword secret_version: Secret version, if customer is using a specific version. - :paramtype secret_version: str - """ - super().__init__(**kwargs) - self.secret_type = secret_type - self.secret_source = secret_source - self.secret_version = secret_version - - -class ValidateSecretOutput(_serialization.Model): - """Output of the validated secret. - - :ivar status: The validation status. Known values are: "Valid", "Invalid", "AccessDenied", and - "CertificateExpired". - :vartype status: str or ~azure.mgmt.cdn.models.Status - :ivar message: Detailed error message. - :vartype message: str - """ - - _attribute_map = { - "status": {"key": "status", "type": "str"}, - "message": {"key": "message", "type": "str"}, - } - - def __init__( - self, *, status: Optional[Union[str, "_models.Status"]] = None, message: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword status: The validation status. Known values are: "Valid", "Invalid", "AccessDenied", - and "CertificateExpired". - :paramtype status: str or ~azure.mgmt.cdn.models.Status - :keyword message: Detailed error message. - :paramtype message: str - """ - super().__init__(**kwargs) - self.status = status - self.message = message - - -class ValidationToken(_serialization.Model): - """The validation token. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar token: - :vartype token: str - """ - - _validation = { - "token": {"readonly": True}, - } - - _attribute_map = { - "token": {"key": "token", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.token = None - - -class WafMetricsResponse(_serialization.Model): - """Waf Metrics Response. - - :ivar date_time_begin: - :vartype date_time_begin: ~datetime.datetime - :ivar date_time_end: - :vartype date_time_end: ~datetime.datetime - :ivar granularity: Known values are: "PT5M", "PT1H", and "P1D". - :vartype granularity: str or ~azure.mgmt.cdn.models.WafMetricsGranularity - :ivar series: - :vartype series: list[~azure.mgmt.cdn.models.WafMetricsResponseSeriesItem] - """ - - _attribute_map = { - "date_time_begin": {"key": "dateTimeBegin", "type": "iso-8601"}, - "date_time_end": {"key": "dateTimeEnd", "type": "iso-8601"}, - "granularity": {"key": "granularity", "type": "str"}, - "series": {"key": "series", "type": "[WafMetricsResponseSeriesItem]"}, - } - - def __init__( - self, - *, - date_time_begin: Optional[datetime.datetime] = None, - date_time_end: Optional[datetime.datetime] = None, - granularity: Optional[Union[str, "_models.WafMetricsGranularity"]] = None, - series: Optional[List["_models.WafMetricsResponseSeriesItem"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword date_time_begin: - :paramtype date_time_begin: ~datetime.datetime - :keyword date_time_end: - :paramtype date_time_end: ~datetime.datetime - :keyword granularity: Known values are: "PT5M", "PT1H", and "P1D". - :paramtype granularity: str or ~azure.mgmt.cdn.models.WafMetricsGranularity - :keyword series: - :paramtype series: list[~azure.mgmt.cdn.models.WafMetricsResponseSeriesItem] - """ - super().__init__(**kwargs) - self.date_time_begin = date_time_begin - self.date_time_end = date_time_end - self.granularity = granularity - self.series = series - - -class WafMetricsResponseSeriesItem(_serialization.Model): - """WafMetricsResponseSeriesItem. - - :ivar metric: - :vartype metric: str - :ivar unit: "count" - :vartype unit: str or ~azure.mgmt.cdn.models.WafMetricsSeriesUnit - :ivar groups: - :vartype groups: list[~azure.mgmt.cdn.models.WafMetricsResponseSeriesPropertiesItemsItem] - :ivar data: - :vartype data: - list[~azure.mgmt.cdn.models.Components18OrqelSchemasWafmetricsresponsePropertiesSeriesItemsPropertiesDataItems] - """ - - _attribute_map = { - "metric": {"key": "metric", "type": "str"}, - "unit": {"key": "unit", "type": "str"}, - "groups": {"key": "groups", "type": "[WafMetricsResponseSeriesPropertiesItemsItem]"}, - "data": { - "key": "data", - "type": "[Components18OrqelSchemasWafmetricsresponsePropertiesSeriesItemsPropertiesDataItems]", - }, - } - - def __init__( - self, - *, - metric: Optional[str] = None, - unit: Optional[Union[str, "_models.WafMetricsSeriesUnit"]] = None, - groups: Optional[List["_models.WafMetricsResponseSeriesPropertiesItemsItem"]] = None, - data: Optional[ - List["_models.Components18OrqelSchemasWafmetricsresponsePropertiesSeriesItemsPropertiesDataItems"] - ] = None, - **kwargs: Any - ) -> None: - """ - :keyword metric: - :paramtype metric: str - :keyword unit: "count" - :paramtype unit: str or ~azure.mgmt.cdn.models.WafMetricsSeriesUnit - :keyword groups: - :paramtype groups: list[~azure.mgmt.cdn.models.WafMetricsResponseSeriesPropertiesItemsItem] - :keyword data: - :paramtype data: - list[~azure.mgmt.cdn.models.Components18OrqelSchemasWafmetricsresponsePropertiesSeriesItemsPropertiesDataItems] - """ - super().__init__(**kwargs) - self.metric = metric - self.unit = unit - self.groups = groups - self.data = data - - -class WafMetricsResponseSeriesPropertiesItemsItem(_serialization.Model): # pylint: disable=name-too-long - """WafMetricsResponseSeriesPropertiesItemsItem. - - :ivar name: - :vartype name: str - :ivar value: - :vartype value: str - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "value": {"key": "value", "type": "str"}, - } - - def __init__(self, *, name: Optional[str] = None, value: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword name: - :paramtype name: str - :keyword value: - :paramtype value: str - """ - super().__init__(**kwargs) - self.name = name - self.value = value - - -class WafRankingsResponse(_serialization.Model): - """Waf Rankings Response. - - :ivar date_time_begin: - :vartype date_time_begin: ~datetime.datetime - :ivar date_time_end: - :vartype date_time_end: ~datetime.datetime - :ivar groups: - :vartype groups: list[str] - :ivar data: - :vartype data: list[~azure.mgmt.cdn.models.WafRankingsResponseDataItem] - """ - - _attribute_map = { - "date_time_begin": {"key": "dateTimeBegin", "type": "iso-8601"}, - "date_time_end": {"key": "dateTimeEnd", "type": "iso-8601"}, - "groups": {"key": "groups", "type": "[str]"}, - "data": {"key": "data", "type": "[WafRankingsResponseDataItem]"}, - } - - def __init__( - self, - *, - date_time_begin: Optional[datetime.datetime] = None, - date_time_end: Optional[datetime.datetime] = None, - groups: Optional[List[str]] = None, - data: Optional[List["_models.WafRankingsResponseDataItem"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword date_time_begin: - :paramtype date_time_begin: ~datetime.datetime - :keyword date_time_end: - :paramtype date_time_end: ~datetime.datetime - :keyword groups: - :paramtype groups: list[str] - :keyword data: - :paramtype data: list[~azure.mgmt.cdn.models.WafRankingsResponseDataItem] - """ - super().__init__(**kwargs) - self.date_time_begin = date_time_begin - self.date_time_end = date_time_end - self.groups = groups - self.data = data - - -class WafRankingsResponseDataItem(_serialization.Model): - """WafRankingsResponseDataItem. - - :ivar group_values: - :vartype group_values: list[str] - :ivar metrics: - :vartype metrics: - list[~azure.mgmt.cdn.models.ComponentsKpo1PjSchemasWafrankingsresponsePropertiesDataItemsPropertiesMetricsItems] - """ - - _attribute_map = { - "group_values": {"key": "groupValues", "type": "[str]"}, - "metrics": { - "key": "metrics", - "type": "[ComponentsKpo1PjSchemasWafrankingsresponsePropertiesDataItemsPropertiesMetricsItems]", - }, - } - - def __init__( - self, - *, - group_values: Optional[List[str]] = None, - metrics: Optional[ - List["_models.ComponentsKpo1PjSchemasWafrankingsresponsePropertiesDataItemsPropertiesMetricsItems"] - ] = None, - **kwargs: Any - ) -> None: - """ - :keyword group_values: - :paramtype group_values: list[str] - :keyword metrics: - :paramtype metrics: - list[~azure.mgmt.cdn.models.ComponentsKpo1PjSchemasWafrankingsresponsePropertiesDataItemsPropertiesMetricsItems] # pylint: disable=line-too-long - """ - super().__init__(**kwargs) - self.group_values = group_values - self.metrics = metrics diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/models/_patch.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/models/_patch.py index f7dd32510333..ea765788358a 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/models/_patch.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/models/_patch.py @@ -1,14 +1,14 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------- """Customize generated code here. Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize """ -from typing import List -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level +__all__: list[str] = [] # Add all objects you want publicly available to users at this package level def patch_sdk(): diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/__init__.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/__init__.py index ebcf7eb37437..cdd6e66a84f4 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 @@ -2,41 +2,46 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -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 ._operations import Operations # type: ignore +from ._operations import ProfilesOperations # type: ignore +from ._operations import AFDEndpointsOperations # type: ignore +from ._operations import AFDOriginGroupsOperations # type: ignore +from ._operations import AFDOriginsOperations # type: ignore +from ._operations import RoutesOperations # type: ignore +from ._operations import RuleSetsOperations # type: ignore +from ._operations import RulesOperations # type: ignore +from ._operations import SecurityPoliciesOperations # type: ignore +from ._operations import SecretsOperations # type: ignore +from ._operations import EndpointsOperations # type: ignore +from ._operations import OriginsOperations # type: ignore +from ._operations import OriginGroupsOperations # type: ignore +from ._operations import CustomDomainsOperations # type: ignore +from ._operations import AFDCustomDomainsOperations # type: ignore +from ._operations import AFDProfilesOperations # type: ignore +from ._operations import LogAnalyticsOperations # type: ignore +from ._operations import PoliciesOperations # type: ignore +from ._operations import ResourceUsageOperations # type: ignore +from ._operations import EdgeNodesOperations # type: ignore +from ._operations import ManagedRuleSetsOperations # type: ignore +from ._operations import _CdnManagementClientOperationsMixin # type: ignore # pylint: disable=unused-import 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__ = [ - "CdnManagementClientOperationsMixin", - "AFDProfilesOperations", - "AFDCustomDomainsOperations", + "Operations", + "ProfilesOperations", "AFDEndpointsOperations", "AFDOriginGroupsOperations", "AFDOriginsOperations", @@ -45,17 +50,17 @@ "RulesOperations", "SecurityPoliciesOperations", "SecretsOperations", - "LogAnalyticsOperations", - "ProfilesOperations", "EndpointsOperations", "OriginsOperations", "OriginGroupsOperations", "CustomDomainsOperations", + "AFDCustomDomainsOperations", + "AFDProfilesOperations", + "LogAnalyticsOperations", + "PoliciesOperations", "ResourceUsageOperations", - "Operations", "EdgeNodesOperations", - "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 deleted file mode 100644 index 43dffe70d382..000000000000 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_afd_custom_domains_operations.py +++ /dev/null @@ -1,1062 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models -from .._serialization import Serializer -from .._vendor import CdnManagementClientMixinABC, _convert_request - -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]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_profile_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", "2024-02-01")) - 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"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, profile_name: str, custom_domain_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_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")) - 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"), - "customDomainName": _SERIALIZER.url("custom_domain_name", custom_domain_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_request( - resource_group_name: str, profile_name: str, custom_domain_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_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")) - 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}/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"), - "customDomainName": _SERIALIZER.url("custom_domain_name", custom_domain_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_update_request( - resource_group_name: str, profile_name: str, custom_domain_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_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")) - 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}/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"), - "customDomainName": _SERIALIZER.url("custom_domain_name", custom_domain_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, profile_name: str, custom_domain_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_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")) - 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"), - "customDomainName": _SERIALIZER.url("custom_domain_name", custom_domain_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_refresh_validation_token_request( - resource_group_name: str, profile_name: str, custom_domain_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_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")) - 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"), - "customDomainName": _SERIALIZER.url("custom_domain_name", custom_domain_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # 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 AFDCustomDomainsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.cdn.CdnManagementClient`'s - :attr:`afd_custom_domains` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_profile( - self, resource_group_name: str, profile_name: str, **kwargs: Any - ) -> Iterable["_models.AFDDomain"]: - """Lists existing AzureFrontDoor domains. - - :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. - :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] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - 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]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_profile_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 = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("AFDDomainListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get( - self, resource_group_name: str, profile_name: str, custom_domain_name: str, **kwargs: Any - ) -> _models.AFDDomain: - """Gets an existing AzureFrontDoor domain with the specified domain name under the specified - subscription, resource group and 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. - :type profile_name: str - :param custom_domain_name: Name of the domain under the profile which is unique globally. - Required. - :type custom_domain_name: str - :return: AFDDomain or the result of cls(response) - :rtype: ~azure.mgmt.cdn.models.AFDDomain - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.AFDDomain] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - custom_domain_name=custom_domain_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AFDDomain", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_initial( - self, - resource_group_name: str, - profile_name: str, - custom_domain_name: str, - custom_domain: Union[_models.AFDDomain, IO[bytes]], - **kwargs: Any - ) -> _models.AFDDomain: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_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.AFDDomain] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(custom_domain, (IOBase, bytes)): - _content = custom_domain - else: - _json = self._serialize.body(custom_domain, "AFDDomain") - - _request = build_create_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - custom_domain_name=custom_domain_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201, 202]: - 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) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create( - self, - resource_group_name: str, - profile_name: str, - custom_domain_name: str, - custom_domain: _models.AFDDomain, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.AFDDomain]: - """Creates a new domain within the specified 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. - :type profile_name: str - :param custom_domain_name: Name of the domain under the profile which is unique globally. - Required. - :type custom_domain_name: str - :param custom_domain: Domain properties. Required. - :type custom_domain: ~azure.mgmt.cdn.models.AFDDomain - :keyword content_type: Body Parameter 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 AFDDomain or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.AFDDomain] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create( - self, - resource_group_name: str, - profile_name: str, - custom_domain_name: str, - custom_domain: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.AFDDomain]: - """Creates a new domain within the specified 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. - :type profile_name: str - :param custom_domain_name: Name of the domain under the profile which is unique globally. - Required. - :type custom_domain_name: str - :param custom_domain: Domain properties. Required. - :type custom_domain: IO[bytes] - :keyword content_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 AFDDomain or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.AFDDomain] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create( - self, - resource_group_name: str, - profile_name: str, - custom_domain_name: str, - custom_domain: Union[_models.AFDDomain, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.AFDDomain]: - """Creates a new domain within the specified 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. - :type profile_name: str - :param custom_domain_name: Name of the domain under the profile which is unique globally. - Required. - :type custom_domain_name: str - :param custom_domain: Domain properties. Is either a AFDDomain type or a IO[bytes] type. - Required. - :type custom_domain: ~azure.mgmt.cdn.models.AFDDomain or IO[bytes] - :return: An instance of LROPoller that returns either AFDDomain or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.AFDDomain] - :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.AFDDomain] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._create_initial( - resource_group_name=resource_group_name, - profile_name=profile_name, - custom_domain_name=custom_domain_name, - custom_domain=custom_domain, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("AFDDomain", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.AFDDomain].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.AFDDomain]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _update_initial( - self, - resource_group_name: str, - profile_name: str, - custom_domain_name: str, - custom_domain_update_properties: Union[_models.AFDDomainUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> _models.AFDDomain: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_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.AFDDomain] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(custom_domain_update_properties, (IOBase, bytes)): - _content = custom_domain_update_properties - else: - _json = self._serialize.body(custom_domain_update_properties, "AFDDomainUpdateParameters") - - _request = build_update_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - custom_domain_name=custom_domain_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.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) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_update( - self, - resource_group_name: str, - profile_name: str, - custom_domain_name: str, - custom_domain_update_properties: _models.AFDDomainUpdateParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.AFDDomain]: - """Updates an existing domain within a 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. - :type profile_name: str - :param custom_domain_name: Name of the domain under the profile which is unique globally. - Required. - :type custom_domain_name: str - :param custom_domain_update_properties: Domain properties. Required. - :type custom_domain_update_properties: ~azure.mgmt.cdn.models.AFDDomainUpdateParameters - :keyword content_type: Body Parameter 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 AFDDomain or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.AFDDomain] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - profile_name: str, - custom_domain_name: str, - custom_domain_update_properties: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.AFDDomain]: - """Updates an existing domain within a 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. - :type profile_name: str - :param custom_domain_name: Name of the domain under the profile which is unique globally. - Required. - :type custom_domain_name: str - :param custom_domain_update_properties: Domain properties. Required. - :type custom_domain_update_properties: IO[bytes] - :keyword content_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 AFDDomain or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.AFDDomain] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update( - self, - resource_group_name: str, - profile_name: str, - custom_domain_name: str, - custom_domain_update_properties: Union[_models.AFDDomainUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.AFDDomain]: - """Updates an existing domain within a 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. - :type profile_name: str - :param custom_domain_name: Name of the domain under the profile which is unique globally. - Required. - :type custom_domain_name: str - :param custom_domain_update_properties: Domain properties. Is either a - AFDDomainUpdateParameters type or a IO[bytes] type. Required. - :type custom_domain_update_properties: ~azure.mgmt.cdn.models.AFDDomainUpdateParameters or - IO[bytes] - :return: An instance of LROPoller that returns either AFDDomain or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.AFDDomain] - :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.AFDDomain] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._update_initial( - resource_group_name=resource_group_name, - profile_name=profile_name, - custom_domain_name=custom_domain_name, - custom_domain_update_properties=custom_domain_update_properties, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("AFDDomain", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.AFDDomain].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.AFDDomain]( - 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, custom_domain_name: str, **kwargs: Any - ) -> None: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - custom_domain_name=custom_domain_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - 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 == 202: - response_headers["location"] = self._deserialize("str", response.headers.get("location")) - - if cls: - return cls(pipeline_response, None, response_headers) # type: ignore - - @distributed_trace - def begin_delete( - self, resource_group_name: str, profile_name: str, custom_domain_name: str, **kwargs: Any - ) -> LROPoller[None]: - """Deletes an existing AzureFrontDoor domain with the specified domain name under the specified - subscription, resource group and 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. - :type profile_name: str - :param custom_domain_name: Name of the domain under the profile which is unique globally. - Required. - :type custom_domain_name: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_initial( # type: ignore - resource_group_name=resource_group_name, - profile_name=profile_name, - custom_domain_name=custom_domain_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _refresh_validation_token_initial( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, profile_name: str, custom_domain_name: str, **kwargs: Any - ) -> None: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_refresh_validation_token_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - custom_domain_name=custom_domain_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, 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")) - - if cls: - return cls(pipeline_response, None, response_headers) # type: ignore - - @distributed_trace - def begin_refresh_validation_token( - self, resource_group_name: str, profile_name: str, custom_domain_name: str, **kwargs: Any - ) -> LROPoller[None]: - """Updates the domain 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. - :type profile_name: str - :param custom_domain_name: Name of the domain under the profile which is unique globally. - Required. - :type custom_domain_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._refresh_validation_token_initial( # type: ignore - resource_group_name=resource_group_name, - profile_name=profile_name, - custom_domain_name=custom_domain_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore 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 deleted file mode 100644 index f4f0f3e5c5c8..000000000000 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_afd_endpoints_operations.py +++ /dev/null @@ -1,1490 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models -from .._serialization import Serializer -from .._vendor import CdnManagementClientMixinABC, _convert_request - -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]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_profile_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", "2024-02-01")) - 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"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, profile_name: str, endpoint_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) - 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"), - "endpointName": _SERIALIZER.url("endpoint_name", endpoint_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_request( - resource_group_name: str, profile_name: str, endpoint_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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"), - "endpointName": _SERIALIZER.url("endpoint_name", endpoint_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_update_request( - resource_group_name: str, profile_name: str, endpoint_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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"), - "endpointName": _SERIALIZER.url("endpoint_name", endpoint_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, profile_name: str, endpoint_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) - 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"), - "endpointName": _SERIALIZER.url("endpoint_name", endpoint_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_purge_content_request( - resource_group_name: str, profile_name: str, endpoint_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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"), - "endpointName": _SERIALIZER.url("endpoint_name", endpoint_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_resource_usage_request( - resource_group_name: str, profile_name: str, endpoint_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) - 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"), - "endpointName": _SERIALIZER.url("endpoint_name", endpoint_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_validate_custom_domain_request( - resource_group_name: str, profile_name: str, endpoint_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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"), - "endpointName": _SERIALIZER.url("endpoint_name", endpoint_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -class AFDEndpointsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.cdn.CdnManagementClient`'s - :attr:`afd_endpoints` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_profile( - self, resource_group_name: str, profile_name: str, **kwargs: Any - ) -> Iterable["_models.AFDEndpoint"]: - """Lists existing AzureFrontDoor endpoints. - - :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. - :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] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - 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]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_profile_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 = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("AFDEndpointListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get( - self, resource_group_name: str, profile_name: str, endpoint_name: str, **kwargs: Any - ) -> _models.AFDEndpoint: - """Gets an existing AzureFrontDoor endpoint with the specified endpoint name under the specified - subscription, resource group and 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. - :type profile_name: str - :param endpoint_name: Name of the endpoint under the profile which is unique globally. - Required. - :type endpoint_name: str - :return: AFDEndpoint or the result of cls(response) - :rtype: ~azure.mgmt.cdn.models.AFDEndpoint - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.AFDEndpoint] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AFDEndpoint", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_initial( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - endpoint: Union[_models.AFDEndpoint, IO[bytes]], - **kwargs: Any - ) -> _models.AFDEndpoint: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_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.AFDEndpoint] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(endpoint, (IOBase, bytes)): - _content = endpoint - else: - _json = self._serialize.body(endpoint, "AFDEndpoint") - - _request = build_create_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201, 202]: - 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) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - endpoint: _models.AFDEndpoint, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.AFDEndpoint]: - """Creates a new AzureFrontDoor endpoint with the specified endpoint name under the specified - subscription, resource group and 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. - :type profile_name: str - :param endpoint_name: Name of the endpoint under the profile which is unique globally. - Required. - :type endpoint_name: str - :param endpoint: Endpoint properties. Required. - :type endpoint: ~azure.mgmt.cdn.models.AFDEndpoint - :keyword content_type: Body Parameter 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 AFDEndpoint or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.AFDEndpoint] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - endpoint: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.AFDEndpoint]: - """Creates a new AzureFrontDoor endpoint with the specified endpoint name under the specified - subscription, resource group and 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. - :type profile_name: str - :param endpoint_name: Name of the endpoint under the profile which is unique globally. - Required. - :type endpoint_name: str - :param endpoint: Endpoint properties. Required. - :type endpoint: IO[bytes] - :keyword content_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 AFDEndpoint or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.AFDEndpoint] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - endpoint: Union[_models.AFDEndpoint, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.AFDEndpoint]: - """Creates a new AzureFrontDoor endpoint with the specified endpoint name under the specified - subscription, resource group and 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. - :type profile_name: str - :param endpoint_name: Name of the endpoint under the profile which is unique globally. - Required. - :type endpoint_name: str - :param endpoint: Endpoint properties. Is either a AFDEndpoint type or a IO[bytes] type. - Required. - :type endpoint: ~azure.mgmt.cdn.models.AFDEndpoint or IO[bytes] - :return: An instance of LROPoller that returns either AFDEndpoint or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.AFDEndpoint] - :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.AFDEndpoint] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._create_initial( - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - endpoint=endpoint, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("AFDEndpoint", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.AFDEndpoint].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.AFDEndpoint]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _update_initial( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - endpoint_update_properties: Union[_models.AFDEndpointUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> _models.AFDEndpoint: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_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.AFDEndpoint] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(endpoint_update_properties, (IOBase, bytes)): - _content = endpoint_update_properties - else: - _json = self._serialize.body(endpoint_update_properties, "AFDEndpointUpdateParameters") - - _request = build_update_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.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) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_update( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - endpoint_update_properties: _models.AFDEndpointUpdateParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.AFDEndpoint]: - """Updates an existing AzureFrontDoor endpoint with the specified endpoint name under the - specified subscription, resource group and profile. Only tags can be updated after creating an - endpoint. To update origins, use the Update Origin operation. To update origin groups, use the - Update Origin group operation. To update domains, use the Update Custom Domain operation. - - :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. - :type profile_name: str - :param endpoint_name: Name of the endpoint under the profile which is unique globally. - Required. - :type endpoint_name: str - :param endpoint_update_properties: Endpoint update properties. Required. - :type endpoint_update_properties: ~azure.mgmt.cdn.models.AFDEndpointUpdateParameters - :keyword content_type: Body Parameter 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 AFDEndpoint or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.AFDEndpoint] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - endpoint_update_properties: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.AFDEndpoint]: - """Updates an existing AzureFrontDoor endpoint with the specified endpoint name under the - specified subscription, resource group and profile. Only tags can be updated after creating an - endpoint. To update origins, use the Update Origin operation. To update origin groups, use the - Update Origin group operation. To update domains, use the Update Custom Domain operation. - - :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. - :type profile_name: str - :param endpoint_name: Name of the endpoint under the profile which is unique globally. - Required. - :type endpoint_name: str - :param endpoint_update_properties: Endpoint update properties. Required. - :type endpoint_update_properties: IO[bytes] - :keyword content_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 AFDEndpoint or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.AFDEndpoint] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - endpoint_update_properties: Union[_models.AFDEndpointUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.AFDEndpoint]: - """Updates an existing AzureFrontDoor endpoint with the specified endpoint name under the - specified subscription, resource group and profile. Only tags can be updated after creating an - endpoint. To update origins, use the Update Origin operation. To update origin groups, use the - Update Origin group operation. To update domains, use the Update Custom Domain operation. - - :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. - :type profile_name: str - :param endpoint_name: Name of the endpoint under the profile which is unique globally. - Required. - :type endpoint_name: str - :param endpoint_update_properties: Endpoint update properties. Is either a - AFDEndpointUpdateParameters type or a IO[bytes] type. Required. - :type endpoint_update_properties: ~azure.mgmt.cdn.models.AFDEndpointUpdateParameters or - IO[bytes] - :return: An instance of LROPoller that returns either AFDEndpoint or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.AFDEndpoint] - :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.AFDEndpoint] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._update_initial( - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - endpoint_update_properties=endpoint_update_properties, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("AFDEndpoint", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.AFDEndpoint].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.AFDEndpoint]( - 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, endpoint_name: str, **kwargs: Any - ) -> None: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - 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 == 202: - response_headers["location"] = self._deserialize("str", response.headers.get("location")) - - if cls: - return cls(pipeline_response, None, response_headers) # type: ignore - - @distributed_trace - def begin_delete( - self, resource_group_name: str, profile_name: str, endpoint_name: str, **kwargs: Any - ) -> LROPoller[None]: - """Deletes an existing AzureFrontDoor endpoint with the specified endpoint name under the - specified subscription, resource group and 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. - :type profile_name: str - :param endpoint_name: Name of the endpoint under the profile which is unique globally. - Required. - :type endpoint_name: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_initial( # type: ignore - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _purge_content_initial( # pylint: disable=inconsistent-return-statements - 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]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(contents, (IOBase, bytes)): - _content = contents - else: - _json = self._serialize.body(contents, "AfdPurgeParameters") - - _request = build_purge_content_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, 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")) - - if cls: - return cls(pipeline_response, None, response_headers) # type: ignore - - @overload - def begin_purge_content( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - contents: _models.AfdPurgeParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Removes a content from AzureFrontDoor. - - :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. - :type profile_name: str - :param endpoint_name: Name of the endpoint under the profile which is unique globally. - Required. - :type endpoint_name: str - :param contents: The list of paths to the content and the list of linked domains to be purged. - Path can be a full URL, e.g. '/pictures/city.png' which removes a single file, or a directory - with a wildcard, e.g. '/pictures/*' which removes all folders and files in the directory. - Required. - :type contents: ~azure.mgmt.cdn.models.AfdPurgeParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_purge_content( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - contents: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Removes a content from AzureFrontDoor. - - :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. - :type profile_name: str - :param endpoint_name: Name of the endpoint under the profile which is unique globally. - Required. - :type endpoint_name: str - :param contents: The list of paths to the content and the list of linked domains to be purged. - Path can be a full URL, e.g. '/pictures/city.png' which removes a single file, or a directory - with a wildcard, e.g. '/pictures/*' which removes all folders and files in the directory. - Required. - :type contents: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_purge_content( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - contents: Union[_models.AfdPurgeParameters, IO[bytes]], - **kwargs: Any - ) -> LROPoller[None]: - """Removes a content from AzureFrontDoor. - - :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. - :type profile_name: str - :param endpoint_name: Name of the endpoint under the profile which is unique globally. - Required. - :type endpoint_name: str - :param contents: The list of paths to the content and the list of linked domains to be purged. - Path can be a full URL, e.g. '/pictures/city.png' which removes a single file, or a directory - with a wildcard, e.g. '/pictures/*' which removes all folders and files in the directory. Is - either a AfdPurgeParameters type or a IO[bytes] type. Required. - :type contents: ~azure.mgmt.cdn.models.AfdPurgeParameters or IO[bytes] - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._purge_content_initial( # type: ignore - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - contents=contents, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def list_resource_usage( - self, resource_group_name: str, profile_name: str, endpoint_name: str, **kwargs: Any - ) -> Iterable["_models.Usage"]: - """Checks the quota and actual usage of endpoints under the given Azure Front Door 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. - :type profile_name: str - :param endpoint_name: Name of the endpoint under the profile which is unique globally. - Required. - :type endpoint_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] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - 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]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_resource_usage_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("UsagesListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @overload - def validate_custom_domain( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - custom_domain_properties: _models.ValidateCustomDomainInput, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ValidateCustomDomainOutput: - """Validates the custom domain mapping to ensure it maps to the correct Azure Front Door endpoint - in DNS. - - :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. - :type profile_name: str - :param endpoint_name: Name of the endpoint under the profile which is unique globally. - Required. - :type endpoint_name: str - :param custom_domain_properties: Custom domain to be validated. Required. - :type custom_domain_properties: ~azure.mgmt.cdn.models.ValidateCustomDomainInput - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: ValidateCustomDomainOutput or the result of cls(response) - :rtype: ~azure.mgmt.cdn.models.ValidateCustomDomainOutput - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def validate_custom_domain( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - custom_domain_properties: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ValidateCustomDomainOutput: - """Validates the custom domain mapping to ensure it maps to the correct Azure Front Door endpoint - in DNS. - - :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. - :type profile_name: str - :param endpoint_name: Name of the endpoint under the profile which is unique globally. - Required. - :type endpoint_name: str - :param custom_domain_properties: Custom domain to be validated. Required. - :type custom_domain_properties: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: ValidateCustomDomainOutput or the result of cls(response) - :rtype: ~azure.mgmt.cdn.models.ValidateCustomDomainOutput - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def validate_custom_domain( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - custom_domain_properties: Union[_models.ValidateCustomDomainInput, IO[bytes]], - **kwargs: Any - ) -> _models.ValidateCustomDomainOutput: - """Validates the custom domain mapping to ensure it maps to the correct Azure Front Door endpoint - in DNS. - - :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. - :type profile_name: str - :param endpoint_name: Name of the endpoint under the profile which is unique globally. - Required. - :type endpoint_name: str - :param custom_domain_properties: Custom domain to be validated. Is either a - ValidateCustomDomainInput type or a IO[bytes] type. Required. - :type custom_domain_properties: ~azure.mgmt.cdn.models.ValidateCustomDomainInput or IO[bytes] - :return: ValidateCustomDomainOutput or the result of cls(response) - :rtype: ~azure.mgmt.cdn.models.ValidateCustomDomainOutput - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_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.ValidateCustomDomainOutput] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(custom_domain_properties, (IOBase, bytes)): - _content = custom_domain_properties - else: - _json = self._serialize.body(custom_domain_properties, "ValidateCustomDomainInput") - - _request = build_validate_custom_domain_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ValidateCustomDomainOutput", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return 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 deleted file mode 100644 index 4280339143c6..000000000000 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_afd_origin_groups_operations.py +++ /dev/null @@ -1,1048 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models -from .._serialization import Serializer -from .._vendor import CdnManagementClientMixinABC, _convert_request - -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]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_profile_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", "2024-02-01")) - 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"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, profile_name: str, origin_group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) - 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"), - "originGroupName": _SERIALIZER.url("origin_group_name", origin_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_request( - resource_group_name: str, profile_name: str, origin_group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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"), - "originGroupName": _SERIALIZER.url("origin_group_name", origin_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_update_request( - resource_group_name: str, profile_name: str, origin_group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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"), - "originGroupName": _SERIALIZER.url("origin_group_name", origin_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, profile_name: str, origin_group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) - 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"), - "originGroupName": _SERIALIZER.url("origin_group_name", origin_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_resource_usage_request( - resource_group_name: str, profile_name: str, origin_group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) - 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"), - "originGroupName": _SERIALIZER.url("origin_group_name", origin_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -class AFDOriginGroupsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.cdn.CdnManagementClient`'s - :attr:`afd_origin_groups` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_profile( - self, resource_group_name: str, profile_name: str, **kwargs: Any - ) -> Iterable["_models.AFDOriginGroup"]: - """Lists all of the existing origin groups within a 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. - :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] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - 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]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_profile_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 = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("AFDOriginGroupListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get( - self, resource_group_name: str, profile_name: str, origin_group_name: str, **kwargs: Any - ) -> _models.AFDOriginGroup: - """Gets an existing origin group within a 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. - :type profile_name: str - :param origin_group_name: Name of the origin group which is unique within the endpoint. - Required. - :type origin_group_name: str - :return: AFDOriginGroup or the result of cls(response) - :rtype: ~azure.mgmt.cdn.models.AFDOriginGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.AFDOriginGroup] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - origin_group_name=origin_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AFDOriginGroup", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_initial( - self, - resource_group_name: str, - profile_name: str, - origin_group_name: str, - origin_group: Union[_models.AFDOriginGroup, IO[bytes]], - **kwargs: Any - ) -> _models.AFDOriginGroup: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_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.AFDOriginGroup] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(origin_group, (IOBase, bytes)): - _content = origin_group - else: - _json = self._serialize.body(origin_group, "AFDOriginGroup") - - _request = build_create_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - origin_group_name=origin_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201, 202]: - 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) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create( - self, - resource_group_name: str, - profile_name: str, - origin_group_name: str, - origin_group: _models.AFDOriginGroup, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.AFDOriginGroup]: - """Creates a new origin group within the specified 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. - :type profile_name: str - :param origin_group_name: Name of the origin group which is unique within the endpoint. - Required. - :type origin_group_name: str - :param origin_group: Origin group properties. Required. - :type origin_group: ~azure.mgmt.cdn.models.AFDOriginGroup - :keyword content_type: Body Parameter 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 AFDOriginGroup or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.AFDOriginGroup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create( - self, - resource_group_name: str, - profile_name: str, - origin_group_name: str, - origin_group: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.AFDOriginGroup]: - """Creates a new origin group within the specified 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. - :type profile_name: str - :param origin_group_name: Name of the origin group which is unique within the endpoint. - Required. - :type origin_group_name: str - :param origin_group: Origin group properties. Required. - :type origin_group: IO[bytes] - :keyword content_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 AFDOriginGroup or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.AFDOriginGroup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create( - self, - resource_group_name: str, - profile_name: str, - origin_group_name: str, - origin_group: Union[_models.AFDOriginGroup, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.AFDOriginGroup]: - """Creates a new origin group within the specified 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. - :type profile_name: str - :param origin_group_name: Name of the origin group which is unique within the endpoint. - Required. - :type origin_group_name: str - :param origin_group: Origin group properties. Is either a AFDOriginGroup type or a IO[bytes] - type. Required. - :type origin_group: ~azure.mgmt.cdn.models.AFDOriginGroup or IO[bytes] - :return: An instance of LROPoller that returns either AFDOriginGroup or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.AFDOriginGroup] - :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.AFDOriginGroup] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._create_initial( - resource_group_name=resource_group_name, - profile_name=profile_name, - origin_group_name=origin_group_name, - origin_group=origin_group, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("AFDOriginGroup", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.AFDOriginGroup].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.AFDOriginGroup]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _update_initial( - self, - resource_group_name: str, - profile_name: str, - origin_group_name: str, - origin_group_update_properties: Union[_models.AFDOriginGroupUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> _models.AFDOriginGroup: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_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.AFDOriginGroup] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(origin_group_update_properties, (IOBase, bytes)): - _content = origin_group_update_properties - else: - _json = self._serialize.body(origin_group_update_properties, "AFDOriginGroupUpdateParameters") - - _request = build_update_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - origin_group_name=origin_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.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) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_update( - self, - resource_group_name: str, - profile_name: str, - origin_group_name: str, - origin_group_update_properties: _models.AFDOriginGroupUpdateParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.AFDOriginGroup]: - """Updates an existing origin group within a 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. - :type profile_name: str - :param origin_group_name: Name of the origin group which is unique within the profile. - Required. - :type origin_group_name: str - :param origin_group_update_properties: Origin group properties. Required. - :type origin_group_update_properties: ~azure.mgmt.cdn.models.AFDOriginGroupUpdateParameters - :keyword content_type: Body Parameter 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 AFDOriginGroup or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.AFDOriginGroup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - profile_name: str, - origin_group_name: str, - origin_group_update_properties: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.AFDOriginGroup]: - """Updates an existing origin group within a 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. - :type profile_name: str - :param origin_group_name: Name of the origin group which is unique within the profile. - Required. - :type origin_group_name: str - :param origin_group_update_properties: Origin group properties. Required. - :type origin_group_update_properties: IO[bytes] - :keyword content_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 AFDOriginGroup or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.AFDOriginGroup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update( - self, - resource_group_name: str, - profile_name: str, - origin_group_name: str, - origin_group_update_properties: Union[_models.AFDOriginGroupUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.AFDOriginGroup]: - """Updates an existing origin group within a 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. - :type profile_name: str - :param origin_group_name: Name of the origin group which is unique within the profile. - Required. - :type origin_group_name: str - :param origin_group_update_properties: Origin group properties. Is either a - AFDOriginGroupUpdateParameters type or a IO[bytes] type. Required. - :type origin_group_update_properties: ~azure.mgmt.cdn.models.AFDOriginGroupUpdateParameters or - IO[bytes] - :return: An instance of LROPoller that returns either AFDOriginGroup or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.AFDOriginGroup] - :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.AFDOriginGroup] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._update_initial( - resource_group_name=resource_group_name, - profile_name=profile_name, - origin_group_name=origin_group_name, - origin_group_update_properties=origin_group_update_properties, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("AFDOriginGroup", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.AFDOriginGroup].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.AFDOriginGroup]( - 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, origin_group_name: str, **kwargs: Any - ) -> None: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - origin_group_name=origin_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - 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 == 202: - response_headers["location"] = self._deserialize("str", response.headers.get("location")) - - if cls: - return cls(pipeline_response, None, response_headers) # type: ignore - - @distributed_trace - def begin_delete( - self, resource_group_name: str, profile_name: str, origin_group_name: str, **kwargs: Any - ) -> LROPoller[None]: - """Deletes an existing origin group within a 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. - :type profile_name: str - :param origin_group_name: Name of the origin group which is unique within the profile. - Required. - :type origin_group_name: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_initial( # type: ignore - resource_group_name=resource_group_name, - profile_name=profile_name, - origin_group_name=origin_group_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def list_resource_usage( - self, resource_group_name: str, profile_name: str, origin_group_name: str, **kwargs: Any - ) -> Iterable["_models.Usage"]: - """Checks the quota and actual usage of endpoints under the given Azure Front Door 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. - :type profile_name: str - :param origin_group_name: Name of the origin group which is unique within the endpoint. - Required. - :type origin_group_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] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - 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]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_resource_usage_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - origin_group_name=origin_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("UsagesListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) 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 deleted file mode 100644 index 72245c2a7c7f..000000000000 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_afd_origins_operations.py +++ /dev/null @@ -1,976 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models -from .._serialization import Serializer -from .._vendor import CdnManagementClientMixinABC, _convert_request - -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]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_origin_group_request( - resource_group_name: str, profile_name: str, origin_group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) - 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"), - "originGroupName": _SERIALIZER.url("origin_group_name", origin_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, - profile_name: str, - origin_group_name: str, - origin_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_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")) - 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"), - "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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_request( - resource_group_name: str, - profile_name: str, - origin_group_name: str, - origin_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_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")) - 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}/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"), - "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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_update_request( - resource_group_name: str, - profile_name: str, - origin_group_name: str, - origin_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_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")) - 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}/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"), - "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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, - profile_name: str, - origin_group_name: str, - origin_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_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")) - 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"), - "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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -class AFDOriginsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.cdn.CdnManagementClient`'s - :attr:`afd_origins` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_origin_group( - self, resource_group_name: str, profile_name: str, origin_group_name: str, **kwargs: Any - ) -> Iterable["_models.AFDOrigin"]: - """Lists all of the existing origins within an 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. - :type profile_name: str - :param origin_group_name: Name of the origin group which is unique within the profile. - Required. - :type origin_group_name: str - :return: An iterator like instance of either AFDOrigin or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cdn.models.AFDOrigin] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - 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]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_origin_group_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - origin_group_name=origin_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("AFDOriginListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get( - self, resource_group_name: str, profile_name: str, origin_group_name: str, origin_name: str, **kwargs: Any - ) -> _models.AFDOrigin: - """Gets an existing origin within an 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. - :type profile_name: str - :param origin_group_name: Name of the origin group which is unique within the profile. - Required. - :type origin_group_name: str - :param origin_name: Name of the origin which is unique within the profile. Required. - :type origin_name: str - :return: AFDOrigin or the result of cls(response) - :rtype: ~azure.mgmt.cdn.models.AFDOrigin - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.AFDOrigin] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - origin_group_name=origin_group_name, - origin_name=origin_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("AFDOrigin", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_initial( - self, - resource_group_name: str, - profile_name: str, - origin_group_name: str, - origin_name: str, - origin: Union[_models.AFDOrigin, IO[bytes]], - **kwargs: Any - ) -> _models.AFDOrigin: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_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.AFDOrigin] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(origin, (IOBase, bytes)): - _content = origin - else: - _json = self._serialize.body(origin, "AFDOrigin") - - _request = build_create_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - origin_group_name=origin_group_name, - origin_name=origin_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201, 202]: - 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) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create( - self, - resource_group_name: str, - profile_name: str, - origin_group_name: str, - origin_name: str, - origin: _models.AFDOrigin, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.AFDOrigin]: - """Creates a new origin within the specified 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. - :type profile_name: str - :param origin_group_name: Name of the origin group which is unique within the profile. - Required. - :type origin_group_name: str - :param origin_name: Name of the origin that is unique within the profile. Required. - :type origin_name: str - :param origin: Origin properties. Required. - :type origin: ~azure.mgmt.cdn.models.AFDOrigin - :keyword content_type: Body Parameter 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 AFDOrigin or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.AFDOrigin] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create( - self, - resource_group_name: str, - profile_name: str, - origin_group_name: str, - origin_name: str, - origin: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.AFDOrigin]: - """Creates a new origin within the specified 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. - :type profile_name: str - :param origin_group_name: Name of the origin group which is unique within the profile. - Required. - :type origin_group_name: str - :param origin_name: Name of the origin that is unique within the profile. Required. - :type origin_name: str - :param origin: Origin properties. Required. - :type origin: IO[bytes] - :keyword content_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 AFDOrigin or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.AFDOrigin] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create( - self, - resource_group_name: str, - profile_name: str, - origin_group_name: str, - origin_name: str, - origin: Union[_models.AFDOrigin, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.AFDOrigin]: - """Creates a new origin within the specified 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. - :type profile_name: str - :param origin_group_name: Name of the origin group which is unique within the profile. - Required. - :type origin_group_name: str - :param origin_name: Name of the origin that is unique within the profile. Required. - :type origin_name: str - :param origin: Origin properties. Is either a AFDOrigin type or a IO[bytes] type. Required. - :type origin: ~azure.mgmt.cdn.models.AFDOrigin or IO[bytes] - :return: An instance of LROPoller that returns either AFDOrigin or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.AFDOrigin] - :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.AFDOrigin] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._create_initial( - resource_group_name=resource_group_name, - profile_name=profile_name, - origin_group_name=origin_group_name, - origin_name=origin_name, - origin=origin, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("AFDOrigin", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.AFDOrigin].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.AFDOrigin]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _update_initial( - self, - resource_group_name: str, - profile_name: str, - origin_group_name: str, - origin_name: str, - origin_update_properties: Union[_models.AFDOriginUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> _models.AFDOrigin: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_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.AFDOrigin] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(origin_update_properties, (IOBase, bytes)): - _content = origin_update_properties - else: - _json = self._serialize.body(origin_update_properties, "AFDOriginUpdateParameters") - - _request = build_update_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - origin_group_name=origin_group_name, - origin_name=origin_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.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) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_update( - self, - resource_group_name: str, - profile_name: str, - origin_group_name: str, - origin_name: str, - origin_update_properties: _models.AFDOriginUpdateParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.AFDOrigin]: - """Updates an existing origin within an 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. - :type profile_name: str - :param origin_group_name: Name of the origin group which is unique within the profile. - Required. - :type origin_group_name: str - :param origin_name: Name of the origin which is unique within the profile. Required. - :type origin_name: str - :param origin_update_properties: Origin properties. Required. - :type origin_update_properties: ~azure.mgmt.cdn.models.AFDOriginUpdateParameters - :keyword content_type: Body Parameter 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 AFDOrigin or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.AFDOrigin] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - profile_name: str, - origin_group_name: str, - origin_name: str, - origin_update_properties: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.AFDOrigin]: - """Updates an existing origin within an 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. - :type profile_name: str - :param origin_group_name: Name of the origin group which is unique within the profile. - Required. - :type origin_group_name: str - :param origin_name: Name of the origin which is unique within the profile. Required. - :type origin_name: str - :param origin_update_properties: Origin properties. Required. - :type origin_update_properties: IO[bytes] - :keyword content_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 AFDOrigin or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.AFDOrigin] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update( - self, - resource_group_name: str, - profile_name: str, - origin_group_name: str, - origin_name: str, - origin_update_properties: Union[_models.AFDOriginUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.AFDOrigin]: - """Updates an existing origin within an 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. - :type profile_name: str - :param origin_group_name: Name of the origin group which is unique within the profile. - Required. - :type origin_group_name: str - :param origin_name: Name of the origin which is unique within the profile. Required. - :type origin_name: str - :param origin_update_properties: Origin properties. Is either a AFDOriginUpdateParameters type - or a IO[bytes] type. Required. - :type origin_update_properties: ~azure.mgmt.cdn.models.AFDOriginUpdateParameters or IO[bytes] - :return: An instance of LROPoller that returns either AFDOrigin or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.AFDOrigin] - :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.AFDOrigin] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._update_initial( - resource_group_name=resource_group_name, - profile_name=profile_name, - origin_group_name=origin_group_name, - origin_name=origin_name, - origin_update_properties=origin_update_properties, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("AFDOrigin", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.AFDOrigin].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.AFDOrigin]( - 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, origin_group_name: str, origin_name: str, **kwargs: Any - ) -> None: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - origin_group_name=origin_group_name, - origin_name=origin_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - 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 == 202: - response_headers["location"] = self._deserialize("str", response.headers.get("location")) - - if cls: - return cls(pipeline_response, None, response_headers) # type: ignore - - @distributed_trace - def begin_delete( - self, resource_group_name: str, profile_name: str, origin_group_name: str, origin_name: str, **kwargs: Any - ) -> LROPoller[None]: - """Deletes an existing origin within an 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. - :type profile_name: str - :param origin_group_name: Name of the origin group which is unique within the profile. - Required. - :type origin_group_name: str - :param origin_name: Name of the origin which is unique within the profile. Required. - :type origin_name: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_initial( # type: ignore - resource_group_name=resource_group_name, - profile_name=profile_name, - origin_group_name=origin_group_name, - origin_name=origin_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore 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 deleted file mode 100644 index fee3bbbd97ad..000000000000 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_afd_profiles_operations.py +++ /dev/null @@ -1,932 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models -from .._serialization import Serializer -from .._vendor import CdnManagementClientMixinABC, _convert_request - -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]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_check_endpoint_name_availability_request( # pylint: disable=name-too-long - 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", "2024-02-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/checkEndpointNameAvailability", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), - "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_list_resource_usage_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", "2024-02-01")) - 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"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # 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_check_host_name_availability_request( # pylint: disable=name-too-long - 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", "2024-02-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_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_validate_secret_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", "2024-02-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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\._\(\)]+$" - ), - "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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_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_upgrade_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", "2024-02-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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\._\(\)]+$" - ), - "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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -class AFDProfilesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.cdn.CdnManagementClient`'s - :attr:`afd_profiles` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @overload - def check_endpoint_name_availability( - self, - resource_group_name: str, - profile_name: str, - check_endpoint_name_availability_input: _models.CheckEndpointNameAvailabilityInput, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.CheckEndpointNameAvailabilityOutput: - """Check the availability of an afdx endpoint name, and return the globally unique endpoint host - name. - - :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 which is - unique within the resource group. Required. - :type profile_name: str - :param check_endpoint_name_availability_input: Input to check. Required. - :type check_endpoint_name_availability_input: - ~azure.mgmt.cdn.models.CheckEndpointNameAvailabilityInput - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: CheckEndpointNameAvailabilityOutput or the result of cls(response) - :rtype: ~azure.mgmt.cdn.models.CheckEndpointNameAvailabilityOutput - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def check_endpoint_name_availability( - self, - resource_group_name: str, - profile_name: str, - check_endpoint_name_availability_input: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.CheckEndpointNameAvailabilityOutput: - """Check the availability of an afdx endpoint name, and return the globally unique endpoint host - name. - - :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 which is - unique within the resource group. Required. - :type profile_name: str - :param check_endpoint_name_availability_input: Input to check. Required. - :type check_endpoint_name_availability_input: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: CheckEndpointNameAvailabilityOutput or the result of cls(response) - :rtype: ~azure.mgmt.cdn.models.CheckEndpointNameAvailabilityOutput - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def check_endpoint_name_availability( - self, - resource_group_name: str, - profile_name: str, - check_endpoint_name_availability_input: Union[_models.CheckEndpointNameAvailabilityInput, IO[bytes]], - **kwargs: Any - ) -> _models.CheckEndpointNameAvailabilityOutput: - """Check the availability of an afdx endpoint name, and return the globally unique endpoint host - name. - - :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 which is - unique within the resource group. Required. - :type profile_name: str - :param check_endpoint_name_availability_input: Input to check. Is either a - CheckEndpointNameAvailabilityInput type or a IO[bytes] type. Required. - :type check_endpoint_name_availability_input: - ~azure.mgmt.cdn.models.CheckEndpointNameAvailabilityInput or IO[bytes] - :return: CheckEndpointNameAvailabilityOutput or the result of cls(response) - :rtype: ~azure.mgmt.cdn.models.CheckEndpointNameAvailabilityOutput - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_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.CheckEndpointNameAvailabilityOutput] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(check_endpoint_name_availability_input, (IOBase, bytes)): - _content = check_endpoint_name_availability_input - else: - _json = self._serialize.body(check_endpoint_name_availability_input, "CheckEndpointNameAvailabilityInput") - - _request = build_check_endpoint_name_availability_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 = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("CheckEndpointNameAvailabilityOutput", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_resource_usage( - self, resource_group_name: str, profile_name: str, **kwargs: Any - ) -> Iterable["_models.Usage"]: - """Checks the quota and actual usage of endpoints under the given Azure Front Door 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. - :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] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - 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]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_resource_usage_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 = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("UsagesListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @overload - def check_host_name_availability( - self, - resource_group_name: str, - profile_name: str, - check_host_name_availability_input: _models.CheckHostNameAvailabilityInput, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.CheckNameAvailabilityOutput: - """Validates the custom domain mapping to ensure it maps to the correct Azure Front Door endpoint - in DNS. - - :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. - :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 - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: CheckNameAvailabilityOutput or the result of cls(response) - :rtype: ~azure.mgmt.cdn.models.CheckNameAvailabilityOutput - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def check_host_name_availability( - self, - resource_group_name: str, - profile_name: str, - check_host_name_availability_input: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.CheckNameAvailabilityOutput: - """Validates the custom domain mapping to ensure it maps to the correct Azure Front Door endpoint - in DNS. - - :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. - :type profile_name: str - :param check_host_name_availability_input: Custom domain to be validated. Required. - :type check_host_name_availability_input: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: CheckNameAvailabilityOutput or the result of cls(response) - :rtype: ~azure.mgmt.cdn.models.CheckNameAvailabilityOutput - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def check_host_name_availability( - self, - resource_group_name: str, - profile_name: str, - check_host_name_availability_input: Union[_models.CheckHostNameAvailabilityInput, IO[bytes]], - **kwargs: Any - ) -> _models.CheckNameAvailabilityOutput: - """Validates the custom domain mapping to ensure it maps to the correct Azure Front Door endpoint - in DNS. - - :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. - :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. - :type check_host_name_availability_input: ~azure.mgmt.cdn.models.CheckHostNameAvailabilityInput - or IO[bytes] - :return: CheckNameAvailabilityOutput or the result of cls(response) - :rtype: ~azure.mgmt.cdn.models.CheckNameAvailabilityOutput - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_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.CheckNameAvailabilityOutput] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(check_host_name_availability_input, (IOBase, bytes)): - _content = check_host_name_availability_input - else: - _json = self._serialize.body(check_host_name_availability_input, "CheckHostNameAvailabilityInput") - - _request = build_check_host_name_availability_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 = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("CheckNameAvailabilityOutput", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def validate_secret( - self, - resource_group_name: str, - profile_name: str, - validate_secret_input: _models.ValidateSecretInput, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ValidateSecretOutput: - """Validate a Secret in the 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 which is - unique within the resource group. Required. - :type profile_name: str - :param validate_secret_input: The Secret source. Required. - :type validate_secret_input: ~azure.mgmt.cdn.models.ValidateSecretInput - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: ValidateSecretOutput or the result of cls(response) - :rtype: ~azure.mgmt.cdn.models.ValidateSecretOutput - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def validate_secret( - self, - resource_group_name: str, - profile_name: str, - validate_secret_input: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ValidateSecretOutput: - """Validate a Secret in the 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 which is - unique within the resource group. Required. - :type profile_name: str - :param validate_secret_input: The Secret source. Required. - :type validate_secret_input: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: ValidateSecretOutput or the result of cls(response) - :rtype: ~azure.mgmt.cdn.models.ValidateSecretOutput - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def validate_secret( - self, - resource_group_name: str, - profile_name: str, - validate_secret_input: Union[_models.ValidateSecretInput, IO[bytes]], - **kwargs: Any - ) -> _models.ValidateSecretOutput: - """Validate a Secret in the 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 which is - unique within the resource group. Required. - :type profile_name: str - :param validate_secret_input: The Secret source. Is either a ValidateSecretInput type or a - IO[bytes] type. Required. - :type validate_secret_input: ~azure.mgmt.cdn.models.ValidateSecretInput or IO[bytes] - :return: ValidateSecretOutput or the result of cls(response) - :rtype: ~azure.mgmt.cdn.models.ValidateSecretOutput - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_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.ValidateSecretOutput] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(validate_secret_input, (IOBase, bytes)): - _content = validate_secret_input - else: - _json = self._serialize.body(validate_secret_input, "ValidateSecretInput") - - _request = build_validate_secret_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 = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ValidateSecretOutput", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _upgrade_initial( - self, - resource_group_name: str, - profile_name: str, - profile_upgrade_parameters: Union[_models.ProfileUpgradeParameters, IO[bytes]], - **kwargs: Any - ) -> _models.Profile: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_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.Profile] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(profile_upgrade_parameters, (IOBase, bytes)): - _content = profile_upgrade_parameters - else: - _json = self._serialize.body(profile_upgrade_parameters, "ProfileUpgradeParameters") - - _request = build_upgrade_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 = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.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) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_upgrade( - self, - resource_group_name: str, - profile_name: str, - profile_upgrade_parameters: _models.ProfileUpgradeParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Profile]: - """Upgrade a profile from Standard_AzureFrontDoor to Premium_AzureFrontDoor. - - :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 which is - unique within the resource group. Required. - :type profile_name: str - :param profile_upgrade_parameters: Profile upgrade input parameter. Required. - :type profile_upgrade_parameters: ~azure.mgmt.cdn.models.ProfileUpgradeParameters - :keyword content_type: Body Parameter 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 Profile or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Profile] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_upgrade( - self, - resource_group_name: str, - profile_name: str, - profile_upgrade_parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Profile]: - """Upgrade a profile from Standard_AzureFrontDoor to Premium_AzureFrontDoor. - - :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 which is - unique within the resource group. Required. - :type profile_name: str - :param profile_upgrade_parameters: Profile upgrade input parameter. Required. - :type profile_upgrade_parameters: IO[bytes] - :keyword content_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 Profile or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Profile] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_upgrade( - self, - resource_group_name: str, - profile_name: str, - profile_upgrade_parameters: Union[_models.ProfileUpgradeParameters, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.Profile]: - """Upgrade a profile from Standard_AzureFrontDoor to Premium_AzureFrontDoor. - - :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 which is - unique within the resource group. Required. - :type profile_name: str - :param profile_upgrade_parameters: Profile upgrade input parameter. Is either a - ProfileUpgradeParameters type or a IO[bytes] type. Required. - :type profile_upgrade_parameters: ~azure.mgmt.cdn.models.ProfileUpgradeParameters or IO[bytes] - :return: An instance of LROPoller that returns either Profile or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Profile] - :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.Profile] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._upgrade_initial( - resource_group_name=resource_group_name, - profile_name=profile_name, - profile_upgrade_parameters=profile_upgrade_parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Profile", pipeline_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.Profile].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Profile]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) 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 deleted file mode 100644 index 0040b37a9a66..000000000000 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_cdn_management_client_operations.py +++ /dev/null @@ -1,598 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, overload - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from .._serialization import Serializer -from .._vendor import CdnManagementClientMixinABC, _convert_request - -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]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_check_endpoint_name_availability_request( # pylint: disable=name-too-long - resource_group_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/checkEndpointNameAvailability", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -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")) - 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", "/providers/Microsoft.Cdn/checkNameAvailability") - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_check_name_availability_with_subscription_request( # pylint: disable=name-too-long - subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Cdn/checkNameAvailability") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_validate_probe_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")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Cdn/validateProbe") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -class CdnManagementClientOperationsMixin(CdnManagementClientMixinABC): - - @overload - def check_endpoint_name_availability( - self, - resource_group_name: str, - check_endpoint_name_availability_input: _models.CheckEndpointNameAvailabilityInput, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.CheckEndpointNameAvailabilityOutput: - """Check the availability of a resource name. This is needed for resources where name is globally - unique, such as a afdx endpoint. - - :param resource_group_name: Name of the Resource group within the Azure subscription. Required. - :type resource_group_name: str - :param check_endpoint_name_availability_input: Input to check. Required. - :type check_endpoint_name_availability_input: - ~azure.mgmt.cdn.models.CheckEndpointNameAvailabilityInput - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: CheckEndpointNameAvailabilityOutput or the result of cls(response) - :rtype: ~azure.mgmt.cdn.models.CheckEndpointNameAvailabilityOutput - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def check_endpoint_name_availability( - self, - resource_group_name: str, - check_endpoint_name_availability_input: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.CheckEndpointNameAvailabilityOutput: - """Check the availability of a resource name. This is needed for resources where name is globally - unique, such as a afdx endpoint. - - :param resource_group_name: Name of the Resource group within the Azure subscription. Required. - :type resource_group_name: str - :param check_endpoint_name_availability_input: Input to check. Required. - :type check_endpoint_name_availability_input: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: CheckEndpointNameAvailabilityOutput or the result of cls(response) - :rtype: ~azure.mgmt.cdn.models.CheckEndpointNameAvailabilityOutput - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def check_endpoint_name_availability( - self, - resource_group_name: str, - check_endpoint_name_availability_input: Union[_models.CheckEndpointNameAvailabilityInput, IO[bytes]], - **kwargs: Any - ) -> _models.CheckEndpointNameAvailabilityOutput: - """Check the availability of a resource name. This is needed for resources where name is globally - unique, such as a afdx endpoint. - - :param resource_group_name: Name of the Resource group within the Azure subscription. Required. - :type resource_group_name: str - :param check_endpoint_name_availability_input: Input to check. Is either a - CheckEndpointNameAvailabilityInput type or a IO[bytes] type. Required. - :type check_endpoint_name_availability_input: - ~azure.mgmt.cdn.models.CheckEndpointNameAvailabilityInput or IO[bytes] - :return: CheckEndpointNameAvailabilityOutput or the result of cls(response) - :rtype: ~azure.mgmt.cdn.models.CheckEndpointNameAvailabilityOutput - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_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.CheckEndpointNameAvailabilityOutput] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(check_endpoint_name_availability_input, (IOBase, bytes)): - _content = check_endpoint_name_availability_input - else: - _json = self._serialize.body(check_endpoint_name_availability_input, "CheckEndpointNameAvailabilityInput") - - _request = build_check_endpoint_name_availability_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("CheckEndpointNameAvailabilityOutput", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def check_name_availability( - self, - check_name_availability_input: _models.CheckNameAvailabilityInput, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.CheckNameAvailabilityOutput: - """Check the availability of a resource name. This is needed for resources where name is globally - unique, such as a CDN endpoint. - - :param check_name_availability_input: Input to check. Required. - :type check_name_availability_input: ~azure.mgmt.cdn.models.CheckNameAvailabilityInput - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: CheckNameAvailabilityOutput or the result of cls(response) - :rtype: ~azure.mgmt.cdn.models.CheckNameAvailabilityOutput - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def check_name_availability( - self, check_name_availability_input: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.CheckNameAvailabilityOutput: - """Check the availability of a resource name. This is needed for resources where name is globally - unique, such as a CDN endpoint. - - :param check_name_availability_input: Input to check. Required. - :type check_name_availability_input: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: CheckNameAvailabilityOutput or the result of cls(response) - :rtype: ~azure.mgmt.cdn.models.CheckNameAvailabilityOutput - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def check_name_availability( - self, check_name_availability_input: Union[_models.CheckNameAvailabilityInput, IO[bytes]], **kwargs: Any - ) -> _models.CheckNameAvailabilityOutput: - """Check the availability of a resource name. This is needed for resources where name is globally - unique, such as a CDN endpoint. - - :param check_name_availability_input: Input to check. Is either a CheckNameAvailabilityInput - type or a IO[bytes] type. Required. - :type check_name_availability_input: ~azure.mgmt.cdn.models.CheckNameAvailabilityInput or - IO[bytes] - :return: CheckNameAvailabilityOutput or the result of cls(response) - :rtype: ~azure.mgmt.cdn.models.CheckNameAvailabilityOutput - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_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.CheckNameAvailabilityOutput] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(check_name_availability_input, (IOBase, bytes)): - _content = check_name_availability_input - else: - _json = self._serialize.body(check_name_availability_input, "CheckNameAvailabilityInput") - - _request = build_check_name_availability_request( - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("CheckNameAvailabilityOutput", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def check_name_availability_with_subscription( # pylint: disable=name-too-long - self, - check_name_availability_input: _models.CheckNameAvailabilityInput, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.CheckNameAvailabilityOutput: - """Check the availability of a resource name. This is needed for resources where name is globally - unique, such as a CDN endpoint. - - :param check_name_availability_input: Input to check. Required. - :type check_name_availability_input: ~azure.mgmt.cdn.models.CheckNameAvailabilityInput - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: CheckNameAvailabilityOutput or the result of cls(response) - :rtype: ~azure.mgmt.cdn.models.CheckNameAvailabilityOutput - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def check_name_availability_with_subscription( # pylint: disable=name-too-long - self, check_name_availability_input: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.CheckNameAvailabilityOutput: - """Check the availability of a resource name. This is needed for resources where name is globally - unique, such as a CDN endpoint. - - :param check_name_availability_input: Input to check. Required. - :type check_name_availability_input: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: CheckNameAvailabilityOutput or the result of cls(response) - :rtype: ~azure.mgmt.cdn.models.CheckNameAvailabilityOutput - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def check_name_availability_with_subscription( # pylint: disable=name-too-long - self, check_name_availability_input: Union[_models.CheckNameAvailabilityInput, IO[bytes]], **kwargs: Any - ) -> _models.CheckNameAvailabilityOutput: - """Check the availability of a resource name. This is needed for resources where name is globally - unique, such as a CDN endpoint. - - :param check_name_availability_input: Input to check. Is either a CheckNameAvailabilityInput - type or a IO[bytes] type. Required. - :type check_name_availability_input: ~azure.mgmt.cdn.models.CheckNameAvailabilityInput or - IO[bytes] - :return: CheckNameAvailabilityOutput or the result of cls(response) - :rtype: ~azure.mgmt.cdn.models.CheckNameAvailabilityOutput - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_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.CheckNameAvailabilityOutput] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(check_name_availability_input, (IOBase, bytes)): - _content = check_name_availability_input - else: - _json = self._serialize.body(check_name_availability_input, "CheckNameAvailabilityInput") - - _request = build_check_name_availability_with_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("CheckNameAvailabilityOutput", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def validate_probe( - self, validate_probe_input: _models.ValidateProbeInput, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.ValidateProbeOutput: - """Check if the probe path is a valid path and the file can be accessed. Probe path is the path to - a file hosted on the origin server to help accelerate the delivery of dynamic content via the - CDN endpoint. This path is relative to the origin path specified in the endpoint configuration. - - :param validate_probe_input: Input to check. Required. - :type validate_probe_input: ~azure.mgmt.cdn.models.ValidateProbeInput - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: ValidateProbeOutput or the result of cls(response) - :rtype: ~azure.mgmt.cdn.models.ValidateProbeOutput - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def validate_probe( - self, validate_probe_input: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.ValidateProbeOutput: - """Check if the probe path is a valid path and the file can be accessed. Probe path is the path to - a file hosted on the origin server to help accelerate the delivery of dynamic content via the - CDN endpoint. This path is relative to the origin path specified in the endpoint configuration. - - :param validate_probe_input: Input to check. Required. - :type validate_probe_input: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: ValidateProbeOutput or the result of cls(response) - :rtype: ~azure.mgmt.cdn.models.ValidateProbeOutput - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def validate_probe( - self, validate_probe_input: Union[_models.ValidateProbeInput, IO[bytes]], **kwargs: Any - ) -> _models.ValidateProbeOutput: - """Check if the probe path is a valid path and the file can be accessed. Probe path is the path to - a file hosted on the origin server to help accelerate the delivery of dynamic content via the - CDN endpoint. This path is relative to the origin path specified in the endpoint configuration. - - :param validate_probe_input: Input to check. Is either a ValidateProbeInput type or a IO[bytes] - type. Required. - :type validate_probe_input: ~azure.mgmt.cdn.models.ValidateProbeInput or IO[bytes] - :return: ValidateProbeOutput or the result of cls(response) - :rtype: ~azure.mgmt.cdn.models.ValidateProbeOutput - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_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.ValidateProbeOutput] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(validate_probe_input, (IOBase, bytes)): - _content = validate_probe_input - else: - _json = self._serialize.body(validate_probe_input, "ValidateProbeInput") - - _request = build_validate_probe_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ValidateProbeOutput", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return 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 deleted file mode 100644 index 54de16bb9e4c..000000000000 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_custom_domains_operations.py +++ /dev/null @@ -1,1163 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models -from .._serialization import Serializer -from .._vendor import CdnManagementClientMixinABC, _convert_request - -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]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_endpoint_request( - resource_group_name: str, profile_name: str, endpoint_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) - 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\._\(\)]+$" - ), - "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), - "endpointName": _SERIALIZER.url("endpoint_name", endpoint_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, - profile_name: str, - endpoint_name: str, - custom_domain_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_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")) - 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\._\(\)]+$" - ), - "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), - "endpointName": _SERIALIZER.url("endpoint_name", endpoint_name, "str"), - "customDomainName": _SERIALIZER.url("custom_domain_name", custom_domain_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_request( - resource_group_name: str, - profile_name: str, - endpoint_name: str, - custom_domain_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_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")) - 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}/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\._\(\)]+$" - ), - "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), - "endpointName": _SERIALIZER.url("endpoint_name", endpoint_name, "str"), - "customDomainName": _SERIALIZER.url("custom_domain_name", custom_domain_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, - profile_name: str, - endpoint_name: str, - custom_domain_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_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")) - 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\._\(\)]+$" - ), - "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), - "endpointName": _SERIALIZER.url("endpoint_name", endpoint_name, "str"), - "customDomainName": _SERIALIZER.url("custom_domain_name", custom_domain_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_disable_custom_https_request( - resource_group_name: str, - profile_name: str, - endpoint_name: str, - custom_domain_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_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")) - 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\._\(\)]+$" - ), - "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), - "endpointName": _SERIALIZER.url("endpoint_name", endpoint_name, "str"), - "customDomainName": _SERIALIZER.url("custom_domain_name", custom_domain_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # 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_enable_custom_https_request( - resource_group_name: str, - profile_name: str, - endpoint_name: str, - custom_domain_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_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")) - 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}/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\._\(\)]+$" - ), - "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), - "endpointName": _SERIALIZER.url("endpoint_name", endpoint_name, "str"), - "customDomainName": _SERIALIZER.url("custom_domain_name", custom_domain_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -class CustomDomainsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.cdn.CdnManagementClient`'s - :attr:`custom_domains` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_endpoint( - self, resource_group_name: str, profile_name: str, endpoint_name: str, **kwargs: Any - ) -> Iterable["_models.CustomDomain"]: - """Lists all of the existing custom domains within an 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 CDN profile 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. - :type endpoint_name: str - :return: An iterator like instance of either CustomDomain or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cdn.models.CustomDomain] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - 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]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_endpoint_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("CustomDomainListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get( - self, resource_group_name: str, profile_name: str, endpoint_name: str, custom_domain_name: str, **kwargs: Any - ) -> _models.CustomDomain: - """Gets an existing custom domain within an 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 CDN profile 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. - :type endpoint_name: str - :param custom_domain_name: Name of the custom domain within an endpoint. Required. - :type custom_domain_name: str - :return: CustomDomain or the result of cls(response) - :rtype: ~azure.mgmt.cdn.models.CustomDomain - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_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) - - _request = build_get_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - custom_domain_name=custom_domain_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("CustomDomain", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_initial( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - custom_domain_name: str, - custom_domain_properties: Union[_models.CustomDomainParameters, IO[bytes]], - **kwargs: Any - ) -> _models.CustomDomain: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_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.CustomDomain] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(custom_domain_properties, (IOBase, bytes)): - _content = custom_domain_properties - else: - _json = self._serialize.body(custom_domain_properties, "CustomDomainParameters") - - _request = build_create_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - custom_domain_name=custom_domain_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - 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) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - custom_domain_name: str, - custom_domain_properties: _models.CustomDomainParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.CustomDomain]: - """Creates a new custom domain within an 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 CDN profile 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. - :type endpoint_name: str - :param custom_domain_name: Name of the custom domain within an endpoint. Required. - :type custom_domain_name: str - :param custom_domain_properties: Properties required to create a new custom domain. Required. - :type custom_domain_properties: ~azure.mgmt.cdn.models.CustomDomainParameters - :keyword content_type: Body Parameter 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 CustomDomain or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.CustomDomain] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - custom_domain_name: str, - custom_domain_properties: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.CustomDomain]: - """Creates a new custom domain within an 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 CDN profile 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. - :type endpoint_name: str - :param custom_domain_name: Name of the custom domain within an endpoint. Required. - :type custom_domain_name: str - :param custom_domain_properties: Properties required to create a new custom domain. Required. - :type custom_domain_properties: IO[bytes] - :keyword content_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 CustomDomain or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.CustomDomain] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - custom_domain_name: str, - custom_domain_properties: Union[_models.CustomDomainParameters, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.CustomDomain]: - """Creates a new custom domain within an 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 CDN profile 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. - :type endpoint_name: str - :param custom_domain_name: Name of the custom domain within an endpoint. Required. - :type custom_domain_name: str - :param custom_domain_properties: Properties required to create a new custom domain. Is either a - CustomDomainParameters type or a IO[bytes] type. Required. - :type custom_domain_properties: ~azure.mgmt.cdn.models.CustomDomainParameters or IO[bytes] - :return: An instance of LROPoller that returns either CustomDomain or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.CustomDomain] - :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.CustomDomain] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._create_initial( - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - custom_domain_name=custom_domain_name, - custom_domain_properties=custom_domain_properties, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("CustomDomain", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.CustomDomain].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.CustomDomain]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - 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]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = 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) - - _request = build_delete_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - custom_domain_name=custom_domain_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - map_error(status_code=response.status_code, 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) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_delete( - self, resource_group_name: str, profile_name: str, endpoint_name: str, custom_domain_name: str, **kwargs: Any - ) -> LROPoller[_models.CustomDomain]: - """Deletes an existing custom domain within an 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 CDN profile 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. - :type endpoint_name: str - :param custom_domain_name: Name of the custom domain within an endpoint. Required. - :type custom_domain_name: str - :return: An instance of LROPoller that returns either CustomDomain or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.CustomDomain] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_initial( - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - custom_domain_name=custom_domain_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - response_headers = {} - response = pipeline_response.http_response - response_headers["location"] = self._deserialize("str", response.headers.get("location")) - - deserialized = self._deserialize("CustomDomain", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.CustomDomain].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.CustomDomain]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - 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]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_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) - - _request = build_disable_custom_https_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - custom_domain_name=custom_domain_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - 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) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_disable_custom_https( - self, resource_group_name: str, profile_name: str, endpoint_name: str, custom_domain_name: str, **kwargs: Any - ) -> LROPoller[_models.CustomDomain]: - """Disable https delivery of the 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 CDN profile 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. - :type endpoint_name: str - :param custom_domain_name: Name of the custom domain within an endpoint. Required. - :type custom_domain_name: str - :return: An instance of LROPoller that returns either CustomDomain or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.CustomDomain] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_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) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._disable_custom_https_initial( - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - custom_domain_name=custom_domain_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("CustomDomain", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.CustomDomain].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.CustomDomain]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _enable_custom_https_initial( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - 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]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_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.CustomDomain] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(custom_domain_https_parameters, (IOBase, bytes)): - _content = custom_domain_https_parameters - else: - if custom_domain_https_parameters is not None: - _json = self._serialize.body(custom_domain_https_parameters, "CustomDomainHttpsParameters") - else: - _json = None - - _request = build_enable_custom_https_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - custom_domain_name=custom_domain_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - 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) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_enable_custom_https( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - custom_domain_name: str, - custom_domain_https_parameters: Optional[_models.CustomDomainHttpsParameters] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.CustomDomain]: - """Enable https delivery of the 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 CDN profile 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. - :type endpoint_name: str - :param custom_domain_name: Name of the custom domain within an endpoint. Required. - :type custom_domain_name: str - :param custom_domain_https_parameters: The configuration specifying how to enable HTTPS for the - custom domain - using CDN managed certificate or user's own certificate. If not specified, - enabling ssl uses CDN managed certificate by default. Default value is None. - :type custom_domain_https_parameters: ~azure.mgmt.cdn.models.CustomDomainHttpsParameters - :keyword content_type: Body Parameter 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 CustomDomain or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.CustomDomain] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_enable_custom_https( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - custom_domain_name: str, - custom_domain_https_parameters: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.CustomDomain]: - """Enable https delivery of the 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 CDN profile 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. - :type endpoint_name: str - :param custom_domain_name: Name of the custom domain within an endpoint. Required. - :type custom_domain_name: str - :param custom_domain_https_parameters: The configuration specifying how to enable HTTPS for the - custom domain - using CDN managed certificate or user's own certificate. If not specified, - enabling ssl uses CDN managed certificate by default. Default value is None. - :type custom_domain_https_parameters: IO[bytes] - :keyword content_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 CustomDomain or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.CustomDomain] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_enable_custom_https( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - custom_domain_name: str, - custom_domain_https_parameters: Optional[Union[_models.CustomDomainHttpsParameters, IO[bytes]]] = None, - **kwargs: Any - ) -> LROPoller[_models.CustomDomain]: - """Enable https delivery of the 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 CDN profile 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. - :type endpoint_name: str - :param custom_domain_name: Name of the custom domain within an endpoint. Required. - :type custom_domain_name: str - :param custom_domain_https_parameters: The configuration specifying how to enable HTTPS for the - custom domain - using CDN managed certificate or user's own certificate. If not specified, - enabling ssl uses CDN managed certificate by default. Is either a CustomDomainHttpsParameters - type or a IO[bytes] type. Default value is None. - :type custom_domain_https_parameters: ~azure.mgmt.cdn.models.CustomDomainHttpsParameters or - IO[bytes] - :return: An instance of LROPoller that returns either CustomDomain or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.CustomDomain] - :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.CustomDomain] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._enable_custom_https_initial( - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - custom_domain_name=custom_domain_name, - custom_domain_https_parameters=custom_domain_https_parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("CustomDomain", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.CustomDomain].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.CustomDomain]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) 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 deleted file mode 100644 index ac995df5bfcd..000000000000 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_edge_nodes_operations.py +++ /dev/null @@ -1,157 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from .._serialization import Serializer -from .._vendor import CdnManagementClientMixinABC, _convert_request - -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]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -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")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Cdn/edgenodes") - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class EdgeNodesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.cdn.CdnManagementClient`'s - :attr:`edge_nodes` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list(self, **kwargs: Any) -> Iterable["_models.EdgeNode"]: - """Edgenodes are the global Point of Presence (POP) locations used to deliver CDN content to end - users. - - :return: An iterator like instance of either EdgeNode or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cdn.models.EdgeNode] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - 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]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("EdgenodeResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_endpoints_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_endpoints_operations.py deleted file mode 100644 index 28c4bba440d6..000000000000 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_endpoints_operations.py +++ /dev/null @@ -1,2005 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models -from .._serialization import Serializer -from .._vendor import CdnManagementClientMixinABC, _convert_request - -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]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_profile_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", "2024-02-01")) - 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\._\(\)]+$" - ), - "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, profile_name: str, endpoint_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) - 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\._\(\)]+$" - ), - "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), - "endpointName": _SERIALIZER.url("endpoint_name", endpoint_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_request( - resource_group_name: str, profile_name: str, endpoint_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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\._\(\)]+$" - ), - "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), - "endpointName": _SERIALIZER.url("endpoint_name", endpoint_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_update_request( - resource_group_name: str, profile_name: str, endpoint_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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\._\(\)]+$" - ), - "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), - "endpointName": _SERIALIZER.url("endpoint_name", endpoint_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, profile_name: str, endpoint_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) - 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\._\(\)]+$" - ), - "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), - "endpointName": _SERIALIZER.url("endpoint_name", endpoint_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_start_request( - resource_group_name: str, profile_name: str, endpoint_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) - 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\._\(\)]+$" - ), - "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), - "endpointName": _SERIALIZER.url("endpoint_name", endpoint_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_stop_request( - resource_group_name: str, profile_name: str, endpoint_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) - 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\._\(\)]+$" - ), - "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), - "endpointName": _SERIALIZER.url("endpoint_name", endpoint_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_purge_content_request( - resource_group_name: str, profile_name: str, endpoint_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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\._\(\)]+$" - ), - "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), - "endpointName": _SERIALIZER.url("endpoint_name", endpoint_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_load_content_request( - resource_group_name: str, profile_name: str, endpoint_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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\._\(\)]+$" - ), - "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), - "endpointName": _SERIALIZER.url("endpoint_name", endpoint_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_validate_custom_domain_request( - resource_group_name: str, profile_name: str, endpoint_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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\._\(\)]+$" - ), - "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), - "endpointName": _SERIALIZER.url("endpoint_name", endpoint_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_resource_usage_request( - resource_group_name: str, profile_name: str, endpoint_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) - 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\._\(\)]+$" - ), - "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), - "endpointName": _SERIALIZER.url("endpoint_name", endpoint_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -class EndpointsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.cdn.CdnManagementClient`'s - :attr:`endpoints` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_profile( - self, resource_group_name: str, profile_name: str, **kwargs: Any - ) -> Iterable["_models.Endpoint"]: - """Lists existing CDN endpoints. - - :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 CDN profile which is unique within the resource group. - Required. - :type profile_name: str - :return: An iterator like instance of either Endpoint or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cdn.models.Endpoint] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - 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]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_profile_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 = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("EndpointListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get(self, resource_group_name: str, profile_name: str, endpoint_name: str, **kwargs: Any) -> _models.Endpoint: - """Gets an existing CDN endpoint with the specified endpoint name under the specified - subscription, resource group and 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 CDN profile 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. - :type endpoint_name: str - :return: Endpoint or the result of cls(response) - :rtype: ~azure.mgmt.cdn.models.Endpoint - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_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) - - _request = build_get_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Endpoint", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_initial( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - endpoint: Union[_models.Endpoint, IO[bytes]], - **kwargs: Any - ) -> _models.Endpoint: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_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.Endpoint] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(endpoint, (IOBase, bytes)): - _content = endpoint - else: - _json = self._serialize.body(endpoint, "Endpoint") - - _request = build_create_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - 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) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - endpoint: _models.Endpoint, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Endpoint]: - """Creates a new CDN endpoint with the specified endpoint name under the specified subscription, - resource group and 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 CDN profile 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. - :type endpoint_name: str - :param endpoint: Endpoint properties. Required. - :type endpoint: ~azure.mgmt.cdn.models.Endpoint - :keyword content_type: Body Parameter 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 Endpoint or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Endpoint] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - endpoint: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Endpoint]: - """Creates a new CDN endpoint with the specified endpoint name under the specified subscription, - resource group and 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 CDN profile 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. - :type endpoint_name: str - :param endpoint: Endpoint properties. Required. - :type endpoint: IO[bytes] - :keyword content_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 Endpoint or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Endpoint] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - endpoint: Union[_models.Endpoint, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.Endpoint]: - """Creates a new CDN endpoint with the specified endpoint name under the specified subscription, - resource group and 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 CDN profile 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. - :type endpoint_name: str - :param endpoint: Endpoint properties. Is either a Endpoint type or a IO[bytes] type. Required. - :type endpoint: ~azure.mgmt.cdn.models.Endpoint or IO[bytes] - :return: An instance of LROPoller that returns either Endpoint or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Endpoint] - :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.Endpoint] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._create_initial( - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - endpoint=endpoint, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Endpoint", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.Endpoint].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Endpoint]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _update_initial( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - endpoint_update_properties: Union[_models.EndpointUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> _models.Endpoint: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_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.Endpoint] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(endpoint_update_properties, (IOBase, bytes)): - _content = endpoint_update_properties - else: - _json = self._serialize.body(endpoint_update_properties, "EndpointUpdateParameters") - - _request = build_update_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - 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) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_update( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - endpoint_update_properties: _models.EndpointUpdateParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Endpoint]: - """Updates an existing CDN endpoint with the specified endpoint name under the specified - subscription, resource group and profile. Only tags can be updated after creating an endpoint. - To update origins, use the Update Origin operation. To update origin groups, use the Update - Origin group operation. To update custom domains, use the Update Custom Domain operation. - - :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 CDN profile 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. - :type endpoint_name: str - :param endpoint_update_properties: Endpoint update properties. Required. - :type endpoint_update_properties: ~azure.mgmt.cdn.models.EndpointUpdateParameters - :keyword content_type: Body Parameter 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 Endpoint or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Endpoint] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - endpoint_update_properties: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Endpoint]: - """Updates an existing CDN endpoint with the specified endpoint name under the specified - subscription, resource group and profile. Only tags can be updated after creating an endpoint. - To update origins, use the Update Origin operation. To update origin groups, use the Update - Origin group operation. To update custom domains, use the Update Custom Domain operation. - - :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 CDN profile 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. - :type endpoint_name: str - :param endpoint_update_properties: Endpoint update properties. Required. - :type endpoint_update_properties: IO[bytes] - :keyword content_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 Endpoint or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Endpoint] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - endpoint_update_properties: Union[_models.EndpointUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.Endpoint]: - """Updates an existing CDN endpoint with the specified endpoint name under the specified - subscription, resource group and profile. Only tags can be updated after creating an endpoint. - To update origins, use the Update Origin operation. To update origin groups, use the Update - Origin group operation. To update custom domains, use the Update Custom Domain operation. - - :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 CDN profile 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. - :type endpoint_name: str - :param endpoint_update_properties: Endpoint update properties. Is either a - EndpointUpdateParameters type or a IO[bytes] type. Required. - :type endpoint_update_properties: ~azure.mgmt.cdn.models.EndpointUpdateParameters or IO[bytes] - :return: An instance of LROPoller that returns either Endpoint or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Endpoint] - :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.Endpoint] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._update_initial( - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - endpoint_update_properties=endpoint_update_properties, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Endpoint", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.Endpoint].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Endpoint]( - 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, endpoint_name: str, **kwargs: Any - ) -> None: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["location"] = self._deserialize("str", response.headers.get("location")) - - if cls: - return cls(pipeline_response, None, response_headers) # type: ignore - - @distributed_trace - def begin_delete( - self, resource_group_name: str, profile_name: str, endpoint_name: str, **kwargs: Any - ) -> LROPoller[None]: - """Deletes an existing CDN endpoint with the specified endpoint name under the specified - subscription, resource group and 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 CDN profile 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. - :type endpoint_name: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_initial( # type: ignore - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _start_initial( - self, resource_group_name: str, profile_name: str, endpoint_name: str, **kwargs: Any - ) -> _models.Endpoint: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_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) - - _request = build_start_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - 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) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_start( - self, resource_group_name: str, profile_name: str, endpoint_name: str, **kwargs: Any - ) -> LROPoller[_models.Endpoint]: - """Starts an existing CDN endpoint that is on a stopped state. - - :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 CDN profile 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. - :type endpoint_name: str - :return: An instance of LROPoller that returns either Endpoint or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Endpoint] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_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) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._start_initial( - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Endpoint", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.Endpoint].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Endpoint]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _stop_initial( - self, resource_group_name: str, profile_name: str, endpoint_name: str, **kwargs: Any - ) -> _models.Endpoint: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_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) - - _request = build_stop_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - 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) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_stop( - self, resource_group_name: str, profile_name: str, endpoint_name: str, **kwargs: Any - ) -> LROPoller[_models.Endpoint]: - """Stops an existing running CDN 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 CDN profile 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. - :type endpoint_name: str - :return: An instance of LROPoller that returns either Endpoint or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Endpoint] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_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) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._stop_initial( - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Endpoint", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.Endpoint].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Endpoint]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _purge_content_initial( # pylint: disable=inconsistent-return-statements - 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]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(content_file_paths, (IOBase, bytes)): - _content = content_file_paths - else: - _json = self._serialize.body(content_file_paths, "PurgeParameters") - - _request = build_purge_content_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["location"] = self._deserialize("str", response.headers.get("location")) - - if cls: - return cls(pipeline_response, None, response_headers) # type: ignore - - @overload - def begin_purge_content( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - content_file_paths: _models.PurgeParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Removes a content from CDN. - - :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 CDN profile 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. - :type endpoint_name: str - :param content_file_paths: The path to the content to be purged. Path can be a full URL, e.g. - '/pictures/city.png' which removes a single file, or a directory with a wildcard, e.g. - '/pictures/*' which removes all folders and files in the directory. Required. - :type content_file_paths: ~azure.mgmt.cdn.models.PurgeParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_purge_content( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - content_file_paths: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Removes a content from CDN. - - :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 CDN profile 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. - :type endpoint_name: str - :param content_file_paths: The path to the content to be purged. Path can be a full URL, e.g. - '/pictures/city.png' which removes a single file, or a directory with a wildcard, e.g. - '/pictures/*' which removes all folders and files in the directory. Required. - :type content_file_paths: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_purge_content( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - content_file_paths: Union[_models.PurgeParameters, IO[bytes]], - **kwargs: Any - ) -> LROPoller[None]: - """Removes a content from CDN. - - :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 CDN profile 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. - :type endpoint_name: str - :param content_file_paths: The path to the content to be purged. Path can be a full URL, e.g. - '/pictures/city.png' which removes a single file, or a directory with a wildcard, e.g. - '/pictures/*' which removes all folders and files in the directory. Is either a PurgeParameters - type or a IO[bytes] type. Required. - :type content_file_paths: ~azure.mgmt.cdn.models.PurgeParameters or IO[bytes] - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._purge_content_initial( # type: ignore - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - content_file_paths=content_file_paths, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _load_content_initial( # pylint: disable=inconsistent-return-statements - 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]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(content_file_paths, (IOBase, bytes)): - _content = content_file_paths - else: - _json = self._serialize.body(content_file_paths, "LoadParameters") - - _request = build_load_content_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["location"] = self._deserialize("str", response.headers.get("location")) - - if cls: - return cls(pipeline_response, None, response_headers) # type: ignore - - @overload - def begin_load_content( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - content_file_paths: _models.LoadParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Pre-loads a content to CDN. Available for Verizon Profiles. - - :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 CDN profile 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. - :type endpoint_name: str - :param content_file_paths: The path to the content to be loaded. Path should be a full URL, - e.g. ‘/pictures/city.png' which loads a single file. Required. - :type content_file_paths: ~azure.mgmt.cdn.models.LoadParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_load_content( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - content_file_paths: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[None]: - """Pre-loads a content to CDN. Available for Verizon Profiles. - - :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 CDN profile 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. - :type endpoint_name: str - :param content_file_paths: The path to the content to be loaded. Path should be a full URL, - e.g. ‘/pictures/city.png' which loads a single file. Required. - :type content_file_paths: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_load_content( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - content_file_paths: Union[_models.LoadParameters, IO[bytes]], - **kwargs: Any - ) -> LROPoller[None]: - """Pre-loads a content to CDN. Available for Verizon Profiles. - - :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 CDN profile 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. - :type endpoint_name: str - :param content_file_paths: The path to the content to be loaded. Path should be a full URL, - e.g. ‘/pictures/city.png' which loads a single file. Is either a LoadParameters type or a - IO[bytes] type. Required. - :type content_file_paths: ~azure.mgmt.cdn.models.LoadParameters or IO[bytes] - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._load_content_initial( # type: ignore - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - content_file_paths=content_file_paths, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @overload - def validate_custom_domain( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - custom_domain_properties: _models.ValidateCustomDomainInput, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ValidateCustomDomainOutput: - """Validates the custom domain mapping to ensure it maps to the correct CDN endpoint in DNS. - - :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 CDN profile 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. - :type endpoint_name: str - :param custom_domain_properties: Custom domain to be validated. Required. - :type custom_domain_properties: ~azure.mgmt.cdn.models.ValidateCustomDomainInput - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: ValidateCustomDomainOutput or the result of cls(response) - :rtype: ~azure.mgmt.cdn.models.ValidateCustomDomainOutput - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def validate_custom_domain( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - custom_domain_properties: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ValidateCustomDomainOutput: - """Validates the custom domain mapping to ensure it maps to the correct CDN endpoint in DNS. - - :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 CDN profile 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. - :type endpoint_name: str - :param custom_domain_properties: Custom domain to be validated. Required. - :type custom_domain_properties: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: ValidateCustomDomainOutput or the result of cls(response) - :rtype: ~azure.mgmt.cdn.models.ValidateCustomDomainOutput - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def validate_custom_domain( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - custom_domain_properties: Union[_models.ValidateCustomDomainInput, IO[bytes]], - **kwargs: Any - ) -> _models.ValidateCustomDomainOutput: - """Validates the custom domain mapping to ensure it maps to the correct CDN endpoint in DNS. - - :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 CDN profile 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. - :type endpoint_name: str - :param custom_domain_properties: Custom domain to be validated. Is either a - ValidateCustomDomainInput type or a IO[bytes] type. Required. - :type custom_domain_properties: ~azure.mgmt.cdn.models.ValidateCustomDomainInput or IO[bytes] - :return: ValidateCustomDomainOutput or the result of cls(response) - :rtype: ~azure.mgmt.cdn.models.ValidateCustomDomainOutput - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_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.ValidateCustomDomainOutput] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(custom_domain_properties, (IOBase, bytes)): - _content = custom_domain_properties - else: - _json = self._serialize.body(custom_domain_properties, "ValidateCustomDomainInput") - - _request = build_validate_custom_domain_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ValidateCustomDomainOutput", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_resource_usage( - self, resource_group_name: str, profile_name: str, endpoint_name: str, **kwargs: Any - ) -> Iterable["_models.ResourceUsage"]: - """Checks the quota and usage of geo filters and custom domains under the given 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 CDN profile 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. - :type endpoint_name: str - :return: An iterator like instance of either ResourceUsage or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cdn.models.ResourceUsage] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - 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]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_resource_usage_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ResourceUsageListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) diff --git a/sdk/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 deleted file mode 100644 index da8ececd9538..000000000000 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_log_analytics_operations.py +++ /dev/null @@ -1,829 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for 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 datetime -import sys -from typing import Any, Callable, Dict, List, Optional, Type, TypeVar, Union - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from .._serialization import Serializer -from .._vendor import CdnManagementClientMixinABC, _convert_request - -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]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_log_analytics_metrics_request( - resource_group_name: str, - profile_name: str, - subscription_id: str, - *, - metrics: List[Union[str, _models.LogMetric]], - date_time_begin: datetime.datetime, - date_time_end: datetime.datetime, - granularity: Union[str, _models.LogMetricsGranularity], - custom_domains: List[str], - protocols: List[str], - group_by: Optional[List[Union[str, _models.LogMetricsGroupBy]]] = None, - continents: Optional[List[str]] = None, - country_or_regions: Optional[List[str]] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) - 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( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), - "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - _params["metrics"] = [_SERIALIZER.query("metrics", q, "str") if q is not None else "" for q in metrics] - _params["dateTimeBegin"] = _SERIALIZER.query("date_time_begin", date_time_begin, "iso-8601") - _params["dateTimeEnd"] = _SERIALIZER.query("date_time_end", date_time_end, "iso-8601") - _params["granularity"] = _SERIALIZER.query("granularity", granularity, "str") - if group_by is not None: - _params["groupBy"] = [_SERIALIZER.query("group_by", q, "str") if q is not None else "" for q in group_by] - if continents is not None: - _params["continents"] = [_SERIALIZER.query("continents", q, "str") if q is not None else "" for q in continents] - if country_or_regions is not None: - _params["countryOrRegions"] = [ - _SERIALIZER.query("country_or_regions", q, "str") if q is not None else "" for q in country_or_regions - ] - _params["customDomains"] = [ - _SERIALIZER.query("custom_domains", q, "str") if q is not None else "" for q in custom_domains - ] - _params["protocols"] = [_SERIALIZER.query("protocols", q, "str") if q is not None else "" for q in protocols] - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_log_analytics_rankings_request( - resource_group_name: str, - profile_name: str, - subscription_id: str, - *, - rankings: List[Union[str, _models.LogRanking]], - metrics: List[Union[str, _models.LogRankingMetric]], - max_ranking: int, - date_time_begin: datetime.datetime, - date_time_end: datetime.datetime, - custom_domains: Optional[List[str]] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) - 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( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), - "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - _params["rankings"] = [_SERIALIZER.query("rankings", q, "str") if q is not None else "" for q in rankings] - _params["metrics"] = [_SERIALIZER.query("metrics", q, "str") if q is not None else "" for q in metrics] - _params["maxRanking"] = _SERIALIZER.query("max_ranking", max_ranking, "int") - _params["dateTimeBegin"] = _SERIALIZER.query("date_time_begin", date_time_begin, "iso-8601") - _params["dateTimeEnd"] = _SERIALIZER.query("date_time_end", date_time_end, "iso-8601") - if custom_domains is not None: - _params["customDomains"] = [ - _SERIALIZER.query("custom_domains", q, "str") if q is not None else "" for q in custom_domains - ] - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_log_analytics_locations_request( # pylint: disable=name-too-long - 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", "2024-02-01")) - 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( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), - "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_log_analytics_resources_request( # pylint: disable=name-too-long - 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", "2024-02-01")) - 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( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), - "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_waf_log_analytics_metrics_request( # pylint: disable=name-too-long - resource_group_name: str, - profile_name: str, - subscription_id: str, - *, - metrics: List[Union[str, _models.WafMetric]], - date_time_begin: datetime.datetime, - date_time_end: datetime.datetime, - granularity: Union[str, _models.WafGranularity], - actions: Optional[List[Union[str, _models.WafAction]]] = None, - group_by: Optional[List[Union[str, _models.WafRankingGroupBy]]] = None, - rule_types: Optional[List[Union[str, _models.WafRuleType]]] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) - 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( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), - "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - _params["metrics"] = [_SERIALIZER.query("metrics", q, "str") if q is not None else "" for q in metrics] - _params["dateTimeBegin"] = _SERIALIZER.query("date_time_begin", date_time_begin, "iso-8601") - _params["dateTimeEnd"] = _SERIALIZER.query("date_time_end", date_time_end, "iso-8601") - _params["granularity"] = _SERIALIZER.query("granularity", granularity, "str") - if actions is not None: - _params["actions"] = [_SERIALIZER.query("actions", q, "str") if q is not None else "" for q in actions] - if group_by is not None: - _params["groupBy"] = [_SERIALIZER.query("group_by", q, "str") if q is not None else "" for q in group_by] - if rule_types is not None: - _params["ruleTypes"] = [_SERIALIZER.query("rule_types", q, "str") if q is not None else "" for q in rule_types] - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_waf_log_analytics_rankings_request( # pylint: disable=name-too-long - resource_group_name: str, - profile_name: str, - subscription_id: str, - *, - metrics: List[Union[str, _models.WafMetric]], - date_time_begin: datetime.datetime, - date_time_end: datetime.datetime, - max_ranking: int, - rankings: List[Union[str, _models.WafRankingType]], - actions: Optional[List[Union[str, _models.WafAction]]] = None, - rule_types: Optional[List[Union[str, _models.WafRuleType]]] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) - 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( - "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" - ), - "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - _params["metrics"] = [_SERIALIZER.query("metrics", q, "str") if q is not None else "" for q in metrics] - _params["dateTimeBegin"] = _SERIALIZER.query("date_time_begin", date_time_begin, "iso-8601") - _params["dateTimeEnd"] = _SERIALIZER.query("date_time_end", date_time_end, "iso-8601") - _params["maxRanking"] = _SERIALIZER.query("max_ranking", max_ranking, "int") - _params["rankings"] = [_SERIALIZER.query("rankings", q, "str") if q is not None else "" for q in rankings] - if actions is not None: - _params["actions"] = [_SERIALIZER.query("actions", q, "str") if q is not None else "" for q in actions] - if rule_types is not None: - _params["ruleTypes"] = [_SERIALIZER.query("rule_types", q, "str") if q is not None else "" for q in rule_types] - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class LogAnalyticsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.cdn.CdnManagementClient`'s - :attr:`log_analytics` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def get_log_analytics_metrics( - self, - resource_group_name: str, - profile_name: str, - metrics: List[Union[str, _models.LogMetric]], - date_time_begin: datetime.datetime, - date_time_end: datetime.datetime, - granularity: Union[str, _models.LogMetricsGranularity], - custom_domains: List[str], - protocols: List[str], - group_by: Optional[List[Union[str, _models.LogMetricsGroupBy]]] = None, - continents: Optional[List[str]] = None, - country_or_regions: Optional[List[str]] = None, - **kwargs: Any - ) -> _models.MetricsResponse: - """Get log report for AFD 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. which is unique within the resource group. Required. - :type profile_name: str - :param metrics: Required. - :type metrics: list[str or ~azure.mgmt.cdn.models.LogMetric] - :param date_time_begin: Required. - :type date_time_begin: ~datetime.datetime - :param date_time_end: Required. - :type date_time_end: ~datetime.datetime - :param granularity: Known values are: "PT5M", "PT1H", and "P1D". Required. - :type granularity: str or ~azure.mgmt.cdn.models.LogMetricsGranularity - :param custom_domains: Required. - :type custom_domains: list[str] - :param protocols: Required. - :type protocols: list[str] - :param group_by: Default value is None. - :type group_by: list[str or ~azure.mgmt.cdn.models.LogMetricsGroupBy] - :param continents: Default value is None. - :type continents: list[str] - :param country_or_regions: Default value is None. - :type country_or_regions: list[str] - :return: MetricsResponse or the result of cls(response) - :rtype: ~azure.mgmt.cdn.models.MetricsResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.MetricsResponse] = kwargs.pop("cls", None) - - _request = build_get_log_analytics_metrics_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - subscription_id=self._config.subscription_id, - metrics=metrics, - date_time_begin=date_time_begin, - date_time_end=date_time_end, - granularity=granularity, - custom_domains=custom_domains, - protocols=protocols, - group_by=group_by, - continents=continents, - country_or_regions=country_or_regions, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("MetricsResponse", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def get_log_analytics_rankings( - self, - resource_group_name: str, - profile_name: str, - rankings: List[Union[str, _models.LogRanking]], - metrics: List[Union[str, _models.LogRankingMetric]], - max_ranking: int, - date_time_begin: datetime.datetime, - date_time_end: datetime.datetime, - custom_domains: Optional[List[str]] = None, - **kwargs: Any - ) -> _models.RankingsResponse: - """Get log analytics ranking report for AFD 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. which is unique within the resource group. Required. - :type profile_name: str - :param rankings: Required. - :type rankings: list[str or ~azure.mgmt.cdn.models.LogRanking] - :param metrics: Required. - :type metrics: list[str or ~azure.mgmt.cdn.models.LogRankingMetric] - :param max_ranking: Required. - :type max_ranking: int - :param date_time_begin: Required. - :type date_time_begin: ~datetime.datetime - :param date_time_end: Required. - :type date_time_end: ~datetime.datetime - :param custom_domains: Default value is None. - :type custom_domains: list[str] - :return: RankingsResponse or the result of cls(response) - :rtype: ~azure.mgmt.cdn.models.RankingsResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.RankingsResponse] = kwargs.pop("cls", None) - - _request = build_get_log_analytics_rankings_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - subscription_id=self._config.subscription_id, - rankings=rankings, - metrics=metrics, - max_ranking=max_ranking, - date_time_begin=date_time_begin, - date_time_end=date_time_end, - custom_domains=custom_domains, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RankingsResponse", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def get_log_analytics_locations( - self, resource_group_name: str, profile_name: str, **kwargs: Any - ) -> _models.ContinentsResponse: - """Get all available location names for AFD log analytics report. - - :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. which is unique within the resource group. Required. - :type profile_name: str - :return: ContinentsResponse or the result of cls(response) - :rtype: ~azure.mgmt.cdn.models.ContinentsResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.ContinentsResponse] = kwargs.pop("cls", None) - - _request = build_get_log_analytics_locations_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 = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ContinentsResponse", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def get_log_analytics_resources( - self, resource_group_name: str, profile_name: str, **kwargs: Any - ) -> _models.ResourcesResponse: - """Get all endpoints and custom domains available for AFD log report. - - :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. which is unique within the resource group. Required. - :type profile_name: str - :return: ResourcesResponse or the result of cls(response) - :rtype: ~azure.mgmt.cdn.models.ResourcesResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.ResourcesResponse] = kwargs.pop("cls", None) - - _request = build_get_log_analytics_resources_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 = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ResourcesResponse", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def get_waf_log_analytics_metrics( - self, - resource_group_name: str, - profile_name: str, - metrics: List[Union[str, _models.WafMetric]], - date_time_begin: datetime.datetime, - date_time_end: datetime.datetime, - granularity: Union[str, _models.WafGranularity], - actions: Optional[List[Union[str, _models.WafAction]]] = None, - group_by: Optional[List[Union[str, _models.WafRankingGroupBy]]] = None, - rule_types: Optional[List[Union[str, _models.WafRuleType]]] = None, - **kwargs: Any - ) -> _models.WafMetricsResponse: - """Get Waf related log analytics report for AFD 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. which is unique within the resource group. Required. - :type profile_name: str - :param metrics: Required. - :type metrics: list[str or ~azure.mgmt.cdn.models.WafMetric] - :param date_time_begin: Required. - :type date_time_begin: ~datetime.datetime - :param date_time_end: Required. - :type date_time_end: ~datetime.datetime - :param granularity: Known values are: "PT5M", "PT1H", and "P1D". Required. - :type granularity: str or ~azure.mgmt.cdn.models.WafGranularity - :param actions: Default value is None. - :type actions: list[str or ~azure.mgmt.cdn.models.WafAction] - :param group_by: Default value is None. - :type group_by: list[str or ~azure.mgmt.cdn.models.WafRankingGroupBy] - :param rule_types: Default value is None. - :type rule_types: list[str or ~azure.mgmt.cdn.models.WafRuleType] - :return: WafMetricsResponse or the result of cls(response) - :rtype: ~azure.mgmt.cdn.models.WafMetricsResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.WafMetricsResponse] = kwargs.pop("cls", None) - - _request = build_get_waf_log_analytics_metrics_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - subscription_id=self._config.subscription_id, - metrics=metrics, - date_time_begin=date_time_begin, - date_time_end=date_time_end, - granularity=granularity, - actions=actions, - group_by=group_by, - rule_types=rule_types, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("WafMetricsResponse", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def get_waf_log_analytics_rankings( - self, - resource_group_name: str, - profile_name: str, - metrics: List[Union[str, _models.WafMetric]], - date_time_begin: datetime.datetime, - date_time_end: datetime.datetime, - max_ranking: int, - rankings: List[Union[str, _models.WafRankingType]], - actions: Optional[List[Union[str, _models.WafAction]]] = None, - rule_types: Optional[List[Union[str, _models.WafRuleType]]] = None, - **kwargs: Any - ) -> _models.WafRankingsResponse: - """Get WAF log analytics charts for AFD 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. which is unique within the resource group. Required. - :type profile_name: str - :param metrics: Required. - :type metrics: list[str or ~azure.mgmt.cdn.models.WafMetric] - :param date_time_begin: Required. - :type date_time_begin: ~datetime.datetime - :param date_time_end: Required. - :type date_time_end: ~datetime.datetime - :param max_ranking: Required. - :type max_ranking: int - :param rankings: Required. - :type rankings: list[str or ~azure.mgmt.cdn.models.WafRankingType] - :param actions: Default value is None. - :type actions: list[str or ~azure.mgmt.cdn.models.WafAction] - :param rule_types: Default value is None. - :type rule_types: list[str or ~azure.mgmt.cdn.models.WafRuleType] - :return: WafRankingsResponse or the result of cls(response) - :rtype: ~azure.mgmt.cdn.models.WafRankingsResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.WafRankingsResponse] = kwargs.pop("cls", None) - - _request = build_get_waf_log_analytics_rankings_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - subscription_id=self._config.subscription_id, - metrics=metrics, - date_time_begin=date_time_begin, - date_time_end=date_time_end, - max_ranking=max_ranking, - rankings=rankings, - actions=actions, - rule_types=rule_types, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("WafRankingsResponse", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return 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 deleted file mode 100644 index 4d8243ab3d6e..000000000000 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_managed_rule_sets_operations.py +++ /dev/null @@ -1,166 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from .._serialization import Serializer -from .._vendor import CdnManagementClientMixinABC, _convert_request - -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]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) - 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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class ManagedRuleSetsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.cdn.CdnManagementClient`'s - :attr:`managed_rule_sets` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list(self, **kwargs: Any) -> Iterable["_models.ManagedRuleSetDefinition"]: - """Lists all available managed rule sets. - - :return: An iterator like instance of either ManagedRuleSetDefinition or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cdn.models.ManagedRuleSetDefinition] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - 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]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ManagedRuleSetDefinitionList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_operations.py index 10d99a59fca4..78b95fce2978 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,55 +1,63 @@ -# 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. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python 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 +import datetime +from io import IOBase +import json +from typing import Any, Callable, IO, Iterator, Optional, TypeVar, Union, cast, overload import urllib.parse +from azure.core import PipelineClient 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.rest import HttpRequest +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models -from .._serialization import Serializer -from .._vendor import CdnManagementClientMixinABC, _convert_request +from .._configuration import CdnManagementClientConfiguration +from .._utils.model_base import SdkJSONEncoder, _deserialize, _failsafe_deserialize +from .._utils.serialization import Deserializer, Serializer +from .._utils.utils import ClientMixinABC +from .._validation import api_version_validation -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]] +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] +JSON = MutableMapping[str, Any] +List = list _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request(**kwargs: Any) -> HttpRequest: +def build_operations_list_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.Cdn/operations") + _url = "/providers/Microsoft.Cdn/operations" # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -60,6 +68,3462 @@ def build_list_request(**kwargs: Any) -> HttpRequest: return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) +def build_profiles_get_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-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_profiles_create_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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_profiles_update_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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_profiles_delete_request( + resource_group_name: str, profile_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_profiles_list_by_resource_group_request( # pylint: disable=name-too-long + resource_group_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_profiles_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.Cdn/profiles" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_profiles_migration_commit_request( + resource_group_name: str, profile_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/migrationCommit" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) + + +def build_profiles_generate_sso_uri_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-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/generateSsoUri" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # 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_profiles_list_supported_optimization_types_request( # pylint: disable=name-too-long + 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-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/getSupportedOptimizationTypes" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # 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_profiles_list_resource_usage_request( # pylint: disable=name-too-long + 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-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/checkResourceUsage" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # 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_profiles_cdn_can_migrate_to_afd_request( # pylint: disable=name-too-long + 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-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _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"), + "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # 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_profiles_cdn_migrate_to_afd_request( # pylint: disable=name-too-long + 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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _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"), + "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_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_profiles_migration_abort_request( + resource_group_name: str, profile_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01")) + # Construct URL + _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"), + "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) + + +def build_profiles_can_migrate_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/canMigrate" + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_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_profiles_migrate_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/migrate" + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_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_afd_endpoints_get_request( + resource_group_name: str, profile_name: str, endpoint_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/afdEndpoints/{endpointName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "endpointName": _SERIALIZER.url("endpoint_name", endpoint_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_afd_endpoints_create_request( + resource_group_name: str, profile_name: str, endpoint_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/afdEndpoints/{endpointName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "endpointName": _SERIALIZER.url("endpoint_name", endpoint_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_afd_endpoints_update_request( + resource_group_name: str, profile_name: str, endpoint_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/afdEndpoints/{endpointName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "endpointName": _SERIALIZER.url("endpoint_name", endpoint_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_afd_endpoints_delete_request( + resource_group_name: str, profile_name: str, endpoint_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/afdEndpoints/{endpointName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "endpointName": _SERIALIZER.url("endpoint_name", endpoint_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_afd_endpoints_list_by_profile_request( # pylint: disable=name-too-long + 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-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/afdEndpoints" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_afd_endpoints_purge_content_request( # pylint: disable=name-too-long + resource_group_name: str, profile_name: str, endpoint_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/afdEndpoints/{endpointName}/purge" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "endpointName": _SERIALIZER.url("endpoint_name", endpoint_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_afd_endpoints_list_resource_usage_request( # pylint: disable=name-too-long + resource_group_name: str, profile_name: str, endpoint_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/afdEndpoints/{endpointName}/usages" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "endpointName": _SERIALIZER.url("endpoint_name", endpoint_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_afd_endpoints_validate_custom_domain_request( # pylint: disable=name-too-long + resource_group_name: str, profile_name: str, endpoint_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/afdEndpoints/{endpointName}/validateCustomDomain" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "endpointName": _SERIALIZER.url("endpoint_name", endpoint_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_afd_origin_groups_get_request( + resource_group_name: str, profile_name: str, origin_group_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/originGroups/{originGroupName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "originGroupName": _SERIALIZER.url("origin_group_name", origin_group_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_afd_origin_groups_create_request( + resource_group_name: str, profile_name: str, origin_group_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/originGroups/{originGroupName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "originGroupName": _SERIALIZER.url("origin_group_name", origin_group_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_afd_origin_groups_update_request( + resource_group_name: str, profile_name: str, origin_group_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/originGroups/{originGroupName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "originGroupName": _SERIALIZER.url("origin_group_name", origin_group_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_afd_origin_groups_delete_request( + resource_group_name: str, profile_name: str, origin_group_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/originGroups/{originGroupName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "originGroupName": _SERIALIZER.url("origin_group_name", origin_group_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_afd_origin_groups_list_by_profile_request( # pylint: disable=name-too-long + 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-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/originGroups" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_afd_origin_groups_list_resource_usage_request( # pylint: disable=name-too-long + resource_group_name: str, profile_name: str, origin_group_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/originGroups/{originGroupName}/usages" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "originGroupName": _SERIALIZER.url("origin_group_name", origin_group_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_afd_origins_get_request( + resource_group_name: str, + profile_name: str, + origin_group_name: str, + origin_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/originGroups/{originGroupName}/origins/{originName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "originGroupName": _SERIALIZER.url("origin_group_name", origin_group_name, "str"), + "originName": _SERIALIZER.url("origin_name", origin_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_afd_origins_create_request( + resource_group_name: str, + profile_name: str, + origin_group_name: str, + origin_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/originGroups/{originGroupName}/origins/{originName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "originGroupName": _SERIALIZER.url("origin_group_name", origin_group_name, "str"), + "originName": _SERIALIZER.url("origin_name", origin_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_afd_origins_update_request( + resource_group_name: str, + profile_name: str, + origin_group_name: str, + origin_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/originGroups/{originGroupName}/origins/{originName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "originGroupName": _SERIALIZER.url("origin_group_name", origin_group_name, "str"), + "originName": _SERIALIZER.url("origin_name", origin_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_afd_origins_delete_request( + resource_group_name: str, + profile_name: str, + origin_group_name: str, + origin_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/originGroups/{originGroupName}/origins/{originName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "originGroupName": _SERIALIZER.url("origin_group_name", origin_group_name, "str"), + "originName": _SERIALIZER.url("origin_name", origin_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_afd_origins_list_by_origin_group_request( # pylint: disable=name-too-long + resource_group_name: str, profile_name: str, origin_group_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/originGroups/{originGroupName}/origins" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "originGroupName": _SERIALIZER.url("origin_group_name", origin_group_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_routes_get_request( + resource_group_name: str, + profile_name: str, + endpoint_name: str, + route_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/afdEndpoints/{endpointName}/routes/{routeName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "endpointName": _SERIALIZER.url("endpoint_name", endpoint_name, "str"), + "routeName": _SERIALIZER.url("route_name", route_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_routes_create_request( + resource_group_name: str, + profile_name: str, + endpoint_name: str, + route_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/afdEndpoints/{endpointName}/routes/{routeName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "endpointName": _SERIALIZER.url("endpoint_name", endpoint_name, "str"), + "routeName": _SERIALIZER.url("route_name", route_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_routes_update_request( + resource_group_name: str, + profile_name: str, + endpoint_name: str, + route_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/afdEndpoints/{endpointName}/routes/{routeName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "endpointName": _SERIALIZER.url("endpoint_name", endpoint_name, "str"), + "routeName": _SERIALIZER.url("route_name", route_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_routes_delete_request( + resource_group_name: str, + profile_name: str, + endpoint_name: str, + route_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/afdEndpoints/{endpointName}/routes/{routeName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "endpointName": _SERIALIZER.url("endpoint_name", endpoint_name, "str"), + "routeName": _SERIALIZER.url("route_name", route_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_routes_list_by_endpoint_request( + resource_group_name: str, profile_name: str, endpoint_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/afdEndpoints/{endpointName}/routes" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "endpointName": _SERIALIZER.url("endpoint_name", endpoint_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_rule_sets_get_request( + resource_group_name: str, profile_name: str, rule_set_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/ruleSets/{ruleSetName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "ruleSetName": _SERIALIZER.url("rule_set_name", rule_set_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_rule_sets_create_request( + resource_group_name: str, profile_name: str, rule_set_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/ruleSets/{ruleSetName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "ruleSetName": _SERIALIZER.url("rule_set_name", rule_set_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_rule_sets_delete_request( + resource_group_name: str, profile_name: str, rule_set_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/ruleSets/{ruleSetName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "ruleSetName": _SERIALIZER.url("rule_set_name", rule_set_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_rule_sets_list_by_profile_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-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/ruleSets" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_rule_sets_list_resource_usage_request( # pylint: disable=name-too-long + resource_group_name: str, profile_name: str, rule_set_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/ruleSets/{ruleSetName}/usages" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "ruleSetName": _SERIALIZER.url("rule_set_name", rule_set_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_rules_get_request( + resource_group_name: str, profile_name: str, rule_set_name: str, rule_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/ruleSets/{ruleSetName}/rules/{ruleName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "ruleSetName": _SERIALIZER.url("rule_set_name", rule_set_name, "str"), + "ruleName": _SERIALIZER.url("rule_name", rule_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_rules_create_request( + resource_group_name: str, profile_name: str, rule_set_name: str, rule_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/ruleSets/{ruleSetName}/rules/{ruleName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "ruleSetName": _SERIALIZER.url("rule_set_name", rule_set_name, "str"), + "ruleName": _SERIALIZER.url("rule_name", rule_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_rules_update_request( + resource_group_name: str, profile_name: str, rule_set_name: str, rule_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/ruleSets/{ruleSetName}/rules/{ruleName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "ruleSetName": _SERIALIZER.url("rule_set_name", rule_set_name, "str"), + "ruleName": _SERIALIZER.url("rule_name", rule_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_rules_delete_request( + resource_group_name: str, profile_name: str, rule_set_name: str, rule_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/ruleSets/{ruleSetName}/rules/{ruleName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "ruleSetName": _SERIALIZER.url("rule_set_name", rule_set_name, "str"), + "ruleName": _SERIALIZER.url("rule_name", rule_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_rules_list_by_rule_set_request( + resource_group_name: str, profile_name: str, rule_set_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/ruleSets/{ruleSetName}/rules" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "ruleSetName": _SERIALIZER.url("rule_set_name", rule_set_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_security_policies_get_request( + resource_group_name: str, profile_name: str, security_policy_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/securityPolicies/{securityPolicyName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "securityPolicyName": _SERIALIZER.url("security_policy_name", security_policy_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_security_policies_create_request( + resource_group_name: str, profile_name: str, security_policy_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/securityPolicies/{securityPolicyName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "securityPolicyName": _SERIALIZER.url("security_policy_name", security_policy_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_security_policies_patch_request( + resource_group_name: str, profile_name: str, security_policy_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/securityPolicies/{securityPolicyName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "securityPolicyName": _SERIALIZER.url("security_policy_name", security_policy_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_security_policies_delete_request( + resource_group_name: str, profile_name: str, security_policy_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/securityPolicies/{securityPolicyName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "securityPolicyName": _SERIALIZER.url("security_policy_name", security_policy_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_security_policies_list_by_profile_request( # pylint: disable=name-too-long + 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-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/securityPolicies" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_secrets_get_request( + resource_group_name: str, profile_name: str, secret_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/secrets/{secretName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "secretName": _SERIALIZER.url("secret_name", secret_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_secrets_create_request( + resource_group_name: str, profile_name: str, secret_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/secrets/{secretName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "secretName": _SERIALIZER.url("secret_name", secret_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_secrets_delete_request( + resource_group_name: str, profile_name: str, secret_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/secrets/{secretName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "secretName": _SERIALIZER.url("secret_name", secret_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_secrets_list_by_profile_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-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/secrets" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_endpoints_get_request( + resource_group_name: str, profile_name: str, endpoint_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "endpointName": _SERIALIZER.url("endpoint_name", endpoint_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_endpoints_create_request( + resource_group_name: str, profile_name: str, endpoint_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "endpointName": _SERIALIZER.url("endpoint_name", endpoint_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_endpoints_update_request( + resource_group_name: str, profile_name: str, endpoint_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "endpointName": _SERIALIZER.url("endpoint_name", endpoint_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_endpoints_delete_request( + resource_group_name: str, profile_name: str, endpoint_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "endpointName": _SERIALIZER.url("endpoint_name", endpoint_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_endpoints_list_by_profile_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-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_endpoints_start_request( + resource_group_name: str, profile_name: str, endpoint_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/start" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "endpointName": _SERIALIZER.url("endpoint_name", endpoint_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_endpoints_stop_request( + resource_group_name: str, profile_name: str, endpoint_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/stop" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "endpointName": _SERIALIZER.url("endpoint_name", endpoint_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_endpoints_purge_content_request( + resource_group_name: str, profile_name: str, endpoint_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/purge" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "endpointName": _SERIALIZER.url("endpoint_name", endpoint_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_endpoints_load_content_request( + resource_group_name: str, profile_name: str, endpoint_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/load" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "endpointName": _SERIALIZER.url("endpoint_name", endpoint_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_endpoints_validate_custom_domain_request( # pylint: disable=name-too-long + resource_group_name: str, profile_name: str, endpoint_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/validateCustomDomain" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "endpointName": _SERIALIZER.url("endpoint_name", endpoint_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_endpoints_list_resource_usage_request( # pylint: disable=name-too-long + resource_group_name: str, profile_name: str, endpoint_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/checkResourceUsage" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "endpointName": _SERIALIZER.url("endpoint_name", endpoint_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_origins_get_request( + resource_group_name: str, + profile_name: str, + endpoint_name: str, + origin_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/origins/{originName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "endpointName": _SERIALIZER.url("endpoint_name", endpoint_name, "str"), + "originName": _SERIALIZER.url("origin_name", origin_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_origins_create_request( + resource_group_name: str, + profile_name: str, + endpoint_name: str, + origin_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/origins/{originName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "endpointName": _SERIALIZER.url("endpoint_name", endpoint_name, "str"), + "originName": _SERIALIZER.url("origin_name", origin_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_origins_update_request( + resource_group_name: str, + profile_name: str, + endpoint_name: str, + origin_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/origins/{originName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "endpointName": _SERIALIZER.url("endpoint_name", endpoint_name, "str"), + "originName": _SERIALIZER.url("origin_name", origin_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_origins_delete_request( + resource_group_name: str, + profile_name: str, + endpoint_name: str, + origin_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/origins/{originName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "endpointName": _SERIALIZER.url("endpoint_name", endpoint_name, "str"), + "originName": _SERIALIZER.url("origin_name", origin_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_origins_list_by_endpoint_request( + resource_group_name: str, profile_name: str, endpoint_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/origins" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "endpointName": _SERIALIZER.url("endpoint_name", endpoint_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_origin_groups_get_request( + resource_group_name: str, + profile_name: str, + endpoint_name: str, + origin_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/originGroups/{originGroupName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "endpointName": _SERIALIZER.url("endpoint_name", endpoint_name, "str"), + "originGroupName": _SERIALIZER.url("origin_group_name", origin_group_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_origin_groups_create_request( + resource_group_name: str, + profile_name: str, + endpoint_name: str, + origin_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/originGroups/{originGroupName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "endpointName": _SERIALIZER.url("endpoint_name", endpoint_name, "str"), + "originGroupName": _SERIALIZER.url("origin_group_name", origin_group_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_origin_groups_update_request( + resource_group_name: str, + profile_name: str, + endpoint_name: str, + origin_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/originGroups/{originGroupName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "endpointName": _SERIALIZER.url("endpoint_name", endpoint_name, "str"), + "originGroupName": _SERIALIZER.url("origin_group_name", origin_group_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_origin_groups_delete_request( + resource_group_name: str, + profile_name: str, + endpoint_name: str, + origin_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/originGroups/{originGroupName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "endpointName": _SERIALIZER.url("endpoint_name", endpoint_name, "str"), + "originGroupName": _SERIALIZER.url("origin_group_name", origin_group_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_origin_groups_list_by_endpoint_request( # pylint: disable=name-too-long + resource_group_name: str, profile_name: str, endpoint_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/originGroups" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "endpointName": _SERIALIZER.url("endpoint_name", endpoint_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_custom_domains_get_request( + resource_group_name: str, + profile_name: str, + endpoint_name: str, + custom_domain_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/customDomains/{customDomainName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "endpointName": _SERIALIZER.url("endpoint_name", endpoint_name, "str"), + "customDomainName": _SERIALIZER.url("custom_domain_name", custom_domain_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_custom_domains_create_request( + resource_group_name: str, + profile_name: str, + endpoint_name: str, + custom_domain_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/customDomains/{customDomainName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "endpointName": _SERIALIZER.url("endpoint_name", endpoint_name, "str"), + "customDomainName": _SERIALIZER.url("custom_domain_name", custom_domain_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_custom_domains_delete_request( + resource_group_name: str, + profile_name: str, + endpoint_name: str, + custom_domain_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/customDomains/{customDomainName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "endpointName": _SERIALIZER.url("endpoint_name", endpoint_name, "str"), + "customDomainName": _SERIALIZER.url("custom_domain_name", custom_domain_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_custom_domains_list_by_endpoint_request( # pylint: disable=name-too-long + resource_group_name: str, profile_name: str, endpoint_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/customDomains" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "endpointName": _SERIALIZER.url("endpoint_name", endpoint_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_custom_domains_disable_custom_https_request( # pylint: disable=name-too-long + resource_group_name: str, + profile_name: str, + endpoint_name: str, + custom_domain_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/customDomains/{customDomainName}/disableCustomHttps" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "endpointName": _SERIALIZER.url("endpoint_name", endpoint_name, "str"), + "customDomainName": _SERIALIZER.url("custom_domain_name", custom_domain_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # 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_custom_domains_enable_custom_https_request( # pylint: disable=name-too-long + resource_group_name: str, + profile_name: str, + endpoint_name: str, + custom_domain_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/customDomains/{customDomainName}/enableCustomHttps" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "endpointName": _SERIALIZER.url("endpoint_name", endpoint_name, "str"), + "customDomainName": _SERIALIZER.url("custom_domain_name", custom_domain_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_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_afd_custom_domains_get_request( + resource_group_name: str, profile_name: str, custom_domain_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/customDomains/{customDomainName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "customDomainName": _SERIALIZER.url("custom_domain_name", custom_domain_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_afd_custom_domains_create_request( + resource_group_name: str, profile_name: str, custom_domain_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/customDomains/{customDomainName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "customDomainName": _SERIALIZER.url("custom_domain_name", custom_domain_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_afd_custom_domains_update_request( + resource_group_name: str, profile_name: str, custom_domain_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/customDomains/{customDomainName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "customDomainName": _SERIALIZER.url("custom_domain_name", custom_domain_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_afd_custom_domains_delete_request( + resource_group_name: str, profile_name: str, custom_domain_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/customDomains/{customDomainName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "customDomainName": _SERIALIZER.url("custom_domain_name", custom_domain_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_afd_custom_domains_list_by_profile_request( # pylint: disable=name-too-long + 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-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/customDomains" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_afd_custom_domains_refresh_validation_token_request( # pylint: disable=name-too-long + resource_group_name: str, profile_name: str, custom_domain_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/customDomains/{customDomainName}/refreshValidationToken" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + "customDomainName": _SERIALIZER.url("custom_domain_name", custom_domain_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) + + +def build_afd_profiles_check_endpoint_name_availability_request( # pylint: disable=name-too-long + 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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/checkEndpointNameAvailability" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_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_afd_profiles_list_resource_usage_request( # pylint: disable=name-too-long + 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-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/usages" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # 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_afd_profiles_check_host_name_availability_request( # pylint: disable=name-too-long + 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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/checkHostNameAvailability" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_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_afd_profiles_validate_secret_request( # pylint: disable=name-too-long + 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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/validateSecret" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_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_afd_profiles_upgrade_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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/upgrade" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_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_log_analytics_get_log_analytics_metrics_request( # pylint: disable=name-too-long + resource_group_name: str, + profile_name: str, + subscription_id: str, + *, + metrics: List[Union[str, _models.LogMetric]], + date_time_begin: datetime.datetime, + date_time_end: datetime.datetime, + granularity: Union[str, _models.LogMetricsGranularity], + custom_domains: List[str], + protocols: List[str], + group_by: Optional[List[Union[str, _models.LogMetricsGroupBy]]] = None, + continents: Optional[List[str]] = None, + country_or_regions: Optional[List[str]] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/getLogAnalyticsMetrics" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + _params["metrics"] = [_SERIALIZER.query("metrics", q, "str") if q is not None else "" for q in metrics] + _params["dateTimeBegin"] = _SERIALIZER.query("date_time_begin", date_time_begin, "iso-8601") + _params["dateTimeEnd"] = _SERIALIZER.query("date_time_end", date_time_end, "iso-8601") + _params["granularity"] = _SERIALIZER.query("granularity", granularity, "str") + if group_by is not None: + _params["groupBy"] = [_SERIALIZER.query("group_by", q, "str") if q is not None else "" for q in group_by] + if continents is not None: + _params["continents"] = [_SERIALIZER.query("continents", q, "str") if q is not None else "" for q in continents] + if country_or_regions is not None: + _params["countryOrRegions"] = [ + _SERIALIZER.query("country_or_regions", q, "str") if q is not None else "" for q in country_or_regions + ] + _params["customDomains"] = [ + _SERIALIZER.query("custom_domains", q, "str") if q is not None else "" for q in custom_domains + ] + _params["protocols"] = [_SERIALIZER.query("protocols", q, "str") if q is not None else "" for q in protocols] + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_log_analytics_get_log_analytics_rankings_request( # pylint: disable=name-too-long + resource_group_name: str, + profile_name: str, + subscription_id: str, + *, + rankings: List[Union[str, _models.LogRanking]], + metrics: List[Union[str, _models.LogRankingMetric]], + max_ranking: int, + date_time_begin: datetime.datetime, + date_time_end: datetime.datetime, + custom_domains: Optional[List[str]] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/getLogAnalyticsRankings" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + _params["rankings"] = [_SERIALIZER.query("rankings", q, "str") if q is not None else "" for q in rankings] + _params["metrics"] = [_SERIALIZER.query("metrics", q, "str") if q is not None else "" for q in metrics] + _params["maxRanking"] = _SERIALIZER.query("max_ranking", max_ranking, "int") + _params["dateTimeBegin"] = _SERIALIZER.query("date_time_begin", date_time_begin, "iso-8601") + _params["dateTimeEnd"] = _SERIALIZER.query("date_time_end", date_time_end, "iso-8601") + if custom_domains is not None: + _params["customDomains"] = [ + _SERIALIZER.query("custom_domains", q, "str") if q is not None else "" for q in custom_domains + ] + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_log_analytics_get_log_analytics_locations_request( # pylint: disable=name-too-long + 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-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/getLogAnalyticsLocations" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_log_analytics_get_log_analytics_resources_request( # pylint: disable=name-too-long + 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-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/getLogAnalyticsResources" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_log_analytics_get_waf_log_analytics_metrics_request( # pylint: disable=name-too-long + resource_group_name: str, + profile_name: str, + subscription_id: str, + *, + metrics: List[Union[str, _models.WafMetric]], + date_time_begin: datetime.datetime, + date_time_end: datetime.datetime, + granularity: Union[str, _models.WafGranularity], + actions: Optional[List[Union[str, _models.WafAction]]] = None, + group_by: Optional[List[Union[str, _models.WafRankingGroupBy]]] = None, + rule_types: Optional[List[Union[str, _models.WafRuleType]]] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/getWafLogAnalyticsMetrics" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + _params["metrics"] = [_SERIALIZER.query("metrics", q, "str") if q is not None else "" for q in metrics] + _params["dateTimeBegin"] = _SERIALIZER.query("date_time_begin", date_time_begin, "iso-8601") + _params["dateTimeEnd"] = _SERIALIZER.query("date_time_end", date_time_end, "iso-8601") + _params["granularity"] = _SERIALIZER.query("granularity", granularity, "str") + if actions is not None: + _params["actions"] = [_SERIALIZER.query("actions", q, "str") if q is not None else "" for q in actions] + if group_by is not None: + _params["groupBy"] = [_SERIALIZER.query("group_by", q, "str") if q is not None else "" for q in group_by] + if rule_types is not None: + _params["ruleTypes"] = [_SERIALIZER.query("rule_types", q, "str") if q is not None else "" for q in rule_types] + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_log_analytics_get_waf_log_analytics_rankings_request( # pylint: disable=name-too-long + resource_group_name: str, + profile_name: str, + subscription_id: str, + *, + metrics: List[Union[str, _models.WafMetric]], + date_time_begin: datetime.datetime, + date_time_end: datetime.datetime, + max_ranking: int, + rankings: List[Union[str, _models.WafRankingType]], + actions: Optional[List[Union[str, _models.WafAction]]] = None, + rule_types: Optional[List[Union[str, _models.WafRuleType]]] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/getWafLogAnalyticsRankings" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + _params["metrics"] = [_SERIALIZER.query("metrics", q, "str") if q is not None else "" for q in metrics] + _params["dateTimeBegin"] = _SERIALIZER.query("date_time_begin", date_time_begin, "iso-8601") + _params["dateTimeEnd"] = _SERIALIZER.query("date_time_end", date_time_end, "iso-8601") + _params["maxRanking"] = _SERIALIZER.query("max_ranking", max_ranking, "int") + _params["rankings"] = [_SERIALIZER.query("rankings", q, "str") if q is not None else "" for q in rankings] + if actions is not None: + _params["actions"] = [_SERIALIZER.query("actions", q, "str") if q is not None else "" for q in actions] + if rule_types is not None: + _params["ruleTypes"] = [_SERIALIZER.query("rule_types", q, "str") if q is not None else "" for q in rule_types] + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_policies_get_request( + resource_group_name: str, policy_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/cdnWebApplicationFirewallPolicies/{policyName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "policyName": _SERIALIZER.url("policy_name", policy_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_policies_create_or_update_request( + resource_group_name: str, policy_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/cdnWebApplicationFirewallPolicies/{policyName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "policyName": _SERIALIZER.url("policy_name", policy_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_policies_update_request( + resource_group_name: str, policy_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/cdnWebApplicationFirewallPolicies/{policyName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "policyName": _SERIALIZER.url("policy_name", policy_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_policies_delete_request( + resource_group_name: str, policy_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/cdnWebApplicationFirewallPolicies/{policyName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "policyName": _SERIALIZER.url("policy_name", policy_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_policies_list_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/cdnWebApplicationFirewallPolicies" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_resource_usage_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.Cdn/checkResourceUsage" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_edge_nodes_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", "2025-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/providers/Microsoft.Cdn/edgenodes" + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_managed_rule_sets_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.Cdn/cdnWebApplicationFirewallManagedRuleSets" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_cdn_management_check_endpoint_name_availability_request( # pylint: disable=name-too-long + resource_group_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/checkEndpointNameAvailability" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_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_cdn_management_check_name_availability_request(**kwargs: Any) -> HttpRequest: # pylint: disable=name-too-long + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/providers/Microsoft.Cdn/checkNameAvailability" + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_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_cdn_management_check_name_availability_with_subscription_request( # pylint: disable=name-too-long + subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.Cdn/checkNameAvailability" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_cdn_management_validate_probe_request( # pylint: disable=name-too-long + subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-12-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.Cdn/validateProbe" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + class Operations: """ .. warning:: @@ -67,33 +3531,17708 @@ class Operations: Instead, you should access the following operations through :class:`~azure.mgmt.cdn.CdnManagementClient`'s - :attr:`operations` attribute. + :attr:`operations` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: 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) -> ItemPaged["_models.Operation"]: + """List the operations for the provider. + + :return: An iterator like instance of Operation + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cdn.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Operation]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_operations_list_request( + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.Operation], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class ProfilesOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cdn.CdnManagementClient`'s + :attr:`profiles` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: 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(self, resource_group_name: str, profile_name: str, **kwargs: Any) -> _models.Profile: + """Gets an Azure Front Door Standard or Azure Front Door Premium or CDN profile with the specified + profile name under the specified subscription and resource group. + + :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 or CDN + profile which is unique within the resource group. Required. + :type profile_name: str + :return: Profile. The Profile is compatible with MutableMapping + :rtype: ~azure.mgmt.cdn.models.Profile + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.Profile] = kwargs.pop("cls", None) + + _request = build_profiles_get_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Profile, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_initial( + self, + resource_group_name: str, + profile_name: str, + profile: Union[_models.Profile, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(profile, (IOBase, bytes)): + _content = profile + else: + _content = json.dumps(profile, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_profiles_create_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create( + self, + resource_group_name: str, + profile_name: str, + profile: _models.Profile, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Profile]: + """Creates a new Azure Front Door Standard or Azure Front Door Premium or CDN profile with a + profile name under the specified subscription and resource group. + + :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 or CDN + profile which is unique within the resource group. Required. + :type profile_name: str + :param profile: Profile properties needed to create a new profile. Required. + :type profile: ~azure.mgmt.cdn.models.Profile + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns Profile. The Profile is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Profile] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + profile_name: str, + profile: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Profile]: + """Creates a new Azure Front Door Standard or Azure Front Door Premium or CDN profile with a + profile name under the specified subscription and resource group. + + :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 or CDN + profile which is unique within the resource group. Required. + :type profile_name: str + :param profile: Profile properties needed to create a new profile. Required. + :type profile: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns Profile. The Profile is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Profile] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + profile_name: str, + profile: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Profile]: + """Creates a new Azure Front Door Standard or Azure Front Door Premium or CDN profile with a + profile name under the specified subscription and resource group. + + :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 or CDN + profile which is unique within the resource group. Required. + :type profile_name: str + :param profile: Profile properties needed to create a new profile. Required. + :type profile: IO[bytes] + :keyword content_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 Profile. The Profile is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Profile] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + profile_name: str, + profile: Union[_models.Profile, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.Profile]: + """Creates a new Azure Front Door Standard or Azure Front Door Premium or CDN profile with a + profile name under the specified subscription and resource group. + + :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 or CDN + profile which is unique within the resource group. Required. + :type profile_name: str + :param profile: Profile properties needed to create a new profile. Is one of the following + types: Profile, JSON, IO[bytes] Required. + :type profile: ~azure.mgmt.cdn.models.Profile or JSON or IO[bytes] + :return: An instance of LROPoller that returns Profile. The Profile is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Profile] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Profile] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_initial( + resource_group_name=resource_group_name, + profile_name=profile_name, + profile=profile, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.Profile, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.Profile].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.Profile]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _update_initial( + self, + resource_group_name: str, + profile_name: str, + profile_update_parameters: Union[_models.ProfileUpdateParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(profile_update_parameters, (IOBase, bytes)): + _content = profile_update_parameters + else: + _content = json.dumps(profile_update_parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_profiles_update_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + profile_name: str, + profile_update_parameters: _models.ProfileUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Profile]: + """Updates an existing Azure Front Door Standard or Azure Front Door Premium or CDN profile with + the specified profile name under the specified subscription and resource group. + + :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 or CDN + profile which is unique within the resource group. Required. + :type profile_name: str + :param profile_update_parameters: Profile properties needed to update an existing profile. + Required. + :type profile_update_parameters: ~azure.mgmt.cdn.models.ProfileUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns Profile. The Profile is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Profile] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + profile_name: str, + profile_update_parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Profile]: + """Updates an existing Azure Front Door Standard or Azure Front Door Premium or CDN profile with + the specified profile name under the specified subscription and resource group. + + :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 or CDN + profile which is unique within the resource group. Required. + :type profile_name: str + :param profile_update_parameters: Profile properties needed to update an existing profile. + Required. + :type profile_update_parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns Profile. The Profile is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Profile] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + profile_name: str, + profile_update_parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Profile]: + """Updates an existing Azure Front Door Standard or Azure Front Door Premium or CDN profile with + the specified profile name under the specified subscription and resource group. + + :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 or CDN + profile which is unique within the resource group. Required. + :type profile_name: str + :param profile_update_parameters: Profile properties needed to update an existing profile. + Required. + :type profile_update_parameters: IO[bytes] + :keyword content_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 Profile. The Profile is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Profile] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + profile_name: str, + profile_update_parameters: Union[_models.ProfileUpdateParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.Profile]: + """Updates an existing Azure Front Door Standard or Azure Front Door Premium or CDN profile with + the specified profile name under the specified subscription and resource group. + + :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 or CDN + profile which is unique within the resource group. Required. + :type profile_name: str + :param profile_update_parameters: Profile properties needed to update an existing profile. Is + one of the following types: ProfileUpdateParameters, JSON, IO[bytes] Required. + :type profile_update_parameters: ~azure.mgmt.cdn.models.ProfileUpdateParameters or JSON or + IO[bytes] + :return: An instance of LROPoller that returns Profile. The Profile is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Profile] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Profile] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._update_initial( + resource_group_name=resource_group_name, + profile_name=profile_name, + profile_update_parameters=profile_update_parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.Profile, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.Profile].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.Profile]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_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 = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_profiles_delete_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete(self, resource_group_name: str, profile_name: str, **kwargs: Any) -> LROPoller[None]: + """Deletes an existing Azure Front Door Standard or Azure Front Door Premium or CDN profile with + the specified parameters. Deleting a profile will result in the deletion of all of the + sub-resources including endpoints, origins and custom domains. + + :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 or CDN + profile which is unique within the resource group. Required. + :type profile_name: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + profile_name=profile_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> ItemPaged["_models.Profile"]: + """Lists all of the Azure Front Door Standard, Azure Front Door Premium, and CDN profiles within a + resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :return: An iterator like instance of Profile + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cdn.models.Profile] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Profile]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_profiles_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.Profile], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list(self, **kwargs: Any) -> ItemPaged["_models.Profile"]: + """Lists all of the Azure Front Door Standard, Azure Front Door Premium, and CDN profiles within + an Azure subscription. + + :return: An iterator like instance of Profile + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cdn.models.Profile] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Profile]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_profiles_list_request( + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.Profile], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + def _migration_commit_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 = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_profiles_migration_commit_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_migration_commit(self, resource_group_name: str, profile_name: str, **kwargs: Any) -> LROPoller[None]: + """Commit the migrated 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 or CDN + profile which is unique within the resource group. Required. + :type profile_name: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._migration_commit_initial( + resource_group_name=resource_group_name, + profile_name=profile_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def generate_sso_uri(self, resource_group_name: str, profile_name: str, **kwargs: Any) -> _models.SsoUri: + """Generates a dynamic SSO URI used to sign in to the CDN supplemental portal. Supplemental portal + is used to configure advanced feature capabilities that are not yet available in the Azure + portal, such as core reports in a standard profile; rules engine, advanced HTTP reports, and + real-time stats and alerts in a premium profile. The SSO URI changes approximately every 10 + minutes. + + :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 or CDN + profile which is unique within the resource group. Required. + :type profile_name: str + :return: SsoUri. The SsoUri is compatible with MutableMapping + :rtype: ~azure.mgmt.cdn.models.SsoUri + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.SsoUri] = kwargs.pop("cls", None) + + _request = build_profiles_generate_sso_uri_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.SsoUri, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_supported_optimization_types( + self, resource_group_name: str, profile_name: str, **kwargs: Any + ) -> _models.SupportedOptimizationTypesListResult: + """Gets the supported optimization types for the current profile. A user can create an endpoint + with an optimization type from the listed values. + + :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 or CDN + profile which is unique within the resource group. Required. + :type profile_name: str + :return: SupportedOptimizationTypesListResult. The SupportedOptimizationTypesListResult is + compatible with MutableMapping + :rtype: ~azure.mgmt.cdn.models.SupportedOptimizationTypesListResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.SupportedOptimizationTypesListResult] = kwargs.pop("cls", None) + + _request = build_profiles_list_supported_optimization_types_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.SupportedOptimizationTypesListResult, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_resource_usage( + self, resource_group_name: str, profile_name: str, **kwargs: Any + ) -> ItemPaged["_models.ResourceUsage"]: + """Checks the quota and actual usage of endpoints under the given Azure Front Door Standard or + Azure Front Door Premium or CDN 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 or CDN + profile which is unique within the resource group. Required. + :type profile_name: str + :return: An iterator like instance of ResourceUsage + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cdn.models.ResourceUsage] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ResourceUsage]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_profiles_list_resource_usage_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ResourceUsage], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + def _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 = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_profiles_cdn_can_migrate_to_afd_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_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 or CDN + profile which is unique within the resource group. Required. + :type profile_name: str + :return: An instance of LROPoller that returns CanMigrateResult. The CanMigrateResult is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.CanMigrateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.CanMigrateResult, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.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, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(migration_parameters, (IOBase, bytes)): + _content = migration_parameters + else: + _content = json.dumps(migration_parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_profiles_cdn_migrate_to_afd_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_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 or CDN + profile 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 MigrateResult. The MigrateResult is compatible + with MutableMapping + :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: JSON, + *, + 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 or CDN + profile 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: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns MigrateResult. The MigrateResult is compatible + with MutableMapping + :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 or CDN + profile 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 MigrateResult. The MigrateResult is compatible + with MutableMapping + :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, JSON, 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 or CDN + profile which is unique within the resource group. Required. + :type profile_name: str + :param migration_parameters: Properties needed to migrate the profile. Is one of the following + types: CdnMigrationToAfdParameters, JSON, IO[bytes] Required. + :type migration_parameters: ~azure.mgmt.cdn.models.CdnMigrationToAfdParameters or JSON or + IO[bytes] + :return: An instance of LROPoller that returns MigrateResult. The MigrateResult is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.MigrateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.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, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.MigrateResult, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.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 = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_profiles_migration_abort_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @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 or CDN + profile which is unique within the resource group. Required. + :type profile_name: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._migration_abort_initial( + resource_group_name=resource_group_name, + profile_name=profile_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + def _can_migrate_initial( + self, + resource_group_name: str, + can_migrate_parameters: Union[_models.CanMigrateParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(can_migrate_parameters, (IOBase, bytes)): + _content = can_migrate_parameters + else: + _content = json.dumps(can_migrate_parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_profiles_can_migrate_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_can_migrate( + self, + resource_group_name: str, + can_migrate_parameters: _models.CanMigrateParameters, + *, + content_type: str = "application/json", + **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 can_migrate_parameters: Properties needed to check if cdn profile or classic frontdoor + can be migrated. Required. + :type can_migrate_parameters: ~azure.mgmt.cdn.models.CanMigrateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns CanMigrateResult. The CanMigrateResult is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.CanMigrateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_can_migrate( + self, + resource_group_name: str, + can_migrate_parameters: JSON, + *, + content_type: str = "application/json", + **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 can_migrate_parameters: Properties needed to check if cdn profile or classic frontdoor + can be migrated. Required. + :type can_migrate_parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns CanMigrateResult. The CanMigrateResult is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.CanMigrateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_can_migrate( + self, + resource_group_name: str, + can_migrate_parameters: IO[bytes], + *, + content_type: str = "application/json", + **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 can_migrate_parameters: Properties needed to check if cdn profile or classic frontdoor + can be migrated. Required. + :type can_migrate_parameters: IO[bytes] + :keyword content_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 CanMigrateResult. The CanMigrateResult is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.CanMigrateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_can_migrate( + self, + resource_group_name: str, + can_migrate_parameters: Union[_models.CanMigrateParameters, JSON, IO[bytes]], + **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 can_migrate_parameters: Properties needed to check if cdn profile or classic frontdoor + can be migrated. Is one of the following types: CanMigrateParameters, JSON, IO[bytes] Required. + :type can_migrate_parameters: ~azure.mgmt.cdn.models.CanMigrateParameters or JSON or IO[bytes] + :return: An instance of LROPoller that returns CanMigrateResult. The CanMigrateResult is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.CanMigrateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.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._can_migrate_initial( + resource_group_name=resource_group_name, + can_migrate_parameters=can_migrate_parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.CanMigrateResult, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.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 _migrate_initial( + self, + resource_group_name: str, + migration_parameters: Union[_models.MigrationParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(migration_parameters, (IOBase, bytes)): + _content = migration_parameters + else: + _content = json.dumps(migration_parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_profiles_migrate_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_migrate( + self, + resource_group_name: str, + migration_parameters: _models.MigrationParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.MigrateResult]: + """Migrate the CDN profile to Azure Frontdoor(Standard/Premium) profile. The change need to be + committed after this. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param migration_parameters: Properties needed to migrate the profile. Required. + :type migration_parameters: ~azure.mgmt.cdn.models.MigrationParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns MigrateResult. The MigrateResult is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.MigrateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_migrate( + self, + resource_group_name: str, + migration_parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.MigrateResult]: + """Migrate the CDN profile to Azure Frontdoor(Standard/Premium) profile. The change need to be + committed after this. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param migration_parameters: Properties needed to migrate the profile. Required. + :type migration_parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns MigrateResult. The MigrateResult is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.MigrateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_migrate( + self, + resource_group_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. The change need to be + committed after this. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_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 MigrateResult. The MigrateResult is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.MigrateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_migrate( + self, + resource_group_name: str, + migration_parameters: Union[_models.MigrationParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.MigrateResult]: + """Migrate the CDN profile to Azure Frontdoor(Standard/Premium) profile. The change need to be + committed after this. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param migration_parameters: Properties needed to migrate the profile. Is one of the following + types: MigrationParameters, JSON, IO[bytes] Required. + :type migration_parameters: ~azure.mgmt.cdn.models.MigrationParameters or JSON or IO[bytes] + :return: An instance of LROPoller that returns MigrateResult. The MigrateResult is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.MigrateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.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._migrate_initial( + resource_group_name=resource_group_name, + migration_parameters=migration_parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.MigrateResult, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.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 + ) + + +class AFDEndpointsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cdn.CdnManagementClient`'s + :attr:`afd_endpoints` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: 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( + self, resource_group_name: str, profile_name: str, endpoint_name: str, **kwargs: Any + ) -> _models.AFDEndpoint: + """Gets an existing AzureFrontDoor endpoint with the specified endpoint name under the specified + subscription, resource group and 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 or CDN + profile 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. + :type endpoint_name: str + :return: AFDEndpoint. The AFDEndpoint is compatible with MutableMapping + :rtype: ~azure.mgmt.cdn.models.AFDEndpoint + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.AFDEndpoint] = kwargs.pop("cls", None) + + _request = build_afd_endpoints_get_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.AFDEndpoint, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_initial( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + endpoint: Union[_models.AFDEndpoint, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(endpoint, (IOBase, bytes)): + _content = endpoint + else: + _content = json.dumps(endpoint, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_afd_endpoints_create_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + endpoint: _models.AFDEndpoint, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AFDEndpoint]: + """Creates a new AzureFrontDoor endpoint with the specified endpoint name under the specified + subscription, resource group and 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 or CDN + profile 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. + :type endpoint_name: str + :param endpoint: Endpoint properties. Required. + :type endpoint: ~azure.mgmt.cdn.models.AFDEndpoint + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns AFDEndpoint. The AFDEndpoint is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.AFDEndpoint] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + endpoint: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AFDEndpoint]: + """Creates a new AzureFrontDoor endpoint with the specified endpoint name under the specified + subscription, resource group and 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 or CDN + profile 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. + :type endpoint_name: str + :param endpoint: Endpoint properties. Required. + :type endpoint: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns AFDEndpoint. The AFDEndpoint is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.AFDEndpoint] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + endpoint: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AFDEndpoint]: + """Creates a new AzureFrontDoor endpoint with the specified endpoint name under the specified + subscription, resource group and 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 or CDN + profile 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. + :type endpoint_name: str + :param endpoint: Endpoint properties. Required. + :type endpoint: IO[bytes] + :keyword content_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 AFDEndpoint. The AFDEndpoint is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.AFDEndpoint] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + endpoint: Union[_models.AFDEndpoint, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.AFDEndpoint]: + """Creates a new AzureFrontDoor endpoint with the specified endpoint name under the specified + subscription, resource group and 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 or CDN + profile 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. + :type endpoint_name: str + :param endpoint: Endpoint properties. Is one of the following types: AFDEndpoint, JSON, + IO[bytes] Required. + :type endpoint: ~azure.mgmt.cdn.models.AFDEndpoint or JSON or IO[bytes] + :return: An instance of LROPoller that returns AFDEndpoint. The AFDEndpoint is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.AFDEndpoint] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AFDEndpoint] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_initial( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + endpoint=endpoint, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.AFDEndpoint, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.AFDEndpoint].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.AFDEndpoint]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _update_initial( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + endpoint_update_properties: Union[_models.AFDEndpointUpdateParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(endpoint_update_properties, (IOBase, bytes)): + _content = endpoint_update_properties + else: + _content = json.dumps(endpoint_update_properties, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_afd_endpoints_update_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + endpoint_update_properties: _models.AFDEndpointUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AFDEndpoint]: + """Updates an existing AzureFrontDoor endpoint with the specified endpoint name under the + specified subscription, resource group and profile. Only tags can be updated after creating an + endpoint. To update origins, use the Update Origin operation. To update origin groups, use the + Update Origin group operation. To update domains, use the Update Custom Domain operation. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param endpoint_update_properties: Endpoint update properties. Required. + :type endpoint_update_properties: ~azure.mgmt.cdn.models.AFDEndpointUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns AFDEndpoint. The AFDEndpoint is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.AFDEndpoint] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + endpoint_update_properties: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AFDEndpoint]: + """Updates an existing AzureFrontDoor endpoint with the specified endpoint name under the + specified subscription, resource group and profile. Only tags can be updated after creating an + endpoint. To update origins, use the Update Origin operation. To update origin groups, use the + Update Origin group operation. To update domains, use the Update Custom Domain operation. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param endpoint_update_properties: Endpoint update properties. Required. + :type endpoint_update_properties: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns AFDEndpoint. The AFDEndpoint is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.AFDEndpoint] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + endpoint_update_properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AFDEndpoint]: + """Updates an existing AzureFrontDoor endpoint with the specified endpoint name under the + specified subscription, resource group and profile. Only tags can be updated after creating an + endpoint. To update origins, use the Update Origin operation. To update origin groups, use the + Update Origin group operation. To update domains, use the Update Custom Domain operation. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param endpoint_update_properties: Endpoint update properties. Required. + :type endpoint_update_properties: IO[bytes] + :keyword content_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 AFDEndpoint. The AFDEndpoint is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.AFDEndpoint] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + endpoint_update_properties: Union[_models.AFDEndpointUpdateParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.AFDEndpoint]: + """Updates an existing AzureFrontDoor endpoint with the specified endpoint name under the + specified subscription, resource group and profile. Only tags can be updated after creating an + endpoint. To update origins, use the Update Origin operation. To update origin groups, use the + Update Origin group operation. To update domains, use the Update Custom Domain operation. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param endpoint_update_properties: Endpoint update properties. Is one of the following types: + AFDEndpointUpdateParameters, JSON, IO[bytes] Required. + :type endpoint_update_properties: ~azure.mgmt.cdn.models.AFDEndpointUpdateParameters or JSON or + IO[bytes] + :return: An instance of LROPoller that returns AFDEndpoint. The AFDEndpoint is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.AFDEndpoint] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AFDEndpoint] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._update_initial( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + endpoint_update_properties=endpoint_update_properties, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.AFDEndpoint, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.AFDEndpoint].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.AFDEndpoint]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_initial( + self, resource_group_name: str, profile_name: str, endpoint_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_afd_endpoints_delete_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, profile_name: str, endpoint_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Deletes an existing AzureFrontDoor endpoint with the specified endpoint name under the + specified subscription, resource group and 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 or CDN + profile 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. + :type endpoint_name: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_profile( + self, resource_group_name: str, profile_name: str, **kwargs: Any + ) -> ItemPaged["_models.AFDEndpoint"]: + """Lists existing AzureFrontDoor endpoints. + + :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 or CDN + profile which is unique within the resource group. Required. + :type profile_name: str + :return: An iterator like instance of AFDEndpoint + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cdn.models.AFDEndpoint] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.AFDEndpoint]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_afd_endpoints_list_by_profile_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.AFDEndpoint], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + def _purge_content_initial( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + contents: Union[_models.AfdPurgeParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(contents, (IOBase, bytes)): + _content = contents + else: + _content = json.dumps(contents, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_afd_endpoints_purge_content_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_purge_content( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + contents: _models.AfdPurgeParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Removes a content from AzureFrontDoor. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param contents: The list of paths to the content and the list of linked domains to be purged. + Path can be a full URL, e.g. '/pictures/city.png' which removes a single file, or a directory + with a wildcard, e.g. '/pictures/*' which removes all folders and files in the directory. + Required. + :type contents: ~azure.mgmt.cdn.models.AfdPurgeParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_purge_content( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + contents: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Removes a content from AzureFrontDoor. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param contents: The list of paths to the content and the list of linked domains to be purged. + Path can be a full URL, e.g. '/pictures/city.png' which removes a single file, or a directory + with a wildcard, e.g. '/pictures/*' which removes all folders and files in the directory. + Required. + :type contents: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_purge_content( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + contents: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Removes a content from AzureFrontDoor. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param contents: The list of paths to the content and the list of linked domains to be purged. + Path can be a full URL, e.g. '/pictures/city.png' which removes a single file, or a directory + with a wildcard, e.g. '/pictures/*' which removes all folders and files in the directory. + Required. + :type contents: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_purge_content( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + contents: Union[_models.AfdPurgeParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[None]: + """Removes a content from AzureFrontDoor. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param contents: The list of paths to the content and the list of linked domains to be purged. + Path can be a full URL, e.g. '/pictures/city.png' which removes a single file, or a directory + with a wildcard, e.g. '/pictures/*' which removes all folders and files in the directory. Is + one of the following types: AfdPurgeParameters, JSON, IO[bytes] Required. + :type contents: ~azure.mgmt.cdn.models.AfdPurgeParameters or JSON or IO[bytes] + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._purge_content_initial( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + contents=contents, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_resource_usage( + self, resource_group_name: str, profile_name: str, endpoint_name: str, **kwargs: Any + ) -> ItemPaged["_models.Usage"]: + """Checks the quota and actual usage of endpoints under the given Azure Front Door 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 or CDN + profile 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. + :type endpoint_name: str + :return: An iterator like instance of Usage + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cdn.models.Usage] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Usage]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_afd_endpoints_list_resource_usage_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.Usage], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @overload + def validate_custom_domain( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + custom_domain_properties: _models.ValidateCustomDomainInput, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ValidateCustomDomainOutput: + """Validates the custom domain mapping to ensure it maps to the correct Azure Front Door endpoint + in DNS. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param custom_domain_properties: Custom domain to be validated. Required. + :type custom_domain_properties: ~azure.mgmt.cdn.models.ValidateCustomDomainInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ValidateCustomDomainOutput. The ValidateCustomDomainOutput is compatible with + MutableMapping + :rtype: ~azure.mgmt.cdn.models.ValidateCustomDomainOutput + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def validate_custom_domain( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + custom_domain_properties: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ValidateCustomDomainOutput: + """Validates the custom domain mapping to ensure it maps to the correct Azure Front Door endpoint + in DNS. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param custom_domain_properties: Custom domain to be validated. Required. + :type custom_domain_properties: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ValidateCustomDomainOutput. The ValidateCustomDomainOutput is compatible with + MutableMapping + :rtype: ~azure.mgmt.cdn.models.ValidateCustomDomainOutput + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def validate_custom_domain( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + custom_domain_properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ValidateCustomDomainOutput: + """Validates the custom domain mapping to ensure it maps to the correct Azure Front Door endpoint + in DNS. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param custom_domain_properties: Custom domain to be validated. Required. + :type custom_domain_properties: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ValidateCustomDomainOutput. The ValidateCustomDomainOutput is compatible with + MutableMapping + :rtype: ~azure.mgmt.cdn.models.ValidateCustomDomainOutput + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def validate_custom_domain( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + custom_domain_properties: Union[_models.ValidateCustomDomainInput, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.ValidateCustomDomainOutput: + """Validates the custom domain mapping to ensure it maps to the correct Azure Front Door endpoint + in DNS. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param custom_domain_properties: Custom domain to be validated. Is one of the following types: + ValidateCustomDomainInput, JSON, IO[bytes] Required. + :type custom_domain_properties: ~azure.mgmt.cdn.models.ValidateCustomDomainInput or JSON or + IO[bytes] + :return: ValidateCustomDomainOutput. The ValidateCustomDomainOutput is compatible with + MutableMapping + :rtype: ~azure.mgmt.cdn.models.ValidateCustomDomainOutput + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ValidateCustomDomainOutput] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(custom_domain_properties, (IOBase, bytes)): + _content = custom_domain_properties + else: + _content = json.dumps(custom_domain_properties, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_afd_endpoints_validate_custom_domain_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ValidateCustomDomainOutput, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class AFDOriginGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cdn.CdnManagementClient`'s + :attr:`afd_origin_groups` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: 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( + self, resource_group_name: str, profile_name: str, origin_group_name: str, **kwargs: Any + ) -> _models.AFDOriginGroup: + """Gets an existing origin group within a 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 or CDN + profile 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. + :type origin_group_name: str + :return: AFDOriginGroup. The AFDOriginGroup is compatible with MutableMapping + :rtype: ~azure.mgmt.cdn.models.AFDOriginGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.AFDOriginGroup] = kwargs.pop("cls", None) + + _request = build_afd_origin_groups_get_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + origin_group_name=origin_group_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.AFDOriginGroup, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_initial( + self, + resource_group_name: str, + profile_name: str, + origin_group_name: str, + origin_group: Union[_models.AFDOriginGroup, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(origin_group, (IOBase, bytes)): + _content = origin_group + else: + _content = json.dumps(origin_group, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_afd_origin_groups_create_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + origin_group_name=origin_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create( + self, + resource_group_name: str, + profile_name: str, + origin_group_name: str, + origin_group: _models.AFDOriginGroup, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AFDOriginGroup]: + """Creates a new origin group within the specified 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 or CDN + profile 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. + :type origin_group_name: str + :param origin_group: Origin group properties. Required. + :type origin_group: ~azure.mgmt.cdn.models.AFDOriginGroup + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns AFDOriginGroup. The AFDOriginGroup is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.AFDOriginGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + profile_name: str, + origin_group_name: str, + origin_group: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AFDOriginGroup]: + """Creates a new origin group within the specified 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 or CDN + profile 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. + :type origin_group_name: str + :param origin_group: Origin group properties. Required. + :type origin_group: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns AFDOriginGroup. The AFDOriginGroup is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.AFDOriginGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + profile_name: str, + origin_group_name: str, + origin_group: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AFDOriginGroup]: + """Creates a new origin group within the specified 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 or CDN + profile 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. + :type origin_group_name: str + :param origin_group: Origin group properties. Required. + :type origin_group: IO[bytes] + :keyword content_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 AFDOriginGroup. The AFDOriginGroup is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.AFDOriginGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + profile_name: str, + origin_group_name: str, + origin_group: Union[_models.AFDOriginGroup, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.AFDOriginGroup]: + """Creates a new origin group within the specified 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 or CDN + profile 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. + :type origin_group_name: str + :param origin_group: Origin group properties. Is one of the following types: AFDOriginGroup, + JSON, IO[bytes] Required. + :type origin_group: ~azure.mgmt.cdn.models.AFDOriginGroup or JSON or IO[bytes] + :return: An instance of LROPoller that returns AFDOriginGroup. The AFDOriginGroup is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.AFDOriginGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AFDOriginGroup] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_initial( + resource_group_name=resource_group_name, + profile_name=profile_name, + origin_group_name=origin_group_name, + origin_group=origin_group, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.AFDOriginGroup, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.AFDOriginGroup].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.AFDOriginGroup]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _update_initial( + self, + resource_group_name: str, + profile_name: str, + origin_group_name: str, + origin_group_update_properties: Union[_models.AFDOriginGroupUpdateParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(origin_group_update_properties, (IOBase, bytes)): + _content = origin_group_update_properties + else: + _content = json.dumps(origin_group_update_properties, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_afd_origin_groups_update_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + origin_group_name=origin_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + profile_name: str, + origin_group_name: str, + origin_group_update_properties: _models.AFDOriginGroupUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AFDOriginGroup]: + """Updates an existing origin group within a 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 or CDN + profile 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. + :type origin_group_name: str + :param origin_group_update_properties: Origin group properties. Required. + :type origin_group_update_properties: ~azure.mgmt.cdn.models.AFDOriginGroupUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns AFDOriginGroup. The AFDOriginGroup is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.AFDOriginGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + profile_name: str, + origin_group_name: str, + origin_group_update_properties: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AFDOriginGroup]: + """Updates an existing origin group within a 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 or CDN + profile 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. + :type origin_group_name: str + :param origin_group_update_properties: Origin group properties. Required. + :type origin_group_update_properties: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns AFDOriginGroup. The AFDOriginGroup is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.AFDOriginGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + profile_name: str, + origin_group_name: str, + origin_group_update_properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AFDOriginGroup]: + """Updates an existing origin group within a 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 or CDN + profile 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. + :type origin_group_name: str + :param origin_group_update_properties: Origin group properties. Required. + :type origin_group_update_properties: IO[bytes] + :keyword content_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 AFDOriginGroup. The AFDOriginGroup is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.AFDOriginGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + profile_name: str, + origin_group_name: str, + origin_group_update_properties: Union[_models.AFDOriginGroupUpdateParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.AFDOriginGroup]: + """Updates an existing origin group within a 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 or CDN + profile 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. + :type origin_group_name: str + :param origin_group_update_properties: Origin group properties. Is one of the following types: + AFDOriginGroupUpdateParameters, JSON, IO[bytes] Required. + :type origin_group_update_properties: ~azure.mgmt.cdn.models.AFDOriginGroupUpdateParameters or + JSON or IO[bytes] + :return: An instance of LROPoller that returns AFDOriginGroup. The AFDOriginGroup is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.AFDOriginGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AFDOriginGroup] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._update_initial( + resource_group_name=resource_group_name, + profile_name=profile_name, + origin_group_name=origin_group_name, + origin_group_update_properties=origin_group_update_properties, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.AFDOriginGroup, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.AFDOriginGroup].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.AFDOriginGroup]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_initial( + self, resource_group_name: str, profile_name: str, origin_group_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_afd_origin_groups_delete_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + origin_group_name=origin_group_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, profile_name: str, origin_group_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Deletes an existing origin group within a 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 or CDN + profile 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. + :type origin_group_name: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + profile_name=profile_name, + origin_group_name=origin_group_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_profile( + self, resource_group_name: str, profile_name: str, **kwargs: Any + ) -> ItemPaged["_models.AFDOriginGroup"]: + """Lists all of the existing origin groups within a 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 or CDN + profile which is unique within the resource group. Required. + :type profile_name: str + :return: An iterator like instance of AFDOriginGroup + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cdn.models.AFDOriginGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.AFDOriginGroup]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_afd_origin_groups_list_by_profile_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.AFDOriginGroup], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_resource_usage( + self, resource_group_name: str, profile_name: str, origin_group_name: str, **kwargs: Any + ) -> ItemPaged["_models.Usage"]: + """Checks the quota and actual usage of endpoints under the given Azure Front Door 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 or CDN + profile 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. + :type origin_group_name: str + :return: An iterator like instance of Usage + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cdn.models.Usage] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Usage]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_afd_origin_groups_list_resource_usage_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + origin_group_name=origin_group_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.Usage], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class AFDOriginsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cdn.CdnManagementClient`'s + :attr:`afd_origins` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: 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( + self, resource_group_name: str, profile_name: str, origin_group_name: str, origin_name: str, **kwargs: Any + ) -> _models.AFDOrigin: + """Gets an existing origin within an origin group. + + :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 or CDN + profile 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. + :type origin_group_name: str + :param origin_name: Name of the origin which is unique within the profile. Required. + :type origin_name: str + :return: AFDOrigin. The AFDOrigin is compatible with MutableMapping + :rtype: ~azure.mgmt.cdn.models.AFDOrigin + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.AFDOrigin] = kwargs.pop("cls", None) + + _request = build_afd_origins_get_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + origin_group_name=origin_group_name, + origin_name=origin_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.AFDOrigin, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_initial( + self, + resource_group_name: str, + profile_name: str, + origin_group_name: str, + origin_name: str, + origin: Union[_models.AFDOrigin, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(origin, (IOBase, bytes)): + _content = origin + else: + _content = json.dumps(origin, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_afd_origins_create_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + origin_group_name=origin_group_name, + origin_name=origin_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create( + self, + resource_group_name: str, + profile_name: str, + origin_group_name: str, + origin_name: str, + origin: _models.AFDOrigin, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AFDOrigin]: + """Creates a new origin within the specified origin group. + + :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 or CDN + profile 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. + :type origin_group_name: str + :param origin_name: Name of the origin which is unique within the profile. Required. + :type origin_name: str + :param origin: Origin properties. Required. + :type origin: ~azure.mgmt.cdn.models.AFDOrigin + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns AFDOrigin. The AFDOrigin is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.AFDOrigin] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + profile_name: str, + origin_group_name: str, + origin_name: str, + origin: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AFDOrigin]: + """Creates a new origin within the specified origin group. + + :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 or CDN + profile 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. + :type origin_group_name: str + :param origin_name: Name of the origin which is unique within the profile. Required. + :type origin_name: str + :param origin: Origin properties. Required. + :type origin: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns AFDOrigin. The AFDOrigin is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.AFDOrigin] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + profile_name: str, + origin_group_name: str, + origin_name: str, + origin: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AFDOrigin]: + """Creates a new origin within the specified origin group. + + :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 or CDN + profile 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. + :type origin_group_name: str + :param origin_name: Name of the origin which is unique within the profile. Required. + :type origin_name: str + :param origin: Origin properties. Required. + :type origin: IO[bytes] + :keyword content_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 AFDOrigin. The AFDOrigin is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.AFDOrigin] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + profile_name: str, + origin_group_name: str, + origin_name: str, + origin: Union[_models.AFDOrigin, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.AFDOrigin]: + """Creates a new origin within the specified origin group. + + :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 or CDN + profile 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. + :type origin_group_name: str + :param origin_name: Name of the origin which is unique within the profile. Required. + :type origin_name: str + :param origin: Origin properties. Is one of the following types: AFDOrigin, JSON, IO[bytes] + Required. + :type origin: ~azure.mgmt.cdn.models.AFDOrigin or JSON or IO[bytes] + :return: An instance of LROPoller that returns AFDOrigin. The AFDOrigin is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.AFDOrigin] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AFDOrigin] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_initial( + resource_group_name=resource_group_name, + profile_name=profile_name, + origin_group_name=origin_group_name, + origin_name=origin_name, + origin=origin, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.AFDOrigin, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.AFDOrigin].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.AFDOrigin]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _update_initial( + self, + resource_group_name: str, + profile_name: str, + origin_group_name: str, + origin_name: str, + origin_update_properties: Union[_models.AFDOriginUpdateParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(origin_update_properties, (IOBase, bytes)): + _content = origin_update_properties + else: + _content = json.dumps(origin_update_properties, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_afd_origins_update_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + origin_group_name=origin_group_name, + origin_name=origin_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + profile_name: str, + origin_group_name: str, + origin_name: str, + origin_update_properties: _models.AFDOriginUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AFDOrigin]: + """Updates an existing origin within an origin group. + + :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 or CDN + profile 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. + :type origin_group_name: str + :param origin_name: Name of the origin which is unique within the profile. Required. + :type origin_name: str + :param origin_update_properties: Origin properties. Required. + :type origin_update_properties: ~azure.mgmt.cdn.models.AFDOriginUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns AFDOrigin. The AFDOrigin is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.AFDOrigin] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + profile_name: str, + origin_group_name: str, + origin_name: str, + origin_update_properties: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AFDOrigin]: + """Updates an existing origin within an origin group. + + :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 or CDN + profile 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. + :type origin_group_name: str + :param origin_name: Name of the origin which is unique within the profile. Required. + :type origin_name: str + :param origin_update_properties: Origin properties. Required. + :type origin_update_properties: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns AFDOrigin. The AFDOrigin is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.AFDOrigin] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + profile_name: str, + origin_group_name: str, + origin_name: str, + origin_update_properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AFDOrigin]: + """Updates an existing origin within an origin group. + + :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 or CDN + profile 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. + :type origin_group_name: str + :param origin_name: Name of the origin which is unique within the profile. Required. + :type origin_name: str + :param origin_update_properties: Origin properties. Required. + :type origin_update_properties: IO[bytes] + :keyword content_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 AFDOrigin. The AFDOrigin is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.AFDOrigin] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + profile_name: str, + origin_group_name: str, + origin_name: str, + origin_update_properties: Union[_models.AFDOriginUpdateParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.AFDOrigin]: + """Updates an existing origin within an origin group. + + :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 or CDN + profile 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. + :type origin_group_name: str + :param origin_name: Name of the origin which is unique within the profile. Required. + :type origin_name: str + :param origin_update_properties: Origin properties. Is one of the following types: + AFDOriginUpdateParameters, JSON, IO[bytes] Required. + :type origin_update_properties: ~azure.mgmt.cdn.models.AFDOriginUpdateParameters or JSON or + IO[bytes] + :return: An instance of LROPoller that returns AFDOrigin. The AFDOrigin is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.AFDOrigin] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AFDOrigin] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._update_initial( + resource_group_name=resource_group_name, + profile_name=profile_name, + origin_group_name=origin_group_name, + origin_name=origin_name, + origin_update_properties=origin_update_properties, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.AFDOrigin, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.AFDOrigin].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.AFDOrigin]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_initial( + self, resource_group_name: str, profile_name: str, origin_group_name: str, origin_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_afd_origins_delete_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + origin_group_name=origin_group_name, + origin_name=origin_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, profile_name: str, origin_group_name: str, origin_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Deletes an existing origin within an origin group. + + :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 or CDN + profile 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. + :type origin_group_name: str + :param origin_name: Name of the origin which is unique within the profile. Required. + :type origin_name: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + profile_name=profile_name, + origin_group_name=origin_group_name, + origin_name=origin_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_origin_group( + self, resource_group_name: str, profile_name: str, origin_group_name: str, **kwargs: Any + ) -> ItemPaged["_models.AFDOrigin"]: + """Lists all of the existing origins within an origin group. + + :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 or CDN + profile 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. + :type origin_group_name: str + :return: An iterator like instance of AFDOrigin + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cdn.models.AFDOrigin] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.AFDOrigin]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_afd_origins_list_by_origin_group_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + origin_group_name=origin_group_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.AFDOrigin], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class RoutesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cdn.CdnManagementClient`'s + :attr:`routes` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: 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( + self, resource_group_name: str, profile_name: str, endpoint_name: str, route_name: str, **kwargs: Any + ) -> _models.Route: + """Gets an existing route with the specified route name under the specified subscription, resource + group, profile, and AzureFrontDoor endpoint. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param route_name: Name of the routing rule. Required. + :type route_name: str + :return: Route. The Route is compatible with MutableMapping + :rtype: ~azure.mgmt.cdn.models.Route + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.Route] = kwargs.pop("cls", None) + + _request = build_routes_get_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + route_name=route_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Route, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_initial( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + route_name: str, + route: Union[_models.Route, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(route, (IOBase, bytes)): + _content = route + else: + _content = json.dumps(route, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_routes_create_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + route_name=route_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + route_name: str, + route: _models.Route, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Route]: + """Creates a new route with the specified route name under the specified subscription, resource + group, profile, and AzureFrontDoor endpoint. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param route_name: Name of the routing rule. Required. + :type route_name: str + :param route: Route properties. Required. + :type route: ~azure.mgmt.cdn.models.Route + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns Route. The Route is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Route] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + route_name: str, + route: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Route]: + """Creates a new route with the specified route name under the specified subscription, resource + group, profile, and AzureFrontDoor endpoint. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param route_name: Name of the routing rule. Required. + :type route_name: str + :param route: Route properties. Required. + :type route: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns Route. The Route is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Route] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + route_name: str, + route: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Route]: + """Creates a new route with the specified route name under the specified subscription, resource + group, profile, and AzureFrontDoor endpoint. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param route_name: Name of the routing rule. Required. + :type route_name: str + :param route: Route properties. Required. + :type route: IO[bytes] + :keyword content_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 Route. The Route is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Route] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + route_name: str, + route: Union[_models.Route, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.Route]: + """Creates a new route with the specified route name under the specified subscription, resource + group, profile, and AzureFrontDoor endpoint. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param route_name: Name of the routing rule. Required. + :type route_name: str + :param route: Route properties. Is one of the following types: Route, JSON, IO[bytes] Required. + :type route: ~azure.mgmt.cdn.models.Route or JSON or IO[bytes] + :return: An instance of LROPoller that returns Route. The Route is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Route] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Route] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_initial( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + route_name=route_name, + route=route, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.Route, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.Route].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.Route]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _update_initial( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + route_name: str, + route_update_properties: Union[_models.RouteUpdateParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(route_update_properties, (IOBase, bytes)): + _content = route_update_properties + else: + _content = json.dumps(route_update_properties, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_routes_update_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + route_name=route_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + route_name: str, + route_update_properties: _models.RouteUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Route]: + """Updates an existing route with the specified route name under the specified subscription, + resource group, profile, and AzureFrontDoor endpoint. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param route_name: Name of the routing rule. Required. + :type route_name: str + :param route_update_properties: Route update properties. Required. + :type route_update_properties: ~azure.mgmt.cdn.models.RouteUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns Route. The Route is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Route] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + route_name: str, + route_update_properties: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Route]: + """Updates an existing route with the specified route name under the specified subscription, + resource group, profile, and AzureFrontDoor endpoint. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param route_name: Name of the routing rule. Required. + :type route_name: str + :param route_update_properties: Route update properties. Required. + :type route_update_properties: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns Route. The Route is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Route] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + route_name: str, + route_update_properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Route]: + """Updates an existing route with the specified route name under the specified subscription, + resource group, profile, and AzureFrontDoor endpoint. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param route_name: Name of the routing rule. Required. + :type route_name: str + :param route_update_properties: Route update properties. Required. + :type route_update_properties: IO[bytes] + :keyword content_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 Route. The Route is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Route] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + route_name: str, + route_update_properties: Union[_models.RouteUpdateParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.Route]: + """Updates an existing route with the specified route name under the specified subscription, + resource group, profile, and AzureFrontDoor endpoint. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param route_name: Name of the routing rule. Required. + :type route_name: str + :param route_update_properties: Route update properties. Is one of the following types: + RouteUpdateParameters, JSON, IO[bytes] Required. + :type route_update_properties: ~azure.mgmt.cdn.models.RouteUpdateParameters or JSON or + IO[bytes] + :return: An instance of LROPoller that returns Route. The Route is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Route] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Route] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._update_initial( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + route_name=route_name, + route_update_properties=route_update_properties, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.Route, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.Route].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.Route]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_initial( + self, resource_group_name: str, profile_name: str, endpoint_name: str, route_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_routes_delete_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + route_name=route_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, profile_name: str, endpoint_name: str, route_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Deletes an existing route with the specified route name under the specified subscription, + resource group, profile, and AzureFrontDoor endpoint. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param route_name: Name of the routing rule. Required. + :type route_name: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + route_name=route_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_endpoint( + self, resource_group_name: str, profile_name: str, endpoint_name: str, **kwargs: Any + ) -> ItemPaged["_models.Route"]: + """Lists all of the existing origins within a 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 or CDN + profile 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. + :type endpoint_name: str + :return: An iterator like instance of Route + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cdn.models.Route] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Route]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_routes_list_by_endpoint_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.Route], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class RuleSetsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cdn.CdnManagementClient`'s + :attr:`rule_sets` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: 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(self, resource_group_name: str, profile_name: str, rule_set_name: str, **kwargs: Any) -> _models.RuleSet: + """Gets an existing AzureFrontDoor rule set with the specified rule set name under the specified + subscription, resource group and 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 or CDN + profile 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. + :type rule_set_name: str + :return: RuleSet. The RuleSet is compatible with MutableMapping + :rtype: ~azure.mgmt.cdn.models.RuleSet + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.RuleSet] = kwargs.pop("cls", None) + + _request = build_rule_sets_get_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + rule_set_name=rule_set_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.RuleSet, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @api_version_validation( + method_added_on="2025-12-01", + params_added_on={ + "2025-12-01": [ + "api_version", + "subscription_id", + "resource_group_name", + "profile_name", + "rule_set_name", + "content_type", + "accept", + ] + }, + api_versions_list=["2025-12-01"], + ) + def _create_initial( + self, + resource_group_name: str, + profile_name: str, + rule_set_name: str, + resource: Optional[Union[_models.RuleSet, JSON, IO[bytes]]] = None, + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + content_type = content_type if resource else None + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" if resource else None + _content = None + if isinstance(resource, (IOBase, bytes)): + _content = resource + else: + if resource is not None: + _content = json.dumps(resource, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + else: + _content = None + + _request = build_rule_sets_create_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + rule_set_name=rule_set_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create( + self, + resource_group_name: str, + profile_name: str, + rule_set_name: str, + resource: Optional[_models.RuleSet] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.RuleSet]: + """Creates or update a batch rule set within the specified profile along with the rules associate + to it. + + :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 or CDN + profile 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. + :type rule_set_name: str + :param resource: Resource create parameters. Default value is None. + :type resource: ~azure.mgmt.cdn.models.RuleSet + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns RuleSet. The RuleSet is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.RuleSet] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + profile_name: str, + rule_set_name: str, + resource: Optional[JSON] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.RuleSet]: + """Creates or update a batch rule set within the specified profile along with the rules associate + to it. + + :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 or CDN + profile 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. + :type rule_set_name: str + :param resource: Resource create parameters. Default value is None. + :type resource: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns RuleSet. The RuleSet is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.RuleSet] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + profile_name: str, + rule_set_name: str, + resource: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.RuleSet]: + """Creates or update a batch rule set within the specified profile along with the rules associate + to it. + + :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 or CDN + profile 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. + :type rule_set_name: str + :param resource: Resource create parameters. Default value is None. + :type resource: IO[bytes] + :keyword content_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 RuleSet. The RuleSet is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.RuleSet] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + @api_version_validation( + method_added_on="2025-12-01", + params_added_on={ + "2025-12-01": [ + "api_version", + "subscription_id", + "resource_group_name", + "profile_name", + "rule_set_name", + "content_type", + "accept", + ] + }, + api_versions_list=["2025-12-01"], + ) + def begin_create( + self, + resource_group_name: str, + profile_name: str, + rule_set_name: str, + resource: Optional[Union[_models.RuleSet, JSON, IO[bytes]]] = None, + **kwargs: Any + ) -> LROPoller[_models.RuleSet]: + """Creates or update a batch rule set within the specified profile along with the rules associate + to it. + + :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 or CDN + profile 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. + :type rule_set_name: str + :param resource: Resource create parameters. Is one of the following types: RuleSet, JSON, + IO[bytes] Default value is None. + :type resource: ~azure.mgmt.cdn.models.RuleSet or JSON or IO[bytes] + :return: An instance of LROPoller that returns RuleSet. The RuleSet is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.RuleSet] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + content_type = content_type if resource else None + cls: ClsType[_models.RuleSet] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_initial( + resource_group_name=resource_group_name, + profile_name=profile_name, + rule_set_name=rule_set_name, + resource=resource, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.RuleSet, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.RuleSet].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.RuleSet]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_initial( + self, resource_group_name: str, profile_name: str, rule_set_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_rule_sets_delete_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + rule_set_name=rule_set_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, profile_name: str, rule_set_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Deletes an existing AzureFrontDoor rule set with the specified rule set name under the + specified subscription, resource group and 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 or CDN + profile 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. + :type rule_set_name: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + profile_name=profile_name, + rule_set_name=rule_set_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_profile( + self, resource_group_name: str, profile_name: str, **kwargs: Any + ) -> ItemPaged["_models.RuleSet"]: + """Lists existing AzureFrontDoor rule sets within a 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 or CDN + profile which is unique within the resource group. Required. + :type profile_name: str + :return: An iterator like instance of RuleSet + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cdn.models.RuleSet] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.RuleSet]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_rule_sets_list_by_profile_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.RuleSet], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_resource_usage( + self, resource_group_name: str, profile_name: str, rule_set_name: str, **kwargs: Any + ) -> ItemPaged["_models.Usage"]: + """Checks the quota and actual usage of endpoints under the given Azure Front Door 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 or CDN + profile 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. + :type rule_set_name: str + :return: An iterator like instance of Usage + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cdn.models.Usage] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Usage]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_rule_sets_list_resource_usage_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + rule_set_name=rule_set_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.Usage], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class RulesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cdn.CdnManagementClient`'s + :attr:`rules` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: 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( + self, resource_group_name: str, profile_name: str, rule_set_name: str, rule_name: str, **kwargs: Any + ) -> _models.Rule: + """Gets an existing delivery rule within a rule set. + + :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 or CDN + profile 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. + :type rule_set_name: str + :param rule_name: Name of the delivery rule which is unique within the endpoint. Required. + :type rule_name: str + :return: Rule. The Rule is compatible with MutableMapping + :rtype: ~azure.mgmt.cdn.models.Rule + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.Rule] = kwargs.pop("cls", None) + + _request = build_rules_get_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + rule_set_name=rule_set_name, + rule_name=rule_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Rule, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_initial( + self, + resource_group_name: str, + profile_name: str, + rule_set_name: str, + rule_name: str, + rule: Union[_models.Rule, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(rule, (IOBase, bytes)): + _content = rule + else: + _content = json.dumps(rule, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_rules_create_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + rule_set_name=rule_set_name, + rule_name=rule_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create( + self, + resource_group_name: str, + profile_name: str, + rule_set_name: str, + rule_name: str, + rule: _models.Rule, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Rule]: + """Creates a new delivery rule within the specified rule set. + + :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 or CDN + profile 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. + :type rule_set_name: str + :param rule_name: Name of the delivery rule which is unique within the endpoint. Required. + :type rule_name: str + :param rule: The delivery rule properties. Required. + :type rule: ~azure.mgmt.cdn.models.Rule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns Rule. The Rule is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Rule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + profile_name: str, + rule_set_name: str, + rule_name: str, + rule: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Rule]: + """Creates a new delivery rule within the specified rule set. + + :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 or CDN + profile 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. + :type rule_set_name: str + :param rule_name: Name of the delivery rule which is unique within the endpoint. Required. + :type rule_name: str + :param rule: The delivery rule properties. Required. + :type rule: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns Rule. The Rule is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Rule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + profile_name: str, + rule_set_name: str, + rule_name: str, + rule: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Rule]: + """Creates a new delivery rule within the specified rule set. + + :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 or CDN + profile 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. + :type rule_set_name: str + :param rule_name: Name of the delivery rule which is unique within the endpoint. Required. + :type rule_name: str + :param rule: The delivery rule properties. Required. + :type rule: IO[bytes] + :keyword content_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 Rule. The Rule is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Rule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + profile_name: str, + rule_set_name: str, + rule_name: str, + rule: Union[_models.Rule, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.Rule]: + """Creates a new delivery rule within the specified rule set. + + :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 or CDN + profile 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. + :type rule_set_name: str + :param rule_name: Name of the delivery rule which is unique within the endpoint. Required. + :type rule_name: str + :param rule: The delivery rule properties. Is one of the following types: Rule, JSON, IO[bytes] + Required. + :type rule: ~azure.mgmt.cdn.models.Rule or JSON or IO[bytes] + :return: An instance of LROPoller that returns Rule. The Rule is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Rule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Rule] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_initial( + resource_group_name=resource_group_name, + profile_name=profile_name, + rule_set_name=rule_set_name, + rule_name=rule_name, + rule=rule, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.Rule, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.Rule].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.Rule]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _update_initial( + self, + resource_group_name: str, + profile_name: str, + rule_set_name: str, + rule_name: str, + rule_update_properties: Union[_models.RuleUpdateParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(rule_update_properties, (IOBase, bytes)): + _content = rule_update_properties + else: + _content = json.dumps(rule_update_properties, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_rules_update_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + rule_set_name=rule_set_name, + rule_name=rule_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + profile_name: str, + rule_set_name: str, + rule_name: str, + rule_update_properties: _models.RuleUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Rule]: + """Updates an existing delivery rule within a rule set. + + :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 or CDN + profile 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. + :type rule_set_name: str + :param rule_name: Name of the delivery rule which is unique within the endpoint. Required. + :type rule_name: str + :param rule_update_properties: Delivery rule properties. Required. + :type rule_update_properties: ~azure.mgmt.cdn.models.RuleUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns Rule. The Rule is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Rule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + profile_name: str, + rule_set_name: str, + rule_name: str, + rule_update_properties: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Rule]: + """Updates an existing delivery rule within a rule set. + + :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 or CDN + profile 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. + :type rule_set_name: str + :param rule_name: Name of the delivery rule which is unique within the endpoint. Required. + :type rule_name: str + :param rule_update_properties: Delivery rule properties. Required. + :type rule_update_properties: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns Rule. The Rule is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Rule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + profile_name: str, + rule_set_name: str, + rule_name: str, + rule_update_properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Rule]: + """Updates an existing delivery rule within a rule set. + + :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 or CDN + profile 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. + :type rule_set_name: str + :param rule_name: Name of the delivery rule which is unique within the endpoint. Required. + :type rule_name: str + :param rule_update_properties: Delivery rule properties. Required. + :type rule_update_properties: IO[bytes] + :keyword content_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 Rule. The Rule is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Rule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + profile_name: str, + rule_set_name: str, + rule_name: str, + rule_update_properties: Union[_models.RuleUpdateParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.Rule]: + """Updates an existing delivery rule within a rule set. + + :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 or CDN + profile 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. + :type rule_set_name: str + :param rule_name: Name of the delivery rule which is unique within the endpoint. Required. + :type rule_name: str + :param rule_update_properties: Delivery rule properties. Is one of the following types: + RuleUpdateParameters, JSON, IO[bytes] Required. + :type rule_update_properties: ~azure.mgmt.cdn.models.RuleUpdateParameters or JSON or IO[bytes] + :return: An instance of LROPoller that returns Rule. The Rule is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Rule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Rule] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._update_initial( + resource_group_name=resource_group_name, + profile_name=profile_name, + rule_set_name=rule_set_name, + rule_name=rule_name, + rule_update_properties=rule_update_properties, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.Rule, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.Rule].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.Rule]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_initial( + self, resource_group_name: str, profile_name: str, rule_set_name: str, rule_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_rules_delete_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + rule_set_name=rule_set_name, + rule_name=rule_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, profile_name: str, rule_set_name: str, rule_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Deletes an existing delivery rule within a rule set. + + :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 or CDN + profile 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. + :type rule_set_name: str + :param rule_name: Name of the delivery rule which is unique within the endpoint. Required. + :type rule_name: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + profile_name=profile_name, + rule_set_name=rule_set_name, + rule_name=rule_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_rule_set( + self, resource_group_name: str, profile_name: str, rule_set_name: str, **kwargs: Any + ) -> ItemPaged["_models.Rule"]: + """Lists all of the existing delivery rules within a rule set. + + :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 or CDN + profile 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. + :type rule_set_name: str + :return: An iterator like instance of Rule + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cdn.models.Rule] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Rule]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_rules_list_by_rule_set_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + rule_set_name=rule_set_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.Rule], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class SecurityPoliciesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cdn.CdnManagementClient`'s + :attr:`security_policies` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: 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( + self, resource_group_name: str, profile_name: str, security_policy_name: str, **kwargs: Any + ) -> _models.SecurityPolicy: + """Gets an existing security policy within a 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 or CDN + profile 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 + :return: SecurityPolicy. The SecurityPolicy is compatible with MutableMapping + :rtype: ~azure.mgmt.cdn.models.SecurityPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.SecurityPolicy] = kwargs.pop("cls", None) + + _request = build_security_policies_get_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + security_policy_name=security_policy_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.SecurityPolicy, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_initial( + self, + resource_group_name: str, + profile_name: str, + security_policy_name: str, + security_policy: Union[_models.SecurityPolicy, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(security_policy, (IOBase, bytes)): + _content = security_policy + else: + _content = json.dumps(security_policy, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_security_policies_create_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + security_policy_name=security_policy_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create( + self, + resource_group_name: str, + profile_name: str, + security_policy_name: str, + security_policy: _models.SecurityPolicy, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.SecurityPolicy]: + """Creates a new security policy within the specified 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 or CDN + profile 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 + :param security_policy: The security policy properties. Required. + :type security_policy: ~azure.mgmt.cdn.models.SecurityPolicy + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns SecurityPolicy. The SecurityPolicy is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.SecurityPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + profile_name: str, + security_policy_name: str, + security_policy: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.SecurityPolicy]: + """Creates a new security policy within the specified 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 or CDN + profile 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 + :param security_policy: The security policy properties. Required. + :type security_policy: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns SecurityPolicy. The SecurityPolicy is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.SecurityPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + profile_name: str, + security_policy_name: str, + security_policy: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.SecurityPolicy]: + """Creates a new security policy within the specified 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 or CDN + profile 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 + :param security_policy: The security policy properties. Required. + :type security_policy: IO[bytes] + :keyword content_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 SecurityPolicy. The SecurityPolicy is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.SecurityPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + profile_name: str, + security_policy_name: str, + security_policy: Union[_models.SecurityPolicy, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.SecurityPolicy]: + """Creates a new security policy within the specified 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 or CDN + profile 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 + :param security_policy: The security policy properties. Is one of the following types: + SecurityPolicy, JSON, IO[bytes] Required. + :type security_policy: ~azure.mgmt.cdn.models.SecurityPolicy or JSON or IO[bytes] + :return: An instance of LROPoller that returns SecurityPolicy. The SecurityPolicy is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.SecurityPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SecurityPolicy] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_initial( + resource_group_name=resource_group_name, + profile_name=profile_name, + security_policy_name=security_policy_name, + security_policy=security_policy, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.SecurityPolicy, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.SecurityPolicy].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.SecurityPolicy]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _patch_initial( + self, + resource_group_name: str, + profile_name: str, + security_policy_name: str, + security_policy_update_properties: Union[_models.SecurityPolicyUpdateParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(security_policy_update_properties, (IOBase, bytes)): + _content = security_policy_update_properties + else: + _content = json.dumps(security_policy_update_properties, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_security_policies_patch_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + security_policy_name=security_policy_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_patch( + self, + resource_group_name: str, + profile_name: str, + security_policy_name: str, + security_policy_update_properties: _models.SecurityPolicyUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.SecurityPolicy]: + """Updates an existing security policy within a 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 or CDN + profile 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 + :param security_policy_update_properties: Security policy update properties. Required. + :type security_policy_update_properties: ~azure.mgmt.cdn.models.SecurityPolicyUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns SecurityPolicy. The SecurityPolicy is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.SecurityPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_patch( + self, + resource_group_name: str, + profile_name: str, + security_policy_name: str, + security_policy_update_properties: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.SecurityPolicy]: + """Updates an existing security policy within a 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 or CDN + profile 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 + :param security_policy_update_properties: Security policy update properties. Required. + :type security_policy_update_properties: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns SecurityPolicy. The SecurityPolicy is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.SecurityPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_patch( + self, + resource_group_name: str, + profile_name: str, + security_policy_name: str, + security_policy_update_properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.SecurityPolicy]: + """Updates an existing security policy within a 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 or CDN + profile 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 + :param security_policy_update_properties: Security policy update properties. Required. + :type security_policy_update_properties: IO[bytes] + :keyword content_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 SecurityPolicy. The SecurityPolicy is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.SecurityPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_patch( + self, + resource_group_name: str, + profile_name: str, + security_policy_name: str, + security_policy_update_properties: Union[_models.SecurityPolicyUpdateParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.SecurityPolicy]: + """Updates an existing security policy within a 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 or CDN + profile 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 + :param security_policy_update_properties: Security policy update properties. Is one of the + following types: SecurityPolicyUpdateParameters, JSON, IO[bytes] Required. + :type security_policy_update_properties: ~azure.mgmt.cdn.models.SecurityPolicyUpdateParameters + or JSON or IO[bytes] + :return: An instance of LROPoller that returns SecurityPolicy. The SecurityPolicy is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.SecurityPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SecurityPolicy] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._patch_initial( + resource_group_name=resource_group_name, + profile_name=profile_name, + security_policy_name=security_policy_name, + security_policy_update_properties=security_policy_update_properties, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.SecurityPolicy, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.SecurityPolicy].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.SecurityPolicy]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_initial( + self, resource_group_name: str, profile_name: str, security_policy_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_security_policies_delete_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + security_policy_name=security_policy_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, profile_name: str, security_policy_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Deletes an existing security policy within 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 or CDN + profile 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 + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + profile_name=profile_name, + security_policy_name=security_policy_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_profile( + self, resource_group_name: str, profile_name: str, **kwargs: Any + ) -> ItemPaged["_models.SecurityPolicy"]: + """Lists security policies associated with the 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 or CDN + profile which is unique within the resource group. Required. + :type profile_name: str + :return: An iterator like instance of SecurityPolicy + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cdn.models.SecurityPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.SecurityPolicy]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_security_policies_list_by_profile_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.SecurityPolicy], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class SecretsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cdn.CdnManagementClient`'s + :attr:`secrets` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: 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(self, resource_group_name: str, profile_name: str, secret_name: str, **kwargs: Any) -> _models.Secret: + """Gets an existing Secret within a 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 or CDN + profile 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 + :return: Secret. The Secret is compatible with MutableMapping + :rtype: ~azure.mgmt.cdn.models.Secret + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.Secret] = kwargs.pop("cls", None) + + _request = build_secrets_get_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + secret_name=secret_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Secret, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_initial( + self, + resource_group_name: str, + profile_name: str, + secret_name: str, + secret: Union[_models.Secret, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(secret, (IOBase, bytes)): + _content = secret + else: + _content = json.dumps(secret, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_secrets_create_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + secret_name=secret_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create( + self, + resource_group_name: str, + profile_name: str, + secret_name: str, + secret: _models.Secret, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Secret]: + """Creates a new Secret within the specified 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 or CDN + profile 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 + :param secret: The Secret properties. Required. + :type secret: ~azure.mgmt.cdn.models.Secret + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns Secret. The Secret is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Secret] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + profile_name: str, + secret_name: str, + secret: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Secret]: + """Creates a new Secret within the specified 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 or CDN + profile 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 + :param secret: The Secret properties. Required. + :type secret: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns Secret. The Secret is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Secret] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + profile_name: str, + secret_name: str, + secret: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Secret]: + """Creates a new Secret within the specified 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 or CDN + profile 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 + :param secret: The Secret properties. Required. + :type secret: IO[bytes] + :keyword content_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 Secret. The Secret is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Secret] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + profile_name: str, + secret_name: str, + secret: Union[_models.Secret, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.Secret]: + """Creates a new Secret within the specified 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 or CDN + profile 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 + :param secret: The Secret properties. Is one of the following types: Secret, JSON, IO[bytes] + Required. + :type secret: ~azure.mgmt.cdn.models.Secret or JSON or IO[bytes] + :return: An instance of LROPoller that returns Secret. The Secret is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Secret] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Secret] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_initial( + resource_group_name=resource_group_name, + profile_name=profile_name, + secret_name=secret_name, + secret=secret, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.Secret, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.Secret].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.Secret]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_initial( + self, resource_group_name: str, profile_name: str, secret_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_secrets_delete_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + secret_name=secret_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, profile_name: str, secret_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Deletes an existing Secret within 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 or CDN + profile 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 + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + profile_name=profile_name, + secret_name=secret_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_profile( + self, resource_group_name: str, profile_name: str, **kwargs: Any + ) -> ItemPaged["_models.Secret"]: + """Lists existing AzureFrontDoor secrets. + + :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 or CDN + profile which is unique within the resource group. Required. + :type profile_name: str + :return: An iterator like instance of Secret + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cdn.models.Secret] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Secret]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_secrets_list_by_profile_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.Secret], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class EndpointsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cdn.CdnManagementClient`'s + :attr:`endpoints` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: 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(self, resource_group_name: str, profile_name: str, endpoint_name: str, **kwargs: Any) -> _models.Endpoint: + """Gets an existing CDN endpoint with the specified endpoint name under the specified + subscription, resource group and 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 or CDN + profile 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. + :type endpoint_name: str + :return: Endpoint. The Endpoint is compatible with MutableMapping + :rtype: ~azure.mgmt.cdn.models.Endpoint + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.Endpoint] = kwargs.pop("cls", None) + + _request = build_endpoints_get_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Endpoint, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_initial( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + endpoint: Union[_models.Endpoint, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(endpoint, (IOBase, bytes)): + _content = endpoint + else: + _content = json.dumps(endpoint, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_endpoints_create_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + endpoint: _models.Endpoint, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Endpoint]: + """Creates a new CDN endpoint with the specified endpoint name under the specified subscription, + resource group and 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 or CDN + profile 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. + :type endpoint_name: str + :param endpoint: Endpoint properties. Required. + :type endpoint: ~azure.mgmt.cdn.models.Endpoint + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns Endpoint. The Endpoint is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Endpoint] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + endpoint: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Endpoint]: + """Creates a new CDN endpoint with the specified endpoint name under the specified subscription, + resource group and 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 or CDN + profile 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. + :type endpoint_name: str + :param endpoint: Endpoint properties. Required. + :type endpoint: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns Endpoint. The Endpoint is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Endpoint] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + endpoint: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Endpoint]: + """Creates a new CDN endpoint with the specified endpoint name under the specified subscription, + resource group and 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 or CDN + profile 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. + :type endpoint_name: str + :param endpoint: Endpoint properties. Required. + :type endpoint: IO[bytes] + :keyword content_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 Endpoint. The Endpoint is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Endpoint] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + endpoint: Union[_models.Endpoint, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.Endpoint]: + """Creates a new CDN endpoint with the specified endpoint name under the specified subscription, + resource group and 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 or CDN + profile 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. + :type endpoint_name: str + :param endpoint: Endpoint properties. Is one of the following types: Endpoint, JSON, IO[bytes] + Required. + :type endpoint: ~azure.mgmt.cdn.models.Endpoint or JSON or IO[bytes] + :return: An instance of LROPoller that returns Endpoint. The Endpoint is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Endpoint] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Endpoint] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_initial( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + endpoint=endpoint, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.Endpoint, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.Endpoint].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.Endpoint]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _update_initial( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + endpoint_update_properties: Union[_models.EndpointUpdateParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(endpoint_update_properties, (IOBase, bytes)): + _content = endpoint_update_properties + else: + _content = json.dumps(endpoint_update_properties, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_endpoints_update_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + endpoint_update_properties: _models.EndpointUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Endpoint]: + """Updates an existing CDN endpoint with the specified endpoint name under the specified + subscription, resource group and profile. Only tags can be updated after creating an endpoint. + To update origins, use the Update Origin operation. To update origin groups, use the Update + Origin group operation. To update custom domains, use the Update Custom Domain operation. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param endpoint_update_properties: Endpoint update properties. Required. + :type endpoint_update_properties: ~azure.mgmt.cdn.models.EndpointUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns Endpoint. The Endpoint is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Endpoint] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + endpoint_update_properties: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Endpoint]: + """Updates an existing CDN endpoint with the specified endpoint name under the specified + subscription, resource group and profile. Only tags can be updated after creating an endpoint. + To update origins, use the Update Origin operation. To update origin groups, use the Update + Origin group operation. To update custom domains, use the Update Custom Domain operation. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param endpoint_update_properties: Endpoint update properties. Required. + :type endpoint_update_properties: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns Endpoint. The Endpoint is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Endpoint] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + endpoint_update_properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Endpoint]: + """Updates an existing CDN endpoint with the specified endpoint name under the specified + subscription, resource group and profile. Only tags can be updated after creating an endpoint. + To update origins, use the Update Origin operation. To update origin groups, use the Update + Origin group operation. To update custom domains, use the Update Custom Domain operation. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param endpoint_update_properties: Endpoint update properties. Required. + :type endpoint_update_properties: IO[bytes] + :keyword content_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 Endpoint. The Endpoint is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Endpoint] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + endpoint_update_properties: Union[_models.EndpointUpdateParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.Endpoint]: + """Updates an existing CDN endpoint with the specified endpoint name under the specified + subscription, resource group and profile. Only tags can be updated after creating an endpoint. + To update origins, use the Update Origin operation. To update origin groups, use the Update + Origin group operation. To update custom domains, use the Update Custom Domain operation. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param endpoint_update_properties: Endpoint update properties. Is one of the following types: + EndpointUpdateParameters, JSON, IO[bytes] Required. + :type endpoint_update_properties: ~azure.mgmt.cdn.models.EndpointUpdateParameters or JSON or + IO[bytes] + :return: An instance of LROPoller that returns Endpoint. The Endpoint is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Endpoint] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Endpoint] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._update_initial( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + endpoint_update_properties=endpoint_update_properties, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.Endpoint, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.Endpoint].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.Endpoint]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_initial( + self, resource_group_name: str, profile_name: str, endpoint_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_endpoints_delete_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, profile_name: str, endpoint_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Deletes an existing CDN endpoint with the specified endpoint name under the specified + subscription, resource group and 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 or CDN + profile 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. + :type endpoint_name: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_profile( + self, resource_group_name: str, profile_name: str, **kwargs: Any + ) -> ItemPaged["_models.Endpoint"]: + """Lists existing CDN endpoints. + + :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 or CDN + profile which is unique within the resource group. Required. + :type profile_name: str + :return: An iterator like instance of Endpoint + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cdn.models.Endpoint] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Endpoint]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_endpoints_list_by_profile_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.Endpoint], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + def _start_initial( + self, resource_group_name: str, profile_name: str, endpoint_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_endpoints_start_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_start( + self, resource_group_name: str, profile_name: str, endpoint_name: str, **kwargs: Any + ) -> LROPoller[_models.Endpoint]: + """Starts an existing CDN endpoint that is on a stopped state. + + :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 or CDN + profile 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. + :type endpoint_name: str + :return: An instance of LROPoller that returns Endpoint. The Endpoint is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Endpoint] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.Endpoint] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._start_initial( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = _deserialize(_models.Endpoint, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.Endpoint].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.Endpoint]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _stop_initial( + self, resource_group_name: str, profile_name: str, endpoint_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_endpoints_stop_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_stop( + self, resource_group_name: str, profile_name: str, endpoint_name: str, **kwargs: Any + ) -> LROPoller[_models.Endpoint]: + """Stops an existing running CDN endpoint. + + :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 or CDN + profile 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. + :type endpoint_name: str + :return: An instance of LROPoller that returns Endpoint. The Endpoint is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Endpoint] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.Endpoint] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._stop_initial( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = _deserialize(_models.Endpoint, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.Endpoint].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.Endpoint]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _purge_content_initial( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + content_file_paths: Union[_models.PurgeParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(content_file_paths, (IOBase, bytes)): + _content = content_file_paths + else: + _content = json.dumps(content_file_paths, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_endpoints_purge_content_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_purge_content( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + content_file_paths: _models.PurgeParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Removes a content from CDN. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param content_file_paths: The path to the content to be purged. Path can be a full URL, e.g. + '/pictures/city.png' which removes a single file, or a directory with a wildcard, e.g. + '/pictures/*' which removes all folders and files in the directory. Required. + :type content_file_paths: ~azure.mgmt.cdn.models.PurgeParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_purge_content( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + content_file_paths: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Removes a content from CDN. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param content_file_paths: The path to the content to be purged. Path can be a full URL, e.g. + '/pictures/city.png' which removes a single file, or a directory with a wildcard, e.g. + '/pictures/*' which removes all folders and files in the directory. Required. + :type content_file_paths: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_purge_content( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + content_file_paths: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Removes a content from CDN. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param content_file_paths: The path to the content to be purged. Path can be a full URL, e.g. + '/pictures/city.png' which removes a single file, or a directory with a wildcard, e.g. + '/pictures/*' which removes all folders and files in the directory. Required. + :type content_file_paths: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_purge_content( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + content_file_paths: Union[_models.PurgeParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[None]: + """Removes a content from CDN. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param content_file_paths: The path to the content to be purged. Path can be a full URL, e.g. + '/pictures/city.png' which removes a single file, or a directory with a wildcard, e.g. + '/pictures/*' which removes all folders and files in the directory. Is one of the following + types: PurgeParameters, JSON, IO[bytes] Required. + :type content_file_paths: ~azure.mgmt.cdn.models.PurgeParameters or JSON or IO[bytes] + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._purge_content_initial( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + content_file_paths=content_file_paths, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + def _load_content_initial( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + content_file_paths: Union[_models.LoadParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(content_file_paths, (IOBase, bytes)): + _content = content_file_paths + else: + _content = json.dumps(content_file_paths, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_endpoints_load_content_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_load_content( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + content_file_paths: _models.LoadParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Pre-loads a content to CDN. Available for Verizon Profiles. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param content_file_paths: The path to the content to be loaded. Path should be a full URL, + e.g. ‘/pictures/city.png' which loads a single file. Required. + :type content_file_paths: ~azure.mgmt.cdn.models.LoadParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_load_content( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + content_file_paths: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Pre-loads a content to CDN. Available for Verizon Profiles. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param content_file_paths: The path to the content to be loaded. Path should be a full URL, + e.g. ‘/pictures/city.png' which loads a single file. Required. + :type content_file_paths: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_load_content( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + content_file_paths: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Pre-loads a content to CDN. Available for Verizon Profiles. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param content_file_paths: The path to the content to be loaded. Path should be a full URL, + e.g. ‘/pictures/city.png' which loads a single file. Required. + :type content_file_paths: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_load_content( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + content_file_paths: Union[_models.LoadParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[None]: + """Pre-loads a content to CDN. Available for Verizon Profiles. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param content_file_paths: The path to the content to be loaded. Path should be a full URL, + e.g. ‘/pictures/city.png' which loads a single file. Is one of the following types: + LoadParameters, JSON, IO[bytes] Required. + :type content_file_paths: ~azure.mgmt.cdn.models.LoadParameters or JSON or IO[bytes] + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._load_content_initial( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + content_file_paths=content_file_paths, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @overload + def validate_custom_domain( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + custom_domain_properties: _models.ValidateCustomDomainInput, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ValidateCustomDomainOutput: + """Validates the custom domain mapping to ensure it maps to the correct CDN endpoint in DNS. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param custom_domain_properties: Custom domain to be validated. Required. + :type custom_domain_properties: ~azure.mgmt.cdn.models.ValidateCustomDomainInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ValidateCustomDomainOutput. The ValidateCustomDomainOutput is compatible with + MutableMapping + :rtype: ~azure.mgmt.cdn.models.ValidateCustomDomainOutput + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def validate_custom_domain( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + custom_domain_properties: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ValidateCustomDomainOutput: + """Validates the custom domain mapping to ensure it maps to the correct CDN endpoint in DNS. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param custom_domain_properties: Custom domain to be validated. Required. + :type custom_domain_properties: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ValidateCustomDomainOutput. The ValidateCustomDomainOutput is compatible with + MutableMapping + :rtype: ~azure.mgmt.cdn.models.ValidateCustomDomainOutput + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def validate_custom_domain( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + custom_domain_properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ValidateCustomDomainOutput: + """Validates the custom domain mapping to ensure it maps to the correct CDN endpoint in DNS. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param custom_domain_properties: Custom domain to be validated. Required. + :type custom_domain_properties: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ValidateCustomDomainOutput. The ValidateCustomDomainOutput is compatible with + MutableMapping + :rtype: ~azure.mgmt.cdn.models.ValidateCustomDomainOutput + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def validate_custom_domain( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + custom_domain_properties: Union[_models.ValidateCustomDomainInput, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.ValidateCustomDomainOutput: + """Validates the custom domain mapping to ensure it maps to the correct CDN endpoint in DNS. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param custom_domain_properties: Custom domain to be validated. Is one of the following types: + ValidateCustomDomainInput, JSON, IO[bytes] Required. + :type custom_domain_properties: ~azure.mgmt.cdn.models.ValidateCustomDomainInput or JSON or + IO[bytes] + :return: ValidateCustomDomainOutput. The ValidateCustomDomainOutput is compatible with + MutableMapping + :rtype: ~azure.mgmt.cdn.models.ValidateCustomDomainOutput + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ValidateCustomDomainOutput] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(custom_domain_properties, (IOBase, bytes)): + _content = custom_domain_properties + else: + _content = json.dumps(custom_domain_properties, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_endpoints_validate_custom_domain_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ValidateCustomDomainOutput, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_resource_usage( + self, resource_group_name: str, profile_name: str, endpoint_name: str, **kwargs: Any + ) -> ItemPaged["_models.ResourceUsage"]: + """Checks the quota and usage of geo filters and custom domains under the given endpoint. + + :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 or CDN + profile 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. + :type endpoint_name: str + :return: An iterator like instance of ResourceUsage + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cdn.models.ResourceUsage] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ResourceUsage]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_endpoints_list_resource_usage_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ResourceUsage], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class OriginsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cdn.CdnManagementClient`'s + :attr:`origins` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: 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( + self, resource_group_name: str, profile_name: str, endpoint_name: str, origin_name: str, **kwargs: Any + ) -> _models.Origin: + """Gets an existing origin within an endpoint. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param origin_name: Name of the origin which is unique within the endpoint. Required. + :type origin_name: str + :return: Origin. The Origin is compatible with MutableMapping + :rtype: ~azure.mgmt.cdn.models.Origin + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.Origin] = kwargs.pop("cls", None) + + _request = build_origins_get_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + origin_name=origin_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Origin, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_initial( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + origin_name: str, + origin: Union[_models.Origin, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(origin, (IOBase, bytes)): + _content = origin + else: + _content = json.dumps(origin, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_origins_create_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + origin_name=origin_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + origin_name: str, + origin: _models.Origin, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Origin]: + """Creates a new origin within the specified endpoint. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param origin_name: Name of the origin which is unique within the endpoint. Required. + :type origin_name: str + :param origin: Origin properties. Required. + :type origin: ~azure.mgmt.cdn.models.Origin + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns Origin. The Origin is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Origin] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + origin_name: str, + origin: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Origin]: + """Creates a new origin within the specified endpoint. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param origin_name: Name of the origin which is unique within the endpoint. Required. + :type origin_name: str + :param origin: Origin properties. Required. + :type origin: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns Origin. The Origin is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Origin] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + origin_name: str, + origin: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Origin]: + """Creates a new origin within the specified endpoint. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param origin_name: Name of the origin which is unique within the endpoint. Required. + :type origin_name: str + :param origin: Origin properties. Required. + :type origin: IO[bytes] + :keyword content_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 Origin. The Origin is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Origin] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + origin_name: str, + origin: Union[_models.Origin, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.Origin]: + """Creates a new origin within the specified endpoint. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param origin_name: Name of the origin which is unique within the endpoint. Required. + :type origin_name: str + :param origin: Origin properties. Is one of the following types: Origin, JSON, IO[bytes] + Required. + :type origin: ~azure.mgmt.cdn.models.Origin or JSON or IO[bytes] + :return: An instance of LROPoller that returns Origin. The Origin is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Origin] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Origin] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_initial( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + origin_name=origin_name, + origin=origin, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.Origin, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.Origin].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.Origin]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _update_initial( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + origin_name: str, + origin_update_properties: Union[_models.OriginUpdateParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(origin_update_properties, (IOBase, bytes)): + _content = origin_update_properties + else: + _content = json.dumps(origin_update_properties, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_origins_update_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + origin_name=origin_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + origin_name: str, + origin_update_properties: _models.OriginUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Origin]: + """Updates an existing origin within an endpoint. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param origin_name: Name of the origin which is unique within the endpoint. Required. + :type origin_name: str + :param origin_update_properties: Origin properties. Required. + :type origin_update_properties: ~azure.mgmt.cdn.models.OriginUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns Origin. The Origin is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Origin] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + origin_name: str, + origin_update_properties: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Origin]: + """Updates an existing origin within an endpoint. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param origin_name: Name of the origin which is unique within the endpoint. Required. + :type origin_name: str + :param origin_update_properties: Origin properties. Required. + :type origin_update_properties: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns Origin. The Origin is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Origin] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + origin_name: str, + origin_update_properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Origin]: + """Updates an existing origin within an endpoint. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param origin_name: Name of the origin which is unique within the endpoint. Required. + :type origin_name: str + :param origin_update_properties: Origin properties. Required. + :type origin_update_properties: IO[bytes] + :keyword content_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 Origin. The Origin is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Origin] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + origin_name: str, + origin_update_properties: Union[_models.OriginUpdateParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.Origin]: + """Updates an existing origin within an endpoint. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param origin_name: Name of the origin which is unique within the endpoint. Required. + :type origin_name: str + :param origin_update_properties: Origin properties. Is one of the following types: + OriginUpdateParameters, JSON, IO[bytes] Required. + :type origin_update_properties: ~azure.mgmt.cdn.models.OriginUpdateParameters or JSON or + IO[bytes] + :return: An instance of LROPoller that returns Origin. The Origin is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Origin] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Origin] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._update_initial( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + origin_name=origin_name, + origin_update_properties=origin_update_properties, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.Origin, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.Origin].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.Origin]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_initial( + self, resource_group_name: str, profile_name: str, endpoint_name: str, origin_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_origins_delete_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + origin_name=origin_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, profile_name: str, endpoint_name: str, origin_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Deletes an existing origin within an endpoint. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param origin_name: Name of the origin which is unique within the endpoint. Required. + :type origin_name: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + origin_name=origin_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_endpoint( + self, resource_group_name: str, profile_name: str, endpoint_name: str, **kwargs: Any + ) -> ItemPaged["_models.Origin"]: + """Lists all of the existing origins within an endpoint. + + :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 or CDN + profile 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. + :type endpoint_name: str + :return: An iterator like instance of Origin + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cdn.models.Origin] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Origin]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_origins_list_by_endpoint_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.Origin], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class OriginGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cdn.CdnManagementClient`'s + :attr:`origin_groups` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: 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( + self, resource_group_name: str, profile_name: str, endpoint_name: str, origin_group_name: str, **kwargs: Any + ) -> _models.OriginGroup: + """Gets an existing origin group within an endpoint. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param origin_group_name: Name of the origin group which is unique within the endpoint. + Required. + :type origin_group_name: str + :return: OriginGroup. The OriginGroup is compatible with MutableMapping + :rtype: ~azure.mgmt.cdn.models.OriginGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.OriginGroup] = kwargs.pop("cls", None) + + _request = build_origin_groups_get_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + origin_group_name=origin_group_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.OriginGroup, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_initial( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + origin_group_name: str, + origin_group: Union[_models.OriginGroup, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(origin_group, (IOBase, bytes)): + _content = origin_group + else: + _content = json.dumps(origin_group, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_origin_groups_create_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + origin_group_name=origin_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + origin_group_name: str, + origin_group: _models.OriginGroup, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.OriginGroup]: + """Creates a new origin group within the specified endpoint. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param origin_group_name: Name of the origin group which is unique within the endpoint. + Required. + :type origin_group_name: str + :param origin_group: Origin group properties. Required. + :type origin_group: ~azure.mgmt.cdn.models.OriginGroup + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns OriginGroup. The OriginGroup is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.OriginGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + origin_group_name: str, + origin_group: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.OriginGroup]: + """Creates a new origin group within the specified endpoint. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param origin_group_name: Name of the origin group which is unique within the endpoint. + Required. + :type origin_group_name: str + :param origin_group: Origin group properties. Required. + :type origin_group: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns OriginGroup. The OriginGroup is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.OriginGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + origin_group_name: str, + origin_group: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.OriginGroup]: + """Creates a new origin group within the specified endpoint. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param origin_group_name: Name of the origin group which is unique within the endpoint. + Required. + :type origin_group_name: str + :param origin_group: Origin group properties. Required. + :type origin_group: IO[bytes] + :keyword content_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 OriginGroup. The OriginGroup is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.OriginGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + origin_group_name: str, + origin_group: Union[_models.OriginGroup, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.OriginGroup]: + """Creates a new origin group within the specified endpoint. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param origin_group_name: Name of the origin group which is unique within the endpoint. + Required. + :type origin_group_name: str + :param origin_group: Origin group properties. Is one of the following types: OriginGroup, JSON, + IO[bytes] Required. + :type origin_group: ~azure.mgmt.cdn.models.OriginGroup or JSON or IO[bytes] + :return: An instance of LROPoller that returns OriginGroup. The OriginGroup is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.OriginGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.OriginGroup] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_initial( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + origin_group_name=origin_group_name, + origin_group=origin_group, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.OriginGroup, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.OriginGroup].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.OriginGroup]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _update_initial( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + origin_group_name: str, + origin_group_update_properties: Union[_models.OriginGroupUpdateParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(origin_group_update_properties, (IOBase, bytes)): + _content = origin_group_update_properties + else: + _content = json.dumps(origin_group_update_properties, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_origin_groups_update_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + origin_group_name=origin_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + origin_group_name: str, + origin_group_update_properties: _models.OriginGroupUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.OriginGroup]: + """Updates an existing origin group within an endpoint. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param origin_group_name: Name of the origin group which is unique within the endpoint. + Required. + :type origin_group_name: str + :param origin_group_update_properties: Origin group properties. Required. + :type origin_group_update_properties: ~azure.mgmt.cdn.models.OriginGroupUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns OriginGroup. The OriginGroup is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.OriginGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + origin_group_name: str, + origin_group_update_properties: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.OriginGroup]: + """Updates an existing origin group within an endpoint. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param origin_group_name: Name of the origin group which is unique within the endpoint. + Required. + :type origin_group_name: str + :param origin_group_update_properties: Origin group properties. Required. + :type origin_group_update_properties: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns OriginGroup. The OriginGroup is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.OriginGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + origin_group_name: str, + origin_group_update_properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.OriginGroup]: + """Updates an existing origin group within an endpoint. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param origin_group_name: Name of the origin group which is unique within the endpoint. + Required. + :type origin_group_name: str + :param origin_group_update_properties: Origin group properties. Required. + :type origin_group_update_properties: IO[bytes] + :keyword content_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 OriginGroup. The OriginGroup is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.OriginGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + origin_group_name: str, + origin_group_update_properties: Union[_models.OriginGroupUpdateParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.OriginGroup]: + """Updates an existing origin group within an endpoint. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param origin_group_name: Name of the origin group which is unique within the endpoint. + Required. + :type origin_group_name: str + :param origin_group_update_properties: Origin group properties. Is one of the following types: + OriginGroupUpdateParameters, JSON, IO[bytes] Required. + :type origin_group_update_properties: ~azure.mgmt.cdn.models.OriginGroupUpdateParameters or + JSON or IO[bytes] + :return: An instance of LROPoller that returns OriginGroup. The OriginGroup is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.OriginGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.OriginGroup] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._update_initial( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + origin_group_name=origin_group_name, + origin_group_update_properties=origin_group_update_properties, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.OriginGroup, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.OriginGroup].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.OriginGroup]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_initial( + self, resource_group_name: str, profile_name: str, endpoint_name: str, origin_group_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_origin_groups_delete_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + origin_group_name=origin_group_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, profile_name: str, endpoint_name: str, origin_group_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Deletes an existing origin group within an endpoint. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param origin_group_name: Name of the origin group which is unique within the endpoint. + Required. + :type origin_group_name: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + origin_group_name=origin_group_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_endpoint( + self, resource_group_name: str, profile_name: str, endpoint_name: str, **kwargs: Any + ) -> ItemPaged["_models.OriginGroup"]: + """Lists all of the existing origin groups within an endpoint. + + :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 or CDN + profile 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. + :type endpoint_name: str + :return: An iterator like instance of OriginGroup + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cdn.models.OriginGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.OriginGroup]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_origin_groups_list_by_endpoint_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.OriginGroup], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class CustomDomainsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cdn.CdnManagementClient`'s + :attr:`custom_domains` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: 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( + self, resource_group_name: str, profile_name: str, endpoint_name: str, custom_domain_name: str, **kwargs: Any + ) -> _models.CustomDomain: + """Gets an existing custom domain within an endpoint. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param custom_domain_name: Name of the custom domain within an endpoint. Required. + :type custom_domain_name: str + :return: CustomDomain. The CustomDomain is compatible with MutableMapping + :rtype: ~azure.mgmt.cdn.models.CustomDomain + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.CustomDomain] = kwargs.pop("cls", None) + + _request = build_custom_domains_get_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + custom_domain_name=custom_domain_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.CustomDomain, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_initial( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + custom_domain_name: str, + custom_domain_properties: Union[_models.CustomDomainParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(custom_domain_properties, (IOBase, bytes)): + _content = custom_domain_properties + else: + _content = json.dumps(custom_domain_properties, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_custom_domains_create_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + custom_domain_name=custom_domain_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + custom_domain_name: str, + custom_domain_properties: _models.CustomDomainParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CustomDomain]: + """Creates a new custom domain within an endpoint. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param custom_domain_name: Name of the custom domain within an endpoint. Required. + :type custom_domain_name: str + :param custom_domain_properties: Properties required to create a new custom domain. Required. + :type custom_domain_properties: ~azure.mgmt.cdn.models.CustomDomainParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns CustomDomain. The CustomDomain is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.CustomDomain] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + custom_domain_name: str, + custom_domain_properties: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CustomDomain]: + """Creates a new custom domain within an endpoint. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param custom_domain_name: Name of the custom domain within an endpoint. Required. + :type custom_domain_name: str + :param custom_domain_properties: Properties required to create a new custom domain. Required. + :type custom_domain_properties: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns CustomDomain. The CustomDomain is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.CustomDomain] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + custom_domain_name: str, + custom_domain_properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CustomDomain]: + """Creates a new custom domain within an endpoint. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param custom_domain_name: Name of the custom domain within an endpoint. Required. + :type custom_domain_name: str + :param custom_domain_properties: Properties required to create a new custom domain. Required. + :type custom_domain_properties: IO[bytes] + :keyword content_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 CustomDomain. The CustomDomain is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.CustomDomain] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + custom_domain_name: str, + custom_domain_properties: Union[_models.CustomDomainParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.CustomDomain]: + """Creates a new custom domain within an endpoint. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param custom_domain_name: Name of the custom domain within an endpoint. Required. + :type custom_domain_name: str + :param custom_domain_properties: Properties required to create a new custom domain. Is one of + the following types: CustomDomainParameters, JSON, IO[bytes] Required. + :type custom_domain_properties: ~azure.mgmt.cdn.models.CustomDomainParameters or JSON or + IO[bytes] + :return: An instance of LROPoller that returns CustomDomain. The CustomDomain is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.CustomDomain] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CustomDomain] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_initial( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + custom_domain_name=custom_domain_name, + custom_domain_properties=custom_domain_properties, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.CustomDomain, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.CustomDomain].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.CustomDomain]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_initial( + self, resource_group_name: str, profile_name: str, endpoint_name: str, custom_domain_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_custom_domains_delete_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + custom_domain_name=custom_domain_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, profile_name: str, endpoint_name: str, custom_domain_name: str, **kwargs: Any + ) -> LROPoller[_models.CustomDomain]: + """Deletes an existing custom domain within an endpoint. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param custom_domain_name: Name of the custom domain within an endpoint. Required. + :type custom_domain_name: str + :return: An instance of LROPoller that returns CustomDomain. The CustomDomain is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.CustomDomain] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.CustomDomain] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + custom_domain_name=custom_domain_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.CustomDomain, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.CustomDomain].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.CustomDomain]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace + def list_by_endpoint( + self, resource_group_name: str, profile_name: str, endpoint_name: str, **kwargs: Any + ) -> ItemPaged["_models.CustomDomain"]: + """Lists all of the existing custom domains within an endpoint. + + :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 or CDN + profile 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. + :type endpoint_name: str + :return: An iterator like instance of CustomDomain + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cdn.models.CustomDomain] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.CustomDomain]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_custom_domains_list_by_endpoint_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.CustomDomain], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + def _disable_custom_https_initial( + self, resource_group_name: str, profile_name: str, endpoint_name: str, custom_domain_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_custom_domains_disable_custom_https_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + custom_domain_name=custom_domain_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_disable_custom_https( + self, resource_group_name: str, profile_name: str, endpoint_name: str, custom_domain_name: str, **kwargs: Any + ) -> LROPoller[_models.CustomDomain]: + """Disable https delivery of the custom domain. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param custom_domain_name: Name of the custom domain within an endpoint. Required. + :type custom_domain_name: str + :return: An instance of LROPoller that returns CustomDomain. The CustomDomain is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.CustomDomain] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.CustomDomain] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._disable_custom_https_initial( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + custom_domain_name=custom_domain_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.CustomDomain, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.CustomDomain].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.CustomDomain]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _enable_custom_https_initial( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + custom_domain_name: str, + custom_domain_https_parameters: Optional[Union[_models.CustomDomainHttpsParameters, JSON, IO[bytes]]] = None, + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + content_type = content_type if custom_domain_https_parameters else None + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" if custom_domain_https_parameters else None + _content = None + if isinstance(custom_domain_https_parameters, (IOBase, bytes)): + _content = custom_domain_https_parameters + else: + if custom_domain_https_parameters is not None: + _content = json.dumps(custom_domain_https_parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + else: + _content = None + + _request = build_custom_domains_enable_custom_https_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + custom_domain_name=custom_domain_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_enable_custom_https( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + custom_domain_name: str, + custom_domain_https_parameters: Optional[_models.CustomDomainHttpsParameters] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CustomDomain]: + """Enable https delivery of the custom domain. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param custom_domain_name: Name of the custom domain within an endpoint. Required. + :type custom_domain_name: str + :param custom_domain_https_parameters: The configuration specifying how to enable HTTPS for the + custom domain - using CDN managed certificate or user's own certificate. If not specified, + enabling ssl uses CDN managed certificate by default. Default value is None. + :type custom_domain_https_parameters: ~azure.mgmt.cdn.models.CustomDomainHttpsParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns CustomDomain. The CustomDomain is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.CustomDomain] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_enable_custom_https( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + custom_domain_name: str, + custom_domain_https_parameters: Optional[JSON] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CustomDomain]: + """Enable https delivery of the custom domain. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param custom_domain_name: Name of the custom domain within an endpoint. Required. + :type custom_domain_name: str + :param custom_domain_https_parameters: The configuration specifying how to enable HTTPS for the + custom domain - using CDN managed certificate or user's own certificate. If not specified, + enabling ssl uses CDN managed certificate by default. Default value is None. + :type custom_domain_https_parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns CustomDomain. The CustomDomain is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.CustomDomain] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_enable_custom_https( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + custom_domain_name: str, + custom_domain_https_parameters: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CustomDomain]: + """Enable https delivery of the custom domain. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param custom_domain_name: Name of the custom domain within an endpoint. Required. + :type custom_domain_name: str + :param custom_domain_https_parameters: The configuration specifying how to enable HTTPS for the + custom domain - using CDN managed certificate or user's own certificate. If not specified, + enabling ssl uses CDN managed certificate by default. Default value is None. + :type custom_domain_https_parameters: IO[bytes] + :keyword content_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 CustomDomain. The CustomDomain is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.CustomDomain] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_enable_custom_https( + self, + resource_group_name: str, + profile_name: str, + endpoint_name: str, + custom_domain_name: str, + custom_domain_https_parameters: Optional[Union[_models.CustomDomainHttpsParameters, JSON, IO[bytes]]] = None, + **kwargs: Any + ) -> LROPoller[_models.CustomDomain]: + """Enable https delivery of the custom domain. + + :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 or CDN + profile 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. + :type endpoint_name: str + :param custom_domain_name: Name of the custom domain within an endpoint. Required. + :type custom_domain_name: str + :param custom_domain_https_parameters: The configuration specifying how to enable HTTPS for the + custom domain - using CDN managed certificate or user's own certificate. If not specified, + enabling ssl uses CDN managed certificate by default. Is one of the following types: + CustomDomainHttpsParameters, JSON, IO[bytes] Default value is None. + :type custom_domain_https_parameters: ~azure.mgmt.cdn.models.CustomDomainHttpsParameters or + JSON or IO[bytes] + :return: An instance of LROPoller that returns CustomDomain. The CustomDomain is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.CustomDomain] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + content_type = content_type if custom_domain_https_parameters else None + cls: ClsType[_models.CustomDomain] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._enable_custom_https_initial( + resource_group_name=resource_group_name, + profile_name=profile_name, + endpoint_name=endpoint_name, + custom_domain_name=custom_domain_name, + custom_domain_https_parameters=custom_domain_https_parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.CustomDomain, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.CustomDomain].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.CustomDomain]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + +class AFDCustomDomainsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cdn.CdnManagementClient`'s + :attr:`afd_custom_domains` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: 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( + self, resource_group_name: str, profile_name: str, custom_domain_name: str, **kwargs: Any + ) -> _models.AFDDomain: + """Gets an existing AzureFrontDoor domain with the specified domain name under the specified + subscription, resource group and 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 or CDN + profile 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. + :type custom_domain_name: str + :return: AFDDomain. The AFDDomain is compatible with MutableMapping + :rtype: ~azure.mgmt.cdn.models.AFDDomain + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.AFDDomain] = kwargs.pop("cls", None) + + _request = build_afd_custom_domains_get_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + custom_domain_name=custom_domain_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.AFDDomain, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_initial( + self, + resource_group_name: str, + profile_name: str, + custom_domain_name: str, + custom_domain: Union[_models.AFDDomain, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(custom_domain, (IOBase, bytes)): + _content = custom_domain + else: + _content = json.dumps(custom_domain, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_afd_custom_domains_create_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + custom_domain_name=custom_domain_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create( + self, + resource_group_name: str, + profile_name: str, + custom_domain_name: str, + custom_domain: _models.AFDDomain, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AFDDomain]: + """Creates a new domain within the specified 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 or CDN + profile 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. + :type custom_domain_name: str + :param custom_domain: Domain properties. Required. + :type custom_domain: ~azure.mgmt.cdn.models.AFDDomain + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns AFDDomain. The AFDDomain is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.AFDDomain] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + profile_name: str, + custom_domain_name: str, + custom_domain: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AFDDomain]: + """Creates a new domain within the specified 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 or CDN + profile 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. + :type custom_domain_name: str + :param custom_domain: Domain properties. Required. + :type custom_domain: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns AFDDomain. The AFDDomain is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.AFDDomain] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + profile_name: str, + custom_domain_name: str, + custom_domain: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AFDDomain]: + """Creates a new domain within the specified 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 or CDN + profile 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. + :type custom_domain_name: str + :param custom_domain: Domain properties. Required. + :type custom_domain: IO[bytes] + :keyword content_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 AFDDomain. The AFDDomain is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.AFDDomain] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + profile_name: str, + custom_domain_name: str, + custom_domain: Union[_models.AFDDomain, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.AFDDomain]: + """Creates a new domain within the specified 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 or CDN + profile 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. + :type custom_domain_name: str + :param custom_domain: Domain properties. Is one of the following types: AFDDomain, JSON, + IO[bytes] Required. + :type custom_domain: ~azure.mgmt.cdn.models.AFDDomain or JSON or IO[bytes] + :return: An instance of LROPoller that returns AFDDomain. The AFDDomain is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.AFDDomain] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AFDDomain] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_initial( + resource_group_name=resource_group_name, + profile_name=profile_name, + custom_domain_name=custom_domain_name, + custom_domain=custom_domain, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.AFDDomain, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.AFDDomain].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.AFDDomain]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _update_initial( + self, + resource_group_name: str, + profile_name: str, + custom_domain_name: str, + custom_domain_update_properties: Union[_models.AFDDomainUpdateParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(custom_domain_update_properties, (IOBase, bytes)): + _content = custom_domain_update_properties + else: + _content = json.dumps(custom_domain_update_properties, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_afd_custom_domains_update_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + custom_domain_name=custom_domain_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + profile_name: str, + custom_domain_name: str, + custom_domain_update_properties: _models.AFDDomainUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AFDDomain]: + """Updates an existing domain within a 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 or CDN + profile 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. + :type custom_domain_name: str + :param custom_domain_update_properties: Domain properties. Required. + :type custom_domain_update_properties: ~azure.mgmt.cdn.models.AFDDomainUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns AFDDomain. The AFDDomain is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.AFDDomain] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + profile_name: str, + custom_domain_name: str, + custom_domain_update_properties: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AFDDomain]: + """Updates an existing domain within a 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 or CDN + profile 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. + :type custom_domain_name: str + :param custom_domain_update_properties: Domain properties. Required. + :type custom_domain_update_properties: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns AFDDomain. The AFDDomain is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.AFDDomain] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + profile_name: str, + custom_domain_name: str, + custom_domain_update_properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AFDDomain]: + """Updates an existing domain within a 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 or CDN + profile 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. + :type custom_domain_name: str + :param custom_domain_update_properties: Domain properties. Required. + :type custom_domain_update_properties: IO[bytes] + :keyword content_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 AFDDomain. The AFDDomain is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.AFDDomain] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + profile_name: str, + custom_domain_name: str, + custom_domain_update_properties: Union[_models.AFDDomainUpdateParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.AFDDomain]: + """Updates an existing domain within a 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 or CDN + profile 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. + :type custom_domain_name: str + :param custom_domain_update_properties: Domain properties. Is one of the following types: + AFDDomainUpdateParameters, JSON, IO[bytes] Required. + :type custom_domain_update_properties: ~azure.mgmt.cdn.models.AFDDomainUpdateParameters or JSON + or IO[bytes] + :return: An instance of LROPoller that returns AFDDomain. The AFDDomain is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.AFDDomain] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AFDDomain] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._update_initial( + resource_group_name=resource_group_name, + profile_name=profile_name, + custom_domain_name=custom_domain_name, + custom_domain_update_properties=custom_domain_update_properties, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.AFDDomain, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.AFDDomain].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.AFDDomain]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_initial( + self, resource_group_name: str, profile_name: str, custom_domain_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_afd_custom_domains_delete_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + custom_domain_name=custom_domain_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, profile_name: str, custom_domain_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Deletes an existing AzureFrontDoor domain with the specified domain name under the specified + subscription, resource group and 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 or CDN + profile 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. + :type custom_domain_name: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + profile_name=profile_name, + custom_domain_name=custom_domain_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_by_profile( + self, resource_group_name: str, profile_name: str, **kwargs: Any + ) -> ItemPaged["_models.AFDDomain"]: + """Lists existing AzureFrontDoor domains. + + :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 or CDN + profile which is unique within the resource group. Required. + :type profile_name: str + :return: An iterator like instance of AFDDomain + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cdn.models.AFDDomain] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.AFDDomain]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_afd_custom_domains_list_by_profile_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.AFDDomain], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + def _refresh_validation_token_initial( + self, resource_group_name: str, profile_name: str, custom_domain_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_afd_custom_domains_refresh_validation_token_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + custom_domain_name=custom_domain_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_refresh_validation_token( + self, resource_group_name: str, profile_name: str, custom_domain_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Updates the domain validation token. + + :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 or CDN + profile 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. + :type custom_domain_name: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._refresh_validation_token_initial( + resource_group_name=resource_group_name, + profile_name=profile_name, + custom_domain_name=custom_domain_name, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + +class AFDProfilesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cdn.CdnManagementClient`'s + :attr:`afd_profiles` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: 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( + self, + resource_group_name: str, + profile_name: str, + check_endpoint_name_availability_input: _models.CheckEndpointNameAvailabilityInput, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CheckEndpointNameAvailabilityOutput: + """Check the availability of an afdx endpoint name, and return the globally unique endpoint host + name. + + :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 or CDN + profile which is unique within the resource group. Required. + :type profile_name: str + :param check_endpoint_name_availability_input: Input to check. Required. + :type check_endpoint_name_availability_input: + ~azure.mgmt.cdn.models.CheckEndpointNameAvailabilityInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: CheckEndpointNameAvailabilityOutput. The CheckEndpointNameAvailabilityOutput is + compatible with MutableMapping + :rtype: ~azure.mgmt.cdn.models.CheckEndpointNameAvailabilityOutput + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_endpoint_name_availability( + self, + resource_group_name: str, + profile_name: str, + check_endpoint_name_availability_input: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CheckEndpointNameAvailabilityOutput: + """Check the availability of an afdx endpoint name, and return the globally unique endpoint host + name. + + :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 or CDN + profile which is unique within the resource group. Required. + :type profile_name: str + :param check_endpoint_name_availability_input: Input to check. Required. + :type check_endpoint_name_availability_input: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: CheckEndpointNameAvailabilityOutput. The CheckEndpointNameAvailabilityOutput is + compatible with MutableMapping + :rtype: ~azure.mgmt.cdn.models.CheckEndpointNameAvailabilityOutput + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_endpoint_name_availability( + self, + resource_group_name: str, + profile_name: str, + check_endpoint_name_availability_input: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CheckEndpointNameAvailabilityOutput: + """Check the availability of an afdx endpoint name, and return the globally unique endpoint host + name. + + :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 or CDN + profile which is unique within the resource group. Required. + :type profile_name: str + :param check_endpoint_name_availability_input: Input to check. Required. + :type check_endpoint_name_availability_input: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: CheckEndpointNameAvailabilityOutput. The CheckEndpointNameAvailabilityOutput is + compatible with MutableMapping + :rtype: ~azure.mgmt.cdn.models.CheckEndpointNameAvailabilityOutput + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_endpoint_name_availability( + self, + resource_group_name: str, + profile_name: str, + check_endpoint_name_availability_input: Union[_models.CheckEndpointNameAvailabilityInput, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.CheckEndpointNameAvailabilityOutput: + """Check the availability of an afdx endpoint name, and return the globally unique endpoint host + name. + + :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 or CDN + profile which is unique within the resource group. Required. + :type profile_name: str + :param check_endpoint_name_availability_input: Input to check. Is one of the following types: + CheckEndpointNameAvailabilityInput, JSON, IO[bytes] Required. + :type check_endpoint_name_availability_input: + ~azure.mgmt.cdn.models.CheckEndpointNameAvailabilityInput or JSON or IO[bytes] + :return: CheckEndpointNameAvailabilityOutput. The CheckEndpointNameAvailabilityOutput is + compatible with MutableMapping + :rtype: ~azure.mgmt.cdn.models.CheckEndpointNameAvailabilityOutput + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CheckEndpointNameAvailabilityOutput] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(check_endpoint_name_availability_input, (IOBase, bytes)): + _content = check_endpoint_name_availability_input + else: + _content = json.dumps(check_endpoint_name_availability_input, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_afd_profiles_check_endpoint_name_availability_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.CheckEndpointNameAvailabilityOutput, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_resource_usage( + self, resource_group_name: str, profile_name: str, **kwargs: Any + ) -> ItemPaged["_models.Usage"]: + """Checks the quota and actual usage of endpoints under the given Azure Front Door 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 or CDN + profile which is unique within the resource group. Required. + :type profile_name: str + :return: An iterator like instance of Usage + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cdn.models.Usage] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Usage]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_afd_profiles_list_resource_usage_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.Usage], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @overload + def check_host_name_availability( + self, + resource_group_name: str, + profile_name: str, + check_host_name_availability_input: _models.CheckHostNameAvailabilityInput, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CheckNameAvailabilityOutput: + """Validates the custom domain mapping to ensure it maps to the correct Azure Front Door endpoint + in DNS. + + :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 or CDN + profile 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 + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: CheckNameAvailabilityOutput. The CheckNameAvailabilityOutput is compatible with + MutableMapping + :rtype: ~azure.mgmt.cdn.models.CheckNameAvailabilityOutput + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_host_name_availability( + self, + resource_group_name: str, + profile_name: str, + check_host_name_availability_input: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CheckNameAvailabilityOutput: + """Validates the custom domain mapping to ensure it maps to the correct Azure Front Door endpoint + in DNS. + + :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 or CDN + profile 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: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: CheckNameAvailabilityOutput. The CheckNameAvailabilityOutput is compatible with + MutableMapping + :rtype: ~azure.mgmt.cdn.models.CheckNameAvailabilityOutput + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_host_name_availability( + self, + resource_group_name: str, + profile_name: str, + check_host_name_availability_input: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CheckNameAvailabilityOutput: + """Validates the custom domain mapping to ensure it maps to the correct Azure Front Door endpoint + in DNS. + + :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 or CDN + profile 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] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: CheckNameAvailabilityOutput. The CheckNameAvailabilityOutput is compatible with + MutableMapping + :rtype: ~azure.mgmt.cdn.models.CheckNameAvailabilityOutput + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_host_name_availability( + self, + resource_group_name: str, + profile_name: str, + check_host_name_availability_input: Union[_models.CheckHostNameAvailabilityInput, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.CheckNameAvailabilityOutput: + """Validates the custom domain mapping to ensure it maps to the correct Azure Front Door endpoint + in DNS. + + :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 or CDN + profile which is unique within the resource group. Required. + :type profile_name: str + :param check_host_name_availability_input: Custom domain to be validated. Is one of the + following types: CheckHostNameAvailabilityInput, JSON, IO[bytes] Required. + :type check_host_name_availability_input: ~azure.mgmt.cdn.models.CheckHostNameAvailabilityInput + or JSON or IO[bytes] + :return: CheckNameAvailabilityOutput. The CheckNameAvailabilityOutput is compatible with + MutableMapping + :rtype: ~azure.mgmt.cdn.models.CheckNameAvailabilityOutput + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CheckNameAvailabilityOutput] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(check_host_name_availability_input, (IOBase, bytes)): + _content = check_host_name_availability_input + else: + _content = json.dumps(check_host_name_availability_input, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_afd_profiles_check_host_name_availability_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.CheckNameAvailabilityOutput, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def validate_secret( + self, + resource_group_name: str, + profile_name: str, + validate_secret_input: _models.ValidateSecretInput, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ValidateSecretOutput: + """Validate a Secret in the 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 or CDN + profile which is unique within the resource group. Required. + :type profile_name: str + :param validate_secret_input: The Secret source. Required. + :type validate_secret_input: ~azure.mgmt.cdn.models.ValidateSecretInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ValidateSecretOutput. The ValidateSecretOutput is compatible with MutableMapping + :rtype: ~azure.mgmt.cdn.models.ValidateSecretOutput + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def validate_secret( + self, + resource_group_name: str, + profile_name: str, + validate_secret_input: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ValidateSecretOutput: + """Validate a Secret in the 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 or CDN + profile which is unique within the resource group. Required. + :type profile_name: str + :param validate_secret_input: The Secret source. Required. + :type validate_secret_input: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ValidateSecretOutput. The ValidateSecretOutput is compatible with MutableMapping + :rtype: ~azure.mgmt.cdn.models.ValidateSecretOutput + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def validate_secret( + self, + resource_group_name: str, + profile_name: str, + validate_secret_input: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ValidateSecretOutput: + """Validate a Secret in the 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 or CDN + profile which is unique within the resource group. Required. + :type profile_name: str + :param validate_secret_input: The Secret source. Required. + :type validate_secret_input: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ValidateSecretOutput. The ValidateSecretOutput is compatible with MutableMapping + :rtype: ~azure.mgmt.cdn.models.ValidateSecretOutput + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def validate_secret( + self, + resource_group_name: str, + profile_name: str, + validate_secret_input: Union[_models.ValidateSecretInput, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.ValidateSecretOutput: + """Validate a Secret in the 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 or CDN + profile which is unique within the resource group. Required. + :type profile_name: str + :param validate_secret_input: The Secret source. Is one of the following types: + ValidateSecretInput, JSON, IO[bytes] Required. + :type validate_secret_input: ~azure.mgmt.cdn.models.ValidateSecretInput or JSON or IO[bytes] + :return: ValidateSecretOutput. The ValidateSecretOutput is compatible with MutableMapping + :rtype: ~azure.mgmt.cdn.models.ValidateSecretOutput + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ValidateSecretOutput] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(validate_secret_input, (IOBase, bytes)): + _content = validate_secret_input + else: + _content = json.dumps(validate_secret_input, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_afd_profiles_validate_secret_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ValidateSecretOutput, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _upgrade_initial( + self, + resource_group_name: str, + profile_name: str, + profile_upgrade_parameters: Union[_models.ProfileUpgradeParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(profile_upgrade_parameters, (IOBase, bytes)): + _content = profile_upgrade_parameters + else: + _content = json.dumps(profile_upgrade_parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_afd_profiles_upgrade_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_upgrade( + self, + resource_group_name: str, + profile_name: str, + profile_upgrade_parameters: _models.ProfileUpgradeParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Profile]: + """Upgrade a profile from Standard_AzureFrontDoor to Premium_AzureFrontDoor. + + :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 or CDN + profile which is unique within the resource group. Required. + :type profile_name: str + :param profile_upgrade_parameters: Profile upgrade input parameter. Required. + :type profile_upgrade_parameters: ~azure.mgmt.cdn.models.ProfileUpgradeParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns Profile. The Profile is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Profile] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_upgrade( + self, + resource_group_name: str, + profile_name: str, + profile_upgrade_parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Profile]: + """Upgrade a profile from Standard_AzureFrontDoor to Premium_AzureFrontDoor. + + :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 or CDN + profile which is unique within the resource group. Required. + :type profile_name: str + :param profile_upgrade_parameters: Profile upgrade input parameter. Required. + :type profile_upgrade_parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns Profile. The Profile is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Profile] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_upgrade( + self, + resource_group_name: str, + profile_name: str, + profile_upgrade_parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Profile]: + """Upgrade a profile from Standard_AzureFrontDoor to Premium_AzureFrontDoor. + + :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 or CDN + profile which is unique within the resource group. Required. + :type profile_name: str + :param profile_upgrade_parameters: Profile upgrade input parameter. Required. + :type profile_upgrade_parameters: IO[bytes] + :keyword content_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 Profile. The Profile is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Profile] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_upgrade( + self, + resource_group_name: str, + profile_name: str, + profile_upgrade_parameters: Union[_models.ProfileUpgradeParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.Profile]: + """Upgrade a profile from Standard_AzureFrontDoor to Premium_AzureFrontDoor. + + :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 or CDN + profile which is unique within the resource group. Required. + :type profile_name: str + :param profile_upgrade_parameters: Profile upgrade input parameter. Is one of the following + types: ProfileUpgradeParameters, JSON, IO[bytes] Required. + :type profile_upgrade_parameters: ~azure.mgmt.cdn.models.ProfileUpgradeParameters or JSON or + IO[bytes] + :return: An instance of LROPoller that returns Profile. The Profile is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Profile] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Profile] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._upgrade_initial( + resource_group_name=resource_group_name, + profile_name=profile_name, + profile_upgrade_parameters=profile_upgrade_parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.Profile, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.Profile].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.Profile]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + +class LogAnalyticsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cdn.CdnManagementClient`'s + :attr:`log_analytics` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: 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( + self, + resource_group_name: str, + profile_name: str, + *, + metrics: List[Union[str, _models.LogMetric]], + date_time_begin: datetime.datetime, + date_time_end: datetime.datetime, + granularity: Union[str, _models.LogMetricsGranularity], + custom_domains: List[str], + protocols: List[str], + group_by: Optional[List[Union[str, _models.LogMetricsGroupBy]]] = None, + continents: Optional[List[str]] = None, + country_or_regions: Optional[List[str]] = None, + **kwargs: Any + ) -> _models.MetricsResponse: + """Get log report for AFD 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 or CDN + profile which is unique within the resource group. Required. + :type profile_name: str + :keyword metrics: Required. + :paramtype metrics: list[str or ~azure.mgmt.cdn.models.LogMetric] + :keyword date_time_begin: Required. + :paramtype date_time_begin: ~datetime.datetime + :keyword date_time_end: Required. + :paramtype date_time_end: ~datetime.datetime + :keyword granularity: Known values are: "PT5M", "PT1H", and "P1D". Required. + :paramtype granularity: str or ~azure.mgmt.cdn.models.LogMetricsGranularity + :keyword custom_domains: Required. + :paramtype custom_domains: list[str] + :keyword protocols: Required. + :paramtype protocols: list[str] + :keyword group_by: Default value is None. + :paramtype group_by: list[str or ~azure.mgmt.cdn.models.LogMetricsGroupBy] + :keyword continents: Default value is None. + :paramtype continents: list[str] + :keyword country_or_regions: Default value is None. + :paramtype country_or_regions: list[str] + :return: MetricsResponse. The MetricsResponse is compatible with MutableMapping + :rtype: ~azure.mgmt.cdn.models.MetricsResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.MetricsResponse] = kwargs.pop("cls", None) + + _request = build_log_analytics_get_log_analytics_metrics_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + subscription_id=self._config.subscription_id, + metrics=metrics, + date_time_begin=date_time_begin, + date_time_end=date_time_end, + granularity=granularity, + custom_domains=custom_domains, + protocols=protocols, + group_by=group_by, + continents=continents, + country_or_regions=country_or_regions, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.MetricsResponse, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get_log_analytics_rankings( + self, + resource_group_name: str, + profile_name: str, + *, + rankings: List[Union[str, _models.LogRanking]], + metrics: List[Union[str, _models.LogRankingMetric]], + max_ranking: int, + date_time_begin: datetime.datetime, + date_time_end: datetime.datetime, + custom_domains: Optional[List[str]] = None, + **kwargs: Any + ) -> _models.RankingsResponse: + """Get log analytics ranking report for AFD 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 or CDN + profile which is unique within the resource group. Required. + :type profile_name: str + :keyword rankings: Required. + :paramtype rankings: list[str or ~azure.mgmt.cdn.models.LogRanking] + :keyword metrics: Required. + :paramtype metrics: list[str or ~azure.mgmt.cdn.models.LogRankingMetric] + :keyword max_ranking: Required. + :paramtype max_ranking: int + :keyword date_time_begin: Required. + :paramtype date_time_begin: ~datetime.datetime + :keyword date_time_end: Required. + :paramtype date_time_end: ~datetime.datetime + :keyword custom_domains: Default value is None. + :paramtype custom_domains: list[str] + :return: RankingsResponse. The RankingsResponse is compatible with MutableMapping + :rtype: ~azure.mgmt.cdn.models.RankingsResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.RankingsResponse] = kwargs.pop("cls", None) + + _request = build_log_analytics_get_log_analytics_rankings_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + subscription_id=self._config.subscription_id, + rankings=rankings, + metrics=metrics, + max_ranking=max_ranking, + date_time_begin=date_time_begin, + date_time_end=date_time_end, + custom_domains=custom_domains, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.RankingsResponse, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get_log_analytics_locations( + self, resource_group_name: str, profile_name: str, **kwargs: Any + ) -> _models.ContinentsResponse: + """Get all available location names for AFD log analytics report. + + :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 or CDN + profile which is unique within the resource group. Required. + :type profile_name: str + :return: ContinentsResponse. The ContinentsResponse is compatible with MutableMapping + :rtype: ~azure.mgmt.cdn.models.ContinentsResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ContinentsResponse] = kwargs.pop("cls", None) + + _request = build_log_analytics_get_log_analytics_locations_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ContinentsResponse, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get_log_analytics_resources( + self, resource_group_name: str, profile_name: str, **kwargs: Any + ) -> _models.ResourcesResponse: + """Get all endpoints and custom domains available for AFD log report. + + :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 or CDN + profile which is unique within the resource group. Required. + :type profile_name: str + :return: ResourcesResponse. The ResourcesResponse is compatible with MutableMapping + :rtype: ~azure.mgmt.cdn.models.ResourcesResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ResourcesResponse] = kwargs.pop("cls", None) + + _request = build_log_analytics_get_log_analytics_resources_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ResourcesResponse, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get_waf_log_analytics_metrics( + self, + resource_group_name: str, + profile_name: str, + *, + metrics: List[Union[str, _models.WafMetric]], + date_time_begin: datetime.datetime, + date_time_end: datetime.datetime, + granularity: Union[str, _models.WafGranularity], + actions: Optional[List[Union[str, _models.WafAction]]] = None, + group_by: Optional[List[Union[str, _models.WafRankingGroupBy]]] = None, + rule_types: Optional[List[Union[str, _models.WafRuleType]]] = None, + **kwargs: Any + ) -> _models.WafMetricsResponse: + """Get Waf related log analytics report for AFD 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 or CDN + profile which is unique within the resource group. Required. + :type profile_name: str + :keyword metrics: Required. + :paramtype metrics: list[str or ~azure.mgmt.cdn.models.WafMetric] + :keyword date_time_begin: Required. + :paramtype date_time_begin: ~datetime.datetime + :keyword date_time_end: Required. + :paramtype date_time_end: ~datetime.datetime + :keyword granularity: Known values are: "PT5M", "PT1H", and "P1D". Required. + :paramtype granularity: str or ~azure.mgmt.cdn.models.WafGranularity + :keyword actions: Default value is None. + :paramtype actions: list[str or ~azure.mgmt.cdn.models.WafAction] + :keyword group_by: Default value is None. + :paramtype group_by: list[str or ~azure.mgmt.cdn.models.WafRankingGroupBy] + :keyword rule_types: Default value is None. + :paramtype rule_types: list[str or ~azure.mgmt.cdn.models.WafRuleType] + :return: WafMetricsResponse. The WafMetricsResponse is compatible with MutableMapping + :rtype: ~azure.mgmt.cdn.models.WafMetricsResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.WafMetricsResponse] = kwargs.pop("cls", None) + + _request = build_log_analytics_get_waf_log_analytics_metrics_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + subscription_id=self._config.subscription_id, + metrics=metrics, + date_time_begin=date_time_begin, + date_time_end=date_time_end, + granularity=granularity, + actions=actions, + group_by=group_by, + rule_types=rule_types, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.WafMetricsResponse, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get_waf_log_analytics_rankings( + self, + resource_group_name: str, + profile_name: str, + *, + metrics: List[Union[str, _models.WafMetric]], + date_time_begin: datetime.datetime, + date_time_end: datetime.datetime, + max_ranking: int, + rankings: List[Union[str, _models.WafRankingType]], + actions: Optional[List[Union[str, _models.WafAction]]] = None, + rule_types: Optional[List[Union[str, _models.WafRuleType]]] = None, + **kwargs: Any + ) -> _models.WafRankingsResponse: + """Get WAF log analytics charts for AFD 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 or CDN + profile which is unique within the resource group. Required. + :type profile_name: str + :keyword metrics: Required. + :paramtype metrics: list[str or ~azure.mgmt.cdn.models.WafMetric] + :keyword date_time_begin: Required. + :paramtype date_time_begin: ~datetime.datetime + :keyword date_time_end: Required. + :paramtype date_time_end: ~datetime.datetime + :keyword max_ranking: Required. + :paramtype max_ranking: int + :keyword rankings: Required. + :paramtype rankings: list[str or ~azure.mgmt.cdn.models.WafRankingType] + :keyword actions: Default value is None. + :paramtype actions: list[str or ~azure.mgmt.cdn.models.WafAction] + :keyword rule_types: Default value is None. + :paramtype rule_types: list[str or ~azure.mgmt.cdn.models.WafRuleType] + :return: WafRankingsResponse. The WafRankingsResponse is compatible with MutableMapping + :rtype: ~azure.mgmt.cdn.models.WafRankingsResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.WafRankingsResponse] = kwargs.pop("cls", None) + + _request = build_log_analytics_get_waf_log_analytics_rankings_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + subscription_id=self._config.subscription_id, + metrics=metrics, + date_time_begin=date_time_begin, + date_time_end=date_time_end, + max_ranking=max_ranking, + rankings=rankings, + actions=actions, + rule_types=rule_types, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.WafRankingsResponse, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class PoliciesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cdn.CdnManagementClient`'s + :attr:`policies` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: 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(self, resource_group_name: str, policy_name: str, **kwargs: Any) -> _models.CdnWebApplicationFirewallPolicy: + """Retrieve protection policy with specified name within a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param policy_name: The name of the CdnWebApplicationFirewallPolicy. Required. + :type policy_name: str + :return: CdnWebApplicationFirewallPolicy. The CdnWebApplicationFirewallPolicy is compatible + with MutableMapping + :rtype: ~azure.mgmt.cdn.models.CdnWebApplicationFirewallPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.CdnWebApplicationFirewallPolicy] = kwargs.pop("cls", None) + + _request = build_policies_get_request( + resource_group_name=resource_group_name, + policy_name=policy_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.CdnWebApplicationFirewallPolicy, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + policy_name: str, + cdn_web_application_firewall_policy: Union[_models.CdnWebApplicationFirewallPolicy, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(cdn_web_application_firewall_policy, (IOBase, bytes)): + _content = cdn_web_application_firewall_policy + else: + _content = json.dumps(cdn_web_application_firewall_policy, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_policies_create_or_update_request( + resource_group_name=resource_group_name, + policy_name=policy_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + policy_name: str, + cdn_web_application_firewall_policy: _models.CdnWebApplicationFirewallPolicy, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CdnWebApplicationFirewallPolicy]: + """Create or update policy with specified rule set name within a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param policy_name: The name of the CdnWebApplicationFirewallPolicy. Required. + :type policy_name: str + :param cdn_web_application_firewall_policy: Policy to be created. Required. + :type cdn_web_application_firewall_policy: + ~azure.mgmt.cdn.models.CdnWebApplicationFirewallPolicy + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns CdnWebApplicationFirewallPolicy. The + CdnWebApplicationFirewallPolicy is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.CdnWebApplicationFirewallPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + policy_name: str, + cdn_web_application_firewall_policy: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CdnWebApplicationFirewallPolicy]: + """Create or update policy with specified rule set name within a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param policy_name: The name of the CdnWebApplicationFirewallPolicy. Required. + :type policy_name: str + :param cdn_web_application_firewall_policy: Policy to be created. Required. + :type cdn_web_application_firewall_policy: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns CdnWebApplicationFirewallPolicy. The + CdnWebApplicationFirewallPolicy is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.CdnWebApplicationFirewallPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + policy_name: str, + cdn_web_application_firewall_policy: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CdnWebApplicationFirewallPolicy]: + """Create or update policy with specified rule set name within a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param policy_name: The name of the CdnWebApplicationFirewallPolicy. Required. + :type policy_name: str + :param cdn_web_application_firewall_policy: Policy to be created. Required. + :type cdn_web_application_firewall_policy: IO[bytes] + :keyword content_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 CdnWebApplicationFirewallPolicy. The + CdnWebApplicationFirewallPolicy is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.CdnWebApplicationFirewallPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + policy_name: str, + cdn_web_application_firewall_policy: Union[_models.CdnWebApplicationFirewallPolicy, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.CdnWebApplicationFirewallPolicy]: + """Create or update policy with specified rule set name within a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param policy_name: The name of the CdnWebApplicationFirewallPolicy. Required. + :type policy_name: str + :param cdn_web_application_firewall_policy: Policy to be created. Is one of the following + types: CdnWebApplicationFirewallPolicy, JSON, IO[bytes] Required. + :type cdn_web_application_firewall_policy: + ~azure.mgmt.cdn.models.CdnWebApplicationFirewallPolicy or JSON or IO[bytes] + :return: An instance of LROPoller that returns CdnWebApplicationFirewallPolicy. The + CdnWebApplicationFirewallPolicy is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.CdnWebApplicationFirewallPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CdnWebApplicationFirewallPolicy] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + policy_name=policy_name, + cdn_web_application_firewall_policy=cdn_web_application_firewall_policy, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.CdnWebApplicationFirewallPolicy, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.CdnWebApplicationFirewallPolicy].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.CdnWebApplicationFirewallPolicy]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _update_initial( + self, + resource_group_name: str, + policy_name: str, + cdn_web_application_firewall_policy_patch_parameters: Union[ + _models.CdnWebApplicationFirewallPolicyPatchParameters, JSON, IO[bytes] + ], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(cdn_web_application_firewall_policy_patch_parameters, (IOBase, bytes)): + _content = cdn_web_application_firewall_policy_patch_parameters + else: + _content = json.dumps(cdn_web_application_firewall_policy_patch_parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_policies_update_request( + resource_group_name=resource_group_name, + policy_name=policy_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + policy_name: str, + cdn_web_application_firewall_policy_patch_parameters: _models.CdnWebApplicationFirewallPolicyPatchParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CdnWebApplicationFirewallPolicy]: + """Update an existing CdnWebApplicationFirewallPolicy with the specified policy name under the + specified subscription and resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param policy_name: The name of the CdnWebApplicationFirewallPolicy. Required. + :type policy_name: str + :param cdn_web_application_firewall_policy_patch_parameters: CdnWebApplicationFirewallPolicy + parameters to be patched. Required. + :type cdn_web_application_firewall_policy_patch_parameters: + ~azure.mgmt.cdn.models.CdnWebApplicationFirewallPolicyPatchParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns CdnWebApplicationFirewallPolicy. The + CdnWebApplicationFirewallPolicy is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.CdnWebApplicationFirewallPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + policy_name: str, + cdn_web_application_firewall_policy_patch_parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CdnWebApplicationFirewallPolicy]: + """Update an existing CdnWebApplicationFirewallPolicy with the specified policy name under the + specified subscription and resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param policy_name: The name of the CdnWebApplicationFirewallPolicy. Required. + :type policy_name: str + :param cdn_web_application_firewall_policy_patch_parameters: CdnWebApplicationFirewallPolicy + parameters to be patched. Required. + :type cdn_web_application_firewall_policy_patch_parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns CdnWebApplicationFirewallPolicy. The + CdnWebApplicationFirewallPolicy is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.CdnWebApplicationFirewallPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + policy_name: str, + cdn_web_application_firewall_policy_patch_parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CdnWebApplicationFirewallPolicy]: + """Update an existing CdnWebApplicationFirewallPolicy with the specified policy name under the + specified subscription and resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param policy_name: The name of the CdnWebApplicationFirewallPolicy. Required. + :type policy_name: str + :param cdn_web_application_firewall_policy_patch_parameters: CdnWebApplicationFirewallPolicy + parameters to be patched. Required. + :type cdn_web_application_firewall_policy_patch_parameters: IO[bytes] + :keyword content_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 CdnWebApplicationFirewallPolicy. The + CdnWebApplicationFirewallPolicy is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.CdnWebApplicationFirewallPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + policy_name: str, + cdn_web_application_firewall_policy_patch_parameters: Union[ + _models.CdnWebApplicationFirewallPolicyPatchParameters, JSON, IO[bytes] + ], + **kwargs: Any + ) -> LROPoller[_models.CdnWebApplicationFirewallPolicy]: + """Update an existing CdnWebApplicationFirewallPolicy with the specified policy name under the + specified subscription and resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param policy_name: The name of the CdnWebApplicationFirewallPolicy. Required. + :type policy_name: str + :param cdn_web_application_firewall_policy_patch_parameters: CdnWebApplicationFirewallPolicy + parameters to be patched. Is one of the following types: + CdnWebApplicationFirewallPolicyPatchParameters, JSON, IO[bytes] Required. + :type cdn_web_application_firewall_policy_patch_parameters: + ~azure.mgmt.cdn.models.CdnWebApplicationFirewallPolicyPatchParameters or JSON or IO[bytes] + :return: An instance of LROPoller that returns CdnWebApplicationFirewallPolicy. The + CdnWebApplicationFirewallPolicy is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.CdnWebApplicationFirewallPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CdnWebApplicationFirewallPolicy] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._update_initial( + resource_group_name=resource_group_name, + policy_name=policy_name, + cdn_web_application_firewall_policy_patch_parameters=cdn_web_application_firewall_policy_patch_parameters, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.CdnWebApplicationFirewallPolicy, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.CdnWebApplicationFirewallPolicy].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.CdnWebApplicationFirewallPolicy]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, policy_name: str, **kwargs: Any + ) -> None: + """Deletes Policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param policy_name: The name of the CdnWebApplicationFirewallPolicy. Required. + :type policy_name: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_policies_delete_request( + resource_group_name=resource_group_name, + policy_name=policy_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list(self, resource_group_name: str, **kwargs: Any) -> ItemPaged["_models.CdnWebApplicationFirewallPolicy"]: + """Lists all of the protection policies within a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :return: An iterator like instance of CdnWebApplicationFirewallPolicy + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cdn.models.CdnWebApplicationFirewallPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.CdnWebApplicationFirewallPolicy]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_policies_list_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.CdnWebApplicationFirewallPolicy], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class ResourceUsageOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cdn.CdnManagementClient`'s + :attr:`resource_usage` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: 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) -> ItemPaged["_models.ResourceUsage"]: + """Check the quota and actual usage of the CDN profiles under the given subscription. + + :return: An iterator like instance of ResourceUsage + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cdn.models.ResourceUsage] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ResourceUsage]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_resource_usage_list_request( + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ResourceUsage], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class EdgeNodesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cdn.CdnManagementClient`'s + :attr:`edge_nodes` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: 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) -> ItemPaged["_models.EdgeNode"]: + """Edgenodes are the global Point of Presence (POP) locations used to deliver CDN content to end + users. + + :return: An iterator like instance of EdgeNode + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cdn.models.EdgeNode] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.EdgeNode]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_edge_nodes_list_request( + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.EdgeNode], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class ManagedRuleSetsOperations: """ + .. warning:: + **DO NOT** instantiate this class directly. - models = _models + Instead, you should access the following operations through + :class:`~azure.mgmt.cdn.CdnManagementClient`'s + :attr:`managed_rule_sets` attribute. + """ - def __init__(self, *args, **kwargs): + 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: 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"]: - """Lists all of the available CDN REST API operations. + def list(self, **kwargs: Any) -> ItemPaged["_models.ManagedRuleSetDefinition"]: + """Lists all available managed rule sets. - :return: An iterator like instance of either Operation or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cdn.models.Operation] + :return: An iterator like instance of ManagedRuleSetDefinition + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cdn.models.ManagedRuleSetDefinition] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + _params = kwargs.pop("params", {}) or {} - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.OperationsListResult] = kwargs.pop("cls", None) + cls: ClsType[List[_models.ManagedRuleSetDefinition]] = kwargs.pop("cls", None) - error_map: MutableMapping[int, Type[HttpResponseError]] = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -104,13 +21243,18 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: def prepare_request(next_link=None): if not next_link: - _request = build_list_request( - api_version=api_version, + _request = build_managed_rule_sets_list_request( + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, headers=_headers, params=_params, ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) else: # make call to next link with the client's api-version @@ -123,19 +21267,29 @@ def prepare_request(next_link=None): ) _next_request_params["api-version"] = self._config.api_version _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + return _request def extract_data(pipeline_response): - deserialized = self._deserialize("OperationsListResult", pipeline_response) - list_of_elem = deserialized.value + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ManagedRuleSetDefinition], + deserialized.get("value", []), + ) if cls: list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) + return deserialized.get("nextLink") or None, iter(list_of_elem) def get_next(next_link=None): _request = prepare_request(next_link) @@ -148,9 +21302,595 @@ def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) + + +class _CdnManagementClientOperationsMixin( + ClientMixinABC[PipelineClient[HttpRequest, HttpResponse], CdnManagementClientConfiguration] +): + + @overload + def check_endpoint_name_availability( + self, + resource_group_name: str, + check_endpoint_name_availability_input: _models.CheckEndpointNameAvailabilityInput, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CheckEndpointNameAvailabilityOutput: + """Check the availability of a resource name. This is needed for resources where name is globally + unique, such as a afdx endpoint. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param check_endpoint_name_availability_input: Input to check. Required. + :type check_endpoint_name_availability_input: + ~azure.mgmt.cdn.models.CheckEndpointNameAvailabilityInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: CheckEndpointNameAvailabilityOutput. The CheckEndpointNameAvailabilityOutput is + compatible with MutableMapping + :rtype: ~azure.mgmt.cdn.models.CheckEndpointNameAvailabilityOutput + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_endpoint_name_availability( + self, + resource_group_name: str, + check_endpoint_name_availability_input: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CheckEndpointNameAvailabilityOutput: + """Check the availability of a resource name. This is needed for resources where name is globally + unique, such as a afdx endpoint. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param check_endpoint_name_availability_input: Input to check. Required. + :type check_endpoint_name_availability_input: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: CheckEndpointNameAvailabilityOutput. The CheckEndpointNameAvailabilityOutput is + compatible with MutableMapping + :rtype: ~azure.mgmt.cdn.models.CheckEndpointNameAvailabilityOutput + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_endpoint_name_availability( + self, + resource_group_name: str, + check_endpoint_name_availability_input: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CheckEndpointNameAvailabilityOutput: + """Check the availability of a resource name. This is needed for resources where name is globally + unique, such as a afdx endpoint. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param check_endpoint_name_availability_input: Input to check. Required. + :type check_endpoint_name_availability_input: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: CheckEndpointNameAvailabilityOutput. The CheckEndpointNameAvailabilityOutput is + compatible with MutableMapping + :rtype: ~azure.mgmt.cdn.models.CheckEndpointNameAvailabilityOutput + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_endpoint_name_availability( + self, + resource_group_name: str, + check_endpoint_name_availability_input: Union[_models.CheckEndpointNameAvailabilityInput, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.CheckEndpointNameAvailabilityOutput: + """Check the availability of a resource name. This is needed for resources where name is globally + unique, such as a afdx endpoint. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param check_endpoint_name_availability_input: Input to check. Is one of the following types: + CheckEndpointNameAvailabilityInput, JSON, IO[bytes] Required. + :type check_endpoint_name_availability_input: + ~azure.mgmt.cdn.models.CheckEndpointNameAvailabilityInput or JSON or IO[bytes] + :return: CheckEndpointNameAvailabilityOutput. The CheckEndpointNameAvailabilityOutput is + compatible with MutableMapping + :rtype: ~azure.mgmt.cdn.models.CheckEndpointNameAvailabilityOutput + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CheckEndpointNameAvailabilityOutput] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(check_endpoint_name_availability_input, (IOBase, bytes)): + _content = check_endpoint_name_availability_input + else: + _content = json.dumps(check_endpoint_name_availability_input, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_cdn_management_check_endpoint_name_availability_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.CheckEndpointNameAvailabilityOutput, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def check_name_availability( + self, + check_name_availability_input: _models.CheckNameAvailabilityInput, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CheckNameAvailabilityOutput: + """Check the availability of a resource name. This is needed for resources where name is globally + unique, such as a CDN endpoint. + + :param check_name_availability_input: The request body. Required. + :type check_name_availability_input: ~azure.mgmt.cdn.models.CheckNameAvailabilityInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: CheckNameAvailabilityOutput. The CheckNameAvailabilityOutput is compatible with + MutableMapping + :rtype: ~azure.mgmt.cdn.models.CheckNameAvailabilityOutput + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, check_name_availability_input: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityOutput: + """Check the availability of a resource name. This is needed for resources where name is globally + unique, such as a CDN endpoint. + + :param check_name_availability_input: The request body. Required. + :type check_name_availability_input: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: CheckNameAvailabilityOutput. The CheckNameAvailabilityOutput is compatible with + MutableMapping + :rtype: ~azure.mgmt.cdn.models.CheckNameAvailabilityOutput + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, check_name_availability_input: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityOutput: + """Check the availability of a resource name. This is needed for resources where name is globally + unique, such as a CDN endpoint. + + :param check_name_availability_input: The request body. Required. + :type check_name_availability_input: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: CheckNameAvailabilityOutput. The CheckNameAvailabilityOutput is compatible with + MutableMapping + :rtype: ~azure.mgmt.cdn.models.CheckNameAvailabilityOutput + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_name_availability( + self, check_name_availability_input: Union[_models.CheckNameAvailabilityInput, JSON, IO[bytes]], **kwargs: Any + ) -> _models.CheckNameAvailabilityOutput: + """Check the availability of a resource name. This is needed for resources where name is globally + unique, such as a CDN endpoint. + + :param check_name_availability_input: The request body. Is one of the following types: + CheckNameAvailabilityInput, JSON, IO[bytes] Required. + :type check_name_availability_input: ~azure.mgmt.cdn.models.CheckNameAvailabilityInput or JSON + or IO[bytes] + :return: CheckNameAvailabilityOutput. The CheckNameAvailabilityOutput is compatible with + MutableMapping + :rtype: ~azure.mgmt.cdn.models.CheckNameAvailabilityOutput + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CheckNameAvailabilityOutput] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(check_name_availability_input, (IOBase, bytes)): + _content = check_name_availability_input + else: + _content = json.dumps(check_name_availability_input, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_cdn_management_check_name_availability_request( + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.CheckNameAvailabilityOutput, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def check_name_availability_with_subscription( # pylint: disable=name-too-long + self, + check_name_availability_input: _models.CheckNameAvailabilityInput, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CheckNameAvailabilityOutput: + """Check the availability of a resource name. This is needed for resources where name is globally + unique, such as a CDN endpoint. + + :param check_name_availability_input: The request body. Required. + :type check_name_availability_input: ~azure.mgmt.cdn.models.CheckNameAvailabilityInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: CheckNameAvailabilityOutput. The CheckNameAvailabilityOutput is compatible with + MutableMapping + :rtype: ~azure.mgmt.cdn.models.CheckNameAvailabilityOutput + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability_with_subscription( # pylint: disable=name-too-long + self, check_name_availability_input: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityOutput: + """Check the availability of a resource name. This is needed for resources where name is globally + unique, such as a CDN endpoint. + + :param check_name_availability_input: The request body. Required. + :type check_name_availability_input: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: CheckNameAvailabilityOutput. The CheckNameAvailabilityOutput is compatible with + MutableMapping + :rtype: ~azure.mgmt.cdn.models.CheckNameAvailabilityOutput + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability_with_subscription( # pylint: disable=name-too-long + self, check_name_availability_input: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityOutput: + """Check the availability of a resource name. This is needed for resources where name is globally + unique, such as a CDN endpoint. + + :param check_name_availability_input: The request body. Required. + :type check_name_availability_input: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: CheckNameAvailabilityOutput. The CheckNameAvailabilityOutput is compatible with + MutableMapping + :rtype: ~azure.mgmt.cdn.models.CheckNameAvailabilityOutput + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_name_availability_with_subscription( # pylint: disable=name-too-long + self, check_name_availability_input: Union[_models.CheckNameAvailabilityInput, JSON, IO[bytes]], **kwargs: Any + ) -> _models.CheckNameAvailabilityOutput: + """Check the availability of a resource name. This is needed for resources where name is globally + unique, such as a CDN endpoint. + + :param check_name_availability_input: The request body. Is one of the following types: + CheckNameAvailabilityInput, JSON, IO[bytes] Required. + :type check_name_availability_input: ~azure.mgmt.cdn.models.CheckNameAvailabilityInput or JSON + or IO[bytes] + :return: CheckNameAvailabilityOutput. The CheckNameAvailabilityOutput is compatible with + MutableMapping + :rtype: ~azure.mgmt.cdn.models.CheckNameAvailabilityOutput + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CheckNameAvailabilityOutput] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(check_name_availability_input, (IOBase, bytes)): + _content = check_name_availability_input + else: + _content = json.dumps(check_name_availability_input, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_cdn_management_check_name_availability_with_subscription_request( + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.CheckNameAvailabilityOutput, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def validate_probe( + self, validate_probe_input: _models.ValidateProbeInput, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ValidateProbeOutput: + """Check if the probe path is a valid path and the file can be accessed. Probe path is the path to + a file hosted on the origin server to help accelerate the delivery of dynamic content via the + CDN endpoint. This path is relative to the origin path specified in the endpoint configuration. + + :param validate_probe_input: The request body. Required. + :type validate_probe_input: ~azure.mgmt.cdn.models.ValidateProbeInput + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ValidateProbeOutput. The ValidateProbeOutput is compatible with MutableMapping + :rtype: ~azure.mgmt.cdn.models.ValidateProbeOutput + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def validate_probe( + self, validate_probe_input: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ValidateProbeOutput: + """Check if the probe path is a valid path and the file can be accessed. Probe path is the path to + a file hosted on the origin server to help accelerate the delivery of dynamic content via the + CDN endpoint. This path is relative to the origin path specified in the endpoint configuration. + + :param validate_probe_input: The request body. Required. + :type validate_probe_input: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ValidateProbeOutput. The ValidateProbeOutput is compatible with MutableMapping + :rtype: ~azure.mgmt.cdn.models.ValidateProbeOutput + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def validate_probe( + self, validate_probe_input: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ValidateProbeOutput: + """Check if the probe path is a valid path and the file can be accessed. Probe path is the path to + a file hosted on the origin server to help accelerate the delivery of dynamic content via the + CDN endpoint. This path is relative to the origin path specified in the endpoint configuration. + + :param validate_probe_input: The request body. Required. + :type validate_probe_input: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ValidateProbeOutput. The ValidateProbeOutput is compatible with MutableMapping + :rtype: ~azure.mgmt.cdn.models.ValidateProbeOutput + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def validate_probe( + self, validate_probe_input: Union[_models.ValidateProbeInput, JSON, IO[bytes]], **kwargs: Any + ) -> _models.ValidateProbeOutput: + """Check if the probe path is a valid path and the file can be accessed. Probe path is the path to + a file hosted on the origin server to help accelerate the delivery of dynamic content via the + CDN endpoint. This path is relative to the origin path specified in the endpoint configuration. + + :param validate_probe_input: The request body. Is one of the following types: + ValidateProbeInput, JSON, IO[bytes] Required. + :type validate_probe_input: ~azure.mgmt.cdn.models.ValidateProbeInput or JSON or IO[bytes] + :return: ValidateProbeOutput. The ValidateProbeOutput is compatible with MutableMapping + :rtype: ~azure.mgmt.cdn.models.ValidateProbeOutput + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ValidateProbeOutput] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(validate_probe_input, (IOBase, bytes)): + _content = validate_probe_input + else: + _content = json.dumps(validate_probe_input, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_cdn_management_validate_probe_request( + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ValidateProbeOutput, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore 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 deleted file mode 100644 index aeca4d14e338..000000000000 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_origin_groups_operations.py +++ /dev/null @@ -1,986 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models -from .._serialization import Serializer -from .._vendor import CdnManagementClientMixinABC, _convert_request - -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]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_endpoint_request( - resource_group_name: str, profile_name: str, endpoint_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) - 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\._\(\)]+$" - ), - "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), - "endpointName": _SERIALIZER.url("endpoint_name", endpoint_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, - profile_name: str, - endpoint_name: str, - origin_group_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) - 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\._\(\)]+$" - ), - "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), - "endpointName": _SERIALIZER.url("endpoint_name", endpoint_name, "str"), - "originGroupName": _SERIALIZER.url("origin_group_name", origin_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_request( - resource_group_name: str, - profile_name: str, - endpoint_name: str, - origin_group_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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\._\(\)]+$" - ), - "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), - "endpointName": _SERIALIZER.url("endpoint_name", endpoint_name, "str"), - "originGroupName": _SERIALIZER.url("origin_group_name", origin_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_update_request( - resource_group_name: str, - profile_name: str, - endpoint_name: str, - origin_group_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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\._\(\)]+$" - ), - "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), - "endpointName": _SERIALIZER.url("endpoint_name", endpoint_name, "str"), - "originGroupName": _SERIALIZER.url("origin_group_name", origin_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, - profile_name: str, - endpoint_name: str, - origin_group_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) - 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\._\(\)]+$" - ), - "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), - "endpointName": _SERIALIZER.url("endpoint_name", endpoint_name, "str"), - "originGroupName": _SERIALIZER.url("origin_group_name", origin_group_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -class OriginGroupsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.cdn.CdnManagementClient`'s - :attr:`origin_groups` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_endpoint( - self, resource_group_name: str, profile_name: str, endpoint_name: str, **kwargs: Any - ) -> Iterable["_models.OriginGroup"]: - """Lists all of the existing origin groups within an 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 CDN profile 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. - :type endpoint_name: str - :return: An iterator like instance of either OriginGroup or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cdn.models.OriginGroup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - 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]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_endpoint_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("OriginGroupListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get( - self, resource_group_name: str, profile_name: str, endpoint_name: str, origin_group_name: str, **kwargs: Any - ) -> _models.OriginGroup: - """Gets an existing origin group within an 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 CDN profile 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. - :type endpoint_name: str - :param origin_group_name: Name of the origin group which is unique within the endpoint. - Required. - :type origin_group_name: str - :return: OriginGroup or the result of cls(response) - :rtype: ~azure.mgmt.cdn.models.OriginGroup - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.OriginGroup] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - origin_group_name=origin_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("OriginGroup", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_initial( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - origin_group_name: str, - origin_group: Union[_models.OriginGroup, IO[bytes]], - **kwargs: Any - ) -> _models.OriginGroup: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_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.OriginGroup] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(origin_group, (IOBase, bytes)): - _content = origin_group - else: - _json = self._serialize.body(origin_group, "OriginGroup") - - _request = build_create_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - origin_group_name=origin_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - 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) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - origin_group_name: str, - origin_group: _models.OriginGroup, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.OriginGroup]: - """Creates a new origin group within the specified 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 CDN profile 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. - :type endpoint_name: str - :param origin_group_name: Name of the origin group which is unique within the endpoint. - Required. - :type origin_group_name: str - :param origin_group: Origin group properties. Required. - :type origin_group: ~azure.mgmt.cdn.models.OriginGroup - :keyword content_type: Body Parameter 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 OriginGroup or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.OriginGroup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - origin_group_name: str, - origin_group: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.OriginGroup]: - """Creates a new origin group within the specified 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 CDN profile 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. - :type endpoint_name: str - :param origin_group_name: Name of the origin group which is unique within the endpoint. - Required. - :type origin_group_name: str - :param origin_group: Origin group properties. Required. - :type origin_group: IO[bytes] - :keyword content_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 OriginGroup or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.OriginGroup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - origin_group_name: str, - origin_group: Union[_models.OriginGroup, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.OriginGroup]: - """Creates a new origin group within the specified 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 CDN profile 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. - :type endpoint_name: str - :param origin_group_name: Name of the origin group which is unique within the endpoint. - Required. - :type origin_group_name: str - :param origin_group: Origin group properties. Is either a OriginGroup type or a IO[bytes] type. - Required. - :type origin_group: ~azure.mgmt.cdn.models.OriginGroup or IO[bytes] - :return: An instance of LROPoller that returns either OriginGroup or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.OriginGroup] - :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.OriginGroup] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._create_initial( - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - origin_group_name=origin_group_name, - origin_group=origin_group, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("OriginGroup", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.OriginGroup].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.OriginGroup]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _update_initial( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - origin_group_name: str, - origin_group_update_properties: Union[_models.OriginGroupUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> _models.OriginGroup: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_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.OriginGroup] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(origin_group_update_properties, (IOBase, bytes)): - _content = origin_group_update_properties - else: - _json = self._serialize.body(origin_group_update_properties, "OriginGroupUpdateParameters") - - _request = build_update_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - origin_group_name=origin_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - 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) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_update( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - origin_group_name: str, - origin_group_update_properties: _models.OriginGroupUpdateParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.OriginGroup]: - """Updates an existing origin group within an 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 CDN profile 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. - :type endpoint_name: str - :param origin_group_name: Name of the origin group which is unique within the endpoint. - Required. - :type origin_group_name: str - :param origin_group_update_properties: Origin group properties. Required. - :type origin_group_update_properties: ~azure.mgmt.cdn.models.OriginGroupUpdateParameters - :keyword content_type: Body Parameter 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 OriginGroup or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.OriginGroup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - origin_group_name: str, - origin_group_update_properties: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.OriginGroup]: - """Updates an existing origin group within an 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 CDN profile 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. - :type endpoint_name: str - :param origin_group_name: Name of the origin group which is unique within the endpoint. - Required. - :type origin_group_name: str - :param origin_group_update_properties: Origin group properties. Required. - :type origin_group_update_properties: IO[bytes] - :keyword content_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 OriginGroup or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.OriginGroup] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - origin_group_name: str, - origin_group_update_properties: Union[_models.OriginGroupUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.OriginGroup]: - """Updates an existing origin group within an 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 CDN profile 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. - :type endpoint_name: str - :param origin_group_name: Name of the origin group which is unique within the endpoint. - Required. - :type origin_group_name: str - :param origin_group_update_properties: Origin group properties. Is either a - OriginGroupUpdateParameters type or a IO[bytes] type. Required. - :type origin_group_update_properties: ~azure.mgmt.cdn.models.OriginGroupUpdateParameters or - IO[bytes] - :return: An instance of LROPoller that returns either OriginGroup or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.OriginGroup] - :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.OriginGroup] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._update_initial( - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - origin_group_name=origin_group_name, - origin_group_update_properties=origin_group_update_properties, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("OriginGroup", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.OriginGroup].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.OriginGroup]( - 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, endpoint_name: str, origin_group_name: str, **kwargs: Any - ) -> None: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - origin_group_name=origin_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["location"] = self._deserialize("str", response.headers.get("location")) - - if cls: - return cls(pipeline_response, None, response_headers) # type: ignore - - @distributed_trace - def begin_delete( - self, resource_group_name: str, profile_name: str, endpoint_name: str, origin_group_name: str, **kwargs: Any - ) -> LROPoller[None]: - """Deletes an existing origin group within an 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 CDN profile 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. - :type endpoint_name: str - :param origin_group_name: Name of the origin group which is unique within the endpoint. - Required. - :type origin_group_name: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_initial( # type: ignore - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - origin_group_name=origin_group_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_origins_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_origins_operations.py deleted file mode 100644 index 3f181ef33b4b..000000000000 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_origins_operations.py +++ /dev/null @@ -1,970 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models -from .._serialization import Serializer -from .._vendor import CdnManagementClientMixinABC, _convert_request - -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]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_endpoint_request( - resource_group_name: str, profile_name: str, endpoint_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) - 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\._\(\)]+$" - ), - "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), - "endpointName": _SERIALIZER.url("endpoint_name", endpoint_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, - profile_name: str, - endpoint_name: str, - origin_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_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")) - 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\._\(\)]+$" - ), - "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), - "endpointName": _SERIALIZER.url("endpoint_name", endpoint_name, "str"), - "originName": _SERIALIZER.url("origin_name", origin_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_request( - resource_group_name: str, - profile_name: str, - endpoint_name: str, - origin_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_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")) - 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}/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\._\(\)]+$" - ), - "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), - "endpointName": _SERIALIZER.url("endpoint_name", endpoint_name, "str"), - "originName": _SERIALIZER.url("origin_name", origin_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_update_request( - resource_group_name: str, - profile_name: str, - endpoint_name: str, - origin_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_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")) - 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}/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\._\(\)]+$" - ), - "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), - "endpointName": _SERIALIZER.url("endpoint_name", endpoint_name, "str"), - "originName": _SERIALIZER.url("origin_name", origin_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, - profile_name: str, - endpoint_name: str, - origin_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_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")) - 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\._\(\)]+$" - ), - "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), - "endpointName": _SERIALIZER.url("endpoint_name", endpoint_name, "str"), - "originName": _SERIALIZER.url("origin_name", origin_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -class OriginsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.cdn.CdnManagementClient`'s - :attr:`origins` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_endpoint( - self, resource_group_name: str, profile_name: str, endpoint_name: str, **kwargs: Any - ) -> Iterable["_models.Origin"]: - """Lists all of the existing origins within an 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 CDN profile 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. - :type endpoint_name: str - :return: An iterator like instance of either Origin or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cdn.models.Origin] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - 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]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_endpoint_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("OriginListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get( - self, resource_group_name: str, profile_name: str, endpoint_name: str, origin_name: str, **kwargs: Any - ) -> _models.Origin: - """Gets an existing origin within an 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 CDN profile 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. - :type endpoint_name: str - :param origin_name: Name of the origin which is unique within the endpoint. Required. - :type origin_name: str - :return: Origin or the result of cls(response) - :rtype: ~azure.mgmt.cdn.models.Origin - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.Origin] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - origin_name=origin_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Origin", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_initial( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - origin_name: str, - origin: Union[_models.Origin, IO[bytes]], - **kwargs: Any - ) -> _models.Origin: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_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.Origin] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(origin, (IOBase, bytes)): - _content = origin - else: - _json = self._serialize.body(origin, "Origin") - - _request = build_create_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - origin_name=origin_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - 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) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - origin_name: str, - origin: _models.Origin, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Origin]: - """Creates a new origin within the specified 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 CDN profile 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. - :type endpoint_name: str - :param origin_name: Name of the origin that is unique within the endpoint. Required. - :type origin_name: str - :param origin: Origin properties. Required. - :type origin: ~azure.mgmt.cdn.models.Origin - :keyword content_type: Body Parameter 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 Origin or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Origin] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - origin_name: str, - origin: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Origin]: - """Creates a new origin within the specified 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 CDN profile 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. - :type endpoint_name: str - :param origin_name: Name of the origin that is unique within the endpoint. Required. - :type origin_name: str - :param origin: Origin properties. Required. - :type origin: IO[bytes] - :keyword content_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 Origin or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Origin] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - origin_name: str, - origin: Union[_models.Origin, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.Origin]: - """Creates a new origin within the specified 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 CDN profile 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. - :type endpoint_name: str - :param origin_name: Name of the origin that is unique within the endpoint. Required. - :type origin_name: str - :param origin: Origin properties. Is either a Origin type or a IO[bytes] type. Required. - :type origin: ~azure.mgmt.cdn.models.Origin or IO[bytes] - :return: An instance of LROPoller that returns either Origin or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Origin] - :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.Origin] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._create_initial( - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - origin_name=origin_name, - origin=origin, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Origin", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.Origin].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Origin]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _update_initial( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - origin_name: str, - origin_update_properties: Union[_models.OriginUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> _models.Origin: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_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.Origin] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(origin_update_properties, (IOBase, bytes)): - _content = origin_update_properties - else: - _json = self._serialize.body(origin_update_properties, "OriginUpdateParameters") - - _request = build_update_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - origin_name=origin_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - 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) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_update( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - origin_name: str, - origin_update_properties: _models.OriginUpdateParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Origin]: - """Updates an existing origin within an 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 CDN profile 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. - :type endpoint_name: str - :param origin_name: Name of the origin which is unique within the endpoint. Required. - :type origin_name: str - :param origin_update_properties: Origin properties. Required. - :type origin_update_properties: ~azure.mgmt.cdn.models.OriginUpdateParameters - :keyword content_type: Body Parameter 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 Origin or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Origin] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - origin_name: str, - origin_update_properties: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Origin]: - """Updates an existing origin within an 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 CDN profile 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. - :type endpoint_name: str - :param origin_name: Name of the origin which is unique within the endpoint. Required. - :type origin_name: str - :param origin_update_properties: Origin properties. Required. - :type origin_update_properties: IO[bytes] - :keyword content_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 Origin or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Origin] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - origin_name: str, - origin_update_properties: Union[_models.OriginUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.Origin]: - """Updates an existing origin within an 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 CDN profile 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. - :type endpoint_name: str - :param origin_name: Name of the origin which is unique within the endpoint. Required. - :type origin_name: str - :param origin_update_properties: Origin properties. Is either a OriginUpdateParameters type or - a IO[bytes] type. Required. - :type origin_update_properties: ~azure.mgmt.cdn.models.OriginUpdateParameters or IO[bytes] - :return: An instance of LROPoller that returns either Origin or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Origin] - :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.Origin] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._update_initial( - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - origin_name=origin_name, - origin_update_properties=origin_update_properties, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Origin", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.Origin].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Origin]( - 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, endpoint_name: str, origin_name: str, **kwargs: Any - ) -> None: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - origin_name=origin_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["location"] = self._deserialize("str", response.headers.get("location")) - - if cls: - return cls(pipeline_response, None, response_headers) # type: ignore - - @distributed_trace - def begin_delete( - self, resource_group_name: str, profile_name: str, endpoint_name: str, origin_name: str, **kwargs: Any - ) -> LROPoller[None]: - """Deletes an existing origin within an 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 CDN profile 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. - :type endpoint_name: str - :param origin_name: Name of the origin which is unique within the endpoint. Required. - :type origin_name: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_initial( # type: ignore - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - origin_name=origin_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_patch.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_patch.py index f7dd32510333..ea765788358a 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_patch.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_patch.py @@ -1,14 +1,14 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------- """Customize generated code here. Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize """ -from typing import List -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level +__all__: list[str] = [] # Add all objects you want publicly available to users at this package level def patch_sdk(): diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_policies_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_policies_operations.py deleted file mode 100644 index a0594244f2de..000000000000 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_policies_operations.py +++ /dev/null @@ -1,849 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models -from .._serialization import Serializer -from .._vendor import CdnManagementClientMixinABC, _convert_request - -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]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) - 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", - resource_group_name, - "str", - max_length=80, - min_length=1, - pattern=r"^[a-zA-Z0-9_\-\(\)\.]*[^\.]$", - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request(resource_group_name: str, policy_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_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")) - 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", - resource_group_name, - "str", - max_length=80, - min_length=1, - pattern=r"^[a-zA-Z0-9_\-\(\)\.]*[^\.]$", - ), - "policyName": _SERIALIZER.url("policy_name", policy_name, "str", max_length=128), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, policy_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_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")) - 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/cdnWebApplicationFirewallPolicies/{policyName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", - resource_group_name, - "str", - max_length=80, - min_length=1, - pattern=r"^[a-zA-Z0-9_\-\(\)\.]*[^\.]$", - ), - "policyName": _SERIALIZER.url("policy_name", policy_name, "str", max_length=128), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_update_request( - resource_group_name: str, policy_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_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")) - 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/cdnWebApplicationFirewallPolicies/{policyName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url( - "resource_group_name", - resource_group_name, - "str", - max_length=80, - min_length=1, - pattern=r"^[a-zA-Z0-9_\-\(\)\.]*[^\.]$", - ), - "policyName": _SERIALIZER.url("policy_name", policy_name, "str", max_length=128), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, policy_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_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")) - 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", - resource_group_name, - "str", - max_length=80, - min_length=1, - pattern=r"^[a-zA-Z0-9_\-\(\)\.]*[^\.]$", - ), - "policyName": _SERIALIZER.url("policy_name", policy_name, "str", max_length=128), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -class PoliciesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.cdn.CdnManagementClient`'s - :attr:`policies` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.CdnWebApplicationFirewallPolicy"]: - """Lists all of the protection policies within a resource group. - - :param resource_group_name: Name of the Resource group within the Azure subscription. Required. - :type resource_group_name: str - :return: An iterator like instance of either CdnWebApplicationFirewallPolicy or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cdn.models.CdnWebApplicationFirewallPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - 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]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("CdnWebApplicationFirewallPolicyList", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get(self, resource_group_name: str, policy_name: str, **kwargs: Any) -> _models.CdnWebApplicationFirewallPolicy: - """Retrieve protection policy with specified name within a resource group. - - :param resource_group_name: Name of the Resource group within the Azure subscription. Required. - :type resource_group_name: str - :param policy_name: The name of the CdnWebApplicationFirewallPolicy. Required. - :type policy_name: str - :return: CdnWebApplicationFirewallPolicy or the result of cls(response) - :rtype: ~azure.mgmt.cdn.models.CdnWebApplicationFirewallPolicy - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.CdnWebApplicationFirewallPolicy] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - policy_name=policy_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("CdnWebApplicationFirewallPolicy", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_or_update_initial( - self, - resource_group_name: str, - policy_name: str, - cdn_web_application_firewall_policy: Union[_models.CdnWebApplicationFirewallPolicy, IO[bytes]], - **kwargs: Any - ) -> _models.CdnWebApplicationFirewallPolicy: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_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.CdnWebApplicationFirewallPolicy] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(cdn_web_application_firewall_policy, (IOBase, bytes)): - _content = cdn_web_application_firewall_policy - else: - _json = self._serialize.body(cdn_web_application_firewall_policy, "CdnWebApplicationFirewallPolicy") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - policy_name=policy_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - 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) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - policy_name: str, - cdn_web_application_firewall_policy: _models.CdnWebApplicationFirewallPolicy, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.CdnWebApplicationFirewallPolicy]: - """Create or update policy with specified rule set name within a resource group. - - :param resource_group_name: Name of the Resource group within the Azure subscription. Required. - :type resource_group_name: str - :param policy_name: The name of the CdnWebApplicationFirewallPolicy. Required. - :type policy_name: str - :param cdn_web_application_firewall_policy: Policy to be created. Required. - :type cdn_web_application_firewall_policy: - ~azure.mgmt.cdn.models.CdnWebApplicationFirewallPolicy - :keyword content_type: Body Parameter 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 CdnWebApplicationFirewallPolicy or the - result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.CdnWebApplicationFirewallPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - policy_name: str, - cdn_web_application_firewall_policy: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.CdnWebApplicationFirewallPolicy]: - """Create or update policy with specified rule set name within a resource group. - - :param resource_group_name: Name of the Resource group within the Azure subscription. Required. - :type resource_group_name: str - :param policy_name: The name of the CdnWebApplicationFirewallPolicy. Required. - :type policy_name: str - :param cdn_web_application_firewall_policy: Policy to be created. Required. - :type cdn_web_application_firewall_policy: IO[bytes] - :keyword content_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 CdnWebApplicationFirewallPolicy or the - result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.CdnWebApplicationFirewallPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - policy_name: str, - cdn_web_application_firewall_policy: Union[_models.CdnWebApplicationFirewallPolicy, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.CdnWebApplicationFirewallPolicy]: - """Create or update policy with specified rule set name within a resource group. - - :param resource_group_name: Name of the Resource group within the Azure subscription. Required. - :type resource_group_name: str - :param policy_name: The name of the CdnWebApplicationFirewallPolicy. Required. - :type policy_name: str - :param cdn_web_application_firewall_policy: Policy to be created. Is either a - CdnWebApplicationFirewallPolicy type or a IO[bytes] type. Required. - :type cdn_web_application_firewall_policy: - ~azure.mgmt.cdn.models.CdnWebApplicationFirewallPolicy or IO[bytes] - :return: An instance of LROPoller that returns either CdnWebApplicationFirewallPolicy or the - result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.CdnWebApplicationFirewallPolicy] - :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.CdnWebApplicationFirewallPolicy] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._create_or_update_initial( - resource_group_name=resource_group_name, - policy_name=policy_name, - cdn_web_application_firewall_policy=cdn_web_application_firewall_policy, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("CdnWebApplicationFirewallPolicy", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.CdnWebApplicationFirewallPolicy].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.CdnWebApplicationFirewallPolicy]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _update_initial( - self, - resource_group_name: str, - policy_name: str, - cdn_web_application_firewall_policy_patch_parameters: Union[ - _models.CdnWebApplicationFirewallPolicyPatchParameters, IO[bytes] - ], - **kwargs: Any - ) -> _models.CdnWebApplicationFirewallPolicy: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_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.CdnWebApplicationFirewallPolicy] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(cdn_web_application_firewall_policy_patch_parameters, (IOBase, bytes)): - _content = cdn_web_application_firewall_policy_patch_parameters - else: - _json = self._serialize.body( - cdn_web_application_firewall_policy_patch_parameters, "CdnWebApplicationFirewallPolicyPatchParameters" - ) - - _request = build_update_request( - resource_group_name=resource_group_name, - policy_name=policy_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - 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) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_update( - self, - resource_group_name: str, - policy_name: str, - cdn_web_application_firewall_policy_patch_parameters: _models.CdnWebApplicationFirewallPolicyPatchParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.CdnWebApplicationFirewallPolicy]: - """Update an existing CdnWebApplicationFirewallPolicy with the specified policy name under the - specified subscription and resource group. - - :param resource_group_name: Name of the Resource group within the Azure subscription. Required. - :type resource_group_name: str - :param policy_name: The name of the CdnWebApplicationFirewallPolicy. Required. - :type policy_name: str - :param cdn_web_application_firewall_policy_patch_parameters: CdnWebApplicationFirewallPolicy - parameters to be patched. Required. - :type cdn_web_application_firewall_policy_patch_parameters: - ~azure.mgmt.cdn.models.CdnWebApplicationFirewallPolicyPatchParameters - :keyword content_type: Body Parameter 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 CdnWebApplicationFirewallPolicy or the - result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.CdnWebApplicationFirewallPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - policy_name: str, - cdn_web_application_firewall_policy_patch_parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.CdnWebApplicationFirewallPolicy]: - """Update an existing CdnWebApplicationFirewallPolicy with the specified policy name under the - specified subscription and resource group. - - :param resource_group_name: Name of the Resource group within the Azure subscription. Required. - :type resource_group_name: str - :param policy_name: The name of the CdnWebApplicationFirewallPolicy. Required. - :type policy_name: str - :param cdn_web_application_firewall_policy_patch_parameters: CdnWebApplicationFirewallPolicy - parameters to be patched. Required. - :type cdn_web_application_firewall_policy_patch_parameters: IO[bytes] - :keyword content_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 CdnWebApplicationFirewallPolicy or the - result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.CdnWebApplicationFirewallPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update( - self, - resource_group_name: str, - policy_name: str, - cdn_web_application_firewall_policy_patch_parameters: Union[ - _models.CdnWebApplicationFirewallPolicyPatchParameters, IO[bytes] - ], - **kwargs: Any - ) -> LROPoller[_models.CdnWebApplicationFirewallPolicy]: - """Update an existing CdnWebApplicationFirewallPolicy with the specified policy name under the - specified subscription and resource group. - - :param resource_group_name: Name of the Resource group within the Azure subscription. Required. - :type resource_group_name: str - :param policy_name: The name of the CdnWebApplicationFirewallPolicy. Required. - :type policy_name: str - :param cdn_web_application_firewall_policy_patch_parameters: CdnWebApplicationFirewallPolicy - parameters to be patched. Is either a CdnWebApplicationFirewallPolicyPatchParameters type or a - IO[bytes] type. Required. - :type cdn_web_application_firewall_policy_patch_parameters: - ~azure.mgmt.cdn.models.CdnWebApplicationFirewallPolicyPatchParameters or IO[bytes] - :return: An instance of LROPoller that returns either CdnWebApplicationFirewallPolicy or the - result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.CdnWebApplicationFirewallPolicy] - :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.CdnWebApplicationFirewallPolicy] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._update_initial( - resource_group_name=resource_group_name, - policy_name=policy_name, - cdn_web_application_firewall_policy_patch_parameters=cdn_web_application_firewall_policy_patch_parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("CdnWebApplicationFirewallPolicy", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.CdnWebApplicationFirewallPolicy].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.CdnWebApplicationFirewallPolicy]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - 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. - :type resource_group_name: str - :param policy_name: The name of the CdnWebApplicationFirewallPolicy. Required. - :type policy_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - policy_name=policy_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_profiles_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_profiles_operations.py deleted file mode 100644 index 6a16d3bf4d1d..000000000000 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_profiles_operations.py +++ /dev/null @@ -1,1834 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models -from .._serialization import Serializer -from .._vendor import CdnManagementClientMixinABC, _convert_request - -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]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Cdn/profiles") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) - 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\._\(\)]+$" - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request(resource_group_name: str, 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", "2024-02-01")) - 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\._\(\)]+$" - ), - "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_request( - resource_group_name: str, 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", "2024-02-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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\._\(\)]+$" - ), - "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_update_request( - resource_group_name: str, 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", "2024-02-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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\._\(\)]+$" - ), - "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_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", "2024-02-01")) - 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\._\(\)]+$" - ), - "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_can_migrate_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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\._\(\)]+$" - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_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_migrate_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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\._\(\)]+$" - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_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_commit_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", "2024-02-01")) - 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\._\(\)]+$" - ), - "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # 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_generate_sso_uri_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", "2024-02-01")) - 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\._\(\)]+$" - ), - "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_supported_optimization_types_request( # pylint: disable=name-too-long - 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", "2024-02-01")) - 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\._\(\)]+$" - ), - "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_resource_usage_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", "2024-02-01")) - 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\._\(\)]+$" - ), - "profileName": _SERIALIZER.url("profile_name", profile_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # 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: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.cdn.CdnManagementClient`'s - :attr:`profiles` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list(self, **kwargs: Any) -> Iterable["_models.Profile"]: - """Lists all of the Azure Front Door Standard, Azure Front Door Premium, and CDN profiles within - an Azure subscription. - - :return: An iterator like instance of either Profile or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cdn.models.Profile] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - 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]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ProfileListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.Profile"]: - """Lists all of the Azure Front Door Standard, Azure Front Door Premium, and CDN profiles within a - resource group. - - :param resource_group_name: Name of the Resource group within the Azure subscription. Required. - :type resource_group_name: str - :return: An iterator like instance of either Profile or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cdn.models.Profile] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - 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]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ProfileListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get(self, resource_group_name: str, profile_name: str, **kwargs: Any) -> _models.Profile: - """Gets an Azure Front Door Standard or Azure Front Door Premium or CDN profile with the specified - profile name under the specified subscription and resource 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 or CDN - profile which is unique within the resource group. Required. - :type profile_name: str - :return: Profile or the result of cls(response) - :rtype: ~azure.mgmt.cdn.models.Profile - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.Profile] = kwargs.pop("cls", None) - - _request = build_get_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 = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Profile", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - 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]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_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.Profile] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(profile, (IOBase, bytes)): - _content = profile - else: - _json = self._serialize.body(profile, "Profile") - - _request = build_create_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 = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - 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) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create( - self, - resource_group_name: str, - profile_name: str, - profile: _models.Profile, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Profile]: - """Creates a new Azure Front Door Standard or Azure Front Door Premium or CDN profile with a - profile name under the specified subscription and resource 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 or CDN - profile which is unique within the resource group. Required. - :type profile_name: str - :param profile: Profile properties needed to create a new profile. Required. - :type profile: ~azure.mgmt.cdn.models.Profile - :keyword content_type: Body Parameter 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 Profile or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Profile] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create( - self, - resource_group_name: str, - profile_name: str, - profile: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Profile]: - """Creates a new Azure Front Door Standard or Azure Front Door Premium or CDN profile with a - profile name under the specified subscription and resource 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 or CDN - profile which is unique within the resource group. Required. - :type profile_name: str - :param profile: Profile properties needed to create a new profile. Required. - :type profile: IO[bytes] - :keyword content_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 Profile or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Profile] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create( - self, resource_group_name: str, profile_name: str, profile: Union[_models.Profile, IO[bytes]], **kwargs: Any - ) -> LROPoller[_models.Profile]: - """Creates a new Azure Front Door Standard or Azure Front Door Premium or CDN profile with a - profile name under the specified subscription and resource 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 or CDN - profile which is unique within the resource group. Required. - :type profile_name: str - :param profile: Profile properties needed to create a new profile. Is either a Profile type or - a IO[bytes] type. Required. - :type profile: ~azure.mgmt.cdn.models.Profile or IO[bytes] - :return: An instance of LROPoller that returns either Profile or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Profile] - :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.Profile] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._create_initial( - resource_group_name=resource_group_name, - profile_name=profile_name, - profile=profile, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Profile", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.Profile].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Profile]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _update_initial( - self, - resource_group_name: str, - profile_name: str, - profile_update_parameters: Union[_models.ProfileUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> _models.Profile: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_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.Profile] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(profile_update_parameters, (IOBase, bytes)): - _content = profile_update_parameters - else: - _json = self._serialize.body(profile_update_parameters, "ProfileUpdateParameters") - - _request = build_update_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 = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - 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) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_update( - self, - resource_group_name: str, - profile_name: str, - profile_update_parameters: _models.ProfileUpdateParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Profile]: - """Updates an existing Azure Front Door Standard or Azure Front Door Premium or CDN profile with - the specified profile name under the specified subscription and resource 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 or CDN - profile which is unique within the resource group. Required. - :type profile_name: str - :param profile_update_parameters: Profile properties needed to update an existing profile. - Required. - :type profile_update_parameters: ~azure.mgmt.cdn.models.ProfileUpdateParameters - :keyword content_type: Body Parameter 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 Profile or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Profile] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - profile_name: str, - profile_update_parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Profile]: - """Updates an existing Azure Front Door Standard or Azure Front Door Premium or CDN profile with - the specified profile name under the specified subscription and resource 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 or CDN - profile which is unique within the resource group. Required. - :type profile_name: str - :param profile_update_parameters: Profile properties needed to update an existing profile. - Required. - :type profile_update_parameters: IO[bytes] - :keyword content_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 Profile or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Profile] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update( - self, - resource_group_name: str, - profile_name: str, - profile_update_parameters: Union[_models.ProfileUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.Profile]: - """Updates an existing Azure Front Door Standard or Azure Front Door Premium or CDN profile with - the specified profile name under the specified subscription and resource 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 or CDN - profile which is unique within the resource group. Required. - :type profile_name: str - :param profile_update_parameters: Profile properties needed to update an existing profile. Is - either a ProfileUpdateParameters type or a IO[bytes] type. Required. - :type profile_update_parameters: ~azure.mgmt.cdn.models.ProfileUpdateParameters or IO[bytes] - :return: An instance of LROPoller that returns either Profile or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Profile] - :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.Profile] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._update_initial( - resource_group_name=resource_group_name, - profile_name=profile_name, - profile_update_parameters=profile_update_parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Profile", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.Profile].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Profile]( - 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]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["location"] = self._deserialize("str", response.headers.get("location")) - - if cls: - return cls(pipeline_response, None, response_headers) # type: ignore - - @distributed_trace - def begin_delete(self, resource_group_name: str, profile_name: str, **kwargs: Any) -> LROPoller[None]: - """Deletes an existing Azure Front Door Standard or Azure Front Door Premium or CDN profile with - the specified parameters. Deleting a profile will result in the deletion of all of the - sub-resources including endpoints, origins and custom domains. - - :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 or CDN - profile 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._delete_initial( # type: ignore - 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 - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _can_migrate_initial( - self, - resource_group_name: str, - can_migrate_parameters: Union[_models.CanMigrateParameters, IO[bytes]], - **kwargs: Any - ) -> Optional[_models.CanMigrateResult]: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.CanMigrateResult]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(can_migrate_parameters, (IOBase, bytes)): - _content = can_migrate_parameters - else: - _json = self._serialize.body(can_migrate_parameters, "CanMigrateParameters") - - _request = build_can_migrate_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = None - response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("CanMigrateResult", pipeline_response) - - if response.status_code == 202: - response_headers["location"] = self._deserialize("str", response.headers.get("location")) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_can_migrate( - self, - resource_group_name: str, - can_migrate_parameters: _models.CanMigrateParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.CanMigrateResult]: - """Checks if CDN profile can be migrated to Azure Frontdoor(Standard/Premium) profile. - - :param resource_group_name: Name of the Resource group within the Azure subscription. Required. - :type resource_group_name: str - :param can_migrate_parameters: Properties needed to check if cdn profile or classic frontdoor - can be migrated. Required. - :type can_migrate_parameters: ~azure.mgmt.cdn.models.CanMigrateParameters - :keyword content_type: Body Parameter 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 CanMigrateResult or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.CanMigrateResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_can_migrate( - self, - resource_group_name: str, - can_migrate_parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.CanMigrateResult]: - """Checks if CDN profile can be migrated to Azure Frontdoor(Standard/Premium) profile. - - :param resource_group_name: Name of the Resource group within the Azure subscription. Required. - :type resource_group_name: str - :param can_migrate_parameters: Properties needed to check if cdn profile or classic frontdoor - can be migrated. Required. - :type can_migrate_parameters: IO[bytes] - :keyword content_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 CanMigrateResult or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.CanMigrateResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_can_migrate( - self, - resource_group_name: str, - can_migrate_parameters: Union[_models.CanMigrateParameters, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.CanMigrateResult]: - """Checks if CDN profile can be migrated to Azure Frontdoor(Standard/Premium) profile. - - :param resource_group_name: Name of the Resource group within the Azure subscription. Required. - :type resource_group_name: str - :param can_migrate_parameters: Properties needed to check if cdn profile or classic frontdoor - can be migrated. Is either a CanMigrateParameters type or a IO[bytes] type. Required. - :type can_migrate_parameters: ~azure.mgmt.cdn.models.CanMigrateParameters or IO[bytes] - :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 = case_insensitive_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.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._can_migrate_initial( - resource_group_name=resource_group_name, - can_migrate_parameters=can_migrate_parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("CanMigrateResult", pipeline_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 _migrate_initial( - self, - resource_group_name: str, - migration_parameters: Union[_models.MigrationParameters, IO[bytes]], - **kwargs: Any - ) -> _models.MigrateResult: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_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) - - 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, "MigrationParameters") - - _request = build_migrate_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - 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) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_migrate( - self, - resource_group_name: str, - migration_parameters: _models.MigrationParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.MigrateResult]: - """Migrate the CDN profile to Azure Frontdoor(Standard/Premium) profile. The change need to be - committed after this. - - :param resource_group_name: Name of the Resource group within the Azure subscription. Required. - :type resource_group_name: str - :param migration_parameters: Properties needed to migrate the profile. Required. - :type migration_parameters: ~azure.mgmt.cdn.models.MigrationParameters - :keyword content_type: Body Parameter 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_migrate( - self, - resource_group_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. The change need to be - committed after this. - - :param resource_group_name: Name of the Resource group within the Azure subscription. Required. - :type resource_group_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_migrate( - self, - resource_group_name: str, - migration_parameters: Union[_models.MigrationParameters, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.MigrateResult]: - """Migrate the CDN profile to Azure Frontdoor(Standard/Premium) profile. The change need to be - committed after this. - - :param resource_group_name: Name of the Resource group within the Azure subscription. Required. - :type resource_group_name: str - :param migration_parameters: Properties needed to migrate the profile. Is either a - MigrationParameters type or a IO[bytes] type. Required. - :type migration_parameters: ~azure.mgmt.cdn.models.MigrationParameters 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._migrate_initial( - resource_group_name=resource_group_name, - migration_parameters=migration_parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("MigrateResult", pipeline_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_commit_initial( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, profile_name: str, **kwargs: Any - ) -> None: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_migration_commit_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 = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - response_headers = {} - if response.status_code == 202: - response_headers["location"] = self._deserialize("str", response.headers.get("location")) - - if cls: - return cls(pipeline_response, None, response_headers) # type: ignore - - @distributed_trace - def begin_migration_commit(self, resource_group_name: str, profile_name: str, **kwargs: Any) -> LROPoller[None]: - """Commit the migrated Azure Frontdoor(Standard/Premium) 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 CDN profile 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_commit_initial( # type: ignore - 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 - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def generate_sso_uri(self, resource_group_name: str, profile_name: str, **kwargs: Any) -> _models.SsoUri: - """Generates a dynamic SSO URI used to sign in to the CDN supplemental portal. Supplemental portal - is used to configure advanced feature capabilities that are not yet available in the Azure - portal, such as core reports in a standard profile; rules engine, advanced HTTP reports, and - real-time stats and alerts in a premium profile. The SSO URI changes approximately every 10 - minutes. - - :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 CDN profile which is unique within the resource group. - Required. - :type profile_name: str - :return: SsoUri or the result of cls(response) - :rtype: ~azure.mgmt.cdn.models.SsoUri - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.SsoUri] = kwargs.pop("cls", None) - - _request = build_generate_sso_uri_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 = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SsoUri", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_supported_optimization_types( - self, resource_group_name: str, profile_name: str, **kwargs: Any - ) -> _models.SupportedOptimizationTypesListResult: - """Gets the supported optimization types for the current profile. A user can create an endpoint - with an optimization type from the listed values. - - :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 or CDN - profile which is unique within the resource group. Required. - :type profile_name: str - :return: SupportedOptimizationTypesListResult or the result of cls(response) - :rtype: ~azure.mgmt.cdn.models.SupportedOptimizationTypesListResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.SupportedOptimizationTypesListResult] = kwargs.pop("cls", None) - - _request = build_list_supported_optimization_types_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 = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SupportedOptimizationTypesListResult", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_resource_usage( - self, resource_group_name: str, profile_name: str, **kwargs: Any - ) -> Iterable["_models.ResourceUsage"]: - """Checks the quota and actual usage of endpoints under the given Azure Front Door Standard or - Azure Front Door Premium or CDN 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 or CDN - profile which is unique within the resource group. Required. - :type profile_name: str - :return: An iterator like instance of either ResourceUsage or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cdn.models.ResourceUsage] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - 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]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_resource_usage_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 = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ResourceUsageListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) diff --git a/sdk/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 deleted file mode 100644 index cadf0a85721a..000000000000 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_resource_usage_operations.py +++ /dev/null @@ -1,162 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from .._serialization import Serializer -from .._vendor import CdnManagementClientMixinABC, _convert_request - -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]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Cdn/checkResourceUsage") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -class ResourceUsageOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.cdn.CdnManagementClient`'s - :attr:`resource_usage` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list(self, **kwargs: Any) -> Iterable["_models.ResourceUsage"]: - """Check the quota and actual usage of the CDN profiles under the given subscription. - - :return: An iterator like instance of either ResourceUsage or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cdn.models.ResourceUsage] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - 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]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ResourceUsageListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_routes_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_routes_operations.py deleted file mode 100644 index 0b9de673cfe5..000000000000 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_routes_operations.py +++ /dev/null @@ -1,984 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models -from .._serialization import Serializer -from .._vendor import CdnManagementClientMixinABC, _convert_request - -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]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_endpoint_request( - resource_group_name: str, profile_name: str, endpoint_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) - 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"), - "endpointName": _SERIALIZER.url("endpoint_name", endpoint_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, - profile_name: str, - endpoint_name: str, - route_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_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")) - 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"), - "endpointName": _SERIALIZER.url("endpoint_name", endpoint_name, "str"), - "routeName": _SERIALIZER.url("route_name", route_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_request( - resource_group_name: str, - profile_name: str, - endpoint_name: str, - route_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_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")) - 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}/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"), - "endpointName": _SERIALIZER.url("endpoint_name", endpoint_name, "str"), - "routeName": _SERIALIZER.url("route_name", route_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_update_request( - resource_group_name: str, - profile_name: str, - endpoint_name: str, - route_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_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")) - 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}/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"), - "endpointName": _SERIALIZER.url("endpoint_name", endpoint_name, "str"), - "routeName": _SERIALIZER.url("route_name", route_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, - profile_name: str, - endpoint_name: str, - route_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_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")) - 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"), - "endpointName": _SERIALIZER.url("endpoint_name", endpoint_name, "str"), - "routeName": _SERIALIZER.url("route_name", route_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -class RoutesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.cdn.CdnManagementClient`'s - :attr:`routes` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_endpoint( - self, resource_group_name: str, profile_name: str, endpoint_name: str, **kwargs: Any - ) -> Iterable["_models.Route"]: - """Lists all of the existing origins within a 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. - :type profile_name: str - :param endpoint_name: Name of the endpoint under the profile which is unique globally. - Required. - :type endpoint_name: str - :return: An iterator like instance of either Route or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cdn.models.Route] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - 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]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_endpoint_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("RouteListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get( - self, resource_group_name: str, profile_name: str, endpoint_name: str, route_name: str, **kwargs: Any - ) -> _models.Route: - """Gets an existing route with the specified route name under the specified subscription, resource - group, profile, and AzureFrontDoor 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. - :type profile_name: str - :param endpoint_name: Name of the endpoint under the profile which is unique globally. - Required. - :type endpoint_name: str - :param route_name: Name of the routing rule. Required. - :type route_name: str - :return: Route or the result of cls(response) - :rtype: ~azure.mgmt.cdn.models.Route - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.Route] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - route_name=route_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Route", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_initial( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - route_name: str, - route: Union[_models.Route, IO[bytes]], - **kwargs: Any - ) -> _models.Route: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_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.Route] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(route, (IOBase, bytes)): - _content = route - else: - _json = self._serialize.body(route, "Route") - - _request = build_create_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - route_name=route_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201, 202]: - 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) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - route_name: str, - route: _models.Route, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Route]: - """Creates a new route with the specified route name under the specified subscription, resource - group, profile, and AzureFrontDoor 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. - :type profile_name: str - :param endpoint_name: Name of the endpoint under the profile which is unique globally. - Required. - :type endpoint_name: str - :param route_name: Name of the routing rule. Required. - :type route_name: str - :param route: Route properties. Required. - :type route: ~azure.mgmt.cdn.models.Route - :keyword content_type: Body Parameter 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 Route or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Route] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - route_name: str, - route: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Route]: - """Creates a new route with the specified route name under the specified subscription, resource - group, profile, and AzureFrontDoor 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. - :type profile_name: str - :param endpoint_name: Name of the endpoint under the profile which is unique globally. - Required. - :type endpoint_name: str - :param route_name: Name of the routing rule. Required. - :type route_name: str - :param route: Route properties. Required. - :type route: IO[bytes] - :keyword content_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 Route or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Route] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - route_name: str, - route: Union[_models.Route, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.Route]: - """Creates a new route with the specified route name under the specified subscription, resource - group, profile, and AzureFrontDoor 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. - :type profile_name: str - :param endpoint_name: Name of the endpoint under the profile which is unique globally. - Required. - :type endpoint_name: str - :param route_name: Name of the routing rule. Required. - :type route_name: str - :param route: Route properties. Is either a Route type or a IO[bytes] type. Required. - :type route: ~azure.mgmt.cdn.models.Route or IO[bytes] - :return: An instance of LROPoller that returns either Route or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Route] - :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.Route] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._create_initial( - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - route_name=route_name, - route=route, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Route", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.Route].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Route]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _update_initial( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - route_name: str, - route_update_properties: Union[_models.RouteUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> _models.Route: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_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.Route] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(route_update_properties, (IOBase, bytes)): - _content = route_update_properties - else: - _json = self._serialize.body(route_update_properties, "RouteUpdateParameters") - - _request = build_update_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - route_name=route_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.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) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_update( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - route_name: str, - route_update_properties: _models.RouteUpdateParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Route]: - """Updates an existing route with the specified route name under the specified subscription, - resource group, profile, and AzureFrontDoor 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. - :type profile_name: str - :param endpoint_name: Name of the endpoint under the profile which is unique globally. - Required. - :type endpoint_name: str - :param route_name: Name of the routing rule. Required. - :type route_name: str - :param route_update_properties: Route update properties. Required. - :type route_update_properties: ~azure.mgmt.cdn.models.RouteUpdateParameters - :keyword content_type: Body Parameter 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 Route or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Route] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - route_name: str, - route_update_properties: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Route]: - """Updates an existing route with the specified route name under the specified subscription, - resource group, profile, and AzureFrontDoor 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. - :type profile_name: str - :param endpoint_name: Name of the endpoint under the profile which is unique globally. - Required. - :type endpoint_name: str - :param route_name: Name of the routing rule. Required. - :type route_name: str - :param route_update_properties: Route update properties. Required. - :type route_update_properties: IO[bytes] - :keyword content_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 Route or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Route] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update( - self, - resource_group_name: str, - profile_name: str, - endpoint_name: str, - route_name: str, - route_update_properties: Union[_models.RouteUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.Route]: - """Updates an existing route with the specified route name under the specified subscription, - resource group, profile, and AzureFrontDoor 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. - :type profile_name: str - :param endpoint_name: Name of the endpoint under the profile which is unique globally. - Required. - :type endpoint_name: str - :param route_name: Name of the routing rule. Required. - :type route_name: str - :param route_update_properties: Route update properties. Is either a RouteUpdateParameters type - or a IO[bytes] type. Required. - :type route_update_properties: ~azure.mgmt.cdn.models.RouteUpdateParameters or IO[bytes] - :return: An instance of LROPoller that returns either Route or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Route] - :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.Route] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._update_initial( - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - route_name=route_name, - route_update_properties=route_update_properties, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Route", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.Route].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Route]( - 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, endpoint_name: str, route_name: str, **kwargs: Any - ) -> None: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - route_name=route_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - 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 == 202: - response_headers["location"] = self._deserialize("str", response.headers.get("location")) - - if cls: - return cls(pipeline_response, None, response_headers) # type: ignore - - @distributed_trace - def begin_delete( - self, resource_group_name: str, profile_name: str, endpoint_name: str, route_name: str, **kwargs: Any - ) -> LROPoller[None]: - """Deletes an existing route with the specified route name under the specified subscription, - resource group, profile, and AzureFrontDoor 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. - :type profile_name: str - :param endpoint_name: Name of the endpoint under the profile which is unique globally. - Required. - :type endpoint_name: str - :param route_name: Name of the routing rule. Required. - :type route_name: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_initial( # type: ignore - resource_group_name=resource_group_name, - profile_name=profile_name, - endpoint_name=endpoint_name, - route_name=route_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore 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 deleted file mode 100644 index 4f4fb842dd03..000000000000 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_rule_sets_operations.py +++ /dev/null @@ -1,644 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar, Union, cast -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models -from .._serialization import Serializer -from .._vendor import CdnManagementClientMixinABC, _convert_request - -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]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_profile_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", "2024-02-01")) - 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"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, profile_name: str, rule_set_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) - 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"), - "ruleSetName": _SERIALIZER.url("rule_set_name", rule_set_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_request( - resource_group_name: str, profile_name: str, rule_set_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) - 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"), - "ruleSetName": _SERIALIZER.url("rule_set_name", rule_set_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, profile_name: str, rule_set_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) - 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"), - "ruleSetName": _SERIALIZER.url("rule_set_name", rule_set_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_resource_usage_request( - resource_group_name: str, profile_name: str, rule_set_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) - 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"), - "ruleSetName": _SERIALIZER.url("rule_set_name", rule_set_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # 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 RuleSetsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.cdn.CdnManagementClient`'s - :attr:`rule_sets` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_profile( - self, resource_group_name: str, profile_name: str, **kwargs: Any - ) -> Iterable["_models.RuleSet"]: - """Lists existing AzureFrontDoor rule sets within a 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. - :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] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - 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]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_profile_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 = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("RuleSetListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get(self, resource_group_name: str, profile_name: str, rule_set_name: str, **kwargs: Any) -> _models.RuleSet: - """Gets an existing AzureFrontDoor rule set with the specified rule set name under the specified - subscription, resource group and 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. - :type profile_name: str - :param rule_set_name: Name of the rule set under the profile which is unique globally. - Required. - :type rule_set_name: str - :return: RuleSet or the result of cls(response) - :rtype: ~azure.mgmt.cdn.models.RuleSet - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.RuleSet] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - rule_set_name=rule_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("RuleSet", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def create(self, resource_group_name: str, profile_name: str, rule_set_name: str, **kwargs: Any) -> _models.RuleSet: - """Creates a new rule set within the specified 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. - :type profile_name: str - :param rule_set_name: Name of the rule set under the profile which is unique globally. - Required. - :type rule_set_name: str - :return: RuleSet or the result of cls(response) - :rtype: ~azure.mgmt.cdn.models.RuleSet - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.RuleSet] = kwargs.pop("cls", None) - - _request = build_create_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - rule_set_name=rule_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - 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) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _delete_initial( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, profile_name: str, rule_set_name: str, **kwargs: Any - ) -> None: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - rule_set_name=rule_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - 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 == 202: - response_headers["location"] = self._deserialize("str", response.headers.get("location")) - - if cls: - return cls(pipeline_response, None, response_headers) # type: ignore - - @distributed_trace - def begin_delete( - self, resource_group_name: str, profile_name: str, rule_set_name: str, **kwargs: Any - ) -> LROPoller[None]: - """Deletes an existing AzureFrontDoor rule set with the specified rule set name under the - specified subscription, resource group and 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. - :type profile_name: str - :param rule_set_name: Name of the rule set under the profile which is unique globally. - Required. - :type rule_set_name: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_initial( # type: ignore - resource_group_name=resource_group_name, - profile_name=profile_name, - rule_set_name=rule_set_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def list_resource_usage( - self, resource_group_name: str, profile_name: str, rule_set_name: str, **kwargs: Any - ) -> Iterable["_models.Usage"]: - """Checks the quota and actual usage of endpoints under the given Azure Front Door 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. - :type profile_name: str - :param rule_set_name: Name of the rule set under the profile which is unique globally. - Required. - :type rule_set_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] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - 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]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_resource_usage_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - rule_set_name=rule_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("UsagesListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) 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 deleted file mode 100644 index 02f15c6f1378..000000000000 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_rules_operations.py +++ /dev/null @@ -1,947 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models -from .._serialization import Serializer -from .._vendor import CdnManagementClientMixinABC, _convert_request - -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]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_rule_set_request( - resource_group_name: str, profile_name: str, rule_set_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) - 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"), - "ruleSetName": _SERIALIZER.url("rule_set_name", rule_set_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, profile_name: str, rule_set_name: str, rule_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) - 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"), - "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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_request( - resource_group_name: str, profile_name: str, rule_set_name: str, rule_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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"), - "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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_update_request( - resource_group_name: str, profile_name: str, rule_set_name: str, rule_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.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"), - "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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, profile_name: str, rule_set_name: str, rule_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) - 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"), - "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"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -class RulesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.cdn.CdnManagementClient`'s - :attr:`rules` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_rule_set( - self, resource_group_name: str, profile_name: str, rule_set_name: str, **kwargs: Any - ) -> Iterable["_models.Rule"]: - """Lists all of the existing delivery rules within a 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. - :type profile_name: str - :param rule_set_name: Name of the rule set under the profile. Required. - :type rule_set_name: str - :return: An iterator like instance of either Rule or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cdn.models.Rule] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - 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]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_rule_set_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - rule_set_name=rule_set_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("RuleListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get( - self, resource_group_name: str, profile_name: str, rule_set_name: str, rule_name: str, **kwargs: Any - ) -> _models.Rule: - """Gets an existing delivery rule within a 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. - :type profile_name: str - :param rule_set_name: Name of the rule set under the profile. Required. - :type rule_set_name: str - :param rule_name: Name of the delivery rule which is unique within the endpoint. Required. - :type rule_name: str - :return: Rule or the result of cls(response) - :rtype: ~azure.mgmt.cdn.models.Rule - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.Rule] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - rule_set_name=rule_set_name, - rule_name=rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Rule", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_initial( - self, - resource_group_name: str, - profile_name: str, - rule_set_name: str, - rule_name: str, - rule: Union[_models.Rule, IO[bytes]], - **kwargs: Any - ) -> _models.Rule: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_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.Rule] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(rule, (IOBase, bytes)): - _content = rule - else: - _json = self._serialize.body(rule, "Rule") - - _request = build_create_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - rule_set_name=rule_set_name, - rule_name=rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201, 202]: - 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) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create( - self, - resource_group_name: str, - profile_name: str, - rule_set_name: str, - rule_name: str, - rule: _models.Rule, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Rule]: - """Creates a new delivery rule within the specified 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. - :type profile_name: str - :param rule_set_name: Name of the rule set under the profile. Required. - :type rule_set_name: str - :param rule_name: Name of the delivery rule which is unique within the endpoint. Required. - :type rule_name: str - :param rule: The delivery rule properties. Required. - :type rule: ~azure.mgmt.cdn.models.Rule - :keyword content_type: Body Parameter 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 Rule or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Rule] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create( - self, - resource_group_name: str, - profile_name: str, - rule_set_name: str, - rule_name: str, - rule: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Rule]: - """Creates a new delivery rule within the specified 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. - :type profile_name: str - :param rule_set_name: Name of the rule set under the profile. Required. - :type rule_set_name: str - :param rule_name: Name of the delivery rule which is unique within the endpoint. Required. - :type rule_name: str - :param rule: The delivery rule properties. Required. - :type rule: IO[bytes] - :keyword content_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 Rule or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Rule] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create( - self, - resource_group_name: str, - profile_name: str, - rule_set_name: str, - rule_name: str, - rule: Union[_models.Rule, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.Rule]: - """Creates a new delivery rule within the specified 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. - :type profile_name: str - :param rule_set_name: Name of the rule set under the profile. Required. - :type rule_set_name: str - :param rule_name: Name of the delivery rule which is unique within the endpoint. Required. - :type rule_name: str - :param rule: The delivery rule properties. Is either a Rule type or a IO[bytes] type. Required. - :type rule: ~azure.mgmt.cdn.models.Rule or IO[bytes] - :return: An instance of LROPoller that returns either Rule or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Rule] - :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.Rule] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._create_initial( - resource_group_name=resource_group_name, - profile_name=profile_name, - rule_set_name=rule_set_name, - rule_name=rule_name, - rule=rule, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Rule", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.Rule].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Rule]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _update_initial( - self, - resource_group_name: str, - profile_name: str, - rule_set_name: str, - rule_name: str, - rule_update_properties: Union[_models.RuleUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> _models.Rule: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_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.Rule] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(rule_update_properties, (IOBase, bytes)): - _content = rule_update_properties - else: - _json = self._serialize.body(rule_update_properties, "RuleUpdateParameters") - - _request = build_update_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - rule_set_name=rule_set_name, - rule_name=rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.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) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_update( - self, - resource_group_name: str, - profile_name: str, - rule_set_name: str, - rule_name: str, - rule_update_properties: _models.RuleUpdateParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Rule]: - """Updates an existing delivery rule within a 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. - :type profile_name: str - :param rule_set_name: Name of the rule set under the profile. Required. - :type rule_set_name: str - :param rule_name: Name of the delivery rule which is unique within the endpoint. Required. - :type rule_name: str - :param rule_update_properties: Delivery rule properties. Required. - :type rule_update_properties: ~azure.mgmt.cdn.models.RuleUpdateParameters - :keyword content_type: Body Parameter 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 Rule or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Rule] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - profile_name: str, - rule_set_name: str, - rule_name: str, - rule_update_properties: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Rule]: - """Updates an existing delivery rule within a 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. - :type profile_name: str - :param rule_set_name: Name of the rule set under the profile. Required. - :type rule_set_name: str - :param rule_name: Name of the delivery rule which is unique within the endpoint. Required. - :type rule_name: str - :param rule_update_properties: Delivery rule properties. Required. - :type rule_update_properties: IO[bytes] - :keyword content_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 Rule or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Rule] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update( - self, - resource_group_name: str, - profile_name: str, - rule_set_name: str, - rule_name: str, - rule_update_properties: Union[_models.RuleUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.Rule]: - """Updates an existing delivery rule within a 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. - :type profile_name: str - :param rule_set_name: Name of the rule set under the profile. Required. - :type rule_set_name: str - :param rule_name: Name of the delivery rule which is unique within the endpoint. Required. - :type rule_name: str - :param rule_update_properties: Delivery rule properties. Is either a RuleUpdateParameters type - or a IO[bytes] type. Required. - :type rule_update_properties: ~azure.mgmt.cdn.models.RuleUpdateParameters or IO[bytes] - :return: An instance of LROPoller that returns either Rule or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Rule] - :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.Rule] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._update_initial( - resource_group_name=resource_group_name, - profile_name=profile_name, - rule_set_name=rule_set_name, - rule_name=rule_name, - rule_update_properties=rule_update_properties, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Rule", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.Rule].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Rule]( - 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, rule_set_name: str, rule_name: str, **kwargs: Any - ) -> None: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - rule_set_name=rule_set_name, - rule_name=rule_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - 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 == 202: - response_headers["location"] = self._deserialize("str", response.headers.get("location")) - - if cls: - return cls(pipeline_response, None, response_headers) # type: ignore - - @distributed_trace - def begin_delete( - self, resource_group_name: str, profile_name: str, rule_set_name: str, rule_name: str, **kwargs: Any - ) -> LROPoller[None]: - """Deletes an existing delivery rule within a 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. - :type profile_name: str - :param rule_set_name: Name of the rule set under the profile. Required. - :type rule_set_name: str - :param rule_name: Name of the delivery rule which is unique within the endpoint. Required. - :type rule_name: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_initial( # type: ignore - resource_group_name=resource_group_name, - profile_name=profile_name, - rule_set_name=rule_set_name, - rule_name=rule_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore 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 deleted file mode 100644 index 8f2d121d8a8b..000000000000 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_secrets_operations.py +++ /dev/null @@ -1,661 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models -from .._serialization import Serializer -from .._vendor import CdnManagementClientMixinABC, _convert_request - -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]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_profile_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", "2024-02-01")) - 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"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, profile_name: str, secret_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_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")) - 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"), - "secretName": _SERIALIZER.url("secret_name", secret_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_request( - resource_group_name: str, profile_name: str, secret_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_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")) - 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}/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"), - "secretName": _SERIALIZER.url("secret_name", secret_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, profile_name: str, secret_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_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")) - 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"), - "secretName": _SERIALIZER.url("secret_name", secret_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -class SecretsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.cdn.CdnManagementClient`'s - :attr:`secrets` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_profile(self, resource_group_name: str, profile_name: str, **kwargs: Any) -> Iterable["_models.Secret"]: - """Lists existing AzureFrontDoor secrets. - - :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. - :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] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - 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]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_profile_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 = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("SecretListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get(self, resource_group_name: str, profile_name: str, secret_name: str, **kwargs: Any) -> _models.Secret: - """Gets an existing Secret within a 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. - :type profile_name: str - :param secret_name: Name of the Secret under the profile. Required. - :type secret_name: str - :return: Secret or the result of cls(response) - :rtype: ~azure.mgmt.cdn.models.Secret - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.Secret] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - secret_name=secret_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Secret", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_initial( - self, - resource_group_name: str, - profile_name: str, - secret_name: str, - secret: Union[_models.Secret, IO[bytes]], - **kwargs: Any - ) -> _models.Secret: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_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.Secret] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(secret, (IOBase, bytes)): - _content = secret - else: - _json = self._serialize.body(secret, "Secret") - - _request = build_create_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - secret_name=secret_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201, 202]: - 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) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create( - self, - resource_group_name: str, - profile_name: str, - secret_name: str, - secret: _models.Secret, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Secret]: - """Creates a new Secret within the specified 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. - :type profile_name: str - :param secret_name: Name of the Secret under the profile. Required. - :type secret_name: str - :param secret: The Secret properties. Required. - :type secret: ~azure.mgmt.cdn.models.Secret - :keyword content_type: Body Parameter 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 Secret or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Secret] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create( - self, - resource_group_name: str, - profile_name: str, - secret_name: str, - secret: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Secret]: - """Creates a new Secret within the specified 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. - :type profile_name: str - :param secret_name: Name of the Secret under the profile. Required. - :type secret_name: str - :param secret: The Secret properties. Required. - :type secret: IO[bytes] - :keyword content_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 Secret or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Secret] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create( - self, - resource_group_name: str, - profile_name: str, - secret_name: str, - secret: Union[_models.Secret, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.Secret]: - """Creates a new Secret within the specified 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. - :type profile_name: str - :param secret_name: Name of the Secret under the profile. Required. - :type secret_name: str - :param secret: The Secret properties. Is either a Secret type or a IO[bytes] type. Required. - :type secret: ~azure.mgmt.cdn.models.Secret or IO[bytes] - :return: An instance of LROPoller that returns either Secret or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Secret] - :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.Secret] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._create_initial( - resource_group_name=resource_group_name, - profile_name=profile_name, - secret_name=secret_name, - secret=secret, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Secret", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.Secret].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Secret]( - 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, secret_name: str, **kwargs: Any - ) -> None: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - secret_name=secret_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - 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 == 202: - response_headers["location"] = self._deserialize("str", response.headers.get("location")) - - if cls: - return cls(pipeline_response, None, response_headers) # type: ignore - - @distributed_trace - def begin_delete( - self, resource_group_name: str, profile_name: str, secret_name: str, **kwargs: Any - ) -> LROPoller[None]: - """Deletes an existing Secret within 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. - :type profile_name: str - :param secret_name: Name of the Secret under the profile. Required. - :type secret_name: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_initial( # type: ignore - resource_group_name=resource_group_name, - profile_name=profile_name, - secret_name=secret_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore 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 deleted file mode 100644 index 6d5a448a343f..000000000000 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_security_policies_operations.py +++ /dev/null @@ -1,916 +0,0 @@ -# pylint: disable=too-many-lines,too-many-statements -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models -from .._serialization import Serializer -from .._vendor import CdnManagementClientMixinABC, _convert_request - -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]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_by_profile_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", "2024-02-01")) - 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"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, profile_name: str, security_policy_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_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")) - 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"), - "securityPolicyName": _SERIALIZER.url("security_policy_name", security_policy_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_request( - resource_group_name: str, profile_name: str, security_policy_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_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")) - 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}/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"), - "securityPolicyName": _SERIALIZER.url("security_policy_name", security_policy_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_patch_request( - resource_group_name: str, profile_name: str, security_policy_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_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")) - 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}/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"), - "securityPolicyName": _SERIALIZER.url("security_policy_name", security_policy_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, profile_name: str, security_policy_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_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")) - 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"), - "securityPolicyName": _SERIALIZER.url("security_policy_name", security_policy_name, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -class SecurityPoliciesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.cdn.CdnManagementClient`'s - :attr:`security_policies` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace - def list_by_profile( - self, resource_group_name: str, profile_name: str, **kwargs: Any - ) -> Iterable["_models.SecurityPolicy"]: - """Lists security policies associated with the 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. - :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] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - 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]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_list_by_profile_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 = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("SecurityPolicyListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get( - self, resource_group_name: str, profile_name: str, security_policy_name: str, **kwargs: Any - ) -> _models.SecurityPolicy: - """Gets an existing security policy within a 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. - :type profile_name: str - :param security_policy_name: Name of the security policy under the profile. Required. - :type security_policy_name: str - :return: SecurityPolicy or the result of cls(response) - :rtype: ~azure.mgmt.cdn.models.SecurityPolicy - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.SecurityPolicy] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - security_policy_name=security_policy_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SecurityPolicy", pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_initial( - self, - resource_group_name: str, - profile_name: str, - security_policy_name: str, - security_policy: Union[_models.SecurityPolicy, IO[bytes]], - **kwargs: Any - ) -> _models.SecurityPolicy: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_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.SecurityPolicy] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(security_policy, (IOBase, bytes)): - _content = security_policy - else: - _json = self._serialize.body(security_policy, "SecurityPolicy") - - _request = build_create_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - security_policy_name=security_policy_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201, 202]: - 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) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create( - self, - resource_group_name: str, - profile_name: str, - security_policy_name: str, - security_policy: _models.SecurityPolicy, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.SecurityPolicy]: - """Creates a new security policy within the specified 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. - :type profile_name: str - :param security_policy_name: Name of the security policy under the profile. Required. - :type security_policy_name: str - :param security_policy: The security policy properties. Required. - :type security_policy: ~azure.mgmt.cdn.models.SecurityPolicy - :keyword content_type: Body Parameter 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 SecurityPolicy or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.SecurityPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create( - self, - resource_group_name: str, - profile_name: str, - security_policy_name: str, - security_policy: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.SecurityPolicy]: - """Creates a new security policy within the specified 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. - :type profile_name: str - :param security_policy_name: Name of the security policy under the profile. Required. - :type security_policy_name: str - :param security_policy: The security policy properties. Required. - :type security_policy: IO[bytes] - :keyword content_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 SecurityPolicy or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.SecurityPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create( - self, - resource_group_name: str, - profile_name: str, - security_policy_name: str, - security_policy: Union[_models.SecurityPolicy, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.SecurityPolicy]: - """Creates a new security policy within the specified 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. - :type profile_name: str - :param security_policy_name: Name of the security policy under the profile. Required. - :type security_policy_name: str - :param security_policy: The security policy properties. Is either a SecurityPolicy type or a - IO[bytes] type. Required. - :type security_policy: ~azure.mgmt.cdn.models.SecurityPolicy or IO[bytes] - :return: An instance of LROPoller that returns either SecurityPolicy or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.SecurityPolicy] - :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.SecurityPolicy] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._create_initial( - resource_group_name=resource_group_name, - profile_name=profile_name, - security_policy_name=security_policy_name, - security_policy=security_policy, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("SecurityPolicy", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.SecurityPolicy].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.SecurityPolicy]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _patch_initial( - self, - resource_group_name: str, - profile_name: str, - security_policy_name: str, - security_policy_update_properties: Union[_models.SecurityPolicyUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> _models.SecurityPolicy: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_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.SecurityPolicy] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(security_policy_update_properties, (IOBase, bytes)): - _content = security_policy_update_properties - else: - _json = self._serialize.body(security_policy_update_properties, "SecurityPolicyUpdateParameters") - - _request = build_patch_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - security_policy_name=security_policy_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.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) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_patch( - self, - resource_group_name: str, - profile_name: str, - security_policy_name: str, - security_policy_update_properties: _models.SecurityPolicyUpdateParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.SecurityPolicy]: - """Updates an existing security policy within a 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. - :type profile_name: str - :param security_policy_name: Name of the security policy under the profile. Required. - :type security_policy_name: str - :param security_policy_update_properties: Security policy update properties. Required. - :type security_policy_update_properties: ~azure.mgmt.cdn.models.SecurityPolicyUpdateParameters - :keyword content_type: Body Parameter 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 SecurityPolicy or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.SecurityPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_patch( - self, - resource_group_name: str, - profile_name: str, - security_policy_name: str, - security_policy_update_properties: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.SecurityPolicy]: - """Updates an existing security policy within a 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. - :type profile_name: str - :param security_policy_name: Name of the security policy under the profile. Required. - :type security_policy_name: str - :param security_policy_update_properties: Security policy update properties. Required. - :type security_policy_update_properties: IO[bytes] - :keyword content_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 SecurityPolicy or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.SecurityPolicy] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_patch( - self, - resource_group_name: str, - profile_name: str, - security_policy_name: str, - security_policy_update_properties: Union[_models.SecurityPolicyUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.SecurityPolicy]: - """Updates an existing security policy within a 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. - :type profile_name: str - :param security_policy_name: Name of the security policy under the profile. Required. - :type security_policy_name: str - :param security_policy_update_properties: Security policy update properties. Is either a - SecurityPolicyUpdateParameters type or a IO[bytes] type. Required. - :type security_policy_update_properties: ~azure.mgmt.cdn.models.SecurityPolicyUpdateParameters - or IO[bytes] - :return: An instance of LROPoller that returns either SecurityPolicy or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.SecurityPolicy] - :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.SecurityPolicy] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._patch_initial( - resource_group_name=resource_group_name, - profile_name=profile_name, - security_policy_name=security_policy_name, - security_policy_update_properties=security_policy_update_properties, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("SecurityPolicy", pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.SecurityPolicy].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.SecurityPolicy]( - 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, security_policy_name: str, **kwargs: Any - ) -> None: - error_map: MutableMapping[int, Type[HttpResponseError]] = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - profile_name=profile_name, - security_policy_name=security_policy_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request = _convert_request(_request) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - 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 == 202: - response_headers["location"] = self._deserialize("str", response.headers.get("location")) - - if cls: - return cls(pipeline_response, None, response_headers) # type: ignore - - @distributed_trace - def begin_delete( - self, resource_group_name: str, profile_name: str, security_policy_name: str, **kwargs: Any - ) -> LROPoller[None]: - """Deletes an existing security policy within 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. - :type profile_name: str - :param security_policy_name: Name of the security policy under the profile. Required. - :type security_policy_name: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._delete_initial( # type: ignore - resource_group_name=resource_group_name, - profile_name=profile_name, - security_policy_name=security_policy_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore 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..f60b460b29ac 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 @@ -2,12 +2,10 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -29,7 +27,7 @@ def main(): client = CdnManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) response = client.afd_custom_domains.begin_create( @@ -40,13 +38,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: 2025-12-01/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..2c14e4872438 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = CdnManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) client.afd_custom_domains.begin_delete( @@ -37,6 +37,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: 2025-12-01/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..ed9b471152c5 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = CdnManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) response = client.afd_custom_domains.get( @@ -38,6 +38,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: 2025-12-01/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..b28e352a505f 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = CdnManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) response = client.afd_custom_domains.list_by_profile( @@ -38,6 +38,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: 2025-12-01/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..64cf0375de34 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = CdnManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) client.afd_custom_domains.begin_refresh_validation_token( @@ -37,6 +37,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: 2025-12-01/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..4d2de0dd417f 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 @@ -2,12 +2,10 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -29,7 +27,7 @@ def main(): client = CdnManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) response = client.afd_custom_domains.begin_update( @@ -39,13 +37,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: 2025-12-01/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..2eee76b158db 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 @@ -2,12 +2,10 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -29,7 +27,7 @@ def main(): client = CdnManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) response = client.afd_endpoints.begin_create( @@ -45,6 +43,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: 2025-12-01/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..13e0faec5088 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = CdnManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) client.afd_endpoints.begin_delete( @@ -37,6 +37,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: 2025-12-01/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..9e1e49ff8c73 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = CdnManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) response = client.afd_endpoints.get( @@ -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: 2025-12-01/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..a8a168b1f987 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = CdnManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) response = client.afd_endpoints.list_by_profile( @@ -38,6 +38,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: 2025-12-01/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..9300ec6a3fec 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = CdnManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) response = client.afd_endpoints.list_resource_usage( @@ -39,6 +39,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: 2025-12-01/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..daeeddc96a59 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 @@ -2,12 +2,10 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -29,7 +27,7 @@ def main(): client = CdnManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) client.afd_endpoints.begin_purge_content( @@ -40,6 +38,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: 2025-12-01/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..7641c0401e08 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 @@ -2,12 +2,10 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -29,7 +27,7 @@ def main(): client = CdnManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) response = client.afd_endpoints.begin_update( @@ -41,6 +39,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: 2025-12-01/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..882bcd10d733 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 @@ -2,12 +2,10 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -29,7 +27,7 @@ def main(): client = CdnManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) response = client.afd_endpoints.validate_custom_domain( @@ -41,6 +39,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: 2025-12-01/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..44bbf7cd26a3 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,13 +1,12 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -29,7 +28,7 @@ def main(): client = CdnManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) response = client.afd_origin_groups.begin_create( @@ -38,6 +37,13 @@ def main(): origin_group_name="origingroup1", origin_group={ "properties": { + "authentication": { + "scope": "https://www.contoso.com/.default", + "type": "UserAssignedIdentity", + "userAssignedIdentity": { + "id": "/subscriptions/subid/resourcegroups/RG/providers/Microsoft.ManagedIdentity/userAssignedIdentities/user-assigned-id-1" + }, + }, "healthProbeSettings": { "probeIntervalInSeconds": 10, "probePath": "/path2", @@ -56,6 +62,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: 2025-12-01/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..f7342bbcb569 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = CdnManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) client.afd_origin_groups.begin_delete( @@ -37,6 +37,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: 2025-12-01/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..77c0f50a5e09 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = CdnManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) response = client.afd_origin_groups.get( @@ -38,6 +38,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: 2025-12-01/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..6874504fa95b 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = CdnManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) response = client.afd_origin_groups.list_by_profile( @@ -38,6 +38,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: 2025-12-01/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..59852eb1acc2 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = CdnManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) response = client.afd_origin_groups.list_resource_usage( @@ -39,6 +39,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: 2025-12-01/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..e1d329a354dd 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,13 +1,12 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -29,7 +28,7 @@ def main(): client = CdnManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) response = client.afd_origin_groups.begin_update( @@ -38,6 +37,13 @@ def main(): origin_group_name="origingroup1", origin_group_update_properties={ "properties": { + "authentication": { + "scope": "https://www.contoso.com/.default", + "type": "UserAssignedIdentity", + "userAssignedIdentity": { + "id": "/subscriptions/subid/resourcegroups/RG/providers/Microsoft.ManagedIdentity/userAssignedIdentities/user-assigned-id-1" + }, + }, "healthProbeSettings": { "probeIntervalInSeconds": 10, "probePath": "/path2", @@ -56,6 +62,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: 2025-12-01/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..1f734cc2cd71 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 @@ -2,12 +2,10 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -29,7 +27,7 @@ def main(): client = CdnManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) response = client.afd_origins.begin_create( @@ -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: 2025-12-01/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..65db4470d60c 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = CdnManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) client.afd_origins.begin_delete( @@ -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: 2025-12-01/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..9620317e29a5 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = CdnManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) response = client.afd_origins.get( @@ -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: 2025-12-01/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..c25a2d0ff930 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = CdnManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) response = client.afd_origins.list_by_origin_group( @@ -39,6 +39,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: 2025-12-01/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..497e44f1a138 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 @@ -2,12 +2,10 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -29,7 +27,7 @@ def main(): client = CdnManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) response = client.afd_origins.begin_update( @@ -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: 2025-12-01/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..54ccc0d28375 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 @@ -2,12 +2,10 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -29,7 +27,7 @@ def main(): client = CdnManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) response = client.afd_profiles.check_endpoint_name_availability( @@ -44,6 +42,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: 2025-12-01/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..62141b9a7fc9 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 @@ -2,12 +2,10 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -29,7 +27,7 @@ def main(): client = CdnManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) response = client.afd_profiles.check_host_name_availability( @@ -40,6 +38,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: 2025-12-01/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..90534c6442ee 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = CdnManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) response = client.afd_profiles.list_resource_usage( @@ -38,6 +38,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: 2025-12-01/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..e777491e2549 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,13 +1,12 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -29,7 +28,7 @@ def main(): client = CdnManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) response = client.afd_profiles.begin_upgrade( @@ -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: 2025-12-01/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..0991ac58003c 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,13 +1,12 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -29,7 +28,7 @@ def main(): client = CdnManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) response = client.afd_profiles.validate_secret( @@ -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: 2025-12-01/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..7b528e262254 --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/cdn_profiles_can_migrate.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.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="SUBSCRIPTION_ID", + ) + + response = client.profiles.begin_cdn_can_migrate_to_afd( + resource_group_name="RG", + profile_name="profile1", + ).result() + print(response) + + +# x-ms-original-file: 2025-12-01/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..0b8872655e63 --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/cdn_profiles_migrate.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.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="SUBSCRIPTION_ID", + ) + + 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: 2025-12-01/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..897480cddd9d 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 @@ -2,12 +2,10 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -29,7 +27,7 @@ def main(): client = CdnManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) response = client.check_endpoint_name_availability( @@ -43,6 +41,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: 2025-12-01/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..92e062c55681 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 @@ -2,12 +2,10 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from 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/CheckNameAvailability.json +# x-ms-original-file: 2025-12-01/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..27c774a5850d 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 @@ -2,12 +2,10 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -29,7 +27,7 @@ def main(): client = CdnManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) response = client.check_name_availability_with_subscription( @@ -38,6 +36,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: 2025-12-01/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..505579cf3ee5 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 @@ -2,12 +2,10 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -29,7 +27,7 @@ def main(): client = CdnManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) response = client.custom_domains.begin_create( @@ -42,6 +40,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: 2025-12-01/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..474d061ec19f 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = CdnManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) response = client.custom_domains.begin_delete( @@ -39,6 +39,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: 2025-12-01/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..5d5698ccc2af 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = CdnManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) response = client.custom_domains.begin_disable_custom_https( @@ -39,6 +39,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: 2025-12-01/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..50e9fc466aec 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = CdnManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) response = client.custom_domains.begin_enable_custom_https( @@ -39,6 +39,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: 2025-12-01/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..13fdb5648c67 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = CdnManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) response = client.custom_domains.begin_enable_custom_https( @@ -39,6 +39,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: 2025-12-01/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..1d86d4f62f5e 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = CdnManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) response = client.custom_domains.get( @@ -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: 2025-12-01/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..417367cc77a6 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = CdnManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) response = client.custom_domains.list_by_endpoint( @@ -39,6 +39,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: 2025-12-01/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..19e490a716bc 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -35,6 +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: 2025-12-01/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..e9e49b1a8ad7 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_create.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_create.py @@ -1,13 +1,12 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -29,7 +28,7 @@ def main(): client = CdnManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) response = client.endpoints.begin_create( @@ -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: 2025-12-01/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..16e3ae1fedbe 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_delete.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_delete.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = CdnManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) client.endpoints.begin_delete( @@ -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: 2025-12-01/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..cf2b5ba66a2a 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_get.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_get.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = CdnManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) response = client.endpoints.get( @@ -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: 2025-12-01/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..95222235933b 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = CdnManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) response = client.endpoints.list_by_profile( @@ -38,6 +38,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: 2025-12-01/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..52370a2c0f65 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = CdnManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) response = client.endpoints.list_resource_usage( @@ -39,6 +39,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: 2025-12-01/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..5ceb73144a9b 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 @@ -2,12 +2,10 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -29,7 +27,7 @@ def main(): client = CdnManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) client.endpoints.begin_load_content( @@ -40,6 +38,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: 2025-12-01/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..5372638ce5e6 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 @@ -2,12 +2,10 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -29,7 +27,7 @@ def main(): client = CdnManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) client.endpoints.begin_purge_content( @@ -40,6 +38,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: 2025-12-01/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..8c47e89e1c18 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_start.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_start.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = CdnManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) response = client.endpoints.begin_start( @@ -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: 2025-12-01/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..be89597a8fc7 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_stop.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_stop.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = CdnManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) response = client.endpoints.begin_stop( @@ -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: 2025-12-01/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..d88a733e2364 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_update.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_update.py @@ -2,12 +2,10 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -29,7 +27,7 @@ def main(): client = CdnManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) response = client.endpoints.begin_update( @@ -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: 2025-12-01/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..2dbac611d63f 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 @@ -2,12 +2,10 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -29,7 +27,7 @@ def main(): client = CdnManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) response = client.endpoints.validate_custom_domain( @@ -41,6 +39,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: 2025-12-01/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..683125e6b161 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = CdnManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) response = client.log_analytics.get_log_analytics_locations( @@ -37,6 +37,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: 2025-12-01/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..7cf06860abd1 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 @@ -2,21 +2,16 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # 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 @@ -34,7 +29,7 @@ def main(): client = CdnManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) response = client.log_analytics.get_log_analytics_metrics( @@ -50,6 +45,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: 2025-12-01/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..410d37f9991e 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 @@ -2,21 +2,16 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # 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 @@ -34,7 +29,7 @@ def main(): client = CdnManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) response = client.log_analytics.get_log_analytics_rankings( @@ -49,6 +44,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: 2025-12-01/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..2dacf9125e76 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = CdnManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) response = client.log_analytics.get_log_analytics_resources( @@ -37,6 +37,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: 2025-12-01/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..7e90063c9e7d 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 @@ -2,21 +2,16 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # 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 @@ -34,7 +29,7 @@ def main(): client = CdnManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) response = client.log_analytics.get_waf_log_analytics_metrics( @@ -48,6 +43,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: 2025-12-01/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..559e1655f4b5 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 @@ -2,21 +2,16 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # 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 @@ -34,7 +29,7 @@ def main(): client = CdnManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) response = client.log_analytics.get_waf_log_analytics_rankings( @@ -49,6 +44,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: 2025-12-01/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..3d0144f41e48 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/operations_list.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/operations_list.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -35,6 +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: 2025-12-01/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..05439e30a45c 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,13 +1,12 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -29,7 +28,7 @@ def main(): client = CdnManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) response = client.origin_groups.begin_create( @@ -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: 2025-12-01/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..52decf0a392e 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = CdnManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) client.origin_groups.begin_delete( @@ -38,6 +38,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: 2025-12-01/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..6c3218c31545 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = CdnManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) response = client.origin_groups.get( @@ -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: 2025-12-01/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..1786f6a01382 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = CdnManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) response = client.origin_groups.list_by_endpoint( @@ -39,6 +39,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: 2025-12-01/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..69a9e03d1021 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,13 +1,12 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -29,7 +28,7 @@ def main(): client = CdnManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) response = client.origin_groups.begin_update( @@ -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: 2025-12-01/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..15d2b78751a8 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/origins_create.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/origins_create.py @@ -1,13 +1,12 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -29,7 +28,7 @@ def main(): client = CdnManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) response = client.origins.begin_create( @@ -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: 2025-12-01/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..5efaa1f006e5 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/origins_delete.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/origins_delete.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = CdnManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) client.origins.begin_delete( @@ -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: 2025-12-01/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..41b6b57f72fa 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/origins_get.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/origins_get.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = CdnManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) response = client.origins.get( @@ -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: 2025-12-01/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..92973d3c0256 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = CdnManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) response = client.origins.list_by_endpoint( @@ -39,6 +39,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: 2025-12-01/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..29b9024163af 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/origins_update.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/origins_update.py @@ -2,12 +2,10 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -29,7 +27,7 @@ def main(): client = CdnManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) response = client.origins.begin_update( @@ -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: 2025-12-01/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..be7fbf74dd20 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 @@ -2,12 +2,10 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -29,7 +27,7 @@ def main(): client = CdnManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) response = client.profiles.begin_can_migrate( @@ -43,6 +41,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: 2025-12-01/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..9ac355d58064 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_create.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_create.py @@ -2,12 +2,10 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -29,7 +27,7 @@ def main(): client = CdnManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) response = client.profiles.begin_create( @@ -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: 2025-12-01/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..e68b9cd37860 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_delete.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_delete.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = CdnManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) client.profiles.begin_delete( @@ -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: 2025-12-01/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..8d1bbbb6b75e 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = CdnManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) response = client.profiles.generate_sso_uri( @@ -37,6 +37,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: 2025-12-01/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..a788cb239e02 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_get.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_get.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = CdnManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) response = client.profiles.get( @@ -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: 2025-12-01/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..ca984dd723c9 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_list.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_list.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = CdnManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) response = client.profiles.list() @@ -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: 2025-12-01/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..1b333c0a767d 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = CdnManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) response = client.profiles.list_by_resource_group( @@ -37,6 +37,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: 2025-12-01/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..165ecad8e605 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = CdnManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) response = client.profiles.list_resource_usage( @@ -38,6 +38,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: 2025-12-01/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..5780f1978092 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = CdnManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) response = client.profiles.list_supported_optimization_types( @@ -37,6 +37,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: 2025-12-01/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..528dbebc8a82 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_migrate.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_migrate.py @@ -2,12 +2,10 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -29,7 +27,7 @@ def main(): client = CdnManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) response = client.profiles.begin_migrate( @@ -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: 2025-12-01/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..a2e7472cb632 --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_migration_abort.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.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="SUBSCRIPTION_ID", + ) + + client.profiles.begin_migration_abort( + resource_group_name="RG", + profile_name="profile1", + ).result() + + +# x-ms-original-file: 2025-12-01/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..4fd152ae373f 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = CdnManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) client.profiles.begin_migration_commit( @@ -36,6 +36,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: 2025-12-01/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..2029d3dce6be 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_update.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_update.py @@ -2,12 +2,10 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -29,7 +27,7 @@ def main(): client = CdnManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) response = client.profiles.begin_update( @@ -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: 2025-12-01/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..5220eb28e044 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = CdnManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) response = client.resource_usage.list() @@ -35,6 +35,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: 2025-12-01/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..989808c170b2 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/routes_create.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/routes_create.py @@ -1,13 +1,12 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -29,7 +28,7 @@ def main(): client = CdnManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) response = client.routes.begin_create( @@ -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: 2025-12-01/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..e5e7b8bfc56a 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/routes_delete.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/routes_delete.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = CdnManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) client.routes.begin_delete( @@ -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: 2025-12-01/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..b904f9da244a 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/routes_get.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/routes_get.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = CdnManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) response = client.routes.get( @@ -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: 2025-12-01/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..f643d84568ff 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = CdnManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) response = client.routes.list_by_endpoint( @@ -39,6 +39,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: 2025-12-01/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..8545a7c52c5b 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/routes_update.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/routes_update.py @@ -1,13 +1,12 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -29,7 +28,7 @@ def main(): client = CdnManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) response = client.routes.begin_update( @@ -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: 2025-12-01/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..7e112e4871c1 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,17 +27,17 @@ def main(): client = CdnManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) - response = client.rule_sets.create( + response = client.rule_sets.begin_create( resource_group_name="RG", profile_name="profile1", rule_set_name="ruleSet1", - ) + ).result() print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/RuleSets_Create.json +# x-ms-original-file: 2025-12-01/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..dda301f56cff 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = CdnManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) client.rule_sets.begin_delete( @@ -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: 2025-12-01/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..efa2c12a9a08 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = CdnManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) response = client.rule_sets.get( @@ -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: 2025-12-01/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..a2e3e548cbb0 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = CdnManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) response = client.rule_sets.list_by_profile( @@ -38,6 +38,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: 2025-12-01/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..2ad38594faec 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = CdnManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) response = client.rule_sets.list_resource_usage( @@ -39,6 +39,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: 2025-12-01/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..e60dddb75e24 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/rules_create.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/rules_create.py @@ -2,12 +2,10 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -29,7 +27,7 @@ def main(): client = CdnManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) response = client.rules.begin_create( @@ -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: 2025-12-01/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..3fa3281c6d7e 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/rules_delete.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/rules_delete.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = CdnManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) client.rules.begin_delete( @@ -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: 2025-12-01/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..2d1fd2db3254 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/rules_get.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/rules_get.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = CdnManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) response = client.rules.get( @@ -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: 2025-12-01/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..e84bf585dbf0 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = CdnManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) response = client.rules.list_by_rule_set( @@ -39,6 +39,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: 2025-12-01/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..932c991196f6 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/rules_update.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/rules_update.py @@ -2,12 +2,10 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -29,7 +27,7 @@ def main(): client = CdnManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) response = client.rules.begin_update( @@ -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: 2025-12-01/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..9a32b3602897 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/secrets_create.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/secrets_create.py @@ -1,13 +1,12 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -29,7 +28,7 @@ def main(): client = CdnManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) response = client.secrets.begin_create( @@ -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: 2025-12-01/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..edf3855ea446 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/secrets_delete.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/secrets_delete.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = CdnManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) client.secrets.begin_delete( @@ -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: 2025-12-01/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..5831e64be087 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/secrets_get.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/secrets_get.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = CdnManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) response = client.secrets.get( @@ -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: 2025-12-01/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..efd1c3376da0 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = CdnManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) response = client.secrets.list_by_profile( @@ -38,6 +38,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: 2025-12-01/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..aa0d84a71dfd 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,13 +1,12 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -29,7 +28,7 @@ def main(): client = CdnManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) response = client.security_policies.begin_create( @@ -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: 2025-12-01/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..9f8953f48b08 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = CdnManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) client.security_policies.begin_delete( @@ -37,6 +37,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: 2025-12-01/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..09a7b8b8c45a 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = CdnManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) response = client.security_policies.get( @@ -38,6 +38,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: 2025-12-01/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..9ff982108c3e 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = CdnManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) response = client.security_policies.list_by_profile( @@ -38,6 +38,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: 2025-12-01/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..d9e5ae1f7b25 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,13 +1,12 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -29,7 +28,7 @@ def main(): client = CdnManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) response = client.security_policies.begin_patch( @@ -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: 2025-12-01/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..baebcfadb53e 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/validate_probe.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/validate_probe.py @@ -2,12 +2,10 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -29,7 +27,7 @@ def main(): client = CdnManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) response = client.validate_probe( @@ -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: 2025-12-01/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..4c320ad1676b 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = CdnManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) response = client.managed_rule_sets.list() @@ -35,6 +35,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: 2025-12-01/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..a0e13b627fc8 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = CdnManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) response = client.policies.list( @@ -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: 2025-12-01/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..55d072a1f1cf 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 @@ -2,12 +2,10 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -29,7 +27,7 @@ def main(): client = CdnManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) response = client.policies.begin_update( @@ -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: 2025-12-01/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..01398316e7c5 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,13 +1,12 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -29,7 +28,7 @@ def main(): client = CdnManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) response = client.policies.begin_create_or_update( @@ -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: 2025-12-01/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..0af172f9983f 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = CdnManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) client.policies.delete( @@ -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: 2025-12-01/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..169f918543ce 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = CdnManagementClient( credential=DefaultAzureCredential(), - subscription_id="subid", + subscription_id="SUBSCRIPTION_ID", ) response = client.policies.get( @@ -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: 2025-12-01/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..dfedef46a2f5 --- /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) Python 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..076efc8337bb --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management.py @@ -0,0 +1,64 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import 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", + }, + ) + + # 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"}, + ) + + # 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"}, + ) + + # 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"}, + ) + + # 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..f6bc7cb1af8b --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_afd_custom_domains_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) Python 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_get(self, resource_group): + response = self.client.afd_custom_domains.get( + resource_group_name=resource_group.name, + profile_name="str", + custom_domain_name="str", + ) + + # 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={ + "id": "str", + "name": "str", + "properties": { + "hostName": "str", + "azureDnsZone": {"id": "str"}, + "deploymentStatus": "str", + "domainValidationState": "str", + "extendedProperties": {"str": "str"}, + "preValidatedCustomDomainResourceId": {"id": "str"}, + "profileName": "str", + "provisioningState": "str", + "tlsSettings": { + "certificateType": "str", + "cipherSuiteSetType": "str", + "customizedCipherSuiteSet": { + "cipherSuiteSetForTls12": ["str"], + "cipherSuiteSetForTls13": ["str"], + }, + "minimumTlsVersion": "str", + "secret": {"id": "str"}, + }, + "validationProperties": {"expirationDate": "str", "validationToken": "str"}, + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_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={ + "properties": { + "azureDnsZone": {"id": "str"}, + "preValidatedCustomDomainResourceId": {"id": "str"}, + "profileName": "str", + "tlsSettings": { + "certificateType": "str", + "cipherSuiteSetType": "str", + "customizedCipherSuiteSet": { + "cipherSuiteSetForTls12": ["str"], + "cipherSuiteSetForTls13": ["str"], + }, + "minimumTlsVersion": "str", + "secret": {"id": "str"}, + }, + } + }, + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + 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", + ).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_list_by_profile(self, resource_group): + response = self.client.afd_custom_domains.list_by_profile( + resource_group_name=resource_group.name, + profile_name="str", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_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", + ).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..1d93a0be1074 --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_afd_custom_domains_operations_async.py @@ -0,0 +1,150 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import 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_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", + ) + + # 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={ + "id": "str", + "name": "str", + "properties": { + "hostName": "str", + "azureDnsZone": {"id": "str"}, + "deploymentStatus": "str", + "domainValidationState": "str", + "extendedProperties": {"str": "str"}, + "preValidatedCustomDomainResourceId": {"id": "str"}, + "profileName": "str", + "provisioningState": "str", + "tlsSettings": { + "certificateType": "str", + "cipherSuiteSetType": "str", + "customizedCipherSuiteSet": { + "cipherSuiteSetForTls12": ["str"], + "cipherSuiteSetForTls13": ["str"], + }, + "minimumTlsVersion": "str", + "secret": {"id": "str"}, + }, + "validationProperties": {"expirationDate": "str", "validationToken": "str"}, + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_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={ + "properties": { + "azureDnsZone": {"id": "str"}, + "preValidatedCustomDomainResourceId": {"id": "str"}, + "profileName": "str", + "tlsSettings": { + "certificateType": "str", + "cipherSuiteSetType": "str", + "customizedCipherSuiteSet": { + "cipherSuiteSetForTls12": ["str"], + "cipherSuiteSetForTls13": ["str"], + }, + "minimumTlsVersion": "str", + "secret": {"id": "str"}, + }, + } + }, + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_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", + ) + ).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_list_by_profile(self, resource_group): + response = self.client.afd_custom_domains.list_by_profile( + resource_group_name=resource_group.name, + profile_name="str", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_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", + ) + ).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..bb17d8377fe1 --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_afd_endpoints_operations.py @@ -0,0 +1,143 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python 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_get(self, resource_group): + response = self.client.afd_endpoints.get( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + ) + + # 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", + "id": "str", + "name": "str", + "properties": { + "autoGeneratedDomainNameLabelScope": "str", + "deploymentStatus": "str", + "enabledState": "str", + "hostName": "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", + }, + ).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={ + "properties": {"enabledState": "str", "profileName": "str"}, + "tags": {"str": "str"}, + }, + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_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", + ).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_by_profile(self, resource_group): + response = self.client.afd_endpoints.list_by_profile( + resource_group_name=resource_group.name, + profile_name="str", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_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"]}, + ).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", + ) + 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"}, + ) + + # 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..22e1f03e3e49 --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_afd_endpoints_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) Python 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_get(self, resource_group): + response = await self.client.afd_endpoints.get( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + ) + + # 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", + "id": "str", + "name": "str", + "properties": { + "autoGeneratedDomainNameLabelScope": "str", + "deploymentStatus": "str", + "enabledState": "str", + "hostName": "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", + }, + ) + ).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={ + "properties": {"enabledState": "str", "profileName": "str"}, + "tags": {"str": "str"}, + }, + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_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", + ) + ).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_by_profile(self, resource_group): + response = self.client.afd_endpoints.list_by_profile( + resource_group_name=resource_group.name, + profile_name="str", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_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"]}, + ) + ).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", + ) + 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"}, + ) + + # 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..ccfbcf8a3500 --- /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) Python 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_get(self, resource_group): + response = self.client.afd_origin_groups.get( + resource_group_name=resource_group.name, + profile_name="str", + origin_group_name="str", + ) + + # 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={ + "id": "str", + "name": "str", + "properties": { + "authentication": {"scope": "str", "type": "str", "userAssignedIdentity": {"id": "str"}}, + "deploymentStatus": "str", + "healthProbeSettings": { + "probeIntervalInSeconds": 0, + "probePath": "str", + "probeProtocol": "str", + "probeRequestType": "str", + }, + "loadBalancingSettings": { + "additionalLatencyInMilliseconds": 0, + "sampleSize": 0, + "successfulSamplesRequired": 0, + }, + "profileName": "str", + "provisioningState": "str", + "sessionAffinityState": "str", + "trafficRestorationTimeToHealedOrNewEndpointsInMinutes": 0, + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @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={ + "properties": { + "authentication": {"scope": "str", "type": "str", "userAssignedIdentity": {"id": "str"}}, + "healthProbeSettings": { + "probeIntervalInSeconds": 0, + "probePath": "str", + "probeProtocol": "str", + "probeRequestType": "str", + }, + "loadBalancingSettings": { + "additionalLatencyInMilliseconds": 0, + "sampleSize": 0, + "successfulSamplesRequired": 0, + }, + "profileName": "str", + "sessionAffinityState": "str", + "trafficRestorationTimeToHealedOrNewEndpointsInMinutes": 0, + } + }, + ).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", + ).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_by_profile(self, resource_group): + response = self.client.afd_origin_groups.list_by_profile( + resource_group_name=resource_group.name, + profile_name="str", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_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", + ) + 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..5abc00b75a42 --- /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) Python 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_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", + ) + + # 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={ + "id": "str", + "name": "str", + "properties": { + "authentication": {"scope": "str", "type": "str", "userAssignedIdentity": {"id": "str"}}, + "deploymentStatus": "str", + "healthProbeSettings": { + "probeIntervalInSeconds": 0, + "probePath": "str", + "probeProtocol": "str", + "probeRequestType": "str", + }, + "loadBalancingSettings": { + "additionalLatencyInMilliseconds": 0, + "sampleSize": 0, + "successfulSamplesRequired": 0, + }, + "profileName": "str", + "provisioningState": "str", + "sessionAffinityState": "str", + "trafficRestorationTimeToHealedOrNewEndpointsInMinutes": 0, + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @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={ + "properties": { + "authentication": {"scope": "str", "type": "str", "userAssignedIdentity": {"id": "str"}}, + "healthProbeSettings": { + "probeIntervalInSeconds": 0, + "probePath": "str", + "probeProtocol": "str", + "probeRequestType": "str", + }, + "loadBalancingSettings": { + "additionalLatencyInMilliseconds": 0, + "sampleSize": 0, + "successfulSamplesRequired": 0, + }, + "profileName": "str", + "sessionAffinityState": "str", + "trafficRestorationTimeToHealedOrNewEndpointsInMinutes": 0, + } + }, + ) + ).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", + ) + ).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_by_profile(self, resource_group): + response = self.client.afd_origin_groups.list_by_profile( + resource_group_name=resource_group.name, + profile_name="str", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_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", + ) + 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..441fba637a90 --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_afd_origins_operations.py @@ -0,0 +1,138 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python 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_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", + ) + + # 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={ + "id": "str", + "name": "str", + "properties": { + "azureOrigin": {"id": "str"}, + "deploymentStatus": "str", + "enabledState": "str", + "enforceCertificateNameCheck": bool, + "hostName": "str", + "httpPort": 0, + "httpsPort": 0, + "originGroupName": "str", + "originHostHeader": "str", + "priority": 0, + "provisioningState": "str", + "sharedPrivateLinkResource": { + "groupId": "str", + "privateLink": {"id": "str"}, + "privateLinkLocation": "str", + "requestMessage": "str", + "status": "str", + }, + "weight": 0, + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @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={ + "properties": { + "azureOrigin": {"id": "str"}, + "enabledState": "str", + "enforceCertificateNameCheck": bool, + "hostName": "str", + "httpPort": 0, + "httpsPort": 0, + "originGroupName": "str", + "originHostHeader": "str", + "priority": 0, + "sharedPrivateLinkResource": { + "groupId": "str", + "privateLink": {"id": "str"}, + "privateLinkLocation": "str", + "requestMessage": "str", + "status": "str", + }, + "weight": 0, + } + }, + ).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", + ).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_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", + ) + 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_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..ae8ef626ec8d --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_afd_origins_operations_async.py @@ -0,0 +1,145 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import 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_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", + ) + + # 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={ + "id": "str", + "name": "str", + "properties": { + "azureOrigin": {"id": "str"}, + "deploymentStatus": "str", + "enabledState": "str", + "enforceCertificateNameCheck": bool, + "hostName": "str", + "httpPort": 0, + "httpsPort": 0, + "originGroupName": "str", + "originHostHeader": "str", + "priority": 0, + "provisioningState": "str", + "sharedPrivateLinkResource": { + "groupId": "str", + "privateLink": {"id": "str"}, + "privateLinkLocation": "str", + "requestMessage": "str", + "status": "str", + }, + "weight": 0, + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @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={ + "properties": { + "azureOrigin": {"id": "str"}, + "enabledState": "str", + "enforceCertificateNameCheck": bool, + "hostName": "str", + "httpPort": 0, + "httpsPort": 0, + "originGroupName": "str", + "originHostHeader": "str", + "priority": 0, + "sharedPrivateLinkResource": { + "groupId": "str", + "privateLink": {"id": "str"}, + "privateLinkLocation": "str", + "requestMessage": "str", + "status": "str", + }, + "weight": 0, + } + }, + ) + ).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", + ) + ).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_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", + ) + 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_profiles_operations.py b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_afd_profiles_operations.py new file mode 100644 index 000000000000..6c3205e39fea --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_afd_profiles_operations.py @@ -0,0 +1,84 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import 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", + }, + ) + + # 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", + ) + 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"}, + ) + + # 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"}, + ) + + # 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"}] + }, + ).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..be5f90f645e1 --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_afd_profiles_operations_async.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) Python 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", + }, + ) + + # 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", + ) + 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"}, + ) + + # 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"}, + ) + + # 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"}] + }, + ) + ).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..9b24389d73ce --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_async.py @@ -0,0 +1,65 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import 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", + }, + ) + + # 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"}, + ) + + # 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"}, + ) + + # 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"}, + ) + + # 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..c805ced6a58b --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_custom_domains_operations.py @@ -0,0 +1,97 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import 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_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", + ) + + # 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={"properties": {"hostName": "str"}}, + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_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", + ).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_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", + ) + 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_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", + ).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", + ).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..b595d8ee1d02 --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_custom_domains_operations_async.py @@ -0,0 +1,106 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import 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_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", + ) + + # 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={"properties": {"hostName": "str"}}, + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_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", + ) + ).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_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", + ) + 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_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", + ) + ).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", + ) + ).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..b67075654b30 --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_edge_nodes_operations.py @@ -0,0 +1,27 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import 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() + 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..24e5ddeada1f --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_edge_nodes_operations_async.py @@ -0,0 +1,28 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import 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() + 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..315033af2675 --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_endpoints_operations.py @@ -0,0 +1,290 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import 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_get(self, resource_group): + response = self.client.endpoints.get( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + ) + + # 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", + "id": "str", + "name": "str", + "properties": { + "origins": [ + { + "name": "str", + "properties": { + "hostName": "str", + "enabled": bool, + "httpPort": 0, + "httpsPort": 0, + "originHostHeader": "str", + "priority": 0, + "privateEndpointStatus": "str", + "privateLinkAlias": "str", + "privateLinkApprovalMessage": "str", + "privateLinkLocation": "str", + "privateLinkResourceId": "str", + "weight": 0, + }, + } + ], + "contentTypesToCompress": ["str"], + "customDomains": [{"name": "str", "properties": {"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", + "isCompressionEnabled": bool, + "isHttpAllowed": bool, + "isHttpsAllowed": bool, + "optimizationType": "str", + "originGroups": [ + { + "name": "str", + "properties": { + "origins": [{"id": "str"}], + "healthProbeSettings": { + "probeIntervalInSeconds": 0, + "probePath": "str", + "probeProtocol": "str", + "probeRequestType": "str", + }, + "responseBasedOriginErrorDetectionSettings": { + "httpErrorRanges": [{"begin": 0, "end": 0}], + "responseBasedDetectedErrorTypes": "str", + "responseBasedFailoverThresholdPercentage": 0, + }, + "trafficRestorationTimeToHealedOrNewEndpointsInMinutes": 0, + }, + } + ], + "originHostHeader": "str", + "originPath": "str", + "probePath": "str", + "provisioningState": "str", + "queryStringCachingBehavior": "str", + "resourceState": "str", + "urlSigningKeys": [ + { + "keyId": "str", + "keySourceParameters": { + "resourceGroupName": "str", + "secretName": "str", + "secretVersion": "str", + "subscriptionId": "str", + "typeName": "str", + "vaultName": "str", + }, + } + ], + "webApplicationFirewallPolicyLink": {"id": "str"}, + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "type": "str", + }, + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_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={ + "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": bool, + "isHttpsAllowed": bool, + "optimizationType": "str", + "originHostHeader": "str", + "originPath": "str", + "probePath": "str", + "queryStringCachingBehavior": "str", + "urlSigningKeys": [ + { + "keyId": "str", + "keySourceParameters": { + "resourceGroupName": "str", + "secretName": "str", + "secretVersion": "str", + "subscriptionId": "str", + "typeName": "str", + "vaultName": "str", + }, + } + ], + "webApplicationFirewallPolicyLink": {"id": "str"}, + }, + "tags": {"str": "str"}, + }, + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_endpoints_begin_delete(self, resource_group): + response = self.client.endpoints.begin_delete( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_endpoints_list_by_profile(self, resource_group): + response = self.client.endpoints.list_by_profile( + resource_group_name=resource_group.name, + profile_name="str", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_endpoints_begin_start(self, resource_group): + response = self.client.endpoints.begin_start( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_endpoints_begin_stop(self, resource_group): + response = self.client.endpoints.begin_stop( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_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"]}, + ).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"]}, + ).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"}, + ) + + # 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", + ) + 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..bdd21c8d8923 --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_endpoints_operations_async.py @@ -0,0 +1,305 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import 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_get(self, resource_group): + response = await self.client.endpoints.get( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + ) + + # 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", + "id": "str", + "name": "str", + "properties": { + "origins": [ + { + "name": "str", + "properties": { + "hostName": "str", + "enabled": bool, + "httpPort": 0, + "httpsPort": 0, + "originHostHeader": "str", + "priority": 0, + "privateEndpointStatus": "str", + "privateLinkAlias": "str", + "privateLinkApprovalMessage": "str", + "privateLinkLocation": "str", + "privateLinkResourceId": "str", + "weight": 0, + }, + } + ], + "contentTypesToCompress": ["str"], + "customDomains": [{"name": "str", "properties": {"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", + "isCompressionEnabled": bool, + "isHttpAllowed": bool, + "isHttpsAllowed": bool, + "optimizationType": "str", + "originGroups": [ + { + "name": "str", + "properties": { + "origins": [{"id": "str"}], + "healthProbeSettings": { + "probeIntervalInSeconds": 0, + "probePath": "str", + "probeProtocol": "str", + "probeRequestType": "str", + }, + "responseBasedOriginErrorDetectionSettings": { + "httpErrorRanges": [{"begin": 0, "end": 0}], + "responseBasedDetectedErrorTypes": "str", + "responseBasedFailoverThresholdPercentage": 0, + }, + "trafficRestorationTimeToHealedOrNewEndpointsInMinutes": 0, + }, + } + ], + "originHostHeader": "str", + "originPath": "str", + "probePath": "str", + "provisioningState": "str", + "queryStringCachingBehavior": "str", + "resourceState": "str", + "urlSigningKeys": [ + { + "keyId": "str", + "keySourceParameters": { + "resourceGroupName": "str", + "secretName": "str", + "secretVersion": "str", + "subscriptionId": "str", + "typeName": "str", + "vaultName": "str", + }, + } + ], + "webApplicationFirewallPolicyLink": {"id": "str"}, + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "type": "str", + }, + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_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={ + "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": bool, + "isHttpsAllowed": bool, + "optimizationType": "str", + "originHostHeader": "str", + "originPath": "str", + "probePath": "str", + "queryStringCachingBehavior": "str", + "urlSigningKeys": [ + { + "keyId": "str", + "keySourceParameters": { + "resourceGroupName": "str", + "secretName": "str", + "secretVersion": "str", + "subscriptionId": "str", + "typeName": "str", + "vaultName": "str", + }, + } + ], + "webApplicationFirewallPolicyLink": {"id": "str"}, + }, + "tags": {"str": "str"}, + }, + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_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", + ) + ).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_list_by_profile(self, resource_group): + response = self.client.endpoints.list_by_profile( + resource_group_name=resource_group.name, + profile_name="str", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_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", + ) + ).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", + ) + ).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"]}, + ) + ).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"]}, + ) + ).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"}, + ) + + # 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", + ) + 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..1b5e277a13b7 --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_log_analytics_operations.py @@ -0,0 +1,105 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import 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"], + ) + + # 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", + ) + + # 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", + ) + + # 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", + ) + + # 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", + ) + + # 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"], + ) + + # 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..402245768fdb --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_log_analytics_operations_async.py @@ -0,0 +1,106 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import 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"], + ) + + # 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", + ) + + # 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", + ) + + # 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", + ) + + # 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", + ) + + # 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"], + ) + + # 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..c22135b92408 --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_managed_rule_sets_operations.py @@ -0,0 +1,27 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import 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() + 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..9b04dd20f54f --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_managed_rule_sets_operations_async.py @@ -0,0 +1,28 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import 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() + 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..262e13d2f4ea --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_operations.py @@ -0,0 +1,27 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import 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() + 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..8bab6751abd7 --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_operations_async.py @@ -0,0 +1,28 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import 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() + 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..5eb3dd477a85 --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_origin_groups_operations.py @@ -0,0 +1,130 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import 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_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", + ) + + # 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={ + "id": "str", + "name": "str", + "properties": { + "healthProbeSettings": { + "probeIntervalInSeconds": 0, + "probePath": "str", + "probeProtocol": "str", + "probeRequestType": "str", + }, + "origins": [{"id": "str"}], + "provisioningState": "str", + "resourceState": "str", + "responseBasedOriginErrorDetectionSettings": { + "httpErrorRanges": [{"begin": 0, "end": 0}], + "responseBasedDetectedErrorTypes": "str", + "responseBasedFailoverThresholdPercentage": 0, + }, + "trafficRestorationTimeToHealedOrNewEndpointsInMinutes": 0, + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @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={ + "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, + } + }, + ).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", + ).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_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", + ) + 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_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..4113ff2cc492 --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_origin_groups_operations_async.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) Python 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_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", + ) + + # 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={ + "id": "str", + "name": "str", + "properties": { + "healthProbeSettings": { + "probeIntervalInSeconds": 0, + "probePath": "str", + "probeProtocol": "str", + "probeRequestType": "str", + }, + "origins": [{"id": "str"}], + "provisioningState": "str", + "resourceState": "str", + "responseBasedOriginErrorDetectionSettings": { + "httpErrorRanges": [{"begin": 0, "end": 0}], + "responseBasedDetectedErrorTypes": "str", + "responseBasedFailoverThresholdPercentage": 0, + }, + "trafficRestorationTimeToHealedOrNewEndpointsInMinutes": 0, + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @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={ + "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, + } + }, + ) + ).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", + ) + ).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_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", + ) + 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_origins_operations.py b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_origins_operations.py new file mode 100644 index 000000000000..43dc381fdd24 --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_origins_operations.py @@ -0,0 +1,127 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import 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_get(self, resource_group): + response = self.client.origins.get( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + origin_name="str", + ) + + # 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={ + "id": "str", + "name": "str", + "properties": { + "hostName": "str", + "enabled": bool, + "httpPort": 0, + "httpsPort": 0, + "originHostHeader": "str", + "priority": 0, + "privateEndpointStatus": "str", + "privateLinkAlias": "str", + "privateLinkApprovalMessage": "str", + "privateLinkLocation": "str", + "privateLinkResourceId": "str", + "provisioningState": "str", + "resourceState": "str", + "weight": 0, + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @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={ + "properties": { + "enabled": bool, + "hostName": "str", + "httpPort": 0, + "httpsPort": 0, + "originHostHeader": "str", + "priority": 0, + "privateLinkAlias": "str", + "privateLinkApprovalMessage": "str", + "privateLinkLocation": "str", + "privateLinkResourceId": "str", + "weight": 0, + } + }, + ).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", + ).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_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", + ) + 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_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..4332c23c6678 --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_origins_operations_async.py @@ -0,0 +1,134 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import 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_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", + ) + + # 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={ + "id": "str", + "name": "str", + "properties": { + "hostName": "str", + "enabled": bool, + "httpPort": 0, + "httpsPort": 0, + "originHostHeader": "str", + "priority": 0, + "privateEndpointStatus": "str", + "privateLinkAlias": "str", + "privateLinkApprovalMessage": "str", + "privateLinkLocation": "str", + "privateLinkResourceId": "str", + "provisioningState": "str", + "resourceState": "str", + "weight": 0, + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @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={ + "properties": { + "enabled": bool, + "hostName": "str", + "httpPort": 0, + "httpsPort": 0, + "originHostHeader": "str", + "priority": 0, + "privateLinkAlias": "str", + "privateLinkApprovalMessage": "str", + "privateLinkLocation": "str", + "privateLinkResourceId": "str", + "weight": 0, + } + }, + ) + ).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", + ) + ).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_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", + ) + 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_policies_operations.py b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_policies_operations.py new file mode 100644 index 000000000000..8cbc8c383e56 --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_policies_operations.py @@ -0,0 +1,161 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python 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_get(self, resource_group): + response = self.client.policies.get( + resource_group_name=resource_group.name, + policy_name="str", + ) + + # 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"}, + "etag": "str", + "id": "str", + "name": "str", + "properties": { + "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"}], + "extendedProperties": {"str": "str"}, + "managedRules": { + "managedRuleSets": [ + { + "ruleSetType": "str", + "ruleSetVersion": "str", + "anomalyScore": 0, + "ruleGroupOverrides": [ + { + "ruleGroupName": "str", + "rules": [{"ruleId": "str", "action": "str", "enabledState": "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", + }, + ).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"}}, + ).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", + ) + + # please add some check logic here by yourself + # ... + + @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, + ) + 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_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..a85bff8fe91d --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_policies_operations_async.py @@ -0,0 +1,166 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import 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_get(self, resource_group): + response = await self.client.policies.get( + resource_group_name=resource_group.name, + policy_name="str", + ) + + # 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"}, + "etag": "str", + "id": "str", + "name": "str", + "properties": { + "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"}], + "extendedProperties": {"str": "str"}, + "managedRules": { + "managedRuleSets": [ + { + "ruleSetType": "str", + "ruleSetVersion": "str", + "anomalyScore": 0, + "ruleGroupOverrides": [ + { + "ruleGroupName": "str", + "rules": [{"ruleId": "str", "action": "str", "enabledState": "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", + }, + ) + ).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"}}, + ) + ).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", + ) + + # please add some check logic here by yourself + # ... + + @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, + ) + 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_profiles_operations.py b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_profiles_operations.py new file mode 100644 index 000000000000..16edfba4fbde --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_profiles_operations.py @@ -0,0 +1,245 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import 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_get(self, resource_group): + response = self.client.profiles.get( + resource_group_name=resource_group.name, + profile_name="str", + ) + + # 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"}, + "id": "str", + "identity": { + "type": "str", + "principalId": "str", + "tenantId": "str", + "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, + }, + "kind": "str", + "name": "str", + "properties": { + "extendedProperties": {"str": "str"}, + "frontDoorId": "str", + "logScrubbing": { + "scrubbingRules": [ + {"matchVariable": "str", "selectorMatchOperator": "str", "selector": "str", "state": "str"} + ], + "state": "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", + }, + ).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"}}, + }, + "properties": { + "logScrubbing": { + "scrubbingRules": [ + {"matchVariable": "str", "selectorMatchOperator": "str", "selector": "str", "state": "str"} + ], + "state": "str", + }, + "originResponseTimeoutSeconds": 0, + }, + "tags": {"str": "str"}, + }, + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_profiles_begin_delete(self, resource_group): + response = self.client.profiles.begin_delete( + resource_group_name=resource_group.name, + profile_name="str", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_profiles_list_by_resource_group(self, resource_group): + response = self.client.profiles.list_by_resource_group( + resource_group_name=resource_group.name, + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_profiles_list(self, resource_group): + response = self.client.profiles.list() + 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_migration_commit(self, resource_group): + response = self.client.profiles.begin_migration_commit( + resource_group_name=resource_group.name, + profile_name="str", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_profiles_generate_sso_uri(self, resource_group): + response = self.client.profiles.generate_sso_uri( + resource_group_name=resource_group.name, + profile_name="str", + ) + + # 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", + ) + + # 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", + ) + 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", + ).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"}], + }, + ).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", + ).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"}}, + ).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"}} + ], + }, + ).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..a659427cb524 --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_profiles_operations_async.py @@ -0,0 +1,274 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import 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_get(self, resource_group): + response = await self.client.profiles.get( + resource_group_name=resource_group.name, + profile_name="str", + ) + + # 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"}, + "id": "str", + "identity": { + "type": "str", + "principalId": "str", + "tenantId": "str", + "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, + }, + "kind": "str", + "name": "str", + "properties": { + "extendedProperties": {"str": "str"}, + "frontDoorId": "str", + "logScrubbing": { + "scrubbingRules": [ + { + "matchVariable": "str", + "selectorMatchOperator": "str", + "selector": "str", + "state": "str", + } + ], + "state": "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", + }, + ) + ).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"}}, + }, + "properties": { + "logScrubbing": { + "scrubbingRules": [ + { + "matchVariable": "str", + "selectorMatchOperator": "str", + "selector": "str", + "state": "str", + } + ], + "state": "str", + }, + "originResponseTimeoutSeconds": 0, + }, + "tags": {"str": "str"}, + }, + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_profiles_begin_delete(self, resource_group): + response = await ( + await self.client.profiles.begin_delete( + resource_group_name=resource_group.name, + profile_name="str", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_profiles_list_by_resource_group(self, resource_group): + response = self.client.profiles.list_by_resource_group( + resource_group_name=resource_group.name, + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_profiles_list(self, resource_group): + response = self.client.profiles.list() + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_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", + ) + ).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", + ) + + # 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", + ) + + # 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", + ) + 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", + ) + ).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"}], + }, + ) + ).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", + ) + ).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"}}, + ) + ).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"}} + ], + }, + ) + ).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..7e6164cd2418 --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_resource_usage_operations.py @@ -0,0 +1,27 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import 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() + 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..c7039444b736 --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_resource_usage_operations_async.py @@ -0,0 +1,28 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import 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() + 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..c3a2d8811758 --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_routes_operations.py @@ -0,0 +1,136 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import 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_get(self, resource_group): + response = self.client.routes.get( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + route_name="str", + ) + + # 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={ + "id": "str", + "name": "str", + "properties": { + "cacheConfiguration": { + "compressionSettings": {"contentTypesToCompress": ["str"], "isCompressionEnabled": bool}, + "queryParameters": "str", + "queryStringCachingBehavior": "str", + }, + "customDomains": [{"id": "str", "isActive": bool}], + "deploymentStatus": "str", + "enabledState": "str", + "endpointName": "str", + "forwardingProtocol": "str", + "httpsRedirect": "str", + "linkToDefaultDomain": "str", + "originGroup": {"id": "str"}, + "originPath": "str", + "patternsToMatch": ["str"], + "provisioningState": "str", + "ruleSets": [{"id": "str"}], + "supportedProtocols": ["str"], + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_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={ + "properties": { + "cacheConfiguration": { + "compressionSettings": {"contentTypesToCompress": ["str"], "isCompressionEnabled": bool}, + "queryParameters": "str", + "queryStringCachingBehavior": "str", + }, + "customDomains": [{"id": "str", "isActive": bool}], + "enabledState": "str", + "endpointName": "str", + "forwardingProtocol": "str", + "httpsRedirect": "str", + "linkToDefaultDomain": "str", + "originGroup": {"id": "str"}, + "originPath": "str", + "patternsToMatch": ["str"], + "ruleSets": [{"id": "str"}], + "supportedProtocols": ["str"], + } + }, + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_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", + ).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_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", + ) + 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_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..ab40f512167e --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_routes_operations_async.py @@ -0,0 +1,143 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python 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_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", + ) + + # 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={ + "id": "str", + "name": "str", + "properties": { + "cacheConfiguration": { + "compressionSettings": {"contentTypesToCompress": ["str"], "isCompressionEnabled": bool}, + "queryParameters": "str", + "queryStringCachingBehavior": "str", + }, + "customDomains": [{"id": "str", "isActive": bool}], + "deploymentStatus": "str", + "enabledState": "str", + "endpointName": "str", + "forwardingProtocol": "str", + "httpsRedirect": "str", + "linkToDefaultDomain": "str", + "originGroup": {"id": "str"}, + "originPath": "str", + "patternsToMatch": ["str"], + "provisioningState": "str", + "ruleSets": [{"id": "str"}], + "supportedProtocols": ["str"], + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_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={ + "properties": { + "cacheConfiguration": { + "compressionSettings": {"contentTypesToCompress": ["str"], "isCompressionEnabled": bool}, + "queryParameters": "str", + "queryStringCachingBehavior": "str", + }, + "customDomains": [{"id": "str", "isActive": bool}], + "enabledState": "str", + "endpointName": "str", + "forwardingProtocol": "str", + "httpsRedirect": "str", + "linkToDefaultDomain": "str", + "originGroup": {"id": "str"}, + "originPath": "str", + "patternsToMatch": ["str"], + "ruleSets": [{"id": "str"}], + "supportedProtocols": ["str"], + } + }, + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_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", + ) + ).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_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", + ) + 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_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..b2cfdec92725 --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_rule_sets_operations.py @@ -0,0 +1,78 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import 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_get(self, resource_group): + response = self.client.rule_sets.get( + resource_group_name=resource_group.name, + profile_name="str", + rule_set_name="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_rule_sets_begin_create(self, resource_group): + response = self.client.rule_sets.begin_create( + resource_group_name=resource_group.name, + profile_name="str", + rule_set_name="str", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_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", + ).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_by_profile(self, resource_group): + response = self.client.rule_sets.list_by_profile( + resource_group_name=resource_group.name, + profile_name="str", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_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", + ) + 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..a2964506eff5 --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_rule_sets_operations_async.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) Python 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_get(self, resource_group): + response = await self.client.rule_sets.get( + resource_group_name=resource_group.name, + profile_name="str", + rule_set_name="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_rule_sets_begin_create(self, resource_group): + response = await ( + await self.client.rule_sets.begin_create( + resource_group_name=resource_group.name, + profile_name="str", + rule_set_name="str", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_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", + ) + ).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_by_profile(self, resource_group): + response = self.client.rule_sets.list_by_profile( + resource_group_name=resource_group.name, + profile_name="str", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_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", + ) + 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..711df420186c --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_rules_operations.py @@ -0,0 +1,114 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import 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_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", + ) + + # 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={ + "id": "str", + "name": "str", + "properties": { + "actions": ["delivery_rule_action"], + "conditions": ["delivery_rule_condition"], + "deploymentStatus": "str", + "matchProcessingBehavior": "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", + }, + ).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={ + "properties": { + "actions": ["delivery_rule_action"], + "conditions": ["delivery_rule_condition"], + "matchProcessingBehavior": "str", + "order": 0, + "ruleSetName": "str", + } + }, + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_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", + ).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_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", + ) + 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_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..7bcab933d35f --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_rules_operations_async.py @@ -0,0 +1,121 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import 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_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", + ) + + # 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={ + "id": "str", + "name": "str", + "properties": { + "actions": ["delivery_rule_action"], + "conditions": ["delivery_rule_condition"], + "deploymentStatus": "str", + "matchProcessingBehavior": "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", + }, + ) + ).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={ + "properties": { + "actions": ["delivery_rule_action"], + "conditions": ["delivery_rule_condition"], + "matchProcessingBehavior": "str", + "order": 0, + "ruleSetName": "str", + } + }, + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_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", + ) + ).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_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", + ) + 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_secrets_operations.py b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_secrets_operations.py new file mode 100644 index 000000000000..c50f94fab3c0 --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_secrets_operations.py @@ -0,0 +1,85 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import 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_get(self, resource_group): + response = self.client.secrets.get( + resource_group_name=resource_group.name, + profile_name="str", + secret_name="str", + ) + + # 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={ + "id": "str", + "name": "str", + "properties": { + "deploymentStatus": "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", + }, + ).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", + ).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_list_by_profile(self, resource_group): + response = self.client.secrets.list_by_profile( + resource_group_name=resource_group.name, + profile_name="str", + ) + 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_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..0757eb077603 --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_secrets_operations_async.py @@ -0,0 +1,90 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import 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_get(self, resource_group): + response = await self.client.secrets.get( + resource_group_name=resource_group.name, + profile_name="str", + secret_name="str", + ) + + # 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={ + "id": "str", + "name": "str", + "properties": { + "deploymentStatus": "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", + }, + ) + ).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", + ) + ).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_list_by_profile(self, resource_group): + response = self.client.secrets.list_by_profile( + resource_group_name=resource_group.name, + profile_name="str", + ) + 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_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..6b958cbe0f69 --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_security_policies_operations.py @@ -0,0 +1,98 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import 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_get(self, resource_group): + response = self.client.security_policies.get( + resource_group_name=resource_group.name, + profile_name="str", + security_policy_name="str", + ) + + # 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={ + "id": "str", + "name": "str", + "properties": { + "deploymentStatus": "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", + }, + ).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={"properties": {"parameters": "security_policy_properties_parameters"}}, + ).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", + ).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_list_by_profile(self, resource_group): + response = self.client.security_policies.list_by_profile( + resource_group_name=resource_group.name, + profile_name="str", + ) + 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_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..130223618876 --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_security_policies_operations_async.py @@ -0,0 +1,107 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import 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_get(self, resource_group): + response = await self.client.security_policies.get( + resource_group_name=resource_group.name, + profile_name="str", + security_policy_name="str", + ) + + # 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={ + "id": "str", + "name": "str", + "properties": { + "deploymentStatus": "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", + }, + ) + ).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={ + "properties": {"parameters": "security_policy_properties_parameters"} + }, + ) + ).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", + ) + ).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_list_by_profile(self, resource_group): + response = self.client.security_policies.list_by_profile( + resource_group_name=resource_group.name, + profile_name="str", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/cdn/azure-mgmt-cdn/pyproject.toml b/sdk/cdn/azure-mgmt-cdn/pyproject.toml index 540da07d41af..aa8b0fa711d1 100644 --- a/sdk/cdn/azure-mgmt-cdn/pyproject.toml +++ b/sdk/cdn/azure-mgmt-cdn/pyproject.toml @@ -1,6 +1,87 @@ +[build-system] +requires = [ + "setuptools>=77.0.3", + "wheel", +] +build-backend = "setuptools.build_meta" + +[project] +name = "azure-mgmt-cdn" +authors = [ + { name = "Microsoft Corporation", email = "azpysdkhelp@microsoft.com" }, +] +description = "Microsoft Azure Cdn Management Client Library for Python" +license = "MIT" +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Programming Language :: Python", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", +] +requires-python = ">=3.10" +keywords = [ + "azure", + "azure sdk", +] +dependencies = [ + "isodate>=0.6.1", + "azure-mgmt-core>=1.6.0", + "typing-extensions>=4.6.0", +] +dynamic = [ + "version", + "readme", +] + +[project.urls] +repository = "https://github.com/Azure/azure-sdk-for-python" + +[tool.setuptools.dynamic.version] +attr = "azure.mgmt.cdn._version.VERSION" + +[tool.setuptools.dynamic.readme] +file = [ + "README.md", + "CHANGELOG.md", +] +content-type = "text/markdown" + +[tool.setuptools.packages.find] +exclude = [ + "tests*", + "generated_tests*", + "samples*", + "generated_samples*", + "doc*", + "azure", + "azure.mgmt", +] + +[tool.setuptools.package-data] +pytyped = [ + "py.typed", +] + [tool.azure-sdk-build] breaking = false mypy = false pyright = false type_check_samples = false verifytypes = false + +[packaging] +package_name = "azure-mgmt-cdn" +package_pprint_name = "CDN Management" +package_doc_id = "cdn" +is_stable = true +sample_link = "" +title = "CdnManagementClient" +package_nspkg = "azure-mgmt-nspkg" +is_arm = true +need_msrestazure = false +need_azuremgmtcore = true +exclude_folders = "" diff --git a/sdk/cdn/azure-mgmt-cdn/sdk_packaging.toml b/sdk/cdn/azure-mgmt-cdn/sdk_packaging.toml deleted file mode 100644 index 115bc64b3abd..000000000000 --- a/sdk/cdn/azure-mgmt-cdn/sdk_packaging.toml +++ /dev/null @@ -1,7 +0,0 @@ -[packaging] -package_name = "azure-mgmt-cdn" -package_pprint_name = "CDN Management" -package_doc_id = "cdn" -is_stable = true -sample_link = "" -title = "CdnManagementClient" diff --git a/sdk/cdn/azure-mgmt-cdn/setup.py b/sdk/cdn/azure-mgmt-cdn/setup.py deleted file mode 100644 index c0f0a3ca2878..000000000000 --- a/sdk/cdn/azure-mgmt-cdn/setup.py +++ /dev/null @@ -1,82 +0,0 @@ -#!/usr/bin/env python - -# ------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -------------------------------------------------------------------------- - -import re -import os.path -from io import open -from setuptools import find_packages, setup - -# Change the PACKAGE_NAME only to change folder and different name -PACKAGE_NAME = "azure-mgmt-cdn" -PACKAGE_PPRINT_NAME = "CDN Management" - -# a-b-c => a/b/c -package_folder_path = PACKAGE_NAME.replace("-", "/") -# a-b-c => a.b.c -namespace_name = PACKAGE_NAME.replace("-", ".") - -# Version extraction inspired from 'requests' -with open( - os.path.join(package_folder_path, "version.py") - if os.path.exists(os.path.join(package_folder_path, "version.py")) - else os.path.join(package_folder_path, "_version.py"), - "r", -) as fd: - version = re.search(r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]', fd.read(), re.MULTILINE).group(1) - -if not version: - raise RuntimeError("Cannot find version information") - -with open("README.md", encoding="utf-8") as f: - readme = f.read() -with open("CHANGELOG.md", encoding="utf-8") as f: - changelog = f.read() - -setup( - name=PACKAGE_NAME, - version=version, - description="Microsoft Azure {} Client Library for Python".format(PACKAGE_PPRINT_NAME), - long_description=readme + "\n\n" + changelog, - long_description_content_type="text/markdown", - license="MIT License", - author="Microsoft Corporation", - author_email="azpysdkhelp@microsoft.com", - url="https://github.com/Azure/azure-sdk-for-python", - keywords="azure, azure sdk", # update with search keywords relevant to the azure service / product - classifiers=[ - "Development Status :: 5 - Production/Stable", - "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", - "Programming Language :: Python :: 3.12", - "License :: OSI Approved :: MIT License", - ], - zip_safe=False, - packages=find_packages( - exclude=[ - "tests", - # Exclude packages that will be covered by PEP420 or nspkg - "azure", - "azure.mgmt", - ] - ), - include_package_data=True, - package_data={ - "pytyped": ["py.typed"], - }, - install_requires=[ - "isodate>=0.6.1", - "azure-common>=1.1", - "azure-mgmt-core>=1.3.2", - ], - python_requires=">=3.8", -) diff --git a/sdk/cdn/azure-mgmt-cdn/tests/conftest.py b/sdk/cdn/azure-mgmt-cdn/tests/conftest.py index e7981d635f56..8c0bebb9a45c 100644 --- a/sdk/cdn/azure-mgmt-cdn/tests/conftest.py +++ b/sdk/cdn/azure-mgmt-cdn/tests/conftest.py @@ -40,6 +40,7 @@ load_dotenv() + @pytest.fixture(scope="session", autouse=True) def add_sanitizers(test_proxy): subscription_id = os.environ.get("AZURE_SUBSCRIPTION_ID", "00000000-0000-0000-0000-000000000000") @@ -52,4 +53,4 @@ def add_sanitizers(test_proxy): add_general_regex_sanitizer(regex=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") \ No newline at end of file + add_body_key_sanitizer(json_path="$..access_token", value="access_token") diff --git a/sdk/cdn/azure-mgmt-cdn/tests/disable_test_cli_mgmt_cdn.py b/sdk/cdn/azure-mgmt-cdn/tests/disable_test_cli_mgmt_cdn.py index afc378569c94..393ce398225f 100644 --- a/sdk/cdn/azure-mgmt-cdn/tests/disable_test_cli_mgmt_cdn.py +++ b/sdk/cdn/azure-mgmt-cdn/tests/disable_test_cli_mgmt_cdn.py @@ -1,10 +1,11 @@ +# pylint: disable=line-too-long,useless-suppression # coding: utf-8 -#------------------------------------------------------------------------- +# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for # license information. -#-------------------------------------------------------------------------- +# -------------------------------------------------------------------------- # TEST SCENARIO COVERAGE @@ -22,15 +23,14 @@ import azure.mgmt.cdn from devtools_testutils import AzureMgmtRecordedTestCase, ResourceGroupPreparer, recorded_by_proxy -AZURE_LOCATION = 'eastus' +AZURE_LOCATION = "eastus" + class TestMgmtCdn(AzureMgmtRecordedTestCase): def setup_method(self, method): - self.mgmt_client = self.create_mgmt_client( - azure.mgmt.cdn.CdnManagementClient - ) - + self.mgmt_client = self.create_mgmt_client(azure.mgmt.cdn.CdnManagementClient) + @ResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_cdn(self, resource_group): @@ -48,12 +48,7 @@ def test_cdn(self, resource_group): ORIGIN_NAME = "origin1" # Profiles_Create[put] - BODY = { - "location": "WestUs", - "sku": { - "name": "Standard_Verizon" - } - } + BODY = {"location": "WestUs", "sku": {"name": "Standard_Verizon"}} result = self.mgmt_client.profiles.begin_create(resource_group.name, PROFILE_NAME, BODY) result = result.result() @@ -169,81 +164,71 @@ def test_cdn(self, resource_group): # Endpoints_Create[put] BODY = { - "origin_host_header": "www.bing.com", - "origin_path": "/image", - "content_types_to_compress": [ - "text/html", - "application/octet-stream" - ], - "is_compression_enabled": True, - "is_http_allowed": True, - "is_https_allowed": True, - "query_string_caching_behavior": "BypassCaching", - # "delivery_policy": { - # "description": "Test description for a policy.", - # "rules": [ - # { - # "name": "rule1", - # "order": "1", - # "conditions": [ - # { - # "name": "RemoteAddress", - # "parameters": { - # "operator": "IPMatch", - # "negate_condition": True, - # "match_values": [ - # "192.168.1.0/24", - # "10.0.0.0/24" - # ], - # "@odata.type": "#Microsoft.Azure.Cdn.Models.DeliveryRuleRemoteAddressConditionParameters" - # } - # } - # ], - # "actions": [ - # { - # "name": "CacheExpiration", - # "parameters": { - # "cache_behavior": "Override", - # "cache_duration": "10:10:09", - # "@odata.type": "#Microsoft.Azure.Cdn.Models.DeliveryRuleCacheExpirationActionParameters", - # "cache_type": "All" - # } - # }, - # { - # "name": "ModifyResponseHeader", - # "parameters": { - # "header_action": "Overwrite", - # "header_name": "Access-Control-Allow-Origin", - # "value": "*", - # "@odata.type": "#Microsoft.Azure.Cdn.Models.DeliveryRuleHeaderActionParameters" - # } - # }, - # { - # "name": "ModifyRequestHeader", - # "parameters": { - # "header_action": "Overwrite", - # "header_name": "Accept-Encoding", - # "value": "gzip", - # "@odata.type": "#Microsoft.Azure.Cdn.Models.DeliveryRuleHeaderActionParameters" - # } - # } - # ] - # } - # ] - # }, - "origins": [ - { - "name": "origin1", - "host_name": "host1.hello.com" - } - ], - # "web_application_firewall_policy_link": { - # "id": "/subscriptions/" + SUBSCRIPTION_ID + "/resourceGroups/" + RESOURCE_GROUP + "/providers/Microsoft.Cdn/CdnWebApplicationFirewallPolicies/" + CDN_WEB_APPLICATION_FIREWALL_POLICY_NAME + "" - # }, - "location": "WestUs", - "tags": { - "kay1": "value1" - } + "origin_host_header": "www.bing.com", + "origin_path": "/image", + "content_types_to_compress": ["text/html", "application/octet-stream"], + "is_compression_enabled": True, + "is_http_allowed": True, + "is_https_allowed": True, + "query_string_caching_behavior": "BypassCaching", + # "delivery_policy": { + # "description": "Test description for a policy.", + # "rules": [ + # { + # "name": "rule1", + # "order": "1", + # "conditions": [ + # { + # "name": "RemoteAddress", + # "parameters": { + # "operator": "IPMatch", + # "negate_condition": True, + # "match_values": [ + # "192.168.1.0/24", + # "10.0.0.0/24" + # ], + # "@odata.type": "#Microsoft.Azure.Cdn.Models.DeliveryRuleRemoteAddressConditionParameters" + # } + # } + # ], + # "actions": [ + # { + # "name": "CacheExpiration", + # "parameters": { + # "cache_behavior": "Override", + # "cache_duration": "10:10:09", + # "@odata.type": "#Microsoft.Azure.Cdn.Models.DeliveryRuleCacheExpirationActionParameters", + # "cache_type": "All" + # } + # }, + # { + # "name": "ModifyResponseHeader", + # "parameters": { + # "header_action": "Overwrite", + # "header_name": "Access-Control-Allow-Origin", + # "value": "*", + # "@odata.type": "#Microsoft.Azure.Cdn.Models.DeliveryRuleHeaderActionParameters" + # } + # }, + # { + # "name": "ModifyRequestHeader", + # "parameters": { + # "header_action": "Overwrite", + # "header_name": "Accept-Encoding", + # "value": "gzip", + # "@odata.type": "#Microsoft.Azure.Cdn.Models.DeliveryRuleHeaderActionParameters" + # } + # } + # ] + # } + # ] + # }, + "origins": [{"name": "origin1", "host_name": "host1.hello.com"}], + # "web_application_firewall_policy_link": { + # "id": "/subscriptions/" + SUBSCRIPTION_ID + "/resourceGroups/" + RESOURCE_GROUP + "/providers/Microsoft.Cdn/CdnWebApplicationFirewallPolicies/" + CDN_WEB_APPLICATION_FIREWALL_POLICY_NAME + "" + # }, + "location": "WestUs", + "tags": {"kay1": "value1"}, } result = self.mgmt_client.endpoints.begin_create(resource_group.name, PROFILE_NAME, ENDPOINT_NAME, BODY) result = result.result() @@ -336,11 +321,10 @@ def test_cdn(self, resource_group): """ # Origins_Update[patch] - BODY = { - "http_port": "42", - "https_port": "43" - } - result = self.mgmt_client.origins.begin_update(resource_group.name, PROFILE_NAME, ENDPOINT_NAME, ORIGIN_NAME, BODY) + BODY = {"http_port": "42", "https_port": "43"} + result = self.mgmt_client.origins.begin_update( + resource_group.name, PROFILE_NAME, ENDPOINT_NAME, ORIGIN_NAME, BODY + ) result = result.result() """ @@ -454,21 +438,17 @@ def test_cdn(self, resource_group): """ # Endpoints_ValidateCustomDomain[post] - BODY = { - "host_name": "www.someDomain.com" - } + BODY = {"host_name": "www.someDomain.com"} # HOST_NAME = "www.someDomain.com" - result = self.mgmt_client.endpoints.validate_custom_domain(resource_group.name, PROFILE_NAME, ENDPOINT_NAME, BODY) + result = self.mgmt_client.endpoints.validate_custom_domain( + resource_group.name, PROFILE_NAME, ENDPOINT_NAME, BODY + ) # Endpoints_ListResourceUsage[post] result = self.mgmt_client.endpoints.list_resource_usage(resource_group.name, PROFILE_NAME, ENDPOINT_NAME) # Endpoints_PurgeContent[post] - BODY = { - "content_paths": [ - "/folder1" - ] - } + BODY = {"content_paths": ["/folder1"]} # CONTENT_PATHS = ["/folder1"] result = self.mgmt_client.endpoints.begin_purge_content(resource_group.name, PROFILE_NAME, ENDPOINT_NAME, BODY) result = result.result() @@ -482,11 +462,7 @@ def test_cdn(self, resource_group): result = result.result() # Endpoints_LoadContent[post] - BODY = { - "content_paths": [ - "/folder1" - ] - } + BODY = {"content_paths": ["/folder1"]} # CONTENT_PATHS = ["/folder1"] result = self.mgmt_client.endpoints.begin_load_content(resource_group.name, PROFILE_NAME, ENDPOINT_NAME, BODY) result = result.result() @@ -496,12 +472,10 @@ def test_cdn(self, resource_group): # Endpoints_Update[patch] BODY = { - "tags": { - "additional_properties": "Tag1" - }, - # "web_application_firewall_policy_link": { - # "id": "/subscriptions/" + SUBSCRIPTION_ID + "/resourceGroups/" + RESOURCE_GROUP + "/providers/Microsoft.Cdn/CdnWebApplicationFirewallPolicies/" + CDN_WEB_APPLICATION_FIREWALL_POLICY_NAME + "" - # } + "tags": {"additional_properties": "Tag1"}, + # "web_application_firewall_policy_link": { + # "id": "/subscriptions/" + SUBSCRIPTION_ID + "/resourceGroups/" + RESOURCE_GROUP + "/providers/Microsoft.Cdn/CdnWebApplicationFirewallPolicies/" + CDN_WEB_APPLICATION_FIREWALL_POLICY_NAME + "" + # } } result = self.mgmt_client.endpoints.begin_update(resource_group.name, PROFILE_NAME, ENDPOINT_NAME, BODY) result = result.result() @@ -513,19 +487,12 @@ def test_cdn(self, resource_group): result = self.mgmt_client.profiles.generate_sso_uri(resource_group.name, PROFILE_NAME) # Profiles_Update[patch] - BODY = { - "tags": { - "additional_properties": "Tag1" - } - } + BODY = {"tags": {"additional_properties": "Tag1"}} result = self.mgmt_client.profiles.begin_update(resource_group.name, PROFILE_NAME, BODY) result = result.result() # CheckNameAvailabilityWithSubscription[post] - BODY = { - "name": "sampleName", - "type": "Microsoft.Cdn/Profiles/Endpoints" - } + BODY = {"name": "sampleName", "type": "Microsoft.Cdn/Profiles/Endpoints"} # CHECK_NAME = "sampleName" result = self.mgmt_client.check_name_availability_with_subscription(BODY) @@ -533,22 +500,19 @@ def test_cdn(self, resource_group): result = self.mgmt_client.resource_usage.list() # ValidateProbe[post] - BODY = { - "probe_url": "https://www.bing.com/image" - } + BODY = {"probe_url": "https://www.bing.com/image"} # PROBEURL = "https://www.bing.com/image" result = self.mgmt_client.validate_probe(BODY) # CheckNameAvailability[post] - BODY = { - "name": "sampleName", - "type": "Microsoft.Cdn/Profiles/Endpoints" - } + BODY = {"name": "sampleName", "type": "Microsoft.Cdn/Profiles/Endpoints"} # CHECKNAME = "sampleName" result = self.mgmt_client.check_name_availability(BODY) # CustomDomains_Delete[delete] - result = self.mgmt_client.custom_domains.begin_delete(resource_group.name, PROFILE_NAME, ENDPOINT_NAME, CUSTOM_DOMAIN_NAME) + result = self.mgmt_client.custom_domains.begin_delete( + resource_group.name, PROFILE_NAME, ENDPOINT_NAME, CUSTOM_DOMAIN_NAME + ) result = result.result() """ @@ -565,6 +529,6 @@ def test_cdn(self, resource_group): result = result.result() -#------------------------------------------------------------------------------ -if __name__ == '__main__': +# ------------------------------------------------------------------------------ +if __name__ == "__main__": unittest.main() diff --git a/sdk/cdn/azure-mgmt-cdn/tsp-location.yaml b/sdk/cdn/azure-mgmt-cdn/tsp-location.yaml new file mode 100644 index 000000000000..98e17aaed5ae --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/tsp-location.yaml @@ -0,0 +1,4 @@ +directory: specification/cdn/resource-manager/Microsoft.Cdn/Cdn +commit: 2283827e2d3992938b814e5b23b6b288093423d5 +repo: Azure/azure-rest-api-specs +additionalDirectories: From fbb126fea607c89c09b92b989f3b7c8c3642b116 Mon Sep 17 00:00:00 2001 From: Yuchao Yan Date: Wed, 20 May 2026 11:08:25 +0800 Subject: [PATCH 2/3] Optimize changelog for azure-mgmt-cdn Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- sdk/cdn/azure-mgmt-cdn/CHANGELOG.md | 281 ++++------------------------ 1 file changed, 40 insertions(+), 241 deletions(-) diff --git a/sdk/cdn/azure-mgmt-cdn/CHANGELOG.md b/sdk/cdn/azure-mgmt-cdn/CHANGELOG.md index 5ae4379974e0..63968212ad85 100644 --- a/sdk/cdn/azure-mgmt-cdn/CHANGELOG.md +++ b/sdk/cdn/azure-mgmt-cdn/CHANGELOG.md @@ -6,42 +6,23 @@ - Client `CdnManagementClient` added parameter `cloud_setting` in method `__init__` - Client `CdnManagementClient` added method `send_request` - - Model `AFDDomain` added property `properties` - Model `AFDDomainHttpsParameters` added property `cipher_suite_set_type` - Model `AFDDomainHttpsParameters` added property `customized_cipher_suite_set` - - Model `AFDEndpoint` added property `properties` - - Model `AFDEndpointUpdateParameters` added property `properties` - - Model `AFDOrigin` added property `properties` - - Model `AFDOriginGroup` added property `properties` - Model `AFDOriginGroupProperties` added property `authentication` - Model `AFDOriginGroupUpdatePropertiesParameters` added property `authentication` - Enum `AfdMinimumTlsVersion` added member `TLS13` - - Model `CanMigrateResult` added property `properties` - - Model `Endpoint` added property `properties` - - Model `EndpointUpdateParameters` added property `properties` - Enum `MatchProcessingBehavior` added member `CONTINUE` - - Model `Operation` added property `operation_properties` - - Model `Origin` added property `properties` - - Model `OriginGroup` added property `properties` - - Model `ProfileUpdateParameters` added property `properties` - - Model `Route` added property `properties` - - Model `Rule` added property `properties` - - Model `RuleSet` added property `properties` - Model `RuleSetProperties` added property `batch_mode` - Model `RuleSetProperties` added property `rules` - - Model `Secret` added property `properties` - - Model `SecurityPolicy` added property `properties` - Added model `AFDDomainHttpsCustomizedCipherSuiteSet` - Added enum `AfdCipherSuiteSetType` - Added enum `AfdCustomizedCipherSuiteForTls12` - Added enum `AfdCustomizedCipherSuiteForTls13` - Added model `BatchRuleProperties` - - Added model `CanMigrateProperties` - Added model `CdnMigrationToAfdParameters` - Added model `CertificateSourceParameters` - Added enum `CertificateSourceParametersType` - Added enum `CreatedByType` - - Added model `CustomDomainPropertiesParameters` - Added enum `DeliveryRuleActionName` - Added model `DeliveryRuleActionParameters` - Added enum `DeliveryRuleActionParametersType` @@ -50,211 +31,51 @@ - Added enum `IsDeviceMatchValue` - Added enum `KeyVaultSigningKeyParametersType` - Added model `MigrationEndpointMapping` - - Added model `OperationProperties` - Added model `OriginAuthenticationProperties` - Added enum `OriginAuthenticationType` - - Added model `ProfilePropertiesUpdateParameters` - Added enum `RequestMethodMatchValue` - Added enum `RequestSchemeMatchValue` - - Added model `SecurityPolicyUpdateProperties` - - 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` - - Model `RuleSetsOperations` added method `begin_create` + - Operation group `ProfilesOperations` added method `begin_cdn_can_migrate_to_afd` + - Operation group `ProfilesOperations` added method `begin_cdn_migrate_to_afd` + - Operation group `ProfilesOperations` added method `begin_migration_abort` + - Operation group `RuleSetsOperations` added method `begin_create` ### Breaking Changes - - Model `AFDDomain` deleted or renamed its instance variable `profile_name` - - Model `AFDDomain` deleted or renamed its instance variable `tls_settings` - - Model `AFDDomain` deleted or renamed its instance variable `azure_dns_zone` - - Model `AFDDomain` deleted or renamed its instance variable `pre_validated_custom_domain_resource_id` - - Model `AFDDomain` deleted or renamed its instance variable `provisioning_state` - - Model `AFDDomain` deleted or renamed its instance variable `deployment_status` - - Model `AFDDomain` deleted or renamed its instance variable `domain_validation_state` - - Model `AFDDomain` deleted or renamed its instance variable `host_name` - - Model `AFDDomain` deleted or renamed its instance variable `extended_properties` - - Model `AFDDomain` deleted or renamed its instance variable `validation_properties` - - Model `AFDDomainUpdateParameters` deleted or renamed its instance variable `profile_name` - - Model `AFDDomainUpdateParameters` deleted or renamed its instance variable `tls_settings` - - Model `AFDDomainUpdateParameters` deleted or renamed its instance variable `azure_dns_zone` - - Model `AFDDomainUpdateParameters` deleted or renamed its instance variable `pre_validated_custom_domain_resource_id` - - Model `AFDEndpoint` deleted or renamed its instance variable `profile_name` - - Model `AFDEndpoint` deleted or renamed its instance variable `enabled_state` - - Model `AFDEndpoint` deleted or renamed its instance variable `provisioning_state` - - Model `AFDEndpoint` deleted or renamed its instance variable `deployment_status` - - Model `AFDEndpoint` deleted or renamed its instance variable `host_name` - - Model `AFDEndpoint` deleted or renamed its instance variable `auto_generated_domain_name_label_scope` - - Model `AFDEndpointUpdateParameters` deleted or renamed its instance variable `profile_name` - - Model `AFDEndpointUpdateParameters` deleted or renamed its instance variable `enabled_state` - - Model `AFDOrigin` deleted or renamed its instance variable `origin_group_name` - - Model `AFDOrigin` deleted or renamed its instance variable `azure_origin` - - Model `AFDOrigin` deleted or renamed its instance variable `host_name` - - Model `AFDOrigin` deleted or renamed its instance variable `http_port` - - Model `AFDOrigin` deleted or renamed its instance variable `https_port` - - Model `AFDOrigin` deleted or renamed its instance variable `origin_host_header` - - Model `AFDOrigin` deleted or renamed its instance variable `priority` - - Model `AFDOrigin` deleted or renamed its instance variable `weight` - - Model `AFDOrigin` deleted or renamed its instance variable `shared_private_link_resource` - - Model `AFDOrigin` deleted or renamed its instance variable `enabled_state` - - Model `AFDOrigin` deleted or renamed its instance variable `enforce_certificate_name_check` - - Model `AFDOrigin` deleted or renamed its instance variable `provisioning_state` - - Model `AFDOrigin` deleted or renamed its instance variable `deployment_status` - - Model `AFDOriginGroup` deleted or renamed its instance variable `profile_name` - - Model `AFDOriginGroup` deleted or renamed its instance variable `load_balancing_settings` - - Model `AFDOriginGroup` deleted or renamed its instance variable `health_probe_settings` - - Model `AFDOriginGroup` deleted or renamed its instance variable `traffic_restoration_time_to_healed_or_new_endpoints_in_minutes` - - Model `AFDOriginGroup` deleted or renamed its instance variable `session_affinity_state` - - Model `AFDOriginGroup` deleted or renamed its instance variable `provisioning_state` - - Model `AFDOriginGroup` deleted or renamed its instance variable `deployment_status` - - Model `AFDOriginGroupUpdateParameters` deleted or renamed its instance variable `profile_name` - - Model `AFDOriginGroupUpdateParameters` deleted or renamed its instance variable `load_balancing_settings` - - Model `AFDOriginGroupUpdateParameters` deleted or renamed its instance variable `health_probe_settings` - - Model `AFDOriginGroupUpdateParameters` deleted or renamed its instance variable `traffic_restoration_time_to_healed_or_new_endpoints_in_minutes` - - Model `AFDOriginGroupUpdateParameters` deleted or renamed its instance variable `session_affinity_state` - - Model `AFDOriginUpdateParameters` deleted or renamed its instance variable `origin_group_name` - - Model `AFDOriginUpdateParameters` deleted or renamed its instance variable `azure_origin` - - Model `AFDOriginUpdateParameters` deleted or renamed its instance variable `host_name` - - Model `AFDOriginUpdateParameters` deleted or renamed its instance variable `http_port` - - Model `AFDOriginUpdateParameters` deleted or renamed its instance variable `https_port` - - Model `AFDOriginUpdateParameters` deleted or renamed its instance variable `origin_host_header` - - Model `AFDOriginUpdateParameters` deleted or renamed its instance variable `priority` - - Model `AFDOriginUpdateParameters` deleted or renamed its instance variable `weight` - - Model `AFDOriginUpdateParameters` deleted or renamed its instance variable `shared_private_link_resource` - - Model `AFDOriginUpdateParameters` deleted or renamed its instance variable `enabled_state` - - Model `AFDOriginUpdateParameters` deleted or renamed its instance variable `enforce_certificate_name_check` - - Model `CanMigrateResult` deleted or renamed its instance variable `can_migrate` - - Model `CanMigrateResult` deleted or renamed its instance variable `default_sku` - - Model `CanMigrateResult` deleted or renamed its instance variable `errors` - - Model `CustomDomainParameters` deleted or renamed its instance variable `host_name` - - Model `Endpoint` deleted or renamed its instance variable `origin_path` - - Model `Endpoint` deleted or renamed its instance variable `content_types_to_compress` - - Model `Endpoint` deleted or renamed its instance variable `origin_host_header` - - Model `Endpoint` deleted or renamed its instance variable `is_compression_enabled` - - Model `Endpoint` deleted or renamed its instance variable `is_http_allowed` - - Model `Endpoint` deleted or renamed its instance variable `is_https_allowed` - - Model `Endpoint` deleted or renamed its instance variable `query_string_caching_behavior` - - Model `Endpoint` deleted or renamed its instance variable `optimization_type` - - Model `Endpoint` deleted or renamed its instance variable `probe_path` - - Model `Endpoint` deleted or renamed its instance variable `geo_filters` - - Model `Endpoint` deleted or renamed its instance variable `default_origin_group` - - Model `Endpoint` deleted or renamed its instance variable `url_signing_keys` - - Model `Endpoint` deleted or renamed its instance variable `delivery_policy` - - Model `Endpoint` deleted or renamed its instance variable `web_application_firewall_policy_link` - - Model `Endpoint` deleted or renamed its instance variable `host_name` - - Model `Endpoint` deleted or renamed its instance variable `origins` - - Model `Endpoint` deleted or renamed its instance variable `origin_groups` - - Model `Endpoint` deleted or renamed its instance variable `custom_domains` - - Model `Endpoint` deleted or renamed its instance variable `resource_state` - - Model `Endpoint` deleted or renamed its instance variable `provisioning_state` - - Model `EndpointUpdateParameters` deleted or renamed its instance variable `origin_path` - - Model `EndpointUpdateParameters` deleted or renamed its instance variable `content_types_to_compress` - - Model `EndpointUpdateParameters` deleted or renamed its instance variable `origin_host_header` - - Model `EndpointUpdateParameters` deleted or renamed its instance variable `is_compression_enabled` - - Model `EndpointUpdateParameters` deleted or renamed its instance variable `is_http_allowed` - - Model `EndpointUpdateParameters` deleted or renamed its instance variable `is_https_allowed` - - Model `EndpointUpdateParameters` deleted or renamed its instance variable `query_string_caching_behavior` - - Model `EndpointUpdateParameters` deleted or renamed its instance variable `optimization_type` - - Model `EndpointUpdateParameters` deleted or renamed its instance variable `probe_path` - - Model `EndpointUpdateParameters` deleted or renamed its instance variable `geo_filters` - - Model `EndpointUpdateParameters` deleted or renamed its instance variable `default_origin_group` - - Model `EndpointUpdateParameters` deleted or renamed its instance variable `url_signing_keys` - - Model `EndpointUpdateParameters` deleted or renamed its instance variable `delivery_policy` - - Model `EndpointUpdateParameters` deleted or renamed its instance variable `web_application_firewall_policy_link` + - This version introduces new hybrid models which have dual dictionary and model nature. Please follow https://aka.ms/azsdk/python/migrate/hybrid-models for migration. + - For the method breakings, please refer to https://aka.ms/azsdk/python/migrate/operations for migration. + - Model `AFDDomain` moved instance variable `profile_name`, `tls_settings`, `azure_dns_zone`, `pre_validated_custom_domain_resource_id`, `provisioning_state`, `deployment_status`, `domain_validation_state`, `host_name`, `extended_properties` and `validation_properties` under property `properties` whose type is `AFDDomainProperties` + - Model `AFDDomainUpdateParameters` moved instance variable `profile_name`, `tls_settings`, `azure_dns_zone` and `pre_validated_custom_domain_resource_id` under property `properties` whose type is `AFDDomainUpdatePropertiesParameters` + - Model `AFDEndpoint` moved instance variable `profile_name`, `enabled_state`, `provisioning_state`, `deployment_status`, `host_name` and `auto_generated_domain_name_label_scope` under property `properties` whose type is `AFDEndpointProperties` + - Model `AFDEndpointUpdateParameters` moved instance variable `profile_name` and `enabled_state` under property `properties` whose type is `AFDEndpointPropertiesUpdateParameters` + - Model `AFDOrigin` moved instance variable `origin_group_name`, `azure_origin`, `host_name`, `http_port`, `https_port`, `origin_host_header`, `priority`, `weight`, `shared_private_link_resource`, `enabled_state`, `enforce_certificate_name_check`, `provisioning_state` and `deployment_status` under property `properties` whose type is `AFDOriginProperties` + - Model `AFDOriginGroup` moved instance variable `profile_name`, `load_balancing_settings`, `health_probe_settings`, `traffic_restoration_time_to_healed_or_new_endpoints_in_minutes`, `session_affinity_state`, `provisioning_state` and `deployment_status` under property `properties` whose type is `AFDOriginGroupProperties` + - Model `AFDOriginGroupUpdateParameters` moved instance variable `profile_name`, `load_balancing_settings`, `health_probe_settings`, `traffic_restoration_time_to_healed_or_new_endpoints_in_minutes` and `session_affinity_state` under property `properties` whose type is `AFDOriginGroupUpdatePropertiesParameters` + - Model `AFDOriginUpdateParameters` moved instance variable `origin_group_name`, `azure_origin`, `host_name`, `http_port`, `https_port`, `origin_host_header`, `priority`, `weight`, `shared_private_link_resource`, `enabled_state` and `enforce_certificate_name_check` under property `properties` whose type is `AFDOriginUpdatePropertiesParameters` + - Model `CanMigrateResult` moved instance variable `can_migrate`, `default_sku` and `errors` under property `properties` whose type is `CanMigrateProperties` + - Model `CustomDomainParameters` moved instance variable `host_name` under property `properties` whose type is `CustomDomainPropertiesParameters` + - Model `Endpoint` moved instance variable `origin_path`, `content_types_to_compress`, `origin_host_header`, `is_compression_enabled`, `is_http_allowed`, `is_https_allowed`, `query_string_caching_behavior`, `optimization_type`, `probe_path`, `geo_filters`, `default_origin_group`, `url_signing_keys`, `delivery_policy`, `web_application_firewall_policy_link`, `host_name`, `origins`, `origin_groups`, `custom_domains`, `resource_state` and `provisioning_state` under property `properties` whose type is `EndpointProperties` + - Model `EndpointUpdateParameters` moved instance variable `origin_path`, `content_types_to_compress`, `origin_host_header`, `is_compression_enabled`, `is_http_allowed`, `is_https_allowed`, `query_string_caching_behavior`, `optimization_type`, `probe_path`, `geo_filters`, `default_origin_group`, `url_signing_keys`, `delivery_policy` and `web_application_firewall_policy_link` under property `properties` whose type is `EndpointPropertiesUpdateParameters` + - Model `Operation` moved instance variable `service_specification` under property `operation_properties` whose type is `OperationProperties` + - Model `Origin` moved instance variable `host_name`, `http_port`, `https_port`, `origin_host_header`, `priority`, `weight`, `enabled`, `private_link_alias`, `private_link_resource_id`, `private_link_location`, `private_link_approval_message`, `resource_state`, `provisioning_state` and `private_endpoint_status` under property `properties` whose type is `OriginProperties` + - Model `OriginGroup` moved instance variable `health_probe_settings`, `origins`, `traffic_restoration_time_to_healed_or_new_endpoints_in_minutes`, `response_based_origin_error_detection_settings`, `resource_state` and `provisioning_state` under property `properties` whose type is `OriginGroupProperties` + - Model `OriginGroupUpdateParameters` moved instance variable `health_probe_settings`, `origins`, `traffic_restoration_time_to_healed_or_new_endpoints_in_minutes` and `response_based_origin_error_detection_settings` under property `properties` whose type is `OriginGroupUpdatePropertiesParameters` + - Model `OriginUpdateParameters` moved instance variable `host_name`, `http_port`, `https_port`, `origin_host_header`, `priority`, `weight`, `enabled`, `private_link_alias`, `private_link_resource_id`, `private_link_location` and `private_link_approval_message` under property `properties` whose type is `OriginUpdatePropertiesParameters` + - Model `ProfileUpdateParameters` moved instance variable `origin_response_timeout_seconds` and `log_scrubbing` under property `properties` whose type is `ProfilePropertiesUpdateParameters` + - Model `Route` moved instance variable `endpoint_name`, `custom_domains`, `origin_group`, `origin_path`, `rule_sets`, `supported_protocols`, `patterns_to_match`, `cache_configuration`, `forwarding_protocol`, `link_to_default_domain`, `https_redirect`, `enabled_state`, `provisioning_state` and `deployment_status` under property `properties` whose type is `RouteProperties` + - Model `RouteUpdateParameters` moved instance variable `endpoint_name`, `custom_domains`, `origin_group`, `origin_path`, `rule_sets`, `supported_protocols`, `patterns_to_match`, `cache_configuration`, `forwarding_protocol`, `link_to_default_domain`, `https_redirect` and `enabled_state` under property `properties` whose type is `RouteUpdatePropertiesParameters` + - Model `Rule` moved instance variable `rule_set_name`, `order`, `conditions`, `actions`, `match_processing_behavior`, `provisioning_state` and `deployment_status` under property `properties` whose type is `RuleProperties` + - Model `RuleSet` moved instance variable `provisioning_state`, `deployment_status` and `profile_name` under property `properties` whose type is `RuleSetProperties` + - Model `RuleUpdateParameters` moved instance variable `rule_set_name`, `order`, `conditions`, `actions` and `match_processing_behavior` under property `properties` whose type is `RuleUpdatePropertiesParameters` + - Model `Secret` moved instance variable `provisioning_state`, `deployment_status`, `profile_name` and `parameters` under property `properties` whose type is `SecretProperties` + - Model `SecurityPolicy` moved instance variable `provisioning_state`, `deployment_status`, `profile_name` and `parameters` under property `properties` whose type is `SecurityPolicyProperties` + - Model `SecurityPolicyUpdateParameters` moved instance variable `parameters` under property `properties` whose type is `SecurityPolicyUpdateProperties` - Deleted or renamed enum value `MatchProcessingBehavior.CONTINUE_ENUM` - - Model `Operation` deleted or renamed its instance variable `service_specification` - - Model `Origin` deleted or renamed its instance variable `host_name` - - Model `Origin` deleted or renamed its instance variable `http_port` - - Model `Origin` deleted or renamed its instance variable `https_port` - - Model `Origin` deleted or renamed its instance variable `origin_host_header` - - Model `Origin` deleted or renamed its instance variable `priority` - - Model `Origin` deleted or renamed its instance variable `weight` - - Model `Origin` deleted or renamed its instance variable `enabled` - - Model `Origin` deleted or renamed its instance variable `private_link_alias` - - Model `Origin` deleted or renamed its instance variable `private_link_resource_id` - - Model `Origin` deleted or renamed its instance variable `private_link_location` - - Model `Origin` deleted or renamed its instance variable `private_link_approval_message` - - Model `Origin` deleted or renamed its instance variable `resource_state` - - Model `Origin` deleted or renamed its instance variable `provisioning_state` - - Model `Origin` deleted or renamed its instance variable `private_endpoint_status` - - Model `OriginGroup` deleted or renamed its instance variable `health_probe_settings` - - Model `OriginGroup` deleted or renamed its instance variable `origins` - - Model `OriginGroup` deleted or renamed its instance variable `traffic_restoration_time_to_healed_or_new_endpoints_in_minutes` - - Model `OriginGroup` deleted or renamed its instance variable `response_based_origin_error_detection_settings` - - Model `OriginGroup` deleted or renamed its instance variable `resource_state` - - Model `OriginGroup` deleted or renamed its instance variable `provisioning_state` - - Model `OriginGroupUpdateParameters` deleted or renamed its instance variable `health_probe_settings` - - Model `OriginGroupUpdateParameters` deleted or renamed its instance variable `origins` - - Model `OriginGroupUpdateParameters` deleted or renamed its instance variable `traffic_restoration_time_to_healed_or_new_endpoints_in_minutes` - - Model `OriginGroupUpdateParameters` deleted or renamed its instance variable `response_based_origin_error_detection_settings` - - Model `OriginUpdateParameters` deleted or renamed its instance variable `host_name` - - Model `OriginUpdateParameters` deleted or renamed its instance variable `http_port` - - Model `OriginUpdateParameters` deleted or renamed its instance variable `https_port` - - Model `OriginUpdateParameters` deleted or renamed its instance variable `origin_host_header` - - Model `OriginUpdateParameters` deleted or renamed its instance variable `priority` - - Model `OriginUpdateParameters` deleted or renamed its instance variable `weight` - - Model `OriginUpdateParameters` deleted or renamed its instance variable `enabled` - - Model `OriginUpdateParameters` deleted or renamed its instance variable `private_link_alias` - - Model `OriginUpdateParameters` deleted or renamed its instance variable `private_link_resource_id` - - Model `OriginUpdateParameters` deleted or renamed its instance variable `private_link_location` - - Model `OriginUpdateParameters` deleted or renamed its instance variable `private_link_approval_message` - - Model `ProfileUpdateParameters` deleted or renamed its instance variable `origin_response_timeout_seconds` - - Model `ProfileUpdateParameters` deleted or renamed its instance variable `log_scrubbing` - - Model `Route` deleted or renamed its instance variable `endpoint_name` - - Model `Route` deleted or renamed its instance variable `custom_domains` - - Model `Route` deleted or renamed its instance variable `origin_group` - - Model `Route` deleted or renamed its instance variable `origin_path` - - Model `Route` deleted or renamed its instance variable `rule_sets` - - Model `Route` deleted or renamed its instance variable `supported_protocols` - - Model `Route` deleted or renamed its instance variable `patterns_to_match` - - Model `Route` deleted or renamed its instance variable `cache_configuration` - - Model `Route` deleted or renamed its instance variable `forwarding_protocol` - - Model `Route` deleted or renamed its instance variable `link_to_default_domain` - - Model `Route` deleted or renamed its instance variable `https_redirect` - - Model `Route` deleted or renamed its instance variable `enabled_state` - - Model `Route` deleted or renamed its instance variable `provisioning_state` - - Model `Route` deleted or renamed its instance variable `deployment_status` - - Model `RouteUpdateParameters` deleted or renamed its instance variable `endpoint_name` - - Model `RouteUpdateParameters` deleted or renamed its instance variable `custom_domains` - - Model `RouteUpdateParameters` deleted or renamed its instance variable `origin_group` - - Model `RouteUpdateParameters` deleted or renamed its instance variable `origin_path` - - Model `RouteUpdateParameters` deleted or renamed its instance variable `rule_sets` - - Model `RouteUpdateParameters` deleted or renamed its instance variable `supported_protocols` - - Model `RouteUpdateParameters` deleted or renamed its instance variable `patterns_to_match` - - Model `RouteUpdateParameters` deleted or renamed its instance variable `cache_configuration` - - Model `RouteUpdateParameters` deleted or renamed its instance variable `forwarding_protocol` - - Model `RouteUpdateParameters` deleted or renamed its instance variable `link_to_default_domain` - - Model `RouteUpdateParameters` deleted or renamed its instance variable `https_redirect` - - Model `RouteUpdateParameters` deleted or renamed its instance variable `enabled_state` - - Model `Rule` deleted or renamed its instance variable `rule_set_name` - - Model `Rule` deleted or renamed its instance variable `order` - - Model `Rule` deleted or renamed its instance variable `conditions` - - Model `Rule` deleted or renamed its instance variable `actions` - - Model `Rule` deleted or renamed its instance variable `match_processing_behavior` - - Model `Rule` deleted or renamed its instance variable `provisioning_state` - - Model `Rule` deleted or renamed its instance variable `deployment_status` - - Model `RuleSet` deleted or renamed its instance variable `provisioning_state` - - Model `RuleSet` deleted or renamed its instance variable `deployment_status` - - Model `RuleSet` deleted or renamed its instance variable `profile_name` - - Model `RuleUpdateParameters` deleted or renamed its instance variable `rule_set_name` - - Model `RuleUpdateParameters` deleted or renamed its instance variable `order` - - Model `RuleUpdateParameters` deleted or renamed its instance variable `conditions` - - Model `RuleUpdateParameters` deleted or renamed its instance variable `actions` - - Model `RuleUpdateParameters` deleted or renamed its instance variable `match_processing_behavior` - - Model `Secret` deleted or renamed its instance variable `provisioning_state` - - Model `Secret` deleted or renamed its instance variable `deployment_status` - - Model `Secret` deleted or renamed its instance variable `profile_name` - - Model `Secret` deleted or renamed its instance variable `parameters` - - Model `SecurityPolicy` deleted or renamed its instance variable `provisioning_state` - - Model `SecurityPolicy` deleted or renamed its instance variable `deployment_status` - - Model `SecurityPolicy` deleted or renamed its instance variable `profile_name` - - Model `SecurityPolicy` deleted or renamed its instance variable `parameters` - - Model `SecurityPolicyUpdateParameters` deleted or renamed its instance variable `parameters` - Deleted or renamed model `AfdErrorResponse` - Deleted or renamed model `AzureFirstPartyManagedCertificate` - Deleted or renamed model `CacheExpirationActionParametersTypeName` - Deleted or renamed model `CacheKeyQueryStringActionParametersTypeName` - Deleted or renamed model `CdnCertificateSourceParametersTypeName` - - Deleted or renamed model `CdnWebApplicationFirewallPolicyList` - Deleted or renamed model `Certificate` - Deleted or renamed model `ClientPortMatchConditionParametersTypeName` - Deleted or renamed model `CookiesMatchConditionParametersTypeName` @@ -270,7 +91,6 @@ - Deleted or renamed model `KeyVaultCertificateSourceParametersTypeName` - Deleted or renamed model `KeyVaultSigningKeyParametersTypeName` - Deleted or renamed model `ManagedCertificate` - - Deleted or renamed model `ManagedRuleSetDefinitionList` - Deleted or renamed model `OriginGroupOverrideActionParametersTypeName` - Deleted or renamed model `PostArgsMatchConditionParametersTypeName` - Deleted or renamed model `QueryStringMatchConditionParametersTypeName` @@ -293,37 +113,16 @@ - Deleted or renamed model `UrlRewriteActionParametersTypeName` - Deleted or renamed model `UrlSigningActionParametersTypeName` - Deleted or renamed model `ValidationToken` - - Method `LogAnalyticsOperations.get_log_analytics_metrics` changed its parameter `metrics` from `positional_or_keyword` to `keyword_only` - - Method `LogAnalyticsOperations.get_log_analytics_metrics` changed its parameter `date_time_begin` from `positional_or_keyword` to `keyword_only` - - Method `LogAnalyticsOperations.get_log_analytics_metrics` changed its parameter `date_time_end` from `positional_or_keyword` to `keyword_only` - - Method `LogAnalyticsOperations.get_log_analytics_metrics` changed its parameter `granularity` from `positional_or_keyword` to `keyword_only` - - Method `LogAnalyticsOperations.get_log_analytics_metrics` changed its parameter `custom_domains` from `positional_or_keyword` to `keyword_only` - - Method `LogAnalyticsOperations.get_log_analytics_metrics` changed its parameter `protocols` from `positional_or_keyword` to `keyword_only` - - Method `LogAnalyticsOperations.get_log_analytics_metrics` changed its parameter `group_by` from `positional_or_keyword` to `keyword_only` - - Method `LogAnalyticsOperations.get_log_analytics_metrics` changed its parameter `continents` from `positional_or_keyword` to `keyword_only` - - Method `LogAnalyticsOperations.get_log_analytics_metrics` changed its parameter `country_or_regions` from `positional_or_keyword` to `keyword_only` - - Method `LogAnalyticsOperations.get_log_analytics_rankings` changed its parameter `rankings` from `positional_or_keyword` to `keyword_only` - - Method `LogAnalyticsOperations.get_log_analytics_rankings` changed its parameter `metrics` from `positional_or_keyword` to `keyword_only` - - Method `LogAnalyticsOperations.get_log_analytics_rankings` changed its parameter `max_ranking` from `positional_or_keyword` to `keyword_only` - - Method `LogAnalyticsOperations.get_log_analytics_rankings` changed its parameter `date_time_begin` from `positional_or_keyword` to `keyword_only` - - Method `LogAnalyticsOperations.get_log_analytics_rankings` changed its parameter `date_time_end` from `positional_or_keyword` to `keyword_only` - - Method `LogAnalyticsOperations.get_log_analytics_rankings` changed its parameter `custom_domains` from `positional_or_keyword` to `keyword_only` - - Method `LogAnalyticsOperations.get_waf_log_analytics_metrics` changed its parameter `metrics` from `positional_or_keyword` to `keyword_only` - - Method `LogAnalyticsOperations.get_waf_log_analytics_metrics` changed its parameter `date_time_begin` from `positional_or_keyword` to `keyword_only` - - Method `LogAnalyticsOperations.get_waf_log_analytics_metrics` changed its parameter `date_time_end` from `positional_or_keyword` to `keyword_only` - - Method `LogAnalyticsOperations.get_waf_log_analytics_metrics` changed its parameter `granularity` from `positional_or_keyword` to `keyword_only` - - Method `LogAnalyticsOperations.get_waf_log_analytics_metrics` changed its parameter `actions` from `positional_or_keyword` to `keyword_only` - - Method `LogAnalyticsOperations.get_waf_log_analytics_metrics` changed its parameter `group_by` from `positional_or_keyword` to `keyword_only` - - Method `LogAnalyticsOperations.get_waf_log_analytics_metrics` changed its parameter `rule_types` from `positional_or_keyword` to `keyword_only` - - Method `LogAnalyticsOperations.get_waf_log_analytics_rankings` changed its parameter `metrics` from `positional_or_keyword` to `keyword_only` - - Method `LogAnalyticsOperations.get_waf_log_analytics_rankings` changed its parameter `date_time_begin` from `positional_or_keyword` to `keyword_only` - - Method `LogAnalyticsOperations.get_waf_log_analytics_rankings` changed its parameter `date_time_end` from `positional_or_keyword` to `keyword_only` - - Method `LogAnalyticsOperations.get_waf_log_analytics_rankings` changed its parameter `max_ranking` from `positional_or_keyword` to `keyword_only` - - Method `LogAnalyticsOperations.get_waf_log_analytics_rankings` changed its parameter `rankings` from `positional_or_keyword` to `keyword_only` - - Method `LogAnalyticsOperations.get_waf_log_analytics_rankings` changed its parameter `actions` from `positional_or_keyword` to `keyword_only` - - Method `LogAnalyticsOperations.get_waf_log_analytics_rankings` changed its parameter `rule_types` from `positional_or_keyword` to `keyword_only` - Deleted or renamed method `RuleSetsOperations.create` - Deleted or renamed model `CdnManagementClientOperationsMixin` + - Method `LogAnalyticsOperations.get_log_analytics_metrics` changed its parameter `metrics`/`date_time_begin`/`date_time_end`/`granularity`/`custom_domains`/`protocols`/`group_by`/`continents`/`country_or_regions` from `positional_or_keyword` to `keyword_only` + - Method `LogAnalyticsOperations.get_log_analytics_rankings` changed its parameter `rankings`/`metrics`/`max_ranking`/`date_time_begin`/`date_time_end`/`custom_domains` from `positional_or_keyword` to `keyword_only` + - Method `LogAnalyticsOperations.get_waf_log_analytics_metrics` changed its parameter `metrics`/`date_time_begin`/`date_time_end`/`granularity`/`actions`/`group_by`/`rule_types` from `positional_or_keyword` to `keyword_only` + - Method `LogAnalyticsOperations.get_waf_log_analytics_rankings` changed its parameter `metrics`/`date_time_begin`/`date_time_end`/`max_ranking`/`rankings`/`actions`/`rule_types` from `positional_or_keyword` to `keyword_only` + +### Other Changes + + - Deleted model `CdnWebApplicationFirewallPolicyList`/`ManagedRuleSetDefinitionList` which actually were not used by SDK users ## 13.1.1 (2024-06-12) From 499460adab4e903dadeafe667f55329147aba1c9 Mon Sep 17 00:00:00 2001 From: Yuchao Yan Date: Wed, 20 May 2026 11:13:36 +0800 Subject: [PATCH 3/3] Add live tests for azure-mgmt-cdn --- sdk/cdn/azure-mgmt-cdn/dev_requirements.txt | 3 +- sdk/cdn/azure-mgmt-cdn/tests/conftest.py | 61 ++++++------------- ...gement_edge_nodes_operations_async_test.py | 27 ++++++++ ...n_management_edge_nodes_operations_test.py | 26 ++++++++ ...managed_rule_sets_operations_async_test.py | 27 ++++++++ ...ement_managed_rule_sets_operations_test.py | 26 ++++++++ ...st_cdn_management_operations_async_test.py | 27 ++++++++ .../test_cdn_management_operations_test.py | 26 ++++++++ ...nagement_profiles_operations_async_test.py | 27 ++++++++ ...cdn_management_profiles_operations_test.py | 26 ++++++++ ...nt_resource_usage_operations_async_test.py | 27 ++++++++ ...nagement_resource_usage_operations_test.py | 26 ++++++++ 12 files changed, 287 insertions(+), 42 deletions(-) create mode 100644 sdk/cdn/azure-mgmt-cdn/tests/test_cdn_management_edge_nodes_operations_async_test.py create mode 100644 sdk/cdn/azure-mgmt-cdn/tests/test_cdn_management_edge_nodes_operations_test.py create mode 100644 sdk/cdn/azure-mgmt-cdn/tests/test_cdn_management_managed_rule_sets_operations_async_test.py create mode 100644 sdk/cdn/azure-mgmt-cdn/tests/test_cdn_management_managed_rule_sets_operations_test.py create mode 100644 sdk/cdn/azure-mgmt-cdn/tests/test_cdn_management_operations_async_test.py create mode 100644 sdk/cdn/azure-mgmt-cdn/tests/test_cdn_management_operations_test.py create mode 100644 sdk/cdn/azure-mgmt-cdn/tests/test_cdn_management_profiles_operations_async_test.py create mode 100644 sdk/cdn/azure-mgmt-cdn/tests/test_cdn_management_profiles_operations_test.py create mode 100644 sdk/cdn/azure-mgmt-cdn/tests/test_cdn_management_resource_usage_operations_async_test.py create mode 100644 sdk/cdn/azure-mgmt-cdn/tests/test_cdn_management_resource_usage_operations_test.py diff --git a/sdk/cdn/azure-mgmt-cdn/dev_requirements.txt b/sdk/cdn/azure-mgmt-cdn/dev_requirements.txt index f802d9f73053..2e3da863badd 100644 --- a/sdk/cdn/azure-mgmt-cdn/dev_requirements.txt +++ b/sdk/cdn/azure-mgmt-cdn/dev_requirements.txt @@ -1,3 +1,4 @@ -e ../../../eng/tools/azure-sdk-tools ../../resources/azure-mgmt-resource -../../identity/azure-identity \ No newline at end of file +../../identity/azure-identity +aiohttp \ No newline at end of file diff --git a/sdk/cdn/azure-mgmt-cdn/tests/conftest.py b/sdk/cdn/azure-mgmt-cdn/tests/conftest.py index 8c0bebb9a45c..dfedef46a2f5 100644 --- a/sdk/cdn/azure-mgmt-cdn/tests/conftest.py +++ b/sdk/cdn/azure-mgmt-cdn/tests/conftest.py @@ -1,56 +1,35 @@ +# 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) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import os -import platform import pytest -import sys - from dotenv import load_dotenv - -from devtools_testutils import test_proxy, add_general_regex_sanitizer -from devtools_testutils import add_header_regex_sanitizer, add_body_key_sanitizer - -# Ignore async tests for Python < 3.5 -collect_ignore_glob = [] -if sys.version_info < (3, 5) or platform.python_implementation() == "PyPy": - collect_ignore_glob.append("*_async.py") +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): - subscription_id = os.environ.get("AZURE_SUBSCRIPTION_ID", "00000000-0000-0000-0000-000000000000") - tenant_id = os.environ.get("AZURE_TENANT_ID", "00000000-0000-0000-0000-000000000000") - client_id = os.environ.get("AZURE_CLIENT_ID", "00000000-0000-0000-0000-000000000000") - client_secret = os.environ.get("AZURE_CLIENT_SECRET", "00000000-0000-0000-0000-000000000000") - add_general_regex_sanitizer(regex=subscription_id, value="00000000-0000-0000-0000-000000000000") - add_general_regex_sanitizer(regex=tenant_id, value="00000000-0000-0000-0000-000000000000") - add_general_regex_sanitizer(regex=client_id, value="00000000-0000-0000-0000-000000000000") - add_general_regex_sanitizer(regex=client_secret, value="00000000-0000-0000-0000-000000000000") + 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/tests/test_cdn_management_edge_nodes_operations_async_test.py b/sdk/cdn/azure-mgmt-cdn/tests/test_cdn_management_edge_nodes_operations_async_test.py new file mode 100644 index 000000000000..2b851f2dc773 --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/tests/test_cdn_management_edge_nodes_operations_async_test.py @@ -0,0 +1,27 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import 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.live_test_only +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() + result = [r async for r in response] + assert len(result) >= 0 diff --git a/sdk/cdn/azure-mgmt-cdn/tests/test_cdn_management_edge_nodes_operations_test.py b/sdk/cdn/azure-mgmt-cdn/tests/test_cdn_management_edge_nodes_operations_test.py new file mode 100644 index 000000000000..5e49303099d3 --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/tests/test_cdn_management_edge_nodes_operations_test.py @@ -0,0 +1,26 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.cdn import CdnManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.live_test_only +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() + result = [r for r in response] + assert len(result) >= 0 diff --git a/sdk/cdn/azure-mgmt-cdn/tests/test_cdn_management_managed_rule_sets_operations_async_test.py b/sdk/cdn/azure-mgmt-cdn/tests/test_cdn_management_managed_rule_sets_operations_async_test.py new file mode 100644 index 000000000000..cdfaa8aad2d4 --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/tests/test_cdn_management_managed_rule_sets_operations_async_test.py @@ -0,0 +1,27 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import 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.live_test_only +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() + result = [r async for r in response] + assert len(result) >= 0 diff --git a/sdk/cdn/azure-mgmt-cdn/tests/test_cdn_management_managed_rule_sets_operations_test.py b/sdk/cdn/azure-mgmt-cdn/tests/test_cdn_management_managed_rule_sets_operations_test.py new file mode 100644 index 000000000000..10945baa8b44 --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/tests/test_cdn_management_managed_rule_sets_operations_test.py @@ -0,0 +1,26 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.cdn import CdnManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.live_test_only +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() + result = [r for r in response] + assert len(result) >= 0 diff --git a/sdk/cdn/azure-mgmt-cdn/tests/test_cdn_management_operations_async_test.py b/sdk/cdn/azure-mgmt-cdn/tests/test_cdn_management_operations_async_test.py new file mode 100644 index 000000000000..10eb347695a6 --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/tests/test_cdn_management_operations_async_test.py @@ -0,0 +1,27 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import 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.live_test_only +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() + result = [r async for r in response] + assert len(result) >= 0 diff --git a/sdk/cdn/azure-mgmt-cdn/tests/test_cdn_management_operations_test.py b/sdk/cdn/azure-mgmt-cdn/tests/test_cdn_management_operations_test.py new file mode 100644 index 000000000000..f6bcd1462539 --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/tests/test_cdn_management_operations_test.py @@ -0,0 +1,26 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.cdn import CdnManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.live_test_only +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() + result = [r for r in response] + assert len(result) >= 0 diff --git a/sdk/cdn/azure-mgmt-cdn/tests/test_cdn_management_profiles_operations_async_test.py b/sdk/cdn/azure-mgmt-cdn/tests/test_cdn_management_profiles_operations_async_test.py new file mode 100644 index 000000000000..30aaf3a9bf8c --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/tests/test_cdn_management_profiles_operations_async_test.py @@ -0,0 +1,27 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import 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.live_test_only +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() + result = [r async for r in response] + assert len(result) >= 0 diff --git a/sdk/cdn/azure-mgmt-cdn/tests/test_cdn_management_profiles_operations_test.py b/sdk/cdn/azure-mgmt-cdn/tests/test_cdn_management_profiles_operations_test.py new file mode 100644 index 000000000000..6663f3114b6a --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/tests/test_cdn_management_profiles_operations_test.py @@ -0,0 +1,26 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.cdn import CdnManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.live_test_only +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() + result = [r for r in response] + assert len(result) >= 0 diff --git a/sdk/cdn/azure-mgmt-cdn/tests/test_cdn_management_resource_usage_operations_async_test.py b/sdk/cdn/azure-mgmt-cdn/tests/test_cdn_management_resource_usage_operations_async_test.py new file mode 100644 index 000000000000..0151f50d9999 --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/tests/test_cdn_management_resource_usage_operations_async_test.py @@ -0,0 +1,27 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import 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.live_test_only +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() + result = [r async for r in response] + assert len(result) >= 0 diff --git a/sdk/cdn/azure-mgmt-cdn/tests/test_cdn_management_resource_usage_operations_test.py b/sdk/cdn/azure-mgmt-cdn/tests/test_cdn_management_resource_usage_operations_test.py new file mode 100644 index 000000000000..d19b2acafc54 --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/tests/test_cdn_management_resource_usage_operations_test.py @@ -0,0 +1,26 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.cdn import CdnManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.live_test_only +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() + result = [r for r in response] + assert len(result) >= 0