From 4866205c9e1b8bfeed40b0f40611ca236b435bf8 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Mon, 9 Sep 2024 23:01:49 +0000 Subject: [PATCH] CodeGen from PR 30309 in Azure/azure-rest-api-specs Merge 0956344ac24745a481a108f858800cf6e9dc8254 into 1ad29756bd141a47cac770140105a706d065ae1b --- sdk/cdn/azure-mgmt-cdn/_meta.json | 6 +- .../azure/mgmt/cdn/_cdn_management_client.py | 9 +- .../azure/mgmt/cdn/_configuration.py | 4 +- .../azure/mgmt/cdn/_serialization.py | 2 + .../azure-mgmt-cdn/azure/mgmt/cdn/_vendor.py | 10 - .../azure-mgmt-cdn/azure/mgmt/cdn/_version.py | 2 +- .../mgmt/cdn/aio/_cdn_management_client.py | 9 +- .../azure/mgmt/cdn/aio/_configuration.py | 4 +- .../azure/mgmt/cdn/aio/_vendor.py | 2 - .../azure/mgmt/cdn/aio/operations/__init__.py | 2 + .../_afd_custom_domains_operations.py | 103 +- .../operations/_afd_endpoints_operations.py | 108 ++- .../_afd_origin_groups_operations.py | 82 +- .../aio/operations/_afd_origins_operations.py | 80 +- .../operations/_afd_profiles_operations.py | 40 +- .../_cdn_management_client_operations.py | 16 +- .../operations/_cdn_profiles_operations.py | 385 ++++++++ .../operations/_custom_domains_operations.py | 95 +- .../aio/operations/_edge_nodes_operations.py | 7 +- .../aio/operations/_endpoints_operations.py | 171 ++-- .../operations/_log_analytics_operations.py | 23 +- .../_managed_rule_sets_operations.py | 7 +- .../mgmt/cdn/aio/operations/_operations.py | 7 +- .../operations/_origin_groups_operations.py | 80 +- .../cdn/aio/operations/_origins_operations.py | 80 +- .../aio/operations/_policies_operations.py | 58 +- .../aio/operations/_profiles_operations.py | 269 ++++-- .../operations/_resource_usage_operations.py | 7 +- .../cdn/aio/operations/_routes_operations.py | 80 +- .../aio/operations/_rule_sets_operations.py | 46 +- .../cdn/aio/operations/_rules_operations.py | 80 +- .../cdn/aio/operations/_secrets_operations.py | 60 +- .../_security_policies_operations.py | 80 +- .../azure/mgmt/cdn/models/__init__.py | 94 +- .../models/_cdn_management_client_enums.py | 249 ++--- .../azure/mgmt/cdn/models/_models_py3.py | 909 +++++++++++++----- .../azure/mgmt/cdn/operations/__init__.py | 2 + .../_afd_custom_domains_operations.py | 114 ++- .../operations/_afd_endpoints_operations.py | 123 +-- .../_afd_origin_groups_operations.py | 93 +- .../cdn/operations/_afd_origins_operations.py | 89 +- .../operations/_afd_profiles_operations.py | 49 +- .../_cdn_management_client_operations.py | 25 +- .../operations/_cdn_profiles_operations.py | 458 +++++++++ .../operations/_custom_domains_operations.py | 106 +- .../cdn/operations/_edge_nodes_operations.py | 8 +- .../cdn/operations/_endpoints_operations.py | 192 ++-- .../operations/_log_analytics_operations.py | 34 +- .../_managed_rule_sets_operations.py | 8 +- .../azure/mgmt/cdn/operations/_operations.py | 8 +- .../operations/_origin_groups_operations.py | 89 +- .../cdn/operations/_origins_operations.py | 89 +- .../cdn/operations/_policies_operations.py | 67 +- .../cdn/operations/_profiles_operations.py | 321 +++++-- .../operations/_resource_usage_operations.py | 8 +- .../mgmt/cdn/operations/_routes_operations.py | 89 +- .../cdn/operations/_rule_sets_operations.py | 55 +- .../mgmt/cdn/operations/_rules_operations.py | 89 +- .../cdn/operations/_secrets_operations.py | 67 +- .../_security_policies_operations.py | 89 +- .../afd_custom_domains_create.py | 4 +- .../afd_custom_domains_delete.py | 2 +- .../afd_custom_domains_get.py | 2 +- .../afd_custom_domains_list_by_profile.py | 2 +- ...custom_domains_refresh_validation_token.py | 2 +- .../afd_custom_domains_update.py | 4 +- .../generated_samples/afd_endpoints_create.py | 4 +- .../generated_samples/afd_endpoints_delete.py | 2 +- .../generated_samples/afd_endpoints_get.py | 2 +- .../afd_endpoints_list_by_profile.py | 2 +- .../afd_endpoints_list_resource_usage.py | 2 +- .../afd_endpoints_purge_content.py | 4 +- .../generated_samples/afd_endpoints_update.py | 4 +- .../afd_endpoints_validate_custom_domain.py | 4 +- .../afd_origin_groups_create.py | 4 +- .../afd_origin_groups_delete.py | 2 +- .../afd_origin_groups_get.py | 2 +- .../afd_origin_groups_list_by_profile.py | 2 +- .../afd_origin_groups_list_resource_usage.py | 2 +- .../afd_origin_groups_update.py | 4 +- .../generated_samples/afd_origins_create.py | 4 +- .../generated_samples/afd_origins_delete.py | 2 +- .../generated_samples/afd_origins_get.py | 2 +- .../afd_origins_list_by_origin_group.py | 2 +- .../generated_samples/afd_origins_update.py | 4 +- ...ofiles_check_endpoint_name_availability.py | 4 +- ...d_profiles_check_host_name_availability.py | 4 +- .../afd_profiles_list_resource_usage.py | 2 +- .../generated_samples/afd_profiles_upgrade.py | 4 +- .../afd_profiles_validate_secret.py | 4 +- .../cdn_profiles_can_migrate.py | 42 + .../generated_samples/cdn_profiles_migrate.py | 43 + .../check_endpoint_name_availability.py | 4 +- .../check_name_availability.py | 4 +- ...eck_name_availability_with_subscription.py | 4 +- .../custom_domains_create.py | 4 +- .../custom_domains_delete.py | 2 +- .../custom_domains_disable_custom_https.py | 2 +- ..._domains_enable_custom_https_using_byoc.py | 2 +- ...tom_https_using_cdn_managed_certificate.py | 2 +- .../generated_samples/custom_domains_get.py | 2 +- .../custom_domains_list_by_endpoint.py | 2 +- .../generated_samples/edge_nodes_list.py | 2 +- .../generated_samples/endpoints_create.py | 4 +- .../generated_samples/endpoints_delete.py | 2 +- .../generated_samples/endpoints_get.py | 2 +- .../endpoints_list_by_profile.py | 2 +- .../endpoints_list_resource_usage.py | 2 +- .../endpoints_load_content.py | 4 +- .../endpoints_purge_content.py | 4 +- .../generated_samples/endpoints_start.py | 2 +- .../generated_samples/endpoints_stop.py | 2 +- .../generated_samples/endpoints_update.py | 4 +- .../endpoints_validate_custom_domain.py | 4 +- ...g_analytics_get_log_analytics_locations.py | 2 +- ...log_analytics_get_log_analytics_metrics.py | 7 +- ...og_analytics_get_log_analytics_rankings.py | 7 +- ...g_analytics_get_log_analytics_resources.py | 2 +- ...analytics_get_waf_log_analytics_metrics.py | 7 +- ...nalytics_get_waf_log_analytics_rankings.py | 7 +- .../generated_samples/operations_list.py | 2 +- .../generated_samples/origin_groups_create.py | 4 +- .../generated_samples/origin_groups_delete.py | 2 +- .../generated_samples/origin_groups_get.py | 2 +- .../origin_groups_list_by_endpoint.py | 2 +- .../generated_samples/origin_groups_update.py | 4 +- .../generated_samples/origins_create.py | 4 +- .../generated_samples/origins_delete.py | 2 +- .../generated_samples/origins_get.py | 2 +- .../origins_list_by_endpoint.py | 2 +- .../generated_samples/origins_update.py | 4 +- .../generated_samples/profiles_can_migrate.py | 4 +- .../generated_samples/profiles_create.py | 4 +- .../generated_samples/profiles_delete.py | 2 +- .../profiles_generate_sso_uri.py | 2 +- .../generated_samples/profiles_get.py | 2 +- .../generated_samples/profiles_list.py | 2 +- .../profiles_list_by_resource_group.py | 2 +- .../profiles_list_resource_usage.py | 2 +- ...files_list_supported_optimization_types.py | 2 +- .../generated_samples/profiles_migrate.py | 4 +- .../profiles_migration_abort.py | 41 + .../profiles_migration_commit.py | 2 +- .../generated_samples/profiles_update.py | 4 +- .../generated_samples/resource_usage_list.py | 2 +- .../generated_samples/routes_create.py | 4 +- .../generated_samples/routes_delete.py | 2 +- .../generated_samples/routes_get.py | 2 +- .../routes_list_by_endpoint.py | 2 +- .../generated_samples/routes_update.py | 4 +- .../generated_samples/rule_sets_create.py | 2 +- .../generated_samples/rule_sets_delete.py | 2 +- .../generated_samples/rule_sets_get.py | 2 +- .../rule_sets_list_by_profile.py | 2 +- .../rule_sets_list_resource_usage.py | 2 +- .../generated_samples/rules_create.py | 4 +- .../generated_samples/rules_delete.py | 2 +- .../generated_samples/rules_get.py | 2 +- .../rules_list_by_rule_set.py | 2 +- .../generated_samples/rules_update.py | 4 +- .../generated_samples/secrets_create.py | 4 +- .../generated_samples/secrets_delete.py | 2 +- .../generated_samples/secrets_get.py | 2 +- .../secrets_list_by_profile.py | 2 +- .../security_policies_create.py | 4 +- .../security_policies_delete.py | 2 +- .../security_policies_get.py | 2 +- .../security_policies_list_by_profile.py | 2 +- .../security_policies_patch.py | 4 +- .../generated_samples/validate_probe.py | 4 +- .../waf_list_managed_rule_sets.py | 2 +- .../generated_samples/waf_list_policies.py | 2 +- .../generated_samples/waf_patch_policy.py | 4 +- .../waf_policy_create_or_update.py | 4 +- .../generated_samples/waf_policy_delete.py | 2 +- .../generated_samples/waf_policy_get.py | 2 +- .../generated_tests/conftest.py | 35 + .../generated_tests/test_cdn_management.py | 68 ++ ...anagement_afd_custom_domains_operations.py | 125 +++ ...ent_afd_custom_domains_operations_async.py | 134 +++ ...cdn_management_afd_endpoints_operations.py | 146 +++ ...nagement_afd_endpoints_operations_async.py | 155 +++ ...management_afd_origin_groups_operations.py | 141 +++ ...ment_afd_origin_groups_operations_async.py | 148 +++ ...t_cdn_management_afd_origins_operations.py | 139 +++ ...management_afd_origins_operations_async.py | 146 +++ ..._cdn_management_afd_profiles_operations.py | 89 ++ ...anagement_afd_profiles_operations_async.py | 92 ++ .../test_cdn_management_async.py | 69 ++ ..._cdn_management_cdn_profiles_operations.py | 47 + ...anagement_cdn_profiles_operations_async.py | 52 + ...dn_management_custom_domains_operations.py | 103 ++ ...agement_custom_domains_operations_async.py | 112 +++ ...st_cdn_management_edge_nodes_operations.py | 29 + ..._management_edge_nodes_operations_async.py | 30 + ...est_cdn_management_endpoints_operations.py | 293 ++++++ ...n_management_endpoints_operations_async.py | 308 ++++++ ...cdn_management_log_analytics_operations.py | 111 +++ ...nagement_log_analytics_operations_async.py | 112 +++ ...management_managed_rule_sets_operations.py | 29 + ...ment_managed_rule_sets_operations_async.py | 30 + .../test_cdn_management_operations.py | 29 + .../test_cdn_management_operations_async.py | 30 + ...cdn_management_origin_groups_operations.py | 131 +++ ...nagement_origin_groups_operations_async.py | 138 +++ .../test_cdn_management_origins_operations.py | 128 +++ ...cdn_management_origins_operations_async.py | 135 +++ ...test_cdn_management_policies_operations.py | 164 ++++ ...dn_management_policies_operations_async.py | 169 ++++ ...test_cdn_management_profiles_operations.py | 229 +++++ ...dn_management_profiles_operations_async.py | 244 +++++ ...dn_management_resource_usage_operations.py | 29 + ...agement_resource_usage_operations_async.py | 30 + .../test_cdn_management_routes_operations.py | 137 +++ ..._cdn_management_routes_operations_async.py | 144 +++ ...est_cdn_management_rule_sets_operations.py | 83 ++ ...n_management_rule_sets_operations_async.py | 86 ++ .../test_cdn_management_rules_operations.py | 115 +++ ...t_cdn_management_rules_operations_async.py | 122 +++ .../test_cdn_management_secrets_operations.py | 87 ++ ...cdn_management_secrets_operations_async.py | 92 ++ ...management_security_policies_operations.py | 101 ++ ...ment_security_policies_operations_async.py | 108 +++ sdk/cdn/azure-mgmt-cdn/setup.py | 1 + 224 files changed, 9028 insertions(+), 2239 deletions(-) create mode 100644 sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_cdn_profiles_operations.py create mode 100644 sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_cdn_profiles_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_cdn_profiles_operations.py create mode 100644 sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_cdn_profiles_operations_async.py create mode 100644 sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_custom_domains_operations.py create mode 100644 sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_custom_domains_operations_async.py create mode 100644 sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_edge_nodes_operations.py create mode 100644 sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_edge_nodes_operations_async.py create mode 100644 sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_endpoints_operations.py create mode 100644 sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_endpoints_operations_async.py create mode 100644 sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_log_analytics_operations.py create mode 100644 sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_log_analytics_operations_async.py create mode 100644 sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_managed_rule_sets_operations.py create mode 100644 sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_managed_rule_sets_operations_async.py create mode 100644 sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_operations.py create mode 100644 sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_operations_async.py create mode 100644 sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_origin_groups_operations.py create mode 100644 sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_origin_groups_operations_async.py create mode 100644 sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_origins_operations.py create mode 100644 sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_origins_operations_async.py create mode 100644 sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_policies_operations.py create mode 100644 sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_policies_operations_async.py create mode 100644 sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_profiles_operations.py create mode 100644 sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_profiles_operations_async.py create mode 100644 sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_resource_usage_operations.py create mode 100644 sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_resource_usage_operations_async.py create mode 100644 sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_routes_operations.py create mode 100644 sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_routes_operations_async.py create mode 100644 sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_rule_sets_operations.py create mode 100644 sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_rule_sets_operations_async.py create mode 100644 sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_rules_operations.py create mode 100644 sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_rules_operations_async.py create mode 100644 sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_secrets_operations.py create mode 100644 sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_secrets_operations_async.py create mode 100644 sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_security_policies_operations.py create mode 100644 sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_security_policies_operations_async.py diff --git a/sdk/cdn/azure-mgmt-cdn/_meta.json b/sdk/cdn/azure-mgmt-cdn/_meta.json index a5cd8e2186b3..4415904e7397 100644 --- a/sdk/cdn/azure-mgmt-cdn/_meta.json +++ b/sdk/cdn/azure-mgmt-cdn/_meta.json @@ -1,11 +1,11 @@ { - "commit": "de1f3772629b6f4d3ac01548a5f6d719bfb97c9e", + "commit": "ebec5263383dba169e7de0938cc855611317179f", "repository_url": "https://github.com/Azure/azure-rest-api-specs", "autorest": "3.10.2", "use": [ - "@autorest/python@6.13.19", + "@autorest/python@6.19.0", "@autorest/modelerfour@4.27.0" ], - "autorest_command": "autorest specification/cdn/resource-manager/readme.md --generate-sample=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/home/vsts/work/1/azure-sdk-for-python/sdk --use=@autorest/python@6.13.19 --use=@autorest/modelerfour@4.27.0 --version=3.10.2 --version-tolerant=False", + "autorest_command": "autorest specification/cdn/resource-manager/readme.md --generate-sample=True --generate-test=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --use=@autorest/python@6.19.0 --use=@autorest/modelerfour@4.27.0 --version=3.10.2 --version-tolerant=False", "readme": "specification/cdn/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/_cdn_management_client.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/_cdn_management_client.py index 99307737ccda..7ea0cdb938c4 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/_cdn_management_client.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/_cdn_management_client.py @@ -8,6 +8,7 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING +from typing_extensions import Self from azure.core.pipeline import policies from azure.core.rest import HttpRequest, HttpResponse @@ -24,6 +25,7 @@ AFDOriginsOperations, AFDProfilesOperations, CdnManagementClientOperationsMixin, + CdnProfilesOperations, CustomDomainsOperations, EdgeNodesOperations, EndpointsOperations, @@ -90,6 +92,8 @@ class CdnManagementClient( :vartype operations: azure.mgmt.cdn.operations.Operations :ivar edge_nodes: EdgeNodesOperations operations :vartype edge_nodes: azure.mgmt.cdn.operations.EdgeNodesOperations + :ivar cdn_profiles: CdnProfilesOperations operations + :vartype cdn_profiles: azure.mgmt.cdn.operations.CdnProfilesOperations :ivar policies: PoliciesOperations operations :vartype policies: azure.mgmt.cdn.operations.PoliciesOperations :ivar managed_rule_sets: ManagedRuleSetsOperations operations @@ -100,7 +104,7 @@ class CdnManagementClient( :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str - :keyword api_version: Api Version. Default value is "2024-02-01". Note that overriding this + :keyword api_version: Api Version. Default value is "2024-09-01". 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 @@ -166,6 +170,7 @@ def __init__( 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.cdn_profiles = CdnProfilesOperations(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 @@ -196,7 +201,7 @@ def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: def close(self) -> None: self._client.close() - def __enter__(self) -> "CdnManagementClient": + def __enter__(self) -> Self: self._client.__enter__() return self diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/_configuration.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/_configuration.py index 42db4d3db8e6..8722f1ee0ea2 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/_configuration.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/_configuration.py @@ -28,13 +28,13 @@ class CdnManagementClientConfiguration: # pylint: disable=too-many-instance-att :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: Azure Subscription ID. Required. :type subscription_id: str - :keyword api_version: Api Version. Default value is "2024-02-01". Note that overriding this + :keyword api_version: Api Version. Default value is "2024-09-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2024-02-01") + api_version: str = kwargs.pop("api_version", "2024-09-01") if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/_serialization.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/_serialization.py index f0c6180722c8..8139854b97bb 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/_serialization.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/_serialization.py @@ -144,6 +144,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 diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/_vendor.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/_vendor.py index 7f38712a5635..d0caebafbca0 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/_vendor.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/_vendor.py @@ -8,8 +8,6 @@ from abc import ABC from typing import TYPE_CHECKING -from azure.core.pipeline.transport import HttpRequest - from ._configuration import CdnManagementClientConfiguration if TYPE_CHECKING: @@ -19,14 +17,6 @@ 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.""" 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..48944bf3938a 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/_version.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "13.1.1" +VERSION = "2.0.0" diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/_cdn_management_client.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/_cdn_management_client.py index d0f896981425..fff4df3ae67f 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/_cdn_management_client.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/_cdn_management_client.py @@ -8,6 +8,7 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING +from typing_extensions import Self from azure.core.pipeline import policies from azure.core.rest import AsyncHttpResponse, HttpRequest @@ -24,6 +25,7 @@ AFDOriginsOperations, AFDProfilesOperations, CdnManagementClientOperationsMixin, + CdnProfilesOperations, CustomDomainsOperations, EdgeNodesOperations, EndpointsOperations, @@ -90,6 +92,8 @@ class CdnManagementClient( :vartype operations: azure.mgmt.cdn.aio.operations.Operations :ivar edge_nodes: EdgeNodesOperations operations :vartype edge_nodes: azure.mgmt.cdn.aio.operations.EdgeNodesOperations + :ivar cdn_profiles: CdnProfilesOperations operations + :vartype cdn_profiles: azure.mgmt.cdn.aio.operations.CdnProfilesOperations :ivar policies: PoliciesOperations operations :vartype policies: azure.mgmt.cdn.aio.operations.PoliciesOperations :ivar managed_rule_sets: ManagedRuleSetsOperations operations @@ -100,7 +104,7 @@ class CdnManagementClient( :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str - :keyword api_version: Api Version. Default value is "2024-02-01". Note that overriding this + :keyword api_version: Api Version. Default value is "2024-09-01". 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 @@ -166,6 +170,7 @@ def __init__( 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.cdn_profiles = CdnProfilesOperations(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 @@ -198,7 +203,7 @@ def _send_request( async def close(self) -> None: await self._client.close() - async def __aenter__(self) -> "CdnManagementClient": + async def __aenter__(self) -> Self: await self._client.__aenter__() return self diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/_configuration.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/_configuration.py index 7c40851bb371..9b83984bf5d7 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 @@ -28,13 +28,13 @@ class CdnManagementClientConfiguration: # pylint: disable=too-many-instance-att :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: Azure Subscription ID. Required. :type subscription_id: str - :keyword api_version: Api Version. Default value is "2024-02-01". Note that overriding this + :keyword api_version: Api Version. Default value is "2024-09-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2024-02-01") + api_version: str = kwargs.pop("api_version", "2024-09-01") if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/_vendor.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/_vendor.py index 2fc2afd41b44..645826ed3890 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/_vendor.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/_vendor.py @@ -8,8 +8,6 @@ from abc import ABC from typing import TYPE_CHECKING -from azure.core.pipeline.transport import HttpRequest - from ._configuration import CdnManagementClientConfiguration if TYPE_CHECKING: 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..6427dbf88769 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 @@ -26,6 +26,7 @@ from ._resource_usage_operations import ResourceUsageOperations from ._operations import Operations from ._edge_nodes_operations import EdgeNodesOperations +from ._cdn_profiles_operations import CdnProfilesOperations from ._policies_operations import PoliciesOperations from ._managed_rule_sets_operations import ManagedRuleSetsOperations @@ -54,6 +55,7 @@ "ResourceUsageOperations", "Operations", "EdgeNodesOperations", + "CdnProfilesOperations", "PoliciesOperations", "ManagedRuleSetsOperations", ] diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_afd_custom_domains_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_afd_custom_domains_operations.py index 92e5deeb37d6..ebaa5090116b 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_afd_custom_domains_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_afd_custom_domains_operations.py @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -18,12 +18,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict @@ -31,7 +32,6 @@ 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, @@ -40,7 +40,6 @@ build_refresh_validation_token_request, build_update_request, ) -from .._vendor import CdnManagementClientMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -109,7 +108,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -125,7 +123,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -197,7 +194,6 @@ async def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -212,7 +208,7 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AFDDomain", pipeline_response) + deserialized = self._deserialize("AFDDomain", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -226,7 +222,7 @@ async def _create_initial( custom_domain_name: str, custom_domain: Union[_models.AFDDomain, IO[bytes]], **kwargs: Any - ) -> _models.AFDDomain: + ) -> AsyncIterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -240,7 +236,7 @@ async def _create_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AFDDomain] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -262,10 +258,10 @@ async def _create_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -273,21 +269,19 @@ async def _create_initial( response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("AFDDomain", pipeline_response) - if response.status_code == 201: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("AFDDomain", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("AFDDomain", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -407,10 +401,11 @@ async def begin_create( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("AFDDomain", pipeline_response) + deserialized = self._deserialize("AFDDomain", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -442,7 +437,7 @@ async def _update_initial( custom_domain_name: str, custom_domain_update_properties: Union[_models.AFDDomainUpdateParameters, IO[bytes]], **kwargs: Any - ) -> _models.AFDDomain: + ) -> AsyncIterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -456,7 +451,7 @@ async def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AFDDomain] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -478,10 +473,10 @@ async def _update_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -489,18 +484,19 @@ async def _update_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("AFDDomain", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("AFDDomain", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -621,10 +617,11 @@ async def begin_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("AFDDomain", pipeline_response) + deserialized = self._deserialize("AFDDomain", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -649,9 +646,9 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - async def _delete_initial( # pylint: disable=inconsistent-return-statements + async def _delete_initial( self, resource_group_name: str, profile_name: str, custom_domain_name: str, **kwargs: Any - ) -> None: + ) -> AsyncIterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -664,7 +661,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) _request = build_delete_request( resource_group_name=resource_group_name, @@ -675,10 +672,10 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -686,6 +683,10 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -694,8 +695,12 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @distributed_trace_async async def begin_delete( @@ -725,7 +730,7 @@ async def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( # type: ignore + raw_result = await self._delete_initial( resource_group_name=resource_group_name, profile_name=profile_name, custom_domain_name=custom_domain_name, @@ -735,6 +740,7 @@ async def begin_delete( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements @@ -759,9 +765,9 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- ) return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _refresh_validation_token_initial( # pylint: disable=inconsistent-return-statements + async def _refresh_validation_token_initial( self, resource_group_name: str, profile_name: str, custom_domain_name: str, **kwargs: Any - ) -> None: + ) -> AsyncIterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -774,7 +780,7 @@ async def _refresh_validation_token_initial( # pylint: disable=inconsistent-ret _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) _request = build_refresh_validation_token_request( resource_group_name=resource_group_name, @@ -785,10 +791,10 @@ async def _refresh_validation_token_initial( # pylint: disable=inconsistent-ret headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -796,6 +802,10 @@ async def _refresh_validation_token_initial( # pylint: disable=inconsistent-ret response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -804,8 +814,12 @@ async def _refresh_validation_token_initial( # pylint: disable=inconsistent-ret if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @distributed_trace_async async def begin_refresh_validation_token( @@ -834,7 +848,7 @@ async def begin_refresh_validation_token( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._refresh_validation_token_initial( # type: ignore + raw_result = await self._refresh_validation_token_initial( resource_group_name=resource_group_name, profile_name=profile_name, custom_domain_name=custom_domain_name, @@ -844,6 +858,7 @@ async def begin_refresh_validation_token( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_afd_endpoints_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_afd_endpoints_operations.py index d9fde2ce9580..88400a852f41 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_afd_endpoints_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_afd_endpoints_operations.py @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -18,12 +18,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict @@ -31,7 +32,6 @@ 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, @@ -42,7 +42,6 @@ build_update_request, build_validate_custom_domain_request, ) -from .._vendor import CdnManagementClientMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -111,7 +110,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -127,7 +125,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -199,7 +196,6 @@ async def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -214,7 +210,7 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AFDEndpoint", pipeline_response) + deserialized = self._deserialize("AFDEndpoint", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -228,7 +224,7 @@ async def _create_initial( endpoint_name: str, endpoint: Union[_models.AFDEndpoint, IO[bytes]], **kwargs: Any - ) -> _models.AFDEndpoint: + ) -> AsyncIterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -242,7 +238,7 @@ async def _create_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AFDEndpoint] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -264,10 +260,10 @@ async def _create_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -275,21 +271,19 @@ async def _create_initial( response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("AFDEndpoint", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("AFDEndpoint", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("AFDEndpoint", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -412,10 +406,11 @@ async def begin_create( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("AFDEndpoint", pipeline_response) + deserialized = self._deserialize("AFDEndpoint", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -447,7 +442,7 @@ async def _update_initial( endpoint_name: str, endpoint_update_properties: Union[_models.AFDEndpointUpdateParameters, IO[bytes]], **kwargs: Any - ) -> _models.AFDEndpoint: + ) -> AsyncIterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -461,7 +456,7 @@ async def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AFDEndpoint] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -483,10 +478,10 @@ async def _update_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -494,18 +489,19 @@ async def _update_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("AFDEndpoint", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("AFDEndpoint", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -635,10 +631,11 @@ async def begin_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("AFDEndpoint", pipeline_response) + deserialized = self._deserialize("AFDEndpoint", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -663,9 +660,9 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - async def _delete_initial( # pylint: disable=inconsistent-return-statements + async def _delete_initial( self, resource_group_name: str, profile_name: str, endpoint_name: str, **kwargs: Any - ) -> None: + ) -> AsyncIterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -678,7 +675,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) _request = build_delete_request( resource_group_name=resource_group_name, @@ -689,10 +686,10 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -700,6 +697,10 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -708,8 +709,12 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @distributed_trace_async async def begin_delete( @@ -739,7 +744,7 @@ async def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( # type: ignore + raw_result = await self._delete_initial( resource_group_name=resource_group_name, profile_name=profile_name, endpoint_name=endpoint_name, @@ -749,6 +754,7 @@ async def begin_delete( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements @@ -773,14 +779,14 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- ) return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _purge_content_initial( # pylint: disable=inconsistent-return-statements + async def _purge_content_initial( self, resource_group_name: str, profile_name: str, endpoint_name: str, contents: Union[_models.AfdPurgeParameters, IO[bytes]], **kwargs: Any - ) -> None: + ) -> AsyncIterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -794,7 +800,7 @@ async def _purge_content_initial( # pylint: disable=inconsistent-return-stateme api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -816,10 +822,10 @@ async def _purge_content_initial( # pylint: disable=inconsistent-return-stateme headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -827,6 +833,10 @@ async def _purge_content_initial( # pylint: disable=inconsistent-return-stateme response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -835,8 +845,12 @@ async def _purge_content_initial( # pylint: disable=inconsistent-return-stateme if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @overload async def begin_purge_content( @@ -944,7 +958,7 @@ async def begin_purge_content( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._purge_content_initial( # type: ignore + raw_result = await self._purge_content_initial( resource_group_name=resource_group_name, profile_name=profile_name, endpoint_name=endpoint_name, @@ -956,6 +970,7 @@ async def begin_purge_content( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements @@ -1024,7 +1039,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1040,7 +1054,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -1196,7 +1209,6 @@ async def validate_custom_domain( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1211,7 +1223,7 @@ async def validate_custom_domain( error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ValidateCustomDomainOutput", pipeline_response) + deserialized = self._deserialize("ValidateCustomDomainOutput", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_afd_origin_groups_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_afd_origin_groups_operations.py index c40286f25555..621ad17578c5 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_afd_origin_groups_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_afd_origin_groups_operations.py @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -18,12 +18,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict @@ -31,7 +32,6 @@ 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, @@ -40,7 +40,6 @@ build_list_resource_usage_request, build_update_request, ) -from .._vendor import CdnManagementClientMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -109,7 +108,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -125,7 +123,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -196,7 +193,6 @@ async def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -211,7 +207,7 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AFDOriginGroup", pipeline_response) + deserialized = self._deserialize("AFDOriginGroup", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -225,7 +221,7 @@ async def _create_initial( origin_group_name: str, origin_group: Union[_models.AFDOriginGroup, IO[bytes]], **kwargs: Any - ) -> _models.AFDOriginGroup: + ) -> AsyncIterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -239,7 +235,7 @@ async def _create_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AFDOriginGroup] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -261,10 +257,10 @@ async def _create_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -272,21 +268,19 @@ async def _create_initial( response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("AFDOriginGroup", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("AFDOriginGroup", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("AFDOriginGroup", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -406,10 +400,11 @@ async def begin_create( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("AFDOriginGroup", pipeline_response) + deserialized = self._deserialize("AFDOriginGroup", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -441,7 +436,7 @@ async def _update_initial( origin_group_name: str, origin_group_update_properties: Union[_models.AFDOriginGroupUpdateParameters, IO[bytes]], **kwargs: Any - ) -> _models.AFDOriginGroup: + ) -> AsyncIterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -455,7 +450,7 @@ async def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AFDOriginGroup] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -477,10 +472,10 @@ async def _update_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -488,18 +483,19 @@ async def _update_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("AFDOriginGroup", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("AFDOriginGroup", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -620,10 +616,11 @@ async def begin_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("AFDOriginGroup", pipeline_response) + deserialized = self._deserialize("AFDOriginGroup", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -648,9 +645,9 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - async def _delete_initial( # pylint: disable=inconsistent-return-statements + async def _delete_initial( self, resource_group_name: str, profile_name: str, origin_group_name: str, **kwargs: Any - ) -> None: + ) -> AsyncIterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -663,7 +660,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) _request = build_delete_request( resource_group_name=resource_group_name, @@ -674,10 +671,10 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -685,6 +682,10 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -693,8 +694,12 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @distributed_trace_async async def begin_delete( @@ -723,7 +728,7 @@ async def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( # type: ignore + raw_result = await self._delete_initial( resource_group_name=resource_group_name, profile_name=profile_name, origin_group_name=origin_group_name, @@ -733,6 +738,7 @@ async def begin_delete( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements @@ -801,7 +807,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -817,7 +822,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_afd_origins_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_afd_origins_operations.py index 49f79d669942..bf03b16a3aa1 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_afd_origins_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_afd_origins_operations.py @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -18,12 +18,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict @@ -31,7 +32,6 @@ 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, @@ -39,7 +39,6 @@ build_list_by_origin_group_request, build_update_request, ) -from .._vendor import CdnManagementClientMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -112,7 +111,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -128,7 +126,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -202,7 +199,6 @@ async def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -217,7 +213,7 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AFDOrigin", pipeline_response) + deserialized = self._deserialize("AFDOrigin", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -232,7 +228,7 @@ async def _create_initial( origin_name: str, origin: Union[_models.AFDOrigin, IO[bytes]], **kwargs: Any - ) -> _models.AFDOrigin: + ) -> AsyncIterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -246,7 +242,7 @@ async def _create_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AFDOrigin] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -269,10 +265,10 @@ async def _create_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -280,21 +276,19 @@ async def _create_initial( response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("AFDOrigin", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("AFDOrigin", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("AFDOrigin", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -423,10 +417,11 @@ async def begin_create( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("AFDOrigin", pipeline_response) + deserialized = self._deserialize("AFDOrigin", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -459,7 +454,7 @@ async def _update_initial( origin_name: str, origin_update_properties: Union[_models.AFDOriginUpdateParameters, IO[bytes]], **kwargs: Any - ) -> _models.AFDOrigin: + ) -> AsyncIterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -473,7 +468,7 @@ async def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AFDOrigin] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -496,10 +491,10 @@ async def _update_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -507,18 +502,19 @@ async def _update_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("AFDOrigin", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("AFDOrigin", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -648,10 +644,11 @@ async def begin_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("AFDOrigin", pipeline_response) + deserialized = self._deserialize("AFDOrigin", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -676,9 +673,9 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - async def _delete_initial( # pylint: disable=inconsistent-return-statements + async def _delete_initial( self, resource_group_name: str, profile_name: str, origin_group_name: str, origin_name: str, **kwargs: Any - ) -> None: + ) -> AsyncIterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -691,7 +688,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) _request = build_delete_request( resource_group_name=resource_group_name, @@ -703,10 +700,10 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -714,6 +711,10 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -722,8 +723,12 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @distributed_trace_async async def begin_delete( @@ -754,7 +759,7 @@ async def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( # type: ignore + raw_result = await self._delete_initial( resource_group_name=resource_group_name, profile_name=profile_name, origin_group_name=origin_group_name, @@ -765,6 +770,7 @@ async def begin_delete( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_afd_profiles_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_afd_profiles_operations.py index 169e0eca6ed8..fed9482381b1 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_afd_profiles_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_afd_profiles_operations.py @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -18,12 +18,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict @@ -31,7 +32,6 @@ 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, @@ -39,7 +39,6 @@ build_upgrade_request, build_validate_secret_request, ) -from .._vendor import CdnManagementClientMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -183,7 +182,6 @@ async def check_endpoint_name_availability( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -198,7 +196,7 @@ async def check_endpoint_name_availability( error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("CheckEndpointNameAvailabilityOutput", pipeline_response) + deserialized = self._deserialize("CheckEndpointNameAvailabilityOutput", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -245,7 +243,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -261,7 +258,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -405,7 +401,6 @@ async def check_host_name_availability( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -420,7 +415,7 @@ async def check_host_name_availability( error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("CheckNameAvailabilityOutput", pipeline_response) + deserialized = self._deserialize("CheckNameAvailabilityOutput", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -537,7 +532,6 @@ async def validate_secret( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -552,7 +546,7 @@ async def validate_secret( error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ValidateSecretOutput", pipeline_response) + deserialized = self._deserialize("ValidateSecretOutput", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -565,7 +559,7 @@ async def _upgrade_initial( profile_name: str, profile_upgrade_parameters: Union[_models.ProfileUpgradeParameters, IO[bytes]], **kwargs: Any - ) -> _models.Profile: + ) -> AsyncIterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -579,7 +573,7 @@ async def _upgrade_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Profile] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -600,10 +594,10 @@ async def _upgrade_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -611,18 +605,19 @@ async def _upgrade_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("Profile", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("Profile", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -729,10 +724,11 @@ async def begin_upgrade( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Profile", pipeline_response) + deserialized = self._deserialize("Profile", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_cdn_management_client_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_cdn_management_client_operations.py index adef934cf76f..03adcaf5d759 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_cdn_management_client_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_cdn_management_client_operations.py @@ -19,14 +19,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._cdn_management_client_operations import ( build_check_endpoint_name_availability_request, build_check_name_availability_request, @@ -147,7 +145,6 @@ async def check_endpoint_name_availability( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -162,7 +159,7 @@ async def check_endpoint_name_availability( error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("CheckEndpointNameAvailabilityOutput", pipeline_response) + deserialized = self._deserialize("CheckEndpointNameAvailabilityOutput", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -253,7 +250,6 @@ async def check_name_availability( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -268,7 +264,7 @@ async def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("CheckNameAvailabilityOutput", pipeline_response) + deserialized = self._deserialize("CheckNameAvailabilityOutput", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -360,7 +356,6 @@ async def check_name_availability_with_subscription( # pylint: disable=name-too headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -375,7 +370,7 @@ async def check_name_availability_with_subscription( # pylint: disable=name-too error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("CheckNameAvailabilityOutput", pipeline_response) + deserialized = self._deserialize("CheckNameAvailabilityOutput", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -465,7 +460,6 @@ async def validate_probe( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -480,7 +474,7 @@ async def validate_probe( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ValidateProbeOutput", pipeline_response) + deserialized = self._deserialize("ValidateProbeOutput", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_cdn_profiles_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_cdn_profiles_operations.py new file mode 100644 index 000000000000..b6369143d78a --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_cdn_profiles_operations.py @@ -0,0 +1,385 @@ +# 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, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ...operations._cdn_profiles_operations import ( + build_cdn_can_migrate_to_afd_request, + build_cdn_migrate_to_afd_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, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class CdnProfilesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cdn.aio.CdnManagementClient`'s + :attr:`cdn_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") + + async def _cdn_can_migrate_to_afd_initial( + self, resource_group_name: str, profile_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + 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[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_cdn_can_migrate_to_afd_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_cdn_can_migrate_to_afd( + self, resource_group_name: str, profile_name: str, **kwargs: Any + ) -> AsyncLROPoller[_models.CanMigrateResult]: + """Checks if CDN profile can be migrated to Azure Frontdoor(Standard/Premium) profile. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. + :type profile_name: str + :return: An instance of AsyncLROPoller that returns either CanMigrateResult or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.CanMigrateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.CanMigrateResult] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._cdn_can_migrate_to_afd_initial( + resource_group_name=resource_group_name, + profile_name=profile_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("CanMigrateResult", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.CanMigrateResult].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.CanMigrateResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _cdn_migrate_to_afd_initial( + self, + resource_group_name: str, + profile_name: str, + migration_parameters: Union[_models.CdnMigrationToAfdParameters, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[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[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(migration_parameters, (IOBase, bytes)): + _content = migration_parameters + else: + _json = self._serialize.body(migration_parameters, "CdnMigrationToAfdParameters") + + _request = build_cdn_migrate_to_afd_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_cdn_migrate_to_afd( + self, + resource_group_name: str, + profile_name: str, + migration_parameters: _models.CdnMigrationToAfdParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.MigrateResult]: + """Migrate the CDN profile to Azure Frontdoor(Standard/Premium) profile. This step prepares the + profile for migration and will be followed by Commit to finalize the migration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. + :type profile_name: str + :param migration_parameters: Properties needed to migrate the profile. Required. + :type migration_parameters: ~azure.mgmt.cdn.models.CdnMigrationToAfdParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either MigrateResult or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.MigrateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_cdn_migrate_to_afd( + self, + resource_group_name: str, + profile_name: str, + migration_parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.MigrateResult]: + """Migrate the CDN profile to Azure Frontdoor(Standard/Premium) profile. This step prepares the + profile for migration and will be followed by Commit to finalize the migration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. + :type profile_name: str + :param migration_parameters: Properties needed to migrate the profile. Required. + :type migration_parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either MigrateResult or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.MigrateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_cdn_migrate_to_afd( + self, + resource_group_name: str, + profile_name: str, + migration_parameters: Union[_models.CdnMigrationToAfdParameters, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.MigrateResult]: + """Migrate the CDN profile to Azure Frontdoor(Standard/Premium) profile. This step prepares the + profile for migration and will be followed by Commit to finalize the migration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. + :type profile_name: str + :param migration_parameters: Properties needed to migrate the profile. Is either a + CdnMigrationToAfdParameters type or a IO[bytes] type. Required. + :type migration_parameters: ~azure.mgmt.cdn.models.CdnMigrationToAfdParameters or IO[bytes] + :return: An instance of AsyncLROPoller that returns either MigrateResult or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.MigrateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.MigrateResult] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._cdn_migrate_to_afd_initial( + resource_group_name=resource_group_name, + profile_name=profile_name, + migration_parameters=migration_parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("MigrateResult", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.MigrateResult].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.MigrateResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_custom_domains_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_custom_domains_operations.py index 52a4b04d3882..6c299e0b469d 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_custom_domains_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_custom_domains_operations.py @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -18,12 +18,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict @@ -31,7 +32,6 @@ 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, @@ -40,7 +40,6 @@ build_get_request, build_list_by_endpoint_request, ) -from .._vendor import CdnManagementClientMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -113,7 +112,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -129,7 +127,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -203,7 +200,6 @@ async def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -218,7 +214,7 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("CustomDomain", pipeline_response) + deserialized = self._deserialize("CustomDomain", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -233,7 +229,7 @@ async def _create_initial( custom_domain_name: str, custom_domain_properties: Union[_models.CustomDomainParameters, IO[bytes]], **kwargs: Any - ) -> _models.CustomDomain: + ) -> AsyncIterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -247,7 +243,7 @@ async def _create_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.CustomDomain] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -270,10 +266,10 @@ async def _create_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -281,21 +277,19 @@ async def _create_initial( response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("CustomDomain", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("CustomDomain", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("CustomDomain", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -425,10 +419,11 @@ async def begin_create( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("CustomDomain", pipeline_response) + deserialized = self._deserialize("CustomDomain", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -452,7 +447,7 @@ def get_long_running_output(pipeline_response): async def _delete_initial( self, resource_group_name: str, profile_name: str, endpoint_name: str, custom_domain_name: str, **kwargs: Any - ) -> Optional[_models.CustomDomain]: + ) -> AsyncIterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -465,7 +460,7 @@ async def _delete_initial( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[Optional[_models.CustomDomain]] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) _request = build_delete_request( resource_group_name=resource_group_name, @@ -477,10 +472,10 @@ async def _delete_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -488,16 +483,19 @@ async def _delete_initial( response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("CustomDomain", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -545,6 +543,7 @@ async def begin_delete( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): @@ -552,7 +551,7 @@ def get_long_running_output(pipeline_response): response = pipeline_response.http_response response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("CustomDomain", pipeline_response) + deserialized = self._deserialize("CustomDomain", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized @@ -576,7 +575,7 @@ def get_long_running_output(pipeline_response): async def _disable_custom_https_initial( self, resource_group_name: str, profile_name: str, endpoint_name: str, custom_domain_name: str, **kwargs: Any - ) -> _models.CustomDomain: + ) -> AsyncIterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -589,7 +588,7 @@ async def _disable_custom_https_initial( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.CustomDomain] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) _request = build_disable_custom_https_request( resource_group_name=resource_group_name, @@ -601,10 +600,10 @@ async def _disable_custom_https_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -612,18 +611,19 @@ async def _disable_custom_https_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("CustomDomain", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("CustomDomain", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -671,10 +671,11 @@ async def begin_disable_custom_https( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("CustomDomain", pipeline_response) + deserialized = self._deserialize("CustomDomain", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -704,7 +705,7 @@ async def _enable_custom_https_initial( custom_domain_name: str, custom_domain_https_parameters: Optional[Union[_models.CustomDomainHttpsParameters, IO[bytes]]] = None, **kwargs: Any - ) -> _models.CustomDomain: + ) -> AsyncIterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -718,7 +719,7 @@ async def _enable_custom_https_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.CustomDomain] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -744,10 +745,10 @@ async def _enable_custom_https_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -755,18 +756,19 @@ async def _enable_custom_https_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("CustomDomain", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("CustomDomain", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -903,10 +905,11 @@ async def begin_enable_custom_https( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("CustomDomain", pipeline_response) + deserialized = self._deserialize("CustomDomain", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_edge_nodes_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_edge_nodes_operations.py index 4cb0f22ba810..740a2db7e6a0 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_edge_nodes_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_edge_nodes_operations.py @@ -20,16 +20,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator 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 @@ -89,7 +86,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -105,7 +101,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_endpoints_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_endpoints_operations.py index 3e51c9b51c27..d2d94264b4ac 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_endpoints_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_endpoints_operations.py @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -18,12 +18,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict @@ -31,7 +32,6 @@ 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, @@ -45,7 +45,6 @@ build_update_request, build_validate_custom_domain_request, ) -from .._vendor import CdnManagementClientMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -114,7 +113,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -130,7 +128,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -202,7 +199,6 @@ async def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -217,7 +213,7 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Endpoint", pipeline_response) + deserialized = self._deserialize("Endpoint", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -231,7 +227,7 @@ async def _create_initial( endpoint_name: str, endpoint: Union[_models.Endpoint, IO[bytes]], **kwargs: Any - ) -> _models.Endpoint: + ) -> AsyncIterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -245,7 +241,7 @@ async def _create_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Endpoint] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -267,10 +263,10 @@ async def _create_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -278,21 +274,19 @@ async def _create_initial( response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("Endpoint", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Endpoint", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("Endpoint", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -414,10 +408,11 @@ async def begin_create( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Endpoint", pipeline_response) + deserialized = self._deserialize("Endpoint", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -446,7 +441,7 @@ async def _update_initial( endpoint_name: str, endpoint_update_properties: Union[_models.EndpointUpdateParameters, IO[bytes]], **kwargs: Any - ) -> _models.Endpoint: + ) -> AsyncIterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -460,7 +455,7 @@ async def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Endpoint] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -482,10 +477,10 @@ async def _update_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -493,18 +488,19 @@ async def _update_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("Endpoint", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("Endpoint", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -633,10 +629,11 @@ async def begin_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Endpoint", pipeline_response) + deserialized = self._deserialize("Endpoint", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -658,9 +655,9 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - async def _delete_initial( # pylint: disable=inconsistent-return-statements + async def _delete_initial( self, resource_group_name: str, profile_name: str, endpoint_name: str, **kwargs: Any - ) -> None: + ) -> AsyncIterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -673,7 +670,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) _request = build_delete_request( resource_group_name=resource_group_name, @@ -684,10 +681,10 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -695,6 +692,10 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -703,8 +704,12 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @distributed_trace_async async def begin_delete( @@ -734,7 +739,7 @@ async def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( # type: ignore + raw_result = await self._delete_initial( resource_group_name=resource_group_name, profile_name=profile_name, endpoint_name=endpoint_name, @@ -744,6 +749,7 @@ async def begin_delete( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements @@ -767,7 +773,7 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- async def _start_initial( self, resource_group_name: str, profile_name: str, endpoint_name: str, **kwargs: Any - ) -> _models.Endpoint: + ) -> AsyncIterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -780,7 +786,7 @@ async def _start_initial( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.Endpoint] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) _request = build_start_request( resource_group_name=resource_group_name, @@ -791,10 +797,10 @@ async def _start_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -802,18 +808,19 @@ async def _start_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("Endpoint", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("Endpoint", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -858,10 +865,11 @@ async def begin_start( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Endpoint", pipeline_response) + deserialized = self._deserialize("Endpoint", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -885,7 +893,7 @@ def get_long_running_output(pipeline_response): async def _stop_initial( self, resource_group_name: str, profile_name: str, endpoint_name: str, **kwargs: Any - ) -> _models.Endpoint: + ) -> AsyncIterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -898,7 +906,7 @@ async def _stop_initial( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.Endpoint] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) _request = build_stop_request( resource_group_name=resource_group_name, @@ -909,10 +917,10 @@ async def _stop_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -920,18 +928,19 @@ async def _stop_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("Endpoint", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("Endpoint", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -976,10 +985,11 @@ async def begin_stop( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Endpoint", pipeline_response) + deserialized = self._deserialize("Endpoint", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -1001,14 +1011,14 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - async def _purge_content_initial( # pylint: disable=inconsistent-return-statements + async def _purge_content_initial( self, resource_group_name: str, profile_name: str, endpoint_name: str, content_file_paths: Union[_models.PurgeParameters, IO[bytes]], **kwargs: Any - ) -> None: + ) -> AsyncIterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -1022,7 +1032,7 @@ async def _purge_content_initial( # pylint: disable=inconsistent-return-stateme api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -1044,10 +1054,10 @@ async def _purge_content_initial( # pylint: disable=inconsistent-return-stateme headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -1055,6 +1065,10 @@ async def _purge_content_initial( # pylint: disable=inconsistent-return-stateme response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -1063,8 +1077,12 @@ async def _purge_content_initial( # pylint: disable=inconsistent-return-stateme if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @overload async def begin_purge_content( @@ -1170,7 +1188,7 @@ async def begin_purge_content( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._purge_content_initial( # type: ignore + raw_result = await self._purge_content_initial( resource_group_name=resource_group_name, profile_name=profile_name, endpoint_name=endpoint_name, @@ -1182,6 +1200,7 @@ async def begin_purge_content( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements @@ -1203,14 +1222,14 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- ) return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _load_content_initial( # pylint: disable=inconsistent-return-statements + async def _load_content_initial( self, resource_group_name: str, profile_name: str, endpoint_name: str, content_file_paths: Union[_models.LoadParameters, IO[bytes]], **kwargs: Any - ) -> None: + ) -> AsyncIterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -1224,7 +1243,7 @@ async def _load_content_initial( # pylint: disable=inconsistent-return-statemen api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -1246,10 +1265,10 @@ async def _load_content_initial( # pylint: disable=inconsistent-return-statemen headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -1257,6 +1276,10 @@ async def _load_content_initial( # pylint: disable=inconsistent-return-statemen response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -1265,8 +1288,12 @@ async def _load_content_initial( # pylint: disable=inconsistent-return-statemen if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @overload async def begin_load_content( @@ -1369,7 +1396,7 @@ async def begin_load_content( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._load_content_initial( # type: ignore + raw_result = await self._load_content_initial( resource_group_name=resource_group_name, profile_name=profile_name, endpoint_name=endpoint_name, @@ -1381,6 +1408,7 @@ async def begin_load_content( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements @@ -1525,7 +1553,6 @@ async def validate_custom_domain( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1540,7 +1567,7 @@ async def validate_custom_domain( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ValidateCustomDomainOutput", pipeline_response) + deserialized = self._deserialize("ValidateCustomDomainOutput", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -1591,7 +1618,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1607,7 +1633,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_log_analytics_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_log_analytics_operations.py index a76b3c5219f4..d793b5635e71 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_log_analytics_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_log_analytics_operations.py @@ -19,14 +19,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._log_analytics_operations import ( build_get_log_analytics_locations_request, build_get_log_analytics_metrics_request, @@ -35,7 +33,6 @@ 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 @@ -140,7 +137,6 @@ async def get_log_analytics_metrics( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -155,7 +151,7 @@ async def get_log_analytics_metrics( error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("MetricsResponse", pipeline_response) + deserialized = self._deserialize("MetricsResponse", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -226,7 +222,6 @@ async def get_log_analytics_rankings( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -241,7 +236,7 @@ async def get_log_analytics_rankings( error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("RankingsResponse", pipeline_response) + deserialized = self._deserialize("RankingsResponse", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -285,7 +280,6 @@ async def get_log_analytics_locations( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -300,7 +294,7 @@ async def get_log_analytics_locations( error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ContinentsResponse", pipeline_response) + deserialized = self._deserialize("ContinentsResponse", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -344,7 +338,6 @@ async def get_log_analytics_resources( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -359,7 +352,7 @@ async def get_log_analytics_resources( error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ResourcesResponse", pipeline_response) + deserialized = self._deserialize("ResourcesResponse", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -434,7 +427,6 @@ async def get_waf_log_analytics_metrics( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -449,7 +441,7 @@ async def get_waf_log_analytics_metrics( error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("WafMetricsResponse", pipeline_response) + deserialized = self._deserialize("WafMetricsResponse", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -524,7 +516,6 @@ async def get_waf_log_analytics_rankings( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -539,7 +530,7 @@ async def get_waf_log_analytics_rankings( error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("WafRankingsResponse", pipeline_response) + deserialized = self._deserialize("WafRankingsResponse", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_managed_rule_sets_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_managed_rule_sets_operations.py index 2e8eb598ea06..e34ac77030c5 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_managed_rule_sets_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_managed_rule_sets_operations.py @@ -20,16 +20,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator 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 @@ -91,7 +88,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -107,7 +103,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_operations.py index cf1ad39ae373..9a19f1ff5094 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 @@ -20,16 +20,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator 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._operations import build_list_request -from .._vendor import CdnManagementClientMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -88,7 +85,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -104,7 +100,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_origin_groups_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_origin_groups_operations.py index 3512194ddb18..0fd4edd20d18 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_origin_groups_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_origin_groups_operations.py @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -18,12 +18,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict @@ -31,7 +32,6 @@ 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, @@ -39,7 +39,6 @@ build_list_by_endpoint_request, build_update_request, ) -from .._vendor import CdnManagementClientMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -112,7 +111,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -128,7 +126,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -203,7 +200,6 @@ async def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -218,7 +214,7 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("OriginGroup", pipeline_response) + deserialized = self._deserialize("OriginGroup", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -233,7 +229,7 @@ async def _create_initial( origin_group_name: str, origin_group: Union[_models.OriginGroup, IO[bytes]], **kwargs: Any - ) -> _models.OriginGroup: + ) -> AsyncIterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -247,7 +243,7 @@ async def _create_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.OriginGroup] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -270,10 +266,10 @@ async def _create_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -281,21 +277,19 @@ async def _create_initial( response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("OriginGroup", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("OriginGroup", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("OriginGroup", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -428,10 +422,11 @@ async def begin_create( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("OriginGroup", pipeline_response) + deserialized = self._deserialize("OriginGroup", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -461,7 +456,7 @@ async def _update_initial( origin_group_name: str, origin_group_update_properties: Union[_models.OriginGroupUpdateParameters, IO[bytes]], **kwargs: Any - ) -> _models.OriginGroup: + ) -> AsyncIterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -475,7 +470,7 @@ async def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.OriginGroup] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -498,10 +493,10 @@ async def _update_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -509,18 +504,19 @@ async def _update_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("OriginGroup", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("OriginGroup", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -654,10 +650,11 @@ async def begin_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("OriginGroup", pipeline_response) + deserialized = self._deserialize("OriginGroup", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -679,9 +676,9 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - async def _delete_initial( # pylint: disable=inconsistent-return-statements + async def _delete_initial( self, resource_group_name: str, profile_name: str, endpoint_name: str, origin_group_name: str, **kwargs: Any - ) -> None: + ) -> AsyncIterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -694,7 +691,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) _request = build_delete_request( resource_group_name=resource_group_name, @@ -706,10 +703,10 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -717,6 +714,10 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -725,8 +726,12 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @distributed_trace_async async def begin_delete( @@ -758,7 +763,7 @@ async def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( # type: ignore + raw_result = await self._delete_initial( resource_group_name=resource_group_name, profile_name=profile_name, endpoint_name=endpoint_name, @@ -769,6 +774,7 @@ async def begin_delete( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_origins_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_origins_operations.py index 21192a6e9ad0..95f430d02637 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_origins_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_origins_operations.py @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -18,12 +18,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict @@ -31,7 +32,6 @@ 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, @@ -39,7 +39,6 @@ build_list_by_endpoint_request, build_update_request, ) -from .._vendor import CdnManagementClientMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -112,7 +111,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -128,7 +126,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -202,7 +199,6 @@ async def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -217,7 +213,7 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Origin", pipeline_response) + deserialized = self._deserialize("Origin", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -232,7 +228,7 @@ async def _create_initial( origin_name: str, origin: Union[_models.Origin, IO[bytes]], **kwargs: Any - ) -> _models.Origin: + ) -> AsyncIterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -246,7 +242,7 @@ async def _create_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Origin] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -269,10 +265,10 @@ async def _create_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -280,21 +276,19 @@ async def _create_initial( response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("Origin", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Origin", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("Origin", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -423,10 +417,11 @@ async def begin_create( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Origin", pipeline_response) + deserialized = self._deserialize("Origin", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -456,7 +451,7 @@ async def _update_initial( origin_name: str, origin_update_properties: Union[_models.OriginUpdateParameters, IO[bytes]], **kwargs: Any - ) -> _models.Origin: + ) -> AsyncIterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -470,7 +465,7 @@ async def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Origin] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -493,10 +488,10 @@ async def _update_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -504,18 +499,19 @@ async def _update_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("Origin", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("Origin", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -645,10 +641,11 @@ async def begin_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Origin", pipeline_response) + deserialized = self._deserialize("Origin", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -670,9 +667,9 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - async def _delete_initial( # pylint: disable=inconsistent-return-statements + async def _delete_initial( self, resource_group_name: str, profile_name: str, endpoint_name: str, origin_name: str, **kwargs: Any - ) -> None: + ) -> AsyncIterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -685,7 +682,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) _request = build_delete_request( resource_group_name=resource_group_name, @@ -697,10 +694,10 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -708,6 +705,10 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -716,8 +717,12 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @distributed_trace_async async def begin_delete( @@ -748,7 +753,7 @@ async def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( # type: ignore + raw_result = await self._delete_initial( resource_group_name=resource_group_name, profile_name=profile_name, endpoint_name=endpoint_name, @@ -759,6 +764,7 @@ async def begin_delete( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_policies_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_policies_operations.py index 7e6760ff2bf3..3c22fb4506d7 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_policies_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_policies_operations.py @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -18,12 +18,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict @@ -31,7 +32,6 @@ 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, @@ -39,7 +39,6 @@ build_list_request, build_update_request, ) -from .._vendor import CdnManagementClientMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -104,7 +103,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -120,7 +118,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -186,7 +183,6 @@ async def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -201,7 +197,7 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("CdnWebApplicationFirewallPolicy", pipeline_response) + deserialized = self._deserialize("CdnWebApplicationFirewallPolicy", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -214,7 +210,7 @@ async def _create_or_update_initial( policy_name: str, cdn_web_application_firewall_policy: Union[_models.CdnWebApplicationFirewallPolicy, IO[bytes]], **kwargs: Any - ) -> _models.CdnWebApplicationFirewallPolicy: + ) -> AsyncIterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -228,7 +224,7 @@ async def _create_or_update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.CdnWebApplicationFirewallPolicy] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -249,10 +245,10 @@ async def _create_or_update_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -260,21 +256,19 @@ async def _create_or_update_initial( response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("CdnWebApplicationFirewallPolicy", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("CdnWebApplicationFirewallPolicy", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("CdnWebApplicationFirewallPolicy", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -383,10 +377,11 @@ async def begin_create_or_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("CdnWebApplicationFirewallPolicy", pipeline_response) + deserialized = self._deserialize("CdnWebApplicationFirewallPolicy", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -416,7 +411,7 @@ async def _update_initial( _models.CdnWebApplicationFirewallPolicyPatchParameters, IO[bytes] ], **kwargs: Any - ) -> _models.CdnWebApplicationFirewallPolicy: + ) -> AsyncIterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -430,7 +425,7 @@ async def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.CdnWebApplicationFirewallPolicy] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -453,10 +448,10 @@ async def _update_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -464,18 +459,19 @@ async def _update_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("CdnWebApplicationFirewallPolicy", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("CdnWebApplicationFirewallPolicy", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -592,10 +588,11 @@ async def begin_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("CdnWebApplicationFirewallPolicy", pipeline_response) + deserialized = self._deserialize("CdnWebApplicationFirewallPolicy", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -653,7 +650,6 @@ async def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_profiles_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_profiles_operations.py index 83eebbe330db..7b7273625cef 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_profiles_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_profiles_operations.py @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -18,12 +18,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict @@ -31,7 +32,6 @@ 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, @@ -43,10 +43,10 @@ build_list_resource_usage_request, build_list_supported_optimization_types_request, build_migrate_request, + build_migration_abort_request, build_migration_commit_request, build_update_request, ) -from .._vendor import CdnManagementClientMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -107,7 +107,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -123,7 +122,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -188,7 +186,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -204,7 +201,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -270,7 +266,6 @@ async def get(self, resource_group_name: str, profile_name: str, **kwargs: Any) headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -285,7 +280,7 @@ async def get(self, resource_group_name: str, profile_name: str, **kwargs: Any) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Profile", pipeline_response) + deserialized = self._deserialize("Profile", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -294,7 +289,7 @@ async def get(self, resource_group_name: str, profile_name: str, **kwargs: Any) async def _create_initial( self, resource_group_name: str, profile_name: str, profile: Union[_models.Profile, IO[bytes]], **kwargs: Any - ) -> _models.Profile: + ) -> AsyncIterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -308,7 +303,7 @@ async def _create_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Profile] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -329,10 +324,10 @@ async def _create_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -340,21 +335,19 @@ async def _create_initial( response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("Profile", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Profile", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("Profile", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -460,10 +453,11 @@ async def begin_create( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Profile", pipeline_response) + deserialized = self._deserialize("Profile", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -491,7 +485,7 @@ async def _update_initial( profile_name: str, profile_update_parameters: Union[_models.ProfileUpdateParameters, IO[bytes]], **kwargs: Any - ) -> _models.Profile: + ) -> AsyncIterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -505,7 +499,7 @@ async def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Profile] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -526,10 +520,10 @@ async def _update_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -537,18 +531,19 @@ async def _update_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("Profile", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("Profile", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -660,10 +655,11 @@ async def begin_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Profile", pipeline_response) + deserialized = self._deserialize("Profile", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -685,9 +681,7 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, profile_name: str, **kwargs: Any - ) -> None: + async def _delete_initial(self, resource_group_name: str, profile_name: str, **kwargs: Any) -> AsyncIterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -700,7 +694,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) _request = build_delete_request( resource_group_name=resource_group_name, @@ -710,10 +704,10 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -721,6 +715,10 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -729,8 +727,12 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @distributed_trace_async async def begin_delete(self, resource_group_name: str, profile_name: str, **kwargs: Any) -> AsyncLROPoller[None]: @@ -756,7 +758,7 @@ async def begin_delete(self, resource_group_name: str, profile_name: str, **kwar lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( # type: ignore + raw_result = await self._delete_initial( resource_group_name=resource_group_name, profile_name=profile_name, api_version=api_version, @@ -765,6 +767,7 @@ async def begin_delete(self, resource_group_name: str, profile_name: str, **kwar params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements @@ -791,7 +794,7 @@ async def _can_migrate_initial( resource_group_name: str, can_migrate_parameters: Union[_models.CanMigrateParameters, IO[bytes]], **kwargs: Any - ) -> Optional[_models.CanMigrateResult]: + ) -> AsyncIterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -805,7 +808,7 @@ async def _can_migrate_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.CanMigrateResult]] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -825,10 +828,10 @@ async def _can_migrate_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -836,18 +839,20 @@ async def _can_migrate_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("CanMigrateResult", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -942,10 +947,11 @@ async def begin_can_migrate( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("CanMigrateResult", pipeline_response) + deserialized = self._deserialize("CanMigrateResult", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -974,7 +980,7 @@ async def _migrate_initial( resource_group_name: str, migration_parameters: Union[_models.MigrationParameters, IO[bytes]], **kwargs: Any - ) -> _models.MigrateResult: + ) -> AsyncIterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -988,7 +994,7 @@ async def _migrate_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.MigrateResult] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -1008,10 +1014,10 @@ async def _migrate_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -1019,18 +1025,19 @@ async def _migrate_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("MigrateResult", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("MigrateResult", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -1127,10 +1134,11 @@ async def begin_migrate( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("MigrateResult", pipeline_response) + deserialized = self._deserialize("MigrateResult", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -1154,9 +1162,9 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - async def _migration_commit_initial( # pylint: disable=inconsistent-return-statements + async def _migration_commit_initial( self, resource_group_name: str, profile_name: str, **kwargs: Any - ) -> None: + ) -> AsyncIterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -1169,7 +1177,7 @@ async def _migration_commit_initial( # pylint: disable=inconsistent-return-stat _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) _request = build_migration_commit_request( resource_group_name=resource_group_name, @@ -1179,10 +1187,10 @@ async def _migration_commit_initial( # pylint: disable=inconsistent-return-stat headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -1190,6 +1198,10 @@ async def _migration_commit_initial( # pylint: disable=inconsistent-return-stat response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -1198,8 +1210,12 @@ async def _migration_commit_initial( # pylint: disable=inconsistent-return-stat if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @distributed_trace_async async def begin_migration_commit( @@ -1225,7 +1241,7 @@ async def begin_migration_commit( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._migration_commit_initial( # type: ignore + raw_result = await self._migration_commit_initial( resource_group_name=resource_group_name, profile_name=profile_name, api_version=api_version, @@ -1234,6 +1250,7 @@ async def begin_migration_commit( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements @@ -1297,7 +1314,6 @@ async def generate_sso_uri(self, resource_group_name: str, profile_name: str, ** headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1312,7 +1328,7 @@ async def generate_sso_uri(self, resource_group_name: str, profile_name: str, ** error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("SsoUri", pipeline_response) + deserialized = self._deserialize("SsoUri", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -1357,7 +1373,6 @@ async def list_supported_optimization_types( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1372,7 +1387,7 @@ async def list_supported_optimization_types( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("SupportedOptimizationTypesListResult", pipeline_response) + deserialized = self._deserialize("SupportedOptimizationTypesListResult", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -1420,7 +1435,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1436,7 +1450,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -1465,3 +1478,117 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) + + async def _migration_abort_initial( + self, resource_group_name: str, profile_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + 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[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_migration_abort_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_migration_abort( + self, resource_group_name: str, profile_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Abort the migration to Azure Frontdoor Premium/Standard. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. + :type profile_name: str + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._migration_abort_initial( + resource_group_name=resource_group_name, + profile_name=profile_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "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/_resource_usage_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_resource_usage_operations.py index 1c15d9080763..33d7ba199ae7 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_resource_usage_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_resource_usage_operations.py @@ -20,16 +20,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator 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 @@ -89,7 +86,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -105,7 +101,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_routes_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_routes_operations.py index f75e5288b804..1946de07c229 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_routes_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_routes_operations.py @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -18,12 +18,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict @@ -31,7 +32,6 @@ 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, @@ -39,7 +39,6 @@ build_list_by_endpoint_request, build_update_request, ) -from .._vendor import CdnManagementClientMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -112,7 +111,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -128,7 +126,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -203,7 +200,6 @@ async def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -218,7 +214,7 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Route", pipeline_response) + deserialized = self._deserialize("Route", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -233,7 +229,7 @@ async def _create_initial( route_name: str, route: Union[_models.Route, IO[bytes]], **kwargs: Any - ) -> _models.Route: + ) -> AsyncIterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -247,7 +243,7 @@ async def _create_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Route] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -270,10 +266,10 @@ async def _create_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -281,21 +277,19 @@ async def _create_initial( response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("Route", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Route", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("Route", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -424,10 +418,11 @@ async def begin_create( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Route", pipeline_response) + deserialized = self._deserialize("Route", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -460,7 +455,7 @@ async def _update_initial( route_name: str, route_update_properties: Union[_models.RouteUpdateParameters, IO[bytes]], **kwargs: Any - ) -> _models.Route: + ) -> AsyncIterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -474,7 +469,7 @@ async def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Route] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -497,10 +492,10 @@ async def _update_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -508,18 +503,19 @@ async def _update_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("Route", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("Route", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -649,10 +645,11 @@ async def begin_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Route", pipeline_response) + deserialized = self._deserialize("Route", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -677,9 +674,9 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - async def _delete_initial( # pylint: disable=inconsistent-return-statements + async def _delete_initial( self, resource_group_name: str, profile_name: str, endpoint_name: str, route_name: str, **kwargs: Any - ) -> None: + ) -> AsyncIterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -692,7 +689,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) _request = build_delete_request( resource_group_name=resource_group_name, @@ -704,10 +701,10 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -715,6 +712,10 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -723,8 +724,12 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @distributed_trace_async async def begin_delete( @@ -756,7 +761,7 @@ async def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( # type: ignore + raw_result = await self._delete_initial( resource_group_name=resource_group_name, profile_name=profile_name, endpoint_name=endpoint_name, @@ -767,6 +772,7 @@ async def begin_delete( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_rule_sets_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_rule_sets_operations.py index fc4b3e11a657..0434d0dfa076 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_rule_sets_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_rule_sets_operations.py @@ -7,7 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar, Union, cast +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, Optional, Type, TypeVar, Union, cast import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -17,12 +17,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict @@ -30,7 +31,6 @@ 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, @@ -38,7 +38,6 @@ 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 @@ -107,7 +106,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -123,7 +121,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -195,7 +192,6 @@ async def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -210,7 +206,7 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("RuleSet", pipeline_response) + deserialized = self._deserialize("RuleSet", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -258,7 +254,6 @@ async def create( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -273,20 +268,16 @@ async def create( error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("RuleSet", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("RuleSet", pipeline_response) + deserialized = self._deserialize("RuleSet", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - async def _delete_initial( # pylint: disable=inconsistent-return-statements + async def _delete_initial( self, resource_group_name: str, profile_name: str, rule_set_name: str, **kwargs: Any - ) -> None: + ) -> AsyncIterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -299,7 +290,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) _request = build_delete_request( resource_group_name=resource_group_name, @@ -310,10 +301,10 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -321,6 +312,10 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -329,8 +324,12 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @distributed_trace_async async def begin_delete( @@ -360,7 +359,7 @@ async def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( # type: ignore + raw_result = await self._delete_initial( resource_group_name=resource_group_name, profile_name=profile_name, rule_set_name=rule_set_name, @@ -370,6 +369,7 @@ async def begin_delete( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements @@ -438,7 +438,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -454,7 +453,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_rules_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_rules_operations.py index 3461ad98d882..ad0157b60c87 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_rules_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_rules_operations.py @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -18,12 +18,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict @@ -31,7 +32,6 @@ 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, @@ -39,7 +39,6 @@ build_list_by_rule_set_request, build_update_request, ) -from .._vendor import CdnManagementClientMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -111,7 +110,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -127,7 +125,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -200,7 +197,6 @@ async def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -215,7 +211,7 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Rule", pipeline_response) + deserialized = self._deserialize("Rule", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -230,7 +226,7 @@ async def _create_initial( rule_name: str, rule: Union[_models.Rule, IO[bytes]], **kwargs: Any - ) -> _models.Rule: + ) -> AsyncIterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -244,7 +240,7 @@ async def _create_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Rule] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -267,10 +263,10 @@ async def _create_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -278,21 +274,19 @@ async def _create_initial( response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("Rule", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Rule", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("Rule", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -415,10 +409,11 @@ async def begin_create( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Rule", pipeline_response) + deserialized = self._deserialize("Rule", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -451,7 +446,7 @@ async def _update_initial( rule_name: str, rule_update_properties: Union[_models.RuleUpdateParameters, IO[bytes]], **kwargs: Any - ) -> _models.Rule: + ) -> AsyncIterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -465,7 +460,7 @@ async def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Rule] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -488,10 +483,10 @@ async def _update_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -499,18 +494,19 @@ async def _update_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("Rule", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("Rule", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -634,10 +630,11 @@ async def begin_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Rule", pipeline_response) + deserialized = self._deserialize("Rule", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -662,9 +659,9 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - async def _delete_initial( # pylint: disable=inconsistent-return-statements + async def _delete_initial( self, resource_group_name: str, profile_name: str, rule_set_name: str, rule_name: str, **kwargs: Any - ) -> None: + ) -> AsyncIterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -677,7 +674,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) _request = build_delete_request( resource_group_name=resource_group_name, @@ -689,10 +686,10 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -700,6 +697,10 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -708,8 +709,12 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @distributed_trace_async async def begin_delete( @@ -739,7 +744,7 @@ async def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( # type: ignore + raw_result = await self._delete_initial( resource_group_name=resource_group_name, profile_name=profile_name, rule_set_name=rule_set_name, @@ -750,6 +755,7 @@ async def begin_delete( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_secrets_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_secrets_operations.py index 181fb64700c9..a83d86da4396 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_secrets_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_secrets_operations.py @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -18,12 +18,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict @@ -31,14 +32,12 @@ 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 @@ -107,7 +106,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -123,7 +121,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -191,7 +188,6 @@ async def get(self, resource_group_name: str, profile_name: str, secret_name: st headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -206,7 +202,7 @@ async def get(self, resource_group_name: str, profile_name: str, secret_name: st error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Secret", pipeline_response) + deserialized = self._deserialize("Secret", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -220,7 +216,7 @@ async def _create_initial( secret_name: str, secret: Union[_models.Secret, IO[bytes]], **kwargs: Any - ) -> _models.Secret: + ) -> AsyncIterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -234,7 +230,7 @@ async def _create_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Secret] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -256,10 +252,10 @@ async def _create_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -267,21 +263,19 @@ async def _create_initial( response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("Secret", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Secret", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("Secret", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -397,10 +391,11 @@ async def begin_create( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Secret", pipeline_response) + deserialized = self._deserialize("Secret", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -425,9 +420,9 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - async def _delete_initial( # pylint: disable=inconsistent-return-statements + async def _delete_initial( self, resource_group_name: str, profile_name: str, secret_name: str, **kwargs: Any - ) -> None: + ) -> AsyncIterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -440,7 +435,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) _request = build_delete_request( resource_group_name=resource_group_name, @@ -451,10 +446,10 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -462,6 +457,10 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -470,8 +469,12 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @distributed_trace_async async def begin_delete( @@ -499,7 +502,7 @@ async def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( # type: ignore + raw_result = await self._delete_initial( resource_group_name=resource_group_name, profile_name=profile_name, secret_name=secret_name, @@ -509,6 +512,7 @@ async def begin_delete( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_security_policies_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_security_policies_operations.py index 5a81547b0bc7..5ee859e9475a 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_security_policies_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_security_policies_operations.py @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -18,12 +18,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict @@ -31,7 +32,6 @@ 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, @@ -39,7 +39,6 @@ build_list_by_profile_request, build_patch_request, ) -from .._vendor import CdnManagementClientMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -108,7 +107,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -124,7 +122,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -194,7 +191,6 @@ async def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -209,7 +205,7 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("SecurityPolicy", pipeline_response) + deserialized = self._deserialize("SecurityPolicy", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -223,7 +219,7 @@ async def _create_initial( security_policy_name: str, security_policy: Union[_models.SecurityPolicy, IO[bytes]], **kwargs: Any - ) -> _models.SecurityPolicy: + ) -> AsyncIterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -237,7 +233,7 @@ async def _create_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.SecurityPolicy] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -259,10 +255,10 @@ async def _create_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -270,21 +266,19 @@ async def _create_initial( response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("SecurityPolicy", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("SecurityPolicy", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("SecurityPolicy", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -401,10 +395,11 @@ async def begin_create( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("SecurityPolicy", pipeline_response) + deserialized = self._deserialize("SecurityPolicy", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -436,7 +431,7 @@ async def _patch_initial( security_policy_name: str, security_policy_update_properties: Union[_models.SecurityPolicyUpdateParameters, IO[bytes]], **kwargs: Any - ) -> _models.SecurityPolicy: + ) -> AsyncIterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -450,7 +445,7 @@ async def _patch_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.SecurityPolicy] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -472,10 +467,10 @@ async def _patch_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -483,18 +478,19 @@ async def _patch_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("SecurityPolicy", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("SecurityPolicy", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -612,10 +608,11 @@ async def begin_patch( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("SecurityPolicy", pipeline_response) + deserialized = self._deserialize("SecurityPolicy", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -640,9 +637,9 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - async def _delete_initial( # pylint: disable=inconsistent-return-statements + async def _delete_initial( self, resource_group_name: str, profile_name: str, security_policy_name: str, **kwargs: Any - ) -> None: + ) -> AsyncIterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -655,7 +652,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) _request = build_delete_request( resource_group_name=resource_group_name, @@ -666,10 +663,10 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -677,6 +674,10 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -685,8 +686,12 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @distributed_trace_async async def begin_delete( @@ -714,7 +719,7 @@ async def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( # type: ignore + raw_result = await self._delete_initial( resource_group_name=resource_group_name, profile_name=profile_name, security_policy_name=security_policy_name, @@ -724,6 +729,7 @@ async def begin_delete( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/models/__init__.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/models/__init__.py index c82bb7b540c6..914eca9dda9a 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 @@ -42,10 +42,12 @@ from ._models_py3 import CdnCertificateSourceParameters from ._models_py3 import CdnEndpoint from ._models_py3 import CdnManagedHttpsParameters +from ._models_py3 import CdnMigrationToAfdParameters from ._models_py3 import CdnWebApplicationFirewallPolicy from ._models_py3 import CdnWebApplicationFirewallPolicyList from ._models_py3 import CdnWebApplicationFirewallPolicyPatchParameters from ._models_py3 import Certificate +from ._models_py3 import CertificateSourceParameters from ._models_py3 import CheckEndpointNameAvailabilityInput from ._models_py3 import CheckEndpointNameAvailabilityOutput from ._models_py3 import CheckHostNameAvailabilityInput @@ -74,10 +76,12 @@ from ._models_py3 import DeepCreatedOriginGroup from ._models_py3 import DeliveryRule from ._models_py3 import DeliveryRuleAction +from ._models_py3 import DeliveryRuleActionParameters from ._models_py3 import DeliveryRuleCacheExpirationAction from ._models_py3 import DeliveryRuleCacheKeyQueryStringAction from ._models_py3 import DeliveryRuleClientPortCondition from ._models_py3 import DeliveryRuleCondition +from ._models_py3 import DeliveryRuleConditionParameters from ._models_py3 import DeliveryRuleCookiesCondition from ._models_py3 import DeliveryRuleHostNameCondition from ._models_py3 import DeliveryRuleHttpVersionCondition @@ -112,7 +116,9 @@ from ._models_py3 import EndpointUpdateParameters from ._models_py3 import ErrorAdditionalInfo from ._models_py3 import ErrorDetail +from ._models_py3 import ErrorDetailAutoGenerated from ._models_py3 import ErrorResponse +from ._models_py3 import ErrorResponseAutoGenerated from ._models_py3 import GeoFilter from ._models_py3 import HeaderActionParameters from ._models_py3 import HealthProbeParameters @@ -144,6 +150,7 @@ from ._models_py3 import MetricsResponseSeriesItem from ._models_py3 import MetricsResponseSeriesPropertiesItemsItem from ._models_py3 import MigrateResult +from ._models_py3 import MigrationEndpointMapping from ._models_py3 import MigrationErrorType from ._models_py3 import MigrationParameters from ._models_py3 import MigrationWebApplicationFirewallMapping @@ -270,16 +277,12 @@ 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 CertificateSourceParametersType 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 @@ -287,6 +290,8 @@ 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 DeliveryRuleActionParametersType +from ._cdn_management_client_enums import DeliveryRuleConditionParametersType from ._cdn_management_client_enums import DeploymentStatus from ._cdn_management_client_enums import DestinationProtocol from ._cdn_management_client_enums import DomainValidationState @@ -296,19 +301,14 @@ 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 IsDeviceMatchValue 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 KeyVaultSigningKeyParametersType from ._cdn_management_client_enums import LinkToDefaultDomain from ._cdn_management_client_enums import LogMetric from ._cdn_management_client_enums import LogMetricsGranularity @@ -324,7 +324,6 @@ 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 @@ -334,7 +333,6 @@ 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 @@ -345,27 +343,19 @@ 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 RequestMethodMatchValue 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 RequestSchemeMatchValue 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 @@ -374,28 +364,19 @@ 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 @@ -447,10 +428,12 @@ "CdnCertificateSourceParameters", "CdnEndpoint", "CdnManagedHttpsParameters", + "CdnMigrationToAfdParameters", "CdnWebApplicationFirewallPolicy", "CdnWebApplicationFirewallPolicyList", "CdnWebApplicationFirewallPolicyPatchParameters", "Certificate", + "CertificateSourceParameters", "CheckEndpointNameAvailabilityInput", "CheckEndpointNameAvailabilityOutput", "CheckHostNameAvailabilityInput", @@ -479,10 +462,12 @@ "DeepCreatedOriginGroup", "DeliveryRule", "DeliveryRuleAction", + "DeliveryRuleActionParameters", "DeliveryRuleCacheExpirationAction", "DeliveryRuleCacheKeyQueryStringAction", "DeliveryRuleClientPortCondition", "DeliveryRuleCondition", + "DeliveryRuleConditionParameters", "DeliveryRuleCookiesCondition", "DeliveryRuleHostNameCondition", "DeliveryRuleHttpVersionCondition", @@ -517,7 +502,9 @@ "EndpointUpdateParameters", "ErrorAdditionalInfo", "ErrorDetail", + "ErrorDetailAutoGenerated", "ErrorResponse", + "ErrorResponseAutoGenerated", "GeoFilter", "HeaderActionParameters", "HealthProbeParameters", @@ -549,6 +536,7 @@ "MetricsResponseSeriesItem", "MetricsResponseSeriesPropertiesItemsItem", "MigrateResult", + "MigrationEndpointMapping", "MigrationErrorType", "MigrationParameters", "MigrationWebApplicationFirewallMapping", @@ -674,16 +662,12 @@ "Algorithm", "AutoGeneratedDomainNameLabelScope", "CacheBehavior", - "CacheExpirationActionParametersTypeName", - "CacheKeyQueryStringActionParametersTypeName", "CacheType", "CanMigrateDefaultSku", - "CdnCertificateSourceParametersTypeName", "CertificateSource", + "CertificateSourceParametersType", "CertificateType", - "ClientPortMatchConditionParametersTypeName", "ClientPortOperator", - "CookiesMatchConditionParametersTypeName", "CookiesOperator", "CustomDomainResourceState", "CustomHttpsProvisioningState", @@ -691,6 +675,8 @@ "CustomRuleEnabledState", "DeleteRule", "DeliveryRuleActionEnum", + "DeliveryRuleActionParametersType", + "DeliveryRuleConditionParametersType", "DeploymentStatus", "DestinationProtocol", "DomainValidationState", @@ -700,19 +686,14 @@ "ForwardingProtocol", "GeoFilterActions", "HeaderAction", - "HeaderActionParametersTypeName", "HealthProbeRequestType", - "HostNameMatchConditionParametersTypeName", "HostNameOperator", - "HttpVersionMatchConditionParametersTypeName", "HttpVersionOperator", "HttpsRedirect", "IdentityType", - "IsDeviceMatchConditionParametersMatchValuesItem", - "IsDeviceMatchConditionParametersTypeName", + "IsDeviceMatchValue", "IsDeviceOperator", - "KeyVaultCertificateSourceParametersTypeName", - "KeyVaultSigningKeyParametersTypeName", + "KeyVaultSigningKeyParametersType", "LinkToDefaultDomain", "LogMetric", "LogMetricsGranularity", @@ -728,7 +709,6 @@ "MinimumTlsVersion", "Operator", "OptimizationType", - "OriginGroupOverrideActionParametersTypeName", "OriginGroupProvisioningState", "OriginGroupResourceState", "OriginProvisioningState", @@ -738,7 +718,6 @@ "PolicyMode", "PolicyResourceState", "PolicySettingsDefaultCustomBlockResponseStatusCode", - "PostArgsMatchConditionParametersTypeName", "PostArgsOperator", "PrivateEndpointStatus", "ProbeProtocol", @@ -749,27 +728,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 +749,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", diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/models/_cdn_management_client_enums.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/models/_cdn_management_client_enums.py index d0164f2b6f7b..b71deaed8a85 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/models/_cdn_management_client_enums.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/models/_cdn_management_client_enums.py @@ -86,20 +86,6 @@ class CacheBehavior(str, Enum, metaclass=CaseInsensitiveEnumMeta): SET_IF_MISSING = "SetIfMissing" -class CacheExpirationActionParametersTypeName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """CacheExpirationActionParametersTypeName.""" - - DELIVERY_RULE_CACHE_EXPIRATION_ACTION_PARAMETERS = "DeliveryRuleCacheExpirationActionParameters" - - -class CacheKeyQueryStringActionParametersTypeName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """CacheKeyQueryStringActionParametersTypeName.""" - - DELIVERY_RULE_CACHE_KEY_QUERY_STRING_BEHAVIOR_ACTION_PARAMETERS = ( - "DeliveryRuleCacheKeyQueryStringBehaviorActionParameters" - ) - - class CacheType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The level at which the content needs to be cached.""" @@ -113,12 +99,6 @@ class CanMigrateDefaultSku(str, Enum, metaclass=CaseInsensitiveEnumMeta): PREMIUM_AZURE_FRONT_DOOR = "Premium_AzureFrontDoor" -class CdnCertificateSourceParametersTypeName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """CdnCertificateSourceParametersTypeName.""" - - CDN_CERTIFICATE_SOURCE_PARAMETERS = "CdnCertificateSourceParameters" - - class CertificateSource(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Defines the source of the SSL certificate.""" @@ -126,6 +106,13 @@ class CertificateSource(str, Enum, metaclass=CaseInsensitiveEnumMeta): CDN = "Cdn" +class CertificateSourceParametersType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """CertificateSourceParametersType.""" + + CDN_CERTIFICATE_SOURCE_PARAMETERS = "CdnCertificateSourceParameters" + KEY_VAULT_CERTIFICATE_SOURCE_PARAMETERS = "KeyVaultCertificateSourceParameters" + + class CertificateType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Type of certificate used.""" @@ -133,12 +120,6 @@ class CertificateType(str, Enum, metaclass=CaseInsensitiveEnumMeta): DEDICATED = "Dedicated" -class ClientPortMatchConditionParametersTypeName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """ClientPortMatchConditionParametersTypeName.""" - - DELIVERY_RULE_CLIENT_PORT_CONDITION_PARAMETERS = "DeliveryRuleClientPortConditionParameters" - - class ClientPortOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Describes operator to be matched.""" @@ -154,12 +135,6 @@ class ClientPortOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): REG_EX = "RegEx" -class CookiesMatchConditionParametersTypeName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """CookiesMatchConditionParametersTypeName.""" - - DELIVERY_RULE_COOKIES_CONDITION_PARAMETERS = "DeliveryRuleCookiesConditionParameters" - - class CookiesOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Describes operator to be matched.""" @@ -239,6 +214,47 @@ class DeliveryRuleActionEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta): ROUTE_CONFIGURATION_OVERRIDE = "RouteConfigurationOverride" +class DeliveryRuleActionParametersType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """DeliveryRuleActionParametersType.""" + + DELIVERY_RULE_URL_REDIRECT_ACTION_PARAMETERS = "DeliveryRuleUrlRedirectActionParameters" + DELIVERY_RULE_URL_SIGNING_ACTION_PARAMETERS = "DeliveryRuleUrlSigningActionParameters" + DELIVERY_RULE_ORIGIN_GROUP_OVERRIDE_ACTION_PARAMETERS = "DeliveryRuleOriginGroupOverrideActionParameters" + DELIVERY_RULE_URL_REWRITE_ACTION_PARAMETERS = "DeliveryRuleUrlRewriteActionParameters" + DELIVERY_RULE_HEADER_ACTION_PARAMETERS = "DeliveryRuleHeaderActionParameters" + DELIVERY_RULE_CACHE_EXPIRATION_ACTION_PARAMETERS = "DeliveryRuleCacheExpirationActionParameters" + DELIVERY_RULE_CACHE_KEY_QUERY_STRING_BEHAVIOR_ACTION_PARAMETERS = ( + "DeliveryRuleCacheKeyQueryStringBehaviorActionParameters" + ) + DELIVERY_RULE_ROUTE_CONFIGURATION_OVERRIDE_ACTION_PARAMETERS = ( + "DeliveryRuleRouteConfigurationOverrideActionParameters" + ) + + +class DeliveryRuleConditionParametersType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """DeliveryRuleConditionParametersType.""" + + DELIVERY_RULE_REMOTE_ADDRESS_CONDITION_PARAMETERS = "DeliveryRuleRemoteAddressConditionParameters" + DELIVERY_RULE_REQUEST_METHOD_CONDITION_PARAMETERS = "DeliveryRuleRequestMethodConditionParameters" + DELIVERY_RULE_QUERY_STRING_CONDITION_PARAMETERS = "DeliveryRuleQueryStringConditionParameters" + DELIVERY_RULE_POST_ARGS_CONDITION_PARAMETERS = "DeliveryRulePostArgsConditionParameters" + DELIVERY_RULE_REQUEST_URI_CONDITION_PARAMETERS = "DeliveryRuleRequestUriConditionParameters" + DELIVERY_RULE_REQUEST_HEADER_CONDITION_PARAMETERS = "DeliveryRuleRequestHeaderConditionParameters" + DELIVERY_RULE_REQUEST_BODY_CONDITION_PARAMETERS = "DeliveryRuleRequestBodyConditionParameters" + DELIVERY_RULE_REQUEST_SCHEME_CONDITION_PARAMETERS = "DeliveryRuleRequestSchemeConditionParameters" + DELIVERY_RULE_URL_PATH_MATCH_CONDITION_PARAMETERS = "DeliveryRuleUrlPathMatchConditionParameters" + DELIVERY_RULE_URL_FILE_EXTENSION_MATCH_CONDITION_PARAMETERS = "DeliveryRuleUrlFileExtensionMatchConditionParameters" + DELIVERY_RULE_URL_FILENAME_CONDITION_PARAMETERS = "DeliveryRuleUrlFilenameConditionParameters" + DELIVERY_RULE_HTTP_VERSION_CONDITION_PARAMETERS = "DeliveryRuleHttpVersionConditionParameters" + DELIVERY_RULE_COOKIES_CONDITION_PARAMETERS = "DeliveryRuleCookiesConditionParameters" + DELIVERY_RULE_IS_DEVICE_CONDITION_PARAMETERS = "DeliveryRuleIsDeviceConditionParameters" + DELIVERY_RULE_SOCKET_ADDR_CONDITION_PARAMETERS = "DeliveryRuleSocketAddrConditionParameters" + DELIVERY_RULE_CLIENT_PORT_CONDITION_PARAMETERS = "DeliveryRuleClientPortConditionParameters" + DELIVERY_RULE_SERVER_PORT_CONDITION_PARAMETERS = "DeliveryRuleServerPortConditionParameters" + DELIVERY_RULE_HOST_NAME_CONDITION_PARAMETERS = "DeliveryRuleHostNameConditionParameters" + DELIVERY_RULE_SSL_PROTOCOL_CONDITION_PARAMETERS = "DeliveryRuleSslProtocolConditionParameters" + + class DeploymentStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """DeploymentStatus.""" @@ -323,12 +339,6 @@ class HeaderAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): DELETE = "Delete" -class HeaderActionParametersTypeName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """HeaderActionParametersTypeName.""" - - DELIVERY_RULE_HEADER_ACTION_PARAMETERS = "DeliveryRuleHeaderActionParameters" - - class HealthProbeRequestType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of health probe request that is made.""" @@ -337,12 +347,6 @@ class HealthProbeRequestType(str, Enum, metaclass=CaseInsensitiveEnumMeta): HEAD = "HEAD" -class HostNameMatchConditionParametersTypeName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """HostNameMatchConditionParametersTypeName.""" - - DELIVERY_RULE_HOST_NAME_CONDITION_PARAMETERS = "DeliveryRuleHostNameConditionParameters" - - class HostNameOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Describes operator to be matched.""" @@ -367,12 +371,6 @@ class HttpsRedirect(str, Enum, metaclass=CaseInsensitiveEnumMeta): DISABLED = "Disabled" -class HttpVersionMatchConditionParametersTypeName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """HttpVersionMatchConditionParametersTypeName.""" - - DELIVERY_RULE_HTTP_VERSION_CONDITION_PARAMETERS = "DeliveryRuleHttpVersionConditionParameters" - - class HttpVersionOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Describes operator to be matched.""" @@ -388,33 +386,21 @@ class IdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): KEY = "key" -class IsDeviceMatchConditionParametersMatchValuesItem(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """IsDeviceMatchConditionParametersMatchValuesItem.""" +class IsDeviceMatchValue(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """IsDeviceMatchValue.""" MOBILE = "Mobile" DESKTOP = "Desktop" -class IsDeviceMatchConditionParametersTypeName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """IsDeviceMatchConditionParametersTypeName.""" - - DELIVERY_RULE_IS_DEVICE_CONDITION_PARAMETERS = "DeliveryRuleIsDeviceConditionParameters" - - class IsDeviceOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Describes operator to be matched.""" EQUAL = "Equal" -class KeyVaultCertificateSourceParametersTypeName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """KeyVaultCertificateSourceParametersTypeName.""" - - KEY_VAULT_CERTIFICATE_SOURCE_PARAMETERS = "KeyVaultCertificateSourceParameters" - - -class KeyVaultSigningKeyParametersTypeName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """KeyVaultSigningKeyParametersTypeName.""" +class KeyVaultSigningKeyParametersType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """KeyVaultSigningKeyParametersType.""" KEY_VAULT_SIGNING_KEY_PARAMETERS = "KeyVaultSigningKeyParameters" @@ -501,8 +487,9 @@ class MatchProcessingBehavior(str, Enum, metaclass=CaseInsensitiveEnumMeta): If not present, defaults to Continue. """ - CONTINUE_ENUM = "Continue" + CONTINUE = "Continue" STOP = "Stop" + CONTINUE_ENUM = "Continue" class MatchVariable(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -583,12 +570,6 @@ class OptimizationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): DYNAMIC_SITE_ACCELERATION = "DynamicSiteAcceleration" -class OriginGroupOverrideActionParametersTypeName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """OriginGroupOverrideActionParametersTypeName.""" - - DELIVERY_RULE_ORIGIN_GROUP_OVERRIDE_ACTION_PARAMETERS = "DeliveryRuleOriginGroupOverrideActionParameters" - - class OriginGroupProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Provisioning status of the origin group.""" @@ -670,12 +651,6 @@ class PolicySettingsDefaultCustomBlockResponseStatusCode(int, Enum, metaclass=Ca FOUR_HUNDRED_TWENTY_NINE = 429 -class PostArgsMatchConditionParametersTypeName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """PostArgsMatchConditionParametersTypeName.""" - - DELIVERY_RULE_POST_ARGS_CONDITION_PARAMETERS = "DeliveryRulePostArgsConditionParameters" - - class PostArgsOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Describes operator to be matched.""" @@ -776,12 +751,6 @@ class QueryStringCachingBehavior(str, Enum, metaclass=CaseInsensitiveEnumMeta): NOT_SET = "NotSet" -class QueryStringMatchConditionParametersTypeName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """QueryStringMatchConditionParametersTypeName.""" - - DELIVERY_RULE_QUERY_STRING_CONDITION_PARAMETERS = "DeliveryRuleQueryStringConditionParameters" - - class QueryStringOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Describes operator to be matched.""" @@ -806,12 +775,6 @@ class RedirectType(str, Enum, metaclass=CaseInsensitiveEnumMeta): PERMANENT_REDIRECT = "PermanentRedirect" -class RemoteAddressMatchConditionParametersTypeName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """RemoteAddressMatchConditionParametersTypeName.""" - - DELIVERY_RULE_REMOTE_ADDRESS_CONDITION_PARAMETERS = "DeliveryRuleRemoteAddressConditionParameters" - - class RemoteAddressOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Describes operator to be matched.""" @@ -820,12 +783,6 @@ class RemoteAddressOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): GEO_MATCH = "GeoMatch" -class RequestBodyMatchConditionParametersTypeName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """RequestBodyMatchConditionParametersTypeName.""" - - DELIVERY_RULE_REQUEST_BODY_CONDITION_PARAMETERS = "DeliveryRuleRequestBodyConditionParameters" - - class RequestBodyOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Describes operator to be matched.""" @@ -841,12 +798,6 @@ class RequestBodyOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): REG_EX = "RegEx" -class RequestHeaderMatchConditionParametersTypeName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """RequestHeaderMatchConditionParametersTypeName.""" - - DELIVERY_RULE_REQUEST_HEADER_CONDITION_PARAMETERS = "DeliveryRuleRequestHeaderConditionParameters" - - class RequestHeaderOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Describes operator to be matched.""" @@ -862,8 +813,8 @@ class RequestHeaderOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): REG_EX = "RegEx" -class RequestMethodMatchConditionParametersMatchValuesItem(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """RequestMethodMatchConditionParametersMatchValuesItem.""" +class RequestMethodMatchValue(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """RequestMethodMatchValue.""" GET = "GET" HEAD = "HEAD" @@ -874,41 +825,23 @@ class RequestMethodMatchConditionParametersMatchValuesItem(str, Enum, metaclass= TRACE = "TRACE" -class RequestMethodMatchConditionParametersTypeName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """RequestMethodMatchConditionParametersTypeName.""" - - DELIVERY_RULE_REQUEST_METHOD_CONDITION_PARAMETERS = "DeliveryRuleRequestMethodConditionParameters" - - class RequestMethodOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Describes operator to be matched.""" EQUAL = "Equal" -class RequestSchemeMatchConditionParametersMatchValuesItem(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """RequestSchemeMatchConditionParametersMatchValuesItem.""" - - HTTP = "HTTP" - HTTPS = "HTTPS" - - class RequestSchemeMatchConditionParametersOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Describes operator to be matched.""" EQUAL = "Equal" -class RequestSchemeMatchConditionParametersTypeName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """RequestSchemeMatchConditionParametersTypeName.""" - - DELIVERY_RULE_REQUEST_SCHEME_CONDITION_PARAMETERS = "DeliveryRuleRequestSchemeConditionParameters" - - -class RequestUriMatchConditionParametersTypeName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """RequestUriMatchConditionParametersTypeName.""" +class RequestSchemeMatchValue(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """RequestSchemeMatchValue.""" - DELIVERY_RULE_REQUEST_URI_CONDITION_PARAMETERS = "DeliveryRuleRequestUriConditionParameters" + HTTP = "HTTP" + HTTPS = "HTTPS" class RequestUriOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -947,14 +880,6 @@ class ResponseBasedDetectedErrorTypes(str, Enum, metaclass=CaseInsensitiveEnumMe TCP_AND_HTTP_ERRORS = "TcpAndHttpErrors" -class RouteConfigurationOverrideActionParametersTypeName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """RouteConfigurationOverrideActionParametersTypeName.""" - - DELIVERY_RULE_ROUTE_CONFIGURATION_OVERRIDE_ACTION_PARAMETERS = ( - "DeliveryRuleRouteConfigurationOverrideActionParameters" - ) - - class RuleCacheBehavior(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Caching behavior for the requests.""" @@ -1023,12 +948,6 @@ class SecurityPolicyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): WEB_APPLICATION_FIREWALL = "WebApplicationFirewall" -class ServerPortMatchConditionParametersTypeName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """ServerPortMatchConditionParametersTypeName.""" - - DELIVERY_RULE_SERVER_PORT_CONDITION_PARAMETERS = "DeliveryRuleServerPortConditionParameters" - - class ServerPortOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Describes operator to be matched.""" @@ -1074,12 +993,6 @@ class SkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): STANDARD_PLUS_AVG_BAND_WIDTH_CHINA_CDN = "StandardPlus_AvgBandWidth_ChinaCdn" -class SocketAddrMatchConditionParametersTypeName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """SocketAddrMatchConditionParametersTypeName.""" - - DELIVERY_RULE_SOCKET_ADDR_CONDITION_PARAMETERS = "DeliveryRuleSocketAddrConditionParameters" - - class SocketAddrOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Describes operator to be matched.""" @@ -1095,12 +1008,6 @@ class SslProtocol(str, Enum, metaclass=CaseInsensitiveEnumMeta): TL_SV1_2 = "TLSv1.2" -class SslProtocolMatchConditionParametersTypeName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """SslProtocolMatchConditionParametersTypeName.""" - - DELIVERY_RULE_SSL_PROTOCOL_CONDITION_PARAMETERS = "DeliveryRuleSslProtocolConditionParameters" - - class SslProtocolOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Describes operator to be matched.""" @@ -1144,12 +1051,6 @@ class UpdateRule(str, Enum, metaclass=CaseInsensitiveEnumMeta): NO_ACTION = "NoAction" -class UrlFileExtensionMatchConditionParametersTypeName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """UrlFileExtensionMatchConditionParametersTypeName.""" - - DELIVERY_RULE_URL_FILE_EXTENSION_MATCH_CONDITION_PARAMETERS = "DeliveryRuleUrlFileExtensionMatchConditionParameters" - - class UrlFileExtensionOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Describes operator to be matched.""" @@ -1165,12 +1066,6 @@ class UrlFileExtensionOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): REG_EX = "RegEx" -class UrlFileNameMatchConditionParametersTypeName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """UrlFileNameMatchConditionParametersTypeName.""" - - DELIVERY_RULE_URL_FILENAME_CONDITION_PARAMETERS = "DeliveryRuleUrlFilenameConditionParameters" - - class UrlFileNameOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Describes operator to be matched.""" @@ -1186,12 +1081,6 @@ class UrlFileNameOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): REG_EX = "RegEx" -class UrlPathMatchConditionParametersTypeName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """UrlPathMatchConditionParametersTypeName.""" - - DELIVERY_RULE_URL_PATH_MATCH_CONDITION_PARAMETERS = "DeliveryRuleUrlPathMatchConditionParameters" - - class UrlPathOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Describes operator to be matched.""" @@ -1208,24 +1097,6 @@ class UrlPathOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): REG_EX = "RegEx" -class UrlRedirectActionParametersTypeName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """UrlRedirectActionParametersTypeName.""" - - DELIVERY_RULE_URL_REDIRECT_ACTION_PARAMETERS = "DeliveryRuleUrlRedirectActionParameters" - - -class UrlRewriteActionParametersTypeName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """UrlRewriteActionParametersTypeName.""" - - DELIVERY_RULE_URL_REWRITE_ACTION_PARAMETERS = "DeliveryRuleUrlRewriteActionParameters" - - -class UrlSigningActionParametersTypeName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """UrlSigningActionParametersTypeName.""" - - DELIVERY_RULE_URL_SIGNING_ACTION_PARAMETERS = "DeliveryRuleUrlSigningActionParameters" - - class UsageUnit(str, Enum, metaclass=CaseInsensitiveEnumMeta): """An enum describing the unit of measurement.""" diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/models/_models_py3.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/models/_models_py3.py index e5fd01153680..1a89370f5f0a 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/models/_models_py3.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/models/_models_py3.py @@ -2173,13 +2173,64 @@ def __init__( self.cache_duration = cache_duration -class CacheExpirationActionParameters(_serialization.Model): +class DeliveryRuleActionParameters(_serialization.Model): + """Defines the parameters for delivery rule actions. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + CacheExpirationActionParameters, CacheKeyQueryStringActionParameters, HeaderActionParameters, + OriginGroupOverrideActionParameters, RouteConfigurationOverrideActionParameters, + UrlRedirectActionParameters, UrlRewriteActionParameters, UrlSigningActionParameters + + All required parameters must be populated in order to send to server. + + :ivar type_name: Required. Known values are: "DeliveryRuleUrlRedirectActionParameters", + "DeliveryRuleUrlSigningActionParameters", "DeliveryRuleOriginGroupOverrideActionParameters", + "DeliveryRuleUrlRewriteActionParameters", "DeliveryRuleHeaderActionParameters", + "DeliveryRuleCacheExpirationActionParameters", + "DeliveryRuleCacheKeyQueryStringBehaviorActionParameters", and + "DeliveryRuleRouteConfigurationOverrideActionParameters". + :vartype type_name: str or ~azure.mgmt.cdn.models.DeliveryRuleActionParametersType + """ + + _validation = { + "type_name": {"required": True}, + } + + _attribute_map = { + "type_name": {"key": "typeName", "type": "str"}, + } + + _subtype_map = { + "type_name": { + "DeliveryRuleCacheExpirationActionParameters": "CacheExpirationActionParameters", + "DeliveryRuleCacheKeyQueryStringBehaviorActionParameters": "CacheKeyQueryStringActionParameters", + "DeliveryRuleHeaderActionParameters": "HeaderActionParameters", + "DeliveryRuleOriginGroupOverrideActionParameters": "OriginGroupOverrideActionParameters", + "DeliveryRuleRouteConfigurationOverrideActionParameters": "RouteConfigurationOverrideActionParameters", + "DeliveryRuleUrlRedirectActionParameters": "UrlRedirectActionParameters", + "DeliveryRuleUrlRewriteActionParameters": "UrlRewriteActionParameters", + "DeliveryRuleUrlSigningActionParameters": "UrlSigningActionParameters", + } + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.type_name: Optional[str] = None + + +class CacheExpirationActionParameters(DeliveryRuleActionParameters): """Defines the parameters for the cache expiration action. All required parameters must be populated in order to send to server. - :ivar type_name: Required. "DeliveryRuleCacheExpirationActionParameters" - :vartype type_name: str or ~azure.mgmt.cdn.models.CacheExpirationActionParametersTypeName + :ivar type_name: Required. Known values are: "DeliveryRuleUrlRedirectActionParameters", + "DeliveryRuleUrlSigningActionParameters", "DeliveryRuleOriginGroupOverrideActionParameters", + "DeliveryRuleUrlRewriteActionParameters", "DeliveryRuleHeaderActionParameters", + "DeliveryRuleCacheExpirationActionParameters", + "DeliveryRuleCacheKeyQueryStringBehaviorActionParameters", and + "DeliveryRuleRouteConfigurationOverrideActionParameters". + :vartype type_name: str or ~azure.mgmt.cdn.models.DeliveryRuleActionParametersType :ivar cache_behavior: Caching behavior for the requests. Required. Known values are: "BypassCache", "Override", and "SetIfMissing". :vartype cache_behavior: str or ~azure.mgmt.cdn.models.CacheBehavior @@ -2206,15 +2257,12 @@ class CacheExpirationActionParameters(_serialization.Model): def __init__( self, *, - type_name: Union[str, "_models.CacheExpirationActionParametersTypeName"], cache_behavior: Union[str, "_models.CacheBehavior"], cache_type: Union[str, "_models.CacheType"], cache_duration: Optional[str] = None, **kwargs: Any ) -> None: """ - :keyword type_name: Required. "DeliveryRuleCacheExpirationActionParameters" - :paramtype type_name: str or ~azure.mgmt.cdn.models.CacheExpirationActionParametersTypeName :keyword cache_behavior: Caching behavior for the requests. Required. Known values are: "BypassCache", "Override", and "SetIfMissing". :paramtype cache_behavior: str or ~azure.mgmt.cdn.models.CacheBehavior @@ -2225,19 +2273,24 @@ def __init__( :paramtype cache_duration: str """ super().__init__(**kwargs) - self.type_name = type_name + self.type_name: str = "DeliveryRuleCacheExpirationActionParameters" self.cache_behavior = cache_behavior self.cache_type = cache_type self.cache_duration = cache_duration -class CacheKeyQueryStringActionParameters(_serialization.Model): +class CacheKeyQueryStringActionParameters(DeliveryRuleActionParameters): """Defines the parameters for the cache-key query string action. All required parameters must be populated in order to send to server. - :ivar type_name: Required. "DeliveryRuleCacheKeyQueryStringBehaviorActionParameters" - :vartype type_name: str or ~azure.mgmt.cdn.models.CacheKeyQueryStringActionParametersTypeName + :ivar type_name: Required. Known values are: "DeliveryRuleUrlRedirectActionParameters", + "DeliveryRuleUrlSigningActionParameters", "DeliveryRuleOriginGroupOverrideActionParameters", + "DeliveryRuleUrlRewriteActionParameters", "DeliveryRuleHeaderActionParameters", + "DeliveryRuleCacheExpirationActionParameters", + "DeliveryRuleCacheKeyQueryStringBehaviorActionParameters", and + "DeliveryRuleRouteConfigurationOverrideActionParameters". + :vartype type_name: str or ~azure.mgmt.cdn.models.DeliveryRuleActionParametersType :ivar query_string_behavior: Caching behavior for the requests. Required. Known values are: "Include", "IncludeAll", "Exclude", and "ExcludeAll". :vartype query_string_behavior: str or ~azure.mgmt.cdn.models.QueryStringBehavior @@ -2259,14 +2312,11 @@ class CacheKeyQueryStringActionParameters(_serialization.Model): def __init__( self, *, - type_name: Union[str, "_models.CacheKeyQueryStringActionParametersTypeName"], query_string_behavior: Union[str, "_models.QueryStringBehavior"], query_parameters: Optional[str] = None, **kwargs: Any ) -> None: """ - :keyword type_name: Required. "DeliveryRuleCacheKeyQueryStringBehaviorActionParameters" - :paramtype type_name: str or ~azure.mgmt.cdn.models.CacheKeyQueryStringActionParametersTypeName :keyword query_string_behavior: Caching behavior for the requests. Required. Known values are: "Include", "IncludeAll", "Exclude", and "ExcludeAll". :paramtype query_string_behavior: str or ~azure.mgmt.cdn.models.QueryStringBehavior @@ -2274,7 +2324,7 @@ def __init__( :paramtype query_parameters: str """ super().__init__(**kwargs) - self.type_name = type_name + self.type_name: str = "DeliveryRuleCacheKeyQueryStringBehaviorActionParameters" self.query_string_behavior = query_string_behavior self.query_parameters = query_parameters @@ -2353,13 +2403,48 @@ def __init__(self, *, errors: Optional[List["_models.MigrationErrorType"]] = Non self.errors = errors -class CdnCertificateSourceParameters(_serialization.Model): +class CertificateSourceParameters(_serialization.Model): + """Defines the parameters for certificate source. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + CdnCertificateSourceParameters, KeyVaultCertificateSourceParameters + + All required parameters must be populated in order to send to server. + + :ivar type_name: Required. Known values are: "CdnCertificateSourceParameters" and + "KeyVaultCertificateSourceParameters". + :vartype type_name: str or ~azure.mgmt.cdn.models.CertificateSourceParametersType + """ + + _validation = { + "type_name": {"required": True}, + } + + _attribute_map = { + "type_name": {"key": "typeName", "type": "str"}, + } + + _subtype_map = { + "type_name": { + "CdnCertificateSourceParameters": "CdnCertificateSourceParameters", + "KeyVaultCertificateSourceParameters": "KeyVaultCertificateSourceParameters", + } + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.type_name: Optional[str] = None + + +class CdnCertificateSourceParameters(CertificateSourceParameters): """Defines the parameters for using CDN managed certificate for securing custom domain. All required parameters must be populated in order to send to server. - :ivar type_name: Required. "CdnCertificateSourceParameters" - :vartype type_name: str or ~azure.mgmt.cdn.models.CdnCertificateSourceParametersTypeName + :ivar type_name: Required. Known values are: "CdnCertificateSourceParameters" and + "KeyVaultCertificateSourceParameters". + :vartype type_name: str or ~azure.mgmt.cdn.models.CertificateSourceParametersType :ivar certificate_type: Type of certificate used. Required. Known values are: "Shared" and "Dedicated". :vartype certificate_type: str or ~azure.mgmt.cdn.models.CertificateType @@ -2375,22 +2460,14 @@ class CdnCertificateSourceParameters(_serialization.Model): "certificate_type": {"key": "certificateType", "type": "str"}, } - def __init__( - self, - *, - type_name: Union[str, "_models.CdnCertificateSourceParametersTypeName"], - certificate_type: Union[str, "_models.CertificateType"], - **kwargs: Any - ) -> None: + def __init__(self, *, certificate_type: Union[str, "_models.CertificateType"], **kwargs: Any) -> None: """ - :keyword type_name: Required. "CdnCertificateSourceParameters" - :paramtype type_name: str or ~azure.mgmt.cdn.models.CdnCertificateSourceParametersTypeName :keyword certificate_type: Type of certificate used. Required. Known values are: "Shared" and "Dedicated". :paramtype certificate_type: str or ~azure.mgmt.cdn.models.CertificateType """ super().__init__(**kwargs) - self.type_name = type_name + self.type_name: str = "CdnCertificateSourceParameters" self.certificate_type = certificate_type @@ -2528,6 +2605,46 @@ def __init__( self.certificate_source_parameters = certificate_source_parameters +class CdnMigrationToAfdParameters(_serialization.Model): + """Request body for Migrate operation. + + All required parameters must be populated in order to send to server. + + :ivar sku: Sku for the migration. Required. + :vartype sku: ~azure.mgmt.cdn.models.Sku + :ivar migration_endpoint_mappings: A name map between classic CDN endpoints and AFD + Premium/Standard endpoints. + :vartype migration_endpoint_mappings: list[~azure.mgmt.cdn.models.MigrationEndpointMapping] + """ + + _validation = { + "sku": {"required": True}, + } + + _attribute_map = { + "sku": {"key": "sku", "type": "Sku"}, + "migration_endpoint_mappings": {"key": "migrationEndpointMappings", "type": "[MigrationEndpointMapping]"}, + } + + def __init__( + self, + *, + sku: "_models.Sku", + migration_endpoint_mappings: Optional[List["_models.MigrationEndpointMapping"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword sku: Sku for the migration. Required. + :paramtype sku: ~azure.mgmt.cdn.models.Sku + :keyword migration_endpoint_mappings: A name map between classic CDN endpoints and AFD + Premium/Standard endpoints. + :paramtype migration_endpoint_mappings: list[~azure.mgmt.cdn.models.MigrationEndpointMapping] + """ + super().__init__(**kwargs) + self.sku = sku + self.migration_endpoint_mappings = migration_endpoint_mappings + + class CdnWebApplicationFirewallPolicy(TrackedResource): # pylint: disable=too-many-instance-attributes """Defines web application firewall policy for Azure CDN. @@ -2925,13 +3042,92 @@ def __init__( self.prefix_length = prefix_length -class ClientPortMatchConditionParameters(_serialization.Model): +class DeliveryRuleConditionParameters(_serialization.Model): + """Defines the parameters for delivery rule match conditions. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + ClientPortMatchConditionParameters, CookiesMatchConditionParameters, + HostNameMatchConditionParameters, HttpVersionMatchConditionParameters, + IsDeviceMatchConditionParameters, PostArgsMatchConditionParameters, + QueryStringMatchConditionParameters, RemoteAddressMatchConditionParameters, + RequestBodyMatchConditionParameters, RequestHeaderMatchConditionParameters, + RequestMethodMatchConditionParameters, RequestSchemeMatchConditionParameters, + RequestUriMatchConditionParameters, ServerPortMatchConditionParameters, + SocketAddrMatchConditionParameters, SslProtocolMatchConditionParameters, + UrlFileExtensionMatchConditionParameters, UrlFileNameMatchConditionParameters, + UrlPathMatchConditionParameters + + All required parameters must be populated in order to send to server. + + :ivar type_name: Required. Known values are: "DeliveryRuleRemoteAddressConditionParameters", + "DeliveryRuleRequestMethodConditionParameters", "DeliveryRuleQueryStringConditionParameters", + "DeliveryRulePostArgsConditionParameters", "DeliveryRuleRequestUriConditionParameters", + "DeliveryRuleRequestHeaderConditionParameters", "DeliveryRuleRequestBodyConditionParameters", + "DeliveryRuleRequestSchemeConditionParameters", "DeliveryRuleUrlPathMatchConditionParameters", + "DeliveryRuleUrlFileExtensionMatchConditionParameters", + "DeliveryRuleUrlFilenameConditionParameters", "DeliveryRuleHttpVersionConditionParameters", + "DeliveryRuleCookiesConditionParameters", "DeliveryRuleIsDeviceConditionParameters", + "DeliveryRuleSocketAddrConditionParameters", "DeliveryRuleClientPortConditionParameters", + "DeliveryRuleServerPortConditionParameters", "DeliveryRuleHostNameConditionParameters", and + "DeliveryRuleSslProtocolConditionParameters". + :vartype type_name: str or ~azure.mgmt.cdn.models.DeliveryRuleConditionParametersType + """ + + _validation = { + "type_name": {"required": True}, + } + + _attribute_map = { + "type_name": {"key": "typeName", "type": "str"}, + } + + _subtype_map = { + "type_name": { + "DeliveryRuleClientPortConditionParameters": "ClientPortMatchConditionParameters", + "DeliveryRuleCookiesConditionParameters": "CookiesMatchConditionParameters", + "DeliveryRuleHostNameConditionParameters": "HostNameMatchConditionParameters", + "DeliveryRuleHttpVersionConditionParameters": "HttpVersionMatchConditionParameters", + "DeliveryRuleIsDeviceConditionParameters": "IsDeviceMatchConditionParameters", + "DeliveryRulePostArgsConditionParameters": "PostArgsMatchConditionParameters", + "DeliveryRuleQueryStringConditionParameters": "QueryStringMatchConditionParameters", + "DeliveryRuleRemoteAddressConditionParameters": "RemoteAddressMatchConditionParameters", + "DeliveryRuleRequestBodyConditionParameters": "RequestBodyMatchConditionParameters", + "DeliveryRuleRequestHeaderConditionParameters": "RequestHeaderMatchConditionParameters", + "DeliveryRuleRequestMethodConditionParameters": "RequestMethodMatchConditionParameters", + "DeliveryRuleRequestSchemeConditionParameters": "RequestSchemeMatchConditionParameters", + "DeliveryRuleRequestUriConditionParameters": "RequestUriMatchConditionParameters", + "DeliveryRuleServerPortConditionParameters": "ServerPortMatchConditionParameters", + "DeliveryRuleSocketAddrConditionParameters": "SocketAddrMatchConditionParameters", + "DeliveryRuleSslProtocolConditionParameters": "SslProtocolMatchConditionParameters", + "DeliveryRuleUrlFileExtensionMatchConditionParameters": "UrlFileExtensionMatchConditionParameters", + "DeliveryRuleUrlFilenameConditionParameters": "UrlFileNameMatchConditionParameters", + "DeliveryRuleUrlPathMatchConditionParameters": "UrlPathMatchConditionParameters", + } + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.type_name: Optional[str] = None + + +class ClientPortMatchConditionParameters(DeliveryRuleConditionParameters): """Defines the parameters for ClientPort match conditions. All required parameters must be populated in order to send to server. - :ivar type_name: Required. "DeliveryRuleClientPortConditionParameters" - :vartype type_name: str or ~azure.mgmt.cdn.models.ClientPortMatchConditionParametersTypeName + :ivar type_name: Required. Known values are: "DeliveryRuleRemoteAddressConditionParameters", + "DeliveryRuleRequestMethodConditionParameters", "DeliveryRuleQueryStringConditionParameters", + "DeliveryRulePostArgsConditionParameters", "DeliveryRuleRequestUriConditionParameters", + "DeliveryRuleRequestHeaderConditionParameters", "DeliveryRuleRequestBodyConditionParameters", + "DeliveryRuleRequestSchemeConditionParameters", "DeliveryRuleUrlPathMatchConditionParameters", + "DeliveryRuleUrlFileExtensionMatchConditionParameters", + "DeliveryRuleUrlFilenameConditionParameters", "DeliveryRuleHttpVersionConditionParameters", + "DeliveryRuleCookiesConditionParameters", "DeliveryRuleIsDeviceConditionParameters", + "DeliveryRuleSocketAddrConditionParameters", "DeliveryRuleClientPortConditionParameters", + "DeliveryRuleServerPortConditionParameters", "DeliveryRuleHostNameConditionParameters", and + "DeliveryRuleSslProtocolConditionParameters". + :vartype type_name: str or ~azure.mgmt.cdn.models.DeliveryRuleConditionParametersType :ivar operator: Describes operator to be matched. Required. Known values are: "Any", "Equal", "Contains", "BeginsWith", "EndsWith", "LessThan", "LessThanOrEqual", "GreaterThan", "GreaterThanOrEqual", and "RegEx". @@ -2960,7 +3156,6 @@ class ClientPortMatchConditionParameters(_serialization.Model): def __init__( self, *, - type_name: Union[str, "_models.ClientPortMatchConditionParametersTypeName"], operator: Union[str, "_models.ClientPortOperator"], negate_condition: bool = False, match_values: Optional[List[str]] = None, @@ -2968,8 +3163,6 @@ def __init__( **kwargs: Any ) -> None: """ - :keyword type_name: Required. "DeliveryRuleClientPortConditionParameters" - :paramtype type_name: str or ~azure.mgmt.cdn.models.ClientPortMatchConditionParametersTypeName :keyword operator: Describes operator to be matched. Required. Known values are: "Any", "Equal", "Contains", "BeginsWith", "EndsWith", "LessThan", "LessThanOrEqual", "GreaterThan", "GreaterThanOrEqual", and "RegEx". @@ -2982,7 +3175,7 @@ def __init__( :paramtype transforms: list[str or ~azure.mgmt.cdn.models.Transform] """ super().__init__(**kwargs) - self.type_name = type_name + self.type_name: str = "DeliveryRuleClientPortConditionParameters" self.operator = operator self.negate_condition = negate_condition self.match_values = match_values @@ -3216,13 +3409,23 @@ def __init__( self.continent_id = continent_id -class CookiesMatchConditionParameters(_serialization.Model): +class CookiesMatchConditionParameters(DeliveryRuleConditionParameters): """Defines the parameters for Cookies match conditions. All required parameters must be populated in order to send to server. - :ivar type_name: Required. "DeliveryRuleCookiesConditionParameters" - :vartype type_name: str or ~azure.mgmt.cdn.models.CookiesMatchConditionParametersTypeName + :ivar type_name: Required. Known values are: "DeliveryRuleRemoteAddressConditionParameters", + "DeliveryRuleRequestMethodConditionParameters", "DeliveryRuleQueryStringConditionParameters", + "DeliveryRulePostArgsConditionParameters", "DeliveryRuleRequestUriConditionParameters", + "DeliveryRuleRequestHeaderConditionParameters", "DeliveryRuleRequestBodyConditionParameters", + "DeliveryRuleRequestSchemeConditionParameters", "DeliveryRuleUrlPathMatchConditionParameters", + "DeliveryRuleUrlFileExtensionMatchConditionParameters", + "DeliveryRuleUrlFilenameConditionParameters", "DeliveryRuleHttpVersionConditionParameters", + "DeliveryRuleCookiesConditionParameters", "DeliveryRuleIsDeviceConditionParameters", + "DeliveryRuleSocketAddrConditionParameters", "DeliveryRuleClientPortConditionParameters", + "DeliveryRuleServerPortConditionParameters", "DeliveryRuleHostNameConditionParameters", and + "DeliveryRuleSslProtocolConditionParameters". + :vartype type_name: str or ~azure.mgmt.cdn.models.DeliveryRuleConditionParametersType :ivar selector: Name of Cookies to be matched. :vartype selector: str :ivar operator: Describes operator to be matched. Required. Known values are: "Any", "Equal", @@ -3254,7 +3457,6 @@ class CookiesMatchConditionParameters(_serialization.Model): def __init__( self, *, - type_name: Union[str, "_models.CookiesMatchConditionParametersTypeName"], operator: Union[str, "_models.CookiesOperator"], selector: Optional[str] = None, negate_condition: bool = False, @@ -3263,8 +3465,6 @@ def __init__( **kwargs: Any ) -> None: """ - :keyword type_name: Required. "DeliveryRuleCookiesConditionParameters" - :paramtype type_name: str or ~azure.mgmt.cdn.models.CookiesMatchConditionParametersTypeName :keyword selector: Name of Cookies to be matched. :paramtype selector: str :keyword operator: Describes operator to be matched. Required. Known values are: "Any", @@ -3279,7 +3479,7 @@ def __init__( :paramtype transforms: list[str or ~azure.mgmt.cdn.models.Transform] """ super().__init__(**kwargs) - self.type_name = type_name + self.type_name: str = "DeliveryRuleCookiesConditionParameters" self.selector = selector self.operator = operator self.negate_condition = negate_condition @@ -6068,6 +6268,49 @@ def __init__(self, **kwargs: Any) -> None: self.additional_info = None +class ErrorDetailAutoGenerated(_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.ErrorDetailAutoGenerated] + :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": "[ErrorDetailAutoGenerated]"}, + "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. @@ -6089,6 +6332,27 @@ def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs: A self.error = error +class ErrorResponseAutoGenerated(_serialization.Model): + """Common error response for all Azure Resource Manager APIs to return error details for failed + operations. (This also follows the OData error response format.). + + :ivar error: The error object. + :vartype error: ~azure.mgmt.cdn.models.ErrorDetailAutoGenerated + """ + + _attribute_map = { + "error": {"key": "error", "type": "ErrorDetailAutoGenerated"}, + } + + def __init__(self, *, error: Optional["_models.ErrorDetailAutoGenerated"] = None, **kwargs: Any) -> None: + """ + :keyword error: The error object. + :paramtype error: ~azure.mgmt.cdn.models.ErrorDetailAutoGenerated + """ + super().__init__(**kwargs) + self.error = error + + class GeoFilter(_serialization.Model): """Rules defining user's geo access within a CDN endpoint. @@ -6142,13 +6406,18 @@ def __init__( self.country_codes = country_codes -class HeaderActionParameters(_serialization.Model): +class HeaderActionParameters(DeliveryRuleActionParameters): """Defines the parameters for the request header action. All required parameters must be populated in order to send to server. - :ivar type_name: Required. "DeliveryRuleHeaderActionParameters" - :vartype type_name: str or ~azure.mgmt.cdn.models.HeaderActionParametersTypeName + :ivar type_name: Required. Known values are: "DeliveryRuleUrlRedirectActionParameters", + "DeliveryRuleUrlSigningActionParameters", "DeliveryRuleOriginGroupOverrideActionParameters", + "DeliveryRuleUrlRewriteActionParameters", "DeliveryRuleHeaderActionParameters", + "DeliveryRuleCacheExpirationActionParameters", + "DeliveryRuleCacheKeyQueryStringBehaviorActionParameters", and + "DeliveryRuleRouteConfigurationOverrideActionParameters". + :vartype type_name: str or ~azure.mgmt.cdn.models.DeliveryRuleActionParametersType :ivar header_action: Action to perform. Required. Known values are: "Append", "Overwrite", and "Delete". :vartype header_action: str or ~azure.mgmt.cdn.models.HeaderAction @@ -6174,15 +6443,12 @@ class HeaderActionParameters(_serialization.Model): def __init__( self, *, - type_name: Union[str, "_models.HeaderActionParametersTypeName"], header_action: Union[str, "_models.HeaderAction"], header_name: str, value: Optional[str] = None, **kwargs: Any ) -> None: """ - :keyword type_name: Required. "DeliveryRuleHeaderActionParameters" - :paramtype type_name: str or ~azure.mgmt.cdn.models.HeaderActionParametersTypeName :keyword header_action: Action to perform. Required. Known values are: "Append", "Overwrite", and "Delete". :paramtype header_action: str or ~azure.mgmt.cdn.models.HeaderAction @@ -6192,7 +6458,7 @@ def __init__( :paramtype value: str """ super().__init__(**kwargs) - self.type_name = type_name + self.type_name: str = "DeliveryRuleHeaderActionParameters" self.header_action = header_action self.header_name = header_name self.value = value @@ -6255,13 +6521,23 @@ def __init__( self.probe_interval_in_seconds = probe_interval_in_seconds -class HostNameMatchConditionParameters(_serialization.Model): +class HostNameMatchConditionParameters(DeliveryRuleConditionParameters): """Defines the parameters for HostName match conditions. All required parameters must be populated in order to send to server. - :ivar type_name: Required. "DeliveryRuleHostNameConditionParameters" - :vartype type_name: str or ~azure.mgmt.cdn.models.HostNameMatchConditionParametersTypeName + :ivar type_name: Required. Known values are: "DeliveryRuleRemoteAddressConditionParameters", + "DeliveryRuleRequestMethodConditionParameters", "DeliveryRuleQueryStringConditionParameters", + "DeliveryRulePostArgsConditionParameters", "DeliveryRuleRequestUriConditionParameters", + "DeliveryRuleRequestHeaderConditionParameters", "DeliveryRuleRequestBodyConditionParameters", + "DeliveryRuleRequestSchemeConditionParameters", "DeliveryRuleUrlPathMatchConditionParameters", + "DeliveryRuleUrlFileExtensionMatchConditionParameters", + "DeliveryRuleUrlFilenameConditionParameters", "DeliveryRuleHttpVersionConditionParameters", + "DeliveryRuleCookiesConditionParameters", "DeliveryRuleIsDeviceConditionParameters", + "DeliveryRuleSocketAddrConditionParameters", "DeliveryRuleClientPortConditionParameters", + "DeliveryRuleServerPortConditionParameters", "DeliveryRuleHostNameConditionParameters", and + "DeliveryRuleSslProtocolConditionParameters". + :vartype type_name: str or ~azure.mgmt.cdn.models.DeliveryRuleConditionParametersType :ivar operator: Describes operator to be matched. Required. Known values are: "Any", "Equal", "Contains", "BeginsWith", "EndsWith", "LessThan", "LessThanOrEqual", "GreaterThan", "GreaterThanOrEqual", and "RegEx". @@ -6290,7 +6566,6 @@ class HostNameMatchConditionParameters(_serialization.Model): def __init__( self, *, - type_name: Union[str, "_models.HostNameMatchConditionParametersTypeName"], operator: Union[str, "_models.HostNameOperator"], negate_condition: bool = False, match_values: Optional[List[str]] = None, @@ -6298,8 +6573,6 @@ def __init__( **kwargs: Any ) -> None: """ - :keyword type_name: Required. "DeliveryRuleHostNameConditionParameters" - :paramtype type_name: str or ~azure.mgmt.cdn.models.HostNameMatchConditionParametersTypeName :keyword operator: Describes operator to be matched. Required. Known values are: "Any", "Equal", "Contains", "BeginsWith", "EndsWith", "LessThan", "LessThanOrEqual", "GreaterThan", "GreaterThanOrEqual", and "RegEx". @@ -6312,7 +6585,7 @@ def __init__( :paramtype transforms: list[str or ~azure.mgmt.cdn.models.Transform] """ super().__init__(**kwargs) - self.type_name = type_name + self.type_name: str = "DeliveryRuleHostNameConditionParameters" self.operator = operator self.negate_condition = negate_condition self.match_values = match_values @@ -6350,13 +6623,23 @@ def __init__(self, *, begin: Optional[int] = None, end: Optional[int] = None, ** self.end = end -class HttpVersionMatchConditionParameters(_serialization.Model): +class HttpVersionMatchConditionParameters(DeliveryRuleConditionParameters): """Defines the parameters for HttpVersion match conditions. All required parameters must be populated in order to send to server. - :ivar type_name: Required. "DeliveryRuleHttpVersionConditionParameters" - :vartype type_name: str or ~azure.mgmt.cdn.models.HttpVersionMatchConditionParametersTypeName + :ivar type_name: Required. Known values are: "DeliveryRuleRemoteAddressConditionParameters", + "DeliveryRuleRequestMethodConditionParameters", "DeliveryRuleQueryStringConditionParameters", + "DeliveryRulePostArgsConditionParameters", "DeliveryRuleRequestUriConditionParameters", + "DeliveryRuleRequestHeaderConditionParameters", "DeliveryRuleRequestBodyConditionParameters", + "DeliveryRuleRequestSchemeConditionParameters", "DeliveryRuleUrlPathMatchConditionParameters", + "DeliveryRuleUrlFileExtensionMatchConditionParameters", + "DeliveryRuleUrlFilenameConditionParameters", "DeliveryRuleHttpVersionConditionParameters", + "DeliveryRuleCookiesConditionParameters", "DeliveryRuleIsDeviceConditionParameters", + "DeliveryRuleSocketAddrConditionParameters", "DeliveryRuleClientPortConditionParameters", + "DeliveryRuleServerPortConditionParameters", "DeliveryRuleHostNameConditionParameters", and + "DeliveryRuleSslProtocolConditionParameters". + :vartype type_name: str or ~azure.mgmt.cdn.models.DeliveryRuleConditionParametersType :ivar operator: Describes operator to be matched. Required. "Equal" :vartype operator: str or ~azure.mgmt.cdn.models.HttpVersionOperator :ivar negate_condition: Describes if this is negate condition or not. @@ -6383,7 +6666,6 @@ class HttpVersionMatchConditionParameters(_serialization.Model): def __init__( self, *, - type_name: Union[str, "_models.HttpVersionMatchConditionParametersTypeName"], operator: Union[str, "_models.HttpVersionOperator"], negate_condition: bool = False, match_values: Optional[List[str]] = None, @@ -6391,8 +6673,6 @@ def __init__( **kwargs: Any ) -> None: """ - :keyword type_name: Required. "DeliveryRuleHttpVersionConditionParameters" - :paramtype type_name: str or ~azure.mgmt.cdn.models.HttpVersionMatchConditionParametersTypeName :keyword operator: Describes operator to be matched. Required. "Equal" :paramtype operator: str or ~azure.mgmt.cdn.models.HttpVersionOperator :keyword negate_condition: Describes if this is negate condition or not. @@ -6403,7 +6683,7 @@ def __init__( :paramtype transforms: list[str or ~azure.mgmt.cdn.models.Transform] """ super().__init__(**kwargs) - self.type_name = type_name + self.type_name: str = "DeliveryRuleHttpVersionConditionParameters" self.operator = operator self.negate_condition = negate_condition self.match_values = match_values @@ -6449,20 +6729,29 @@ def __init__( self.ipv6_addresses = ipv6_addresses -class IsDeviceMatchConditionParameters(_serialization.Model): +class IsDeviceMatchConditionParameters(DeliveryRuleConditionParameters): """Defines the parameters for IsDevice match conditions. All required parameters must be populated in order to send to server. - :ivar type_name: Required. "DeliveryRuleIsDeviceConditionParameters" - :vartype type_name: str or ~azure.mgmt.cdn.models.IsDeviceMatchConditionParametersTypeName + :ivar type_name: Required. Known values are: "DeliveryRuleRemoteAddressConditionParameters", + "DeliveryRuleRequestMethodConditionParameters", "DeliveryRuleQueryStringConditionParameters", + "DeliveryRulePostArgsConditionParameters", "DeliveryRuleRequestUriConditionParameters", + "DeliveryRuleRequestHeaderConditionParameters", "DeliveryRuleRequestBodyConditionParameters", + "DeliveryRuleRequestSchemeConditionParameters", "DeliveryRuleUrlPathMatchConditionParameters", + "DeliveryRuleUrlFileExtensionMatchConditionParameters", + "DeliveryRuleUrlFilenameConditionParameters", "DeliveryRuleHttpVersionConditionParameters", + "DeliveryRuleCookiesConditionParameters", "DeliveryRuleIsDeviceConditionParameters", + "DeliveryRuleSocketAddrConditionParameters", "DeliveryRuleClientPortConditionParameters", + "DeliveryRuleServerPortConditionParameters", "DeliveryRuleHostNameConditionParameters", and + "DeliveryRuleSslProtocolConditionParameters". + :vartype type_name: str or ~azure.mgmt.cdn.models.DeliveryRuleConditionParametersType :ivar operator: Describes operator to be matched. Required. "Equal" :vartype operator: str or ~azure.mgmt.cdn.models.IsDeviceOperator :ivar negate_condition: Describes if this is negate condition or not. :vartype negate_condition: bool :ivar match_values: The match value for the condition of the delivery rule. - :vartype match_values: list[str or - ~azure.mgmt.cdn.models.IsDeviceMatchConditionParametersMatchValuesItem] + :vartype match_values: list[str or ~azure.mgmt.cdn.models.IsDeviceMatchValue] :ivar transforms: List of transforms. :vartype transforms: list[str or ~azure.mgmt.cdn.models.Transform] """ @@ -6483,41 +6772,38 @@ class IsDeviceMatchConditionParameters(_serialization.Model): def __init__( self, *, - type_name: Union[str, "_models.IsDeviceMatchConditionParametersTypeName"], operator: Union[str, "_models.IsDeviceOperator"], negate_condition: bool = False, - match_values: Optional[List[Union[str, "_models.IsDeviceMatchConditionParametersMatchValuesItem"]]] = None, + match_values: Optional[List[Union[str, "_models.IsDeviceMatchValue"]]] = None, transforms: Optional[List[Union[str, "_models.Transform"]]] = None, **kwargs: Any ) -> None: """ - :keyword type_name: Required. "DeliveryRuleIsDeviceConditionParameters" - :paramtype type_name: str or ~azure.mgmt.cdn.models.IsDeviceMatchConditionParametersTypeName :keyword operator: Describes operator to be matched. Required. "Equal" :paramtype operator: str or ~azure.mgmt.cdn.models.IsDeviceOperator :keyword negate_condition: Describes if this is negate condition or not. :paramtype negate_condition: bool :keyword match_values: The match value for the condition of the delivery rule. - :paramtype match_values: list[str or - ~azure.mgmt.cdn.models.IsDeviceMatchConditionParametersMatchValuesItem] + :paramtype match_values: list[str or ~azure.mgmt.cdn.models.IsDeviceMatchValue] :keyword transforms: List of transforms. :paramtype transforms: list[str or ~azure.mgmt.cdn.models.Transform] """ super().__init__(**kwargs) - self.type_name = type_name + self.type_name: str = "DeliveryRuleIsDeviceConditionParameters" self.operator = operator self.negate_condition = negate_condition self.match_values = match_values self.transforms = transforms -class KeyVaultCertificateSourceParameters(_serialization.Model): +class KeyVaultCertificateSourceParameters(CertificateSourceParameters): """Describes the parameters for using a user's KeyVault certificate for securing custom domain. All required parameters must be populated in order to send to server. - :ivar type_name: Required. "KeyVaultCertificateSourceParameters" - :vartype type_name: str or ~azure.mgmt.cdn.models.KeyVaultCertificateSourceParametersTypeName + :ivar type_name: Required. Known values are: "CdnCertificateSourceParameters" and + "KeyVaultCertificateSourceParameters". + :vartype type_name: str or ~azure.mgmt.cdn.models.CertificateSourceParametersType :ivar subscription_id: Subscription Id of the user's Key Vault containing the SSL certificate. Required. :vartype subscription_id: str @@ -6563,7 +6849,6 @@ class KeyVaultCertificateSourceParameters(_serialization.Model): def __init__( self, *, - type_name: Union[str, "_models.KeyVaultCertificateSourceParametersTypeName"], subscription_id: str, resource_group_name: str, vault_name: str, @@ -6574,8 +6859,6 @@ def __init__( **kwargs: Any ) -> None: """ - :keyword type_name: Required. "KeyVaultCertificateSourceParameters" - :paramtype type_name: str or ~azure.mgmt.cdn.models.KeyVaultCertificateSourceParametersTypeName :keyword subscription_id: Subscription Id of the user's Key Vault containing the SSL certificate. Required. :paramtype subscription_id: str @@ -6597,7 +6880,7 @@ def __init__( :paramtype delete_rule: str or ~azure.mgmt.cdn.models.DeleteRule """ super().__init__(**kwargs) - self.type_name = type_name + self.type_name: str = "KeyVaultCertificateSourceParameters" self.subscription_id = subscription_id self.resource_group_name = resource_group_name self.vault_name = vault_name @@ -6613,7 +6896,7 @@ class KeyVaultSigningKeyParameters(_serialization.Model): All required parameters must be populated in order to send to server. :ivar type_name: Required. "KeyVaultSigningKeyParameters" - :vartype type_name: str or ~azure.mgmt.cdn.models.KeyVaultSigningKeyParametersTypeName + :vartype type_name: str or ~azure.mgmt.cdn.models.KeyVaultSigningKeyParametersType :ivar subscription_id: Subscription Id of the user's Key Vault containing the secret. Required. :vartype subscription_id: str :ivar resource_group_name: Resource group of the user's Key Vault containing the secret. @@ -6648,7 +6931,7 @@ class KeyVaultSigningKeyParameters(_serialization.Model): def __init__( self, *, - type_name: Union[str, "_models.KeyVaultSigningKeyParametersTypeName"], + type_name: Union[str, "_models.KeyVaultSigningKeyParametersType"], subscription_id: str, resource_group_name: str, vault_name: str, @@ -6658,7 +6941,7 @@ def __init__( ) -> None: """ :keyword type_name: Required. "KeyVaultSigningKeyParameters" - :paramtype type_name: str or ~azure.mgmt.cdn.models.KeyVaultSigningKeyParametersTypeName + :paramtype type_name: str or ~azure.mgmt.cdn.models.KeyVaultSigningKeyParametersType :keyword subscription_id: Subscription Id of the user's Key Vault containing the secret. Required. :paramtype subscription_id: str @@ -7587,6 +7870,36 @@ def __init__(self, **kwargs: Any) -> None: self.migrated_profile_resource_id = None +class MigrationEndpointMapping(_serialization.Model): + """CDN Endpoint Mapping. + + :ivar migrated_from: Name of the classic CDN profile endpoint. + :vartype migrated_from: str + :ivar migrated_to: Name of the newly created migrated Azure Frontdoor Standard/Premium profile + endpoint. This name will replace the name of the classic CDN endpoint resource. + :vartype migrated_to: str + """ + + _attribute_map = { + "migrated_from": {"key": "migratedFrom", "type": "str"}, + "migrated_to": {"key": "migratedTo", "type": "str"}, + } + + def __init__( + self, *, migrated_from: Optional[str] = None, migrated_to: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword migrated_from: Name of the classic CDN profile endpoint. + :paramtype migrated_from: str + :keyword migrated_to: Name of the newly created migrated Azure Frontdoor Standard/Premium + profile endpoint. This name will replace the name of the classic CDN endpoint resource. + :paramtype migrated_to: str + """ + super().__init__(**kwargs) + self.migrated_from = migrated_from + self.migrated_to = migrated_to + + class MigrationErrorType(_serialization.Model): """Error response indicates CDN service is not able to process the incoming request. The reason is provided in the error message. @@ -8208,13 +8521,18 @@ def __init__(self, *, parameters: "_models.OriginGroupOverrideActionParameters", self.parameters = parameters -class OriginGroupOverrideActionParameters(_serialization.Model): +class OriginGroupOverrideActionParameters(DeliveryRuleActionParameters): """Defines the parameters for the origin group override action. All required parameters must be populated in order to send to server. - :ivar type_name: Required. "DeliveryRuleOriginGroupOverrideActionParameters" - :vartype type_name: str or ~azure.mgmt.cdn.models.OriginGroupOverrideActionParametersTypeName + :ivar type_name: Required. Known values are: "DeliveryRuleUrlRedirectActionParameters", + "DeliveryRuleUrlSigningActionParameters", "DeliveryRuleOriginGroupOverrideActionParameters", + "DeliveryRuleUrlRewriteActionParameters", "DeliveryRuleHeaderActionParameters", + "DeliveryRuleCacheExpirationActionParameters", + "DeliveryRuleCacheKeyQueryStringBehaviorActionParameters", and + "DeliveryRuleRouteConfigurationOverrideActionParameters". + :vartype type_name: str or ~azure.mgmt.cdn.models.DeliveryRuleActionParametersType :ivar origin_group: defines the OriginGroup that would override the DefaultOriginGroup. Required. :vartype origin_group: ~azure.mgmt.cdn.models.ResourceReference @@ -8230,22 +8548,14 @@ class OriginGroupOverrideActionParameters(_serialization.Model): "origin_group": {"key": "originGroup", "type": "ResourceReference"}, } - def __init__( - self, - *, - type_name: Union[str, "_models.OriginGroupOverrideActionParametersTypeName"], - origin_group: "_models.ResourceReference", - **kwargs: Any - ) -> None: + def __init__(self, *, origin_group: "_models.ResourceReference", **kwargs: Any) -> None: """ - :keyword type_name: Required. "DeliveryRuleOriginGroupOverrideActionParameters" - :paramtype type_name: str or ~azure.mgmt.cdn.models.OriginGroupOverrideActionParametersTypeName :keyword origin_group: defines the OriginGroup that would override the DefaultOriginGroup. Required. :paramtype origin_group: ~azure.mgmt.cdn.models.ResourceReference """ super().__init__(**kwargs) - self.type_name = type_name + self.type_name: str = "DeliveryRuleOriginGroupOverrideActionParameters" self.origin_group = origin_group @@ -8979,13 +9289,23 @@ def __init__( self.default_custom_block_response_body = default_custom_block_response_body -class PostArgsMatchConditionParameters(_serialization.Model): +class PostArgsMatchConditionParameters(DeliveryRuleConditionParameters): """Defines the parameters for PostArgs match conditions. All required parameters must be populated in order to send to server. - :ivar type_name: Required. "DeliveryRulePostArgsConditionParameters" - :vartype type_name: str or ~azure.mgmt.cdn.models.PostArgsMatchConditionParametersTypeName + :ivar type_name: Required. Known values are: "DeliveryRuleRemoteAddressConditionParameters", + "DeliveryRuleRequestMethodConditionParameters", "DeliveryRuleQueryStringConditionParameters", + "DeliveryRulePostArgsConditionParameters", "DeliveryRuleRequestUriConditionParameters", + "DeliveryRuleRequestHeaderConditionParameters", "DeliveryRuleRequestBodyConditionParameters", + "DeliveryRuleRequestSchemeConditionParameters", "DeliveryRuleUrlPathMatchConditionParameters", + "DeliveryRuleUrlFileExtensionMatchConditionParameters", + "DeliveryRuleUrlFilenameConditionParameters", "DeliveryRuleHttpVersionConditionParameters", + "DeliveryRuleCookiesConditionParameters", "DeliveryRuleIsDeviceConditionParameters", + "DeliveryRuleSocketAddrConditionParameters", "DeliveryRuleClientPortConditionParameters", + "DeliveryRuleServerPortConditionParameters", "DeliveryRuleHostNameConditionParameters", and + "DeliveryRuleSslProtocolConditionParameters". + :vartype type_name: str or ~azure.mgmt.cdn.models.DeliveryRuleConditionParametersType :ivar selector: Name of PostArg to be matched. :vartype selector: str :ivar operator: Describes operator to be matched. Required. Known values are: "Any", "Equal", @@ -9017,7 +9337,6 @@ class PostArgsMatchConditionParameters(_serialization.Model): def __init__( self, *, - type_name: Union[str, "_models.PostArgsMatchConditionParametersTypeName"], operator: Union[str, "_models.PostArgsOperator"], selector: Optional[str] = None, negate_condition: bool = False, @@ -9026,8 +9345,6 @@ def __init__( **kwargs: Any ) -> None: """ - :keyword type_name: Required. "DeliveryRulePostArgsConditionParameters" - :paramtype type_name: str or ~azure.mgmt.cdn.models.PostArgsMatchConditionParametersTypeName :keyword selector: Name of PostArg to be matched. :paramtype selector: str :keyword operator: Describes operator to be matched. Required. Known values are: "Any", @@ -9042,7 +9359,7 @@ def __init__( :paramtype transforms: list[str or ~azure.mgmt.cdn.models.Transform] """ super().__init__(**kwargs) - self.type_name = type_name + self.type_name: str = "DeliveryRulePostArgsConditionParameters" self.selector = selector self.operator = operator self.negate_condition = negate_condition @@ -9441,13 +9758,23 @@ def __init__(self, *, content_paths: List[str], **kwargs: Any) -> None: self.content_paths = content_paths -class QueryStringMatchConditionParameters(_serialization.Model): +class QueryStringMatchConditionParameters(DeliveryRuleConditionParameters): """Defines the parameters for QueryString match conditions. All required parameters must be populated in order to send to server. - :ivar type_name: Required. "DeliveryRuleQueryStringConditionParameters" - :vartype type_name: str or ~azure.mgmt.cdn.models.QueryStringMatchConditionParametersTypeName + :ivar type_name: Required. Known values are: "DeliveryRuleRemoteAddressConditionParameters", + "DeliveryRuleRequestMethodConditionParameters", "DeliveryRuleQueryStringConditionParameters", + "DeliveryRulePostArgsConditionParameters", "DeliveryRuleRequestUriConditionParameters", + "DeliveryRuleRequestHeaderConditionParameters", "DeliveryRuleRequestBodyConditionParameters", + "DeliveryRuleRequestSchemeConditionParameters", "DeliveryRuleUrlPathMatchConditionParameters", + "DeliveryRuleUrlFileExtensionMatchConditionParameters", + "DeliveryRuleUrlFilenameConditionParameters", "DeliveryRuleHttpVersionConditionParameters", + "DeliveryRuleCookiesConditionParameters", "DeliveryRuleIsDeviceConditionParameters", + "DeliveryRuleSocketAddrConditionParameters", "DeliveryRuleClientPortConditionParameters", + "DeliveryRuleServerPortConditionParameters", "DeliveryRuleHostNameConditionParameters", and + "DeliveryRuleSslProtocolConditionParameters". + :vartype type_name: str or ~azure.mgmt.cdn.models.DeliveryRuleConditionParametersType :ivar operator: Describes operator to be matched. Required. Known values are: "Any", "Equal", "Contains", "BeginsWith", "EndsWith", "LessThan", "LessThanOrEqual", "GreaterThan", "GreaterThanOrEqual", and "RegEx". @@ -9476,7 +9803,6 @@ class QueryStringMatchConditionParameters(_serialization.Model): def __init__( self, *, - type_name: Union[str, "_models.QueryStringMatchConditionParametersTypeName"], operator: Union[str, "_models.QueryStringOperator"], negate_condition: bool = False, match_values: Optional[List[str]] = None, @@ -9484,8 +9810,6 @@ def __init__( **kwargs: Any ) -> None: """ - :keyword type_name: Required. "DeliveryRuleQueryStringConditionParameters" - :paramtype type_name: str or ~azure.mgmt.cdn.models.QueryStringMatchConditionParametersTypeName :keyword operator: Describes operator to be matched. Required. Known values are: "Any", "Equal", "Contains", "BeginsWith", "EndsWith", "LessThan", "LessThanOrEqual", "GreaterThan", "GreaterThanOrEqual", and "RegEx". @@ -9498,7 +9822,7 @@ def __init__( :paramtype transforms: list[str or ~azure.mgmt.cdn.models.Transform] """ super().__init__(**kwargs) - self.type_name = type_name + self.type_name: str = "DeliveryRuleQueryStringConditionParameters" self.operator = operator self.negate_condition = negate_condition self.match_values = match_values @@ -9756,13 +10080,23 @@ def __init__(self, *, rules: Optional[List["_models.RateLimitRule"]] = None, **k self.rules = rules -class RemoteAddressMatchConditionParameters(_serialization.Model): +class RemoteAddressMatchConditionParameters(DeliveryRuleConditionParameters): """Defines the parameters for RemoteAddress match conditions. All required parameters must be populated in order to send to server. - :ivar type_name: Required. "DeliveryRuleRemoteAddressConditionParameters" - :vartype type_name: str or ~azure.mgmt.cdn.models.RemoteAddressMatchConditionParametersTypeName + :ivar type_name: Required. Known values are: "DeliveryRuleRemoteAddressConditionParameters", + "DeliveryRuleRequestMethodConditionParameters", "DeliveryRuleQueryStringConditionParameters", + "DeliveryRulePostArgsConditionParameters", "DeliveryRuleRequestUriConditionParameters", + "DeliveryRuleRequestHeaderConditionParameters", "DeliveryRuleRequestBodyConditionParameters", + "DeliveryRuleRequestSchemeConditionParameters", "DeliveryRuleUrlPathMatchConditionParameters", + "DeliveryRuleUrlFileExtensionMatchConditionParameters", + "DeliveryRuleUrlFilenameConditionParameters", "DeliveryRuleHttpVersionConditionParameters", + "DeliveryRuleCookiesConditionParameters", "DeliveryRuleIsDeviceConditionParameters", + "DeliveryRuleSocketAddrConditionParameters", "DeliveryRuleClientPortConditionParameters", + "DeliveryRuleServerPortConditionParameters", "DeliveryRuleHostNameConditionParameters", and + "DeliveryRuleSslProtocolConditionParameters". + :vartype type_name: str or ~azure.mgmt.cdn.models.DeliveryRuleConditionParametersType :ivar operator: Describes operator to be matched. Required. Known values are: "Any", "IPMatch", and "GeoMatch". :vartype operator: str or ~azure.mgmt.cdn.models.RemoteAddressOperator @@ -9792,7 +10126,6 @@ class RemoteAddressMatchConditionParameters(_serialization.Model): def __init__( self, *, - type_name: Union[str, "_models.RemoteAddressMatchConditionParametersTypeName"], operator: Union[str, "_models.RemoteAddressOperator"], negate_condition: bool = False, match_values: Optional[List[str]] = None, @@ -9800,9 +10133,6 @@ def __init__( **kwargs: Any ) -> None: """ - :keyword type_name: Required. "DeliveryRuleRemoteAddressConditionParameters" - :paramtype type_name: str or - ~azure.mgmt.cdn.models.RemoteAddressMatchConditionParametersTypeName :keyword operator: Describes operator to be matched. Required. Known values are: "Any", "IPMatch", and "GeoMatch". :paramtype operator: str or ~azure.mgmt.cdn.models.RemoteAddressOperator @@ -9816,20 +10146,30 @@ def __init__( :paramtype transforms: list[str or ~azure.mgmt.cdn.models.Transform] """ super().__init__(**kwargs) - self.type_name = type_name + self.type_name: str = "DeliveryRuleRemoteAddressConditionParameters" self.operator = operator self.negate_condition = negate_condition self.match_values = match_values self.transforms = transforms -class RequestBodyMatchConditionParameters(_serialization.Model): +class RequestBodyMatchConditionParameters(DeliveryRuleConditionParameters): """Defines the parameters for RequestBody match conditions. All required parameters must be populated in order to send to server. - :ivar type_name: Required. "DeliveryRuleRequestBodyConditionParameters" - :vartype type_name: str or ~azure.mgmt.cdn.models.RequestBodyMatchConditionParametersTypeName + :ivar type_name: Required. Known values are: "DeliveryRuleRemoteAddressConditionParameters", + "DeliveryRuleRequestMethodConditionParameters", "DeliveryRuleQueryStringConditionParameters", + "DeliveryRulePostArgsConditionParameters", "DeliveryRuleRequestUriConditionParameters", + "DeliveryRuleRequestHeaderConditionParameters", "DeliveryRuleRequestBodyConditionParameters", + "DeliveryRuleRequestSchemeConditionParameters", "DeliveryRuleUrlPathMatchConditionParameters", + "DeliveryRuleUrlFileExtensionMatchConditionParameters", + "DeliveryRuleUrlFilenameConditionParameters", "DeliveryRuleHttpVersionConditionParameters", + "DeliveryRuleCookiesConditionParameters", "DeliveryRuleIsDeviceConditionParameters", + "DeliveryRuleSocketAddrConditionParameters", "DeliveryRuleClientPortConditionParameters", + "DeliveryRuleServerPortConditionParameters", "DeliveryRuleHostNameConditionParameters", and + "DeliveryRuleSslProtocolConditionParameters". + :vartype type_name: str or ~azure.mgmt.cdn.models.DeliveryRuleConditionParametersType :ivar operator: Describes operator to be matched. Required. Known values are: "Any", "Equal", "Contains", "BeginsWith", "EndsWith", "LessThan", "LessThanOrEqual", "GreaterThan", "GreaterThanOrEqual", and "RegEx". @@ -9858,7 +10198,6 @@ class RequestBodyMatchConditionParameters(_serialization.Model): def __init__( self, *, - type_name: Union[str, "_models.RequestBodyMatchConditionParametersTypeName"], operator: Union[str, "_models.RequestBodyOperator"], negate_condition: bool = False, match_values: Optional[List[str]] = None, @@ -9866,8 +10205,6 @@ def __init__( **kwargs: Any ) -> None: """ - :keyword type_name: Required. "DeliveryRuleRequestBodyConditionParameters" - :paramtype type_name: str or ~azure.mgmt.cdn.models.RequestBodyMatchConditionParametersTypeName :keyword operator: Describes operator to be matched. Required. Known values are: "Any", "Equal", "Contains", "BeginsWith", "EndsWith", "LessThan", "LessThanOrEqual", "GreaterThan", "GreaterThanOrEqual", and "RegEx". @@ -9880,20 +10217,30 @@ def __init__( :paramtype transforms: list[str or ~azure.mgmt.cdn.models.Transform] """ super().__init__(**kwargs) - self.type_name = type_name + self.type_name: str = "DeliveryRuleRequestBodyConditionParameters" self.operator = operator self.negate_condition = negate_condition self.match_values = match_values self.transforms = transforms -class RequestHeaderMatchConditionParameters(_serialization.Model): +class RequestHeaderMatchConditionParameters(DeliveryRuleConditionParameters): """Defines the parameters for RequestHeader match conditions. All required parameters must be populated in order to send to server. - :ivar type_name: Required. "DeliveryRuleRequestHeaderConditionParameters" - :vartype type_name: str or ~azure.mgmt.cdn.models.RequestHeaderMatchConditionParametersTypeName + :ivar type_name: Required. Known values are: "DeliveryRuleRemoteAddressConditionParameters", + "DeliveryRuleRequestMethodConditionParameters", "DeliveryRuleQueryStringConditionParameters", + "DeliveryRulePostArgsConditionParameters", "DeliveryRuleRequestUriConditionParameters", + "DeliveryRuleRequestHeaderConditionParameters", "DeliveryRuleRequestBodyConditionParameters", + "DeliveryRuleRequestSchemeConditionParameters", "DeliveryRuleUrlPathMatchConditionParameters", + "DeliveryRuleUrlFileExtensionMatchConditionParameters", + "DeliveryRuleUrlFilenameConditionParameters", "DeliveryRuleHttpVersionConditionParameters", + "DeliveryRuleCookiesConditionParameters", "DeliveryRuleIsDeviceConditionParameters", + "DeliveryRuleSocketAddrConditionParameters", "DeliveryRuleClientPortConditionParameters", + "DeliveryRuleServerPortConditionParameters", "DeliveryRuleHostNameConditionParameters", and + "DeliveryRuleSslProtocolConditionParameters". + :vartype type_name: str or ~azure.mgmt.cdn.models.DeliveryRuleConditionParametersType :ivar selector: Name of Header to be matched. :vartype selector: str :ivar operator: Describes operator to be matched. Required. Known values are: "Any", "Equal", @@ -9925,7 +10272,6 @@ class RequestHeaderMatchConditionParameters(_serialization.Model): def __init__( self, *, - type_name: Union[str, "_models.RequestHeaderMatchConditionParametersTypeName"], operator: Union[str, "_models.RequestHeaderOperator"], selector: Optional[str] = None, negate_condition: bool = False, @@ -9934,9 +10280,6 @@ def __init__( **kwargs: Any ) -> None: """ - :keyword type_name: Required. "DeliveryRuleRequestHeaderConditionParameters" - :paramtype type_name: str or - ~azure.mgmt.cdn.models.RequestHeaderMatchConditionParametersTypeName :keyword selector: Name of Header to be matched. :paramtype selector: str :keyword operator: Describes operator to be matched. Required. Known values are: "Any", @@ -9951,7 +10294,7 @@ def __init__( :paramtype transforms: list[str or ~azure.mgmt.cdn.models.Transform] """ super().__init__(**kwargs) - self.type_name = type_name + self.type_name: str = "DeliveryRuleRequestHeaderConditionParameters" self.selector = selector self.operator = operator self.negate_condition = negate_condition @@ -9959,13 +10302,23 @@ def __init__( self.transforms = transforms -class RequestMethodMatchConditionParameters(_serialization.Model): +class RequestMethodMatchConditionParameters(DeliveryRuleConditionParameters): """Defines the parameters for RequestMethod match conditions. All required parameters must be populated in order to send to server. - :ivar type_name: Required. "DeliveryRuleRequestMethodConditionParameters" - :vartype type_name: str or ~azure.mgmt.cdn.models.RequestMethodMatchConditionParametersTypeName + :ivar type_name: Required. Known values are: "DeliveryRuleRemoteAddressConditionParameters", + "DeliveryRuleRequestMethodConditionParameters", "DeliveryRuleQueryStringConditionParameters", + "DeliveryRulePostArgsConditionParameters", "DeliveryRuleRequestUriConditionParameters", + "DeliveryRuleRequestHeaderConditionParameters", "DeliveryRuleRequestBodyConditionParameters", + "DeliveryRuleRequestSchemeConditionParameters", "DeliveryRuleUrlPathMatchConditionParameters", + "DeliveryRuleUrlFileExtensionMatchConditionParameters", + "DeliveryRuleUrlFilenameConditionParameters", "DeliveryRuleHttpVersionConditionParameters", + "DeliveryRuleCookiesConditionParameters", "DeliveryRuleIsDeviceConditionParameters", + "DeliveryRuleSocketAddrConditionParameters", "DeliveryRuleClientPortConditionParameters", + "DeliveryRuleServerPortConditionParameters", "DeliveryRuleHostNameConditionParameters", and + "DeliveryRuleSslProtocolConditionParameters". + :vartype type_name: str or ~azure.mgmt.cdn.models.DeliveryRuleConditionParametersType :ivar operator: Describes operator to be matched. Required. "Equal" :vartype operator: str or ~azure.mgmt.cdn.models.RequestMethodOperator :ivar negate_condition: Describes if this is negate condition or not. @@ -9973,8 +10326,7 @@ class RequestMethodMatchConditionParameters(_serialization.Model): :ivar transforms: List of transforms. :vartype transforms: list[str or ~azure.mgmt.cdn.models.Transform] :ivar match_values: The match value for the condition of the delivery rule. - :vartype match_values: list[str or - ~azure.mgmt.cdn.models.RequestMethodMatchConditionParametersMatchValuesItem] + :vartype match_values: list[str or ~azure.mgmt.cdn.models.RequestMethodMatchValue] """ _validation = { @@ -9993,17 +10345,13 @@ class RequestMethodMatchConditionParameters(_serialization.Model): def __init__( self, *, - type_name: Union[str, "_models.RequestMethodMatchConditionParametersTypeName"], operator: Union[str, "_models.RequestMethodOperator"], negate_condition: bool = False, transforms: Optional[List[Union[str, "_models.Transform"]]] = None, - match_values: Optional[List[Union[str, "_models.RequestMethodMatchConditionParametersMatchValuesItem"]]] = None, + match_values: Optional[List[Union[str, "_models.RequestMethodMatchValue"]]] = None, **kwargs: Any ) -> None: """ - :keyword type_name: Required. "DeliveryRuleRequestMethodConditionParameters" - :paramtype type_name: str or - ~azure.mgmt.cdn.models.RequestMethodMatchConditionParametersTypeName :keyword operator: Describes operator to be matched. Required. "Equal" :paramtype operator: str or ~azure.mgmt.cdn.models.RequestMethodOperator :keyword negate_condition: Describes if this is negate condition or not. @@ -10011,24 +10359,33 @@ def __init__( :keyword transforms: List of transforms. :paramtype transforms: list[str or ~azure.mgmt.cdn.models.Transform] :keyword match_values: The match value for the condition of the delivery rule. - :paramtype match_values: list[str or - ~azure.mgmt.cdn.models.RequestMethodMatchConditionParametersMatchValuesItem] + :paramtype match_values: list[str or ~azure.mgmt.cdn.models.RequestMethodMatchValue] """ super().__init__(**kwargs) - self.type_name = type_name + self.type_name: str = "DeliveryRuleRequestMethodConditionParameters" self.operator = operator self.negate_condition = negate_condition self.transforms = transforms self.match_values = match_values -class RequestSchemeMatchConditionParameters(_serialization.Model): +class RequestSchemeMatchConditionParameters(DeliveryRuleConditionParameters): """Defines the parameters for RequestScheme match conditions. All required parameters must be populated in order to send to server. - :ivar type_name: Required. "DeliveryRuleRequestSchemeConditionParameters" - :vartype type_name: str or ~azure.mgmt.cdn.models.RequestSchemeMatchConditionParametersTypeName + :ivar type_name: Required. Known values are: "DeliveryRuleRemoteAddressConditionParameters", + "DeliveryRuleRequestMethodConditionParameters", "DeliveryRuleQueryStringConditionParameters", + "DeliveryRulePostArgsConditionParameters", "DeliveryRuleRequestUriConditionParameters", + "DeliveryRuleRequestHeaderConditionParameters", "DeliveryRuleRequestBodyConditionParameters", + "DeliveryRuleRequestSchemeConditionParameters", "DeliveryRuleUrlPathMatchConditionParameters", + "DeliveryRuleUrlFileExtensionMatchConditionParameters", + "DeliveryRuleUrlFilenameConditionParameters", "DeliveryRuleHttpVersionConditionParameters", + "DeliveryRuleCookiesConditionParameters", "DeliveryRuleIsDeviceConditionParameters", + "DeliveryRuleSocketAddrConditionParameters", "DeliveryRuleClientPortConditionParameters", + "DeliveryRuleServerPortConditionParameters", "DeliveryRuleHostNameConditionParameters", and + "DeliveryRuleSslProtocolConditionParameters". + :vartype type_name: str or ~azure.mgmt.cdn.models.DeliveryRuleConditionParametersType :ivar operator: Describes operator to be matched. Required. "Equal" :vartype operator: str or ~azure.mgmt.cdn.models.RequestSchemeMatchConditionParametersOperator :ivar negate_condition: Describes if this is negate condition or not. @@ -10036,8 +10393,7 @@ class RequestSchemeMatchConditionParameters(_serialization.Model): :ivar transforms: List of transforms. :vartype transforms: list[str or ~azure.mgmt.cdn.models.Transform] :ivar match_values: The match value for the condition of the delivery rule. - :vartype match_values: list[str or - ~azure.mgmt.cdn.models.RequestSchemeMatchConditionParametersMatchValuesItem] + :vartype match_values: list[str or ~azure.mgmt.cdn.models.RequestSchemeMatchValue] """ _validation = { @@ -10056,17 +10412,13 @@ class RequestSchemeMatchConditionParameters(_serialization.Model): def __init__( self, *, - type_name: Union[str, "_models.RequestSchemeMatchConditionParametersTypeName"], operator: Union[str, "_models.RequestSchemeMatchConditionParametersOperator"], negate_condition: bool = False, transforms: Optional[List[Union[str, "_models.Transform"]]] = None, - match_values: Optional[List[Union[str, "_models.RequestSchemeMatchConditionParametersMatchValuesItem"]]] = None, + match_values: Optional[List[Union[str, "_models.RequestSchemeMatchValue"]]] = None, **kwargs: Any ) -> None: """ - :keyword type_name: Required. "DeliveryRuleRequestSchemeConditionParameters" - :paramtype type_name: str or - ~azure.mgmt.cdn.models.RequestSchemeMatchConditionParametersTypeName :keyword operator: Describes operator to be matched. Required. "Equal" :paramtype operator: str or ~azure.mgmt.cdn.models.RequestSchemeMatchConditionParametersOperator @@ -10075,24 +10427,33 @@ def __init__( :keyword transforms: List of transforms. :paramtype transforms: list[str or ~azure.mgmt.cdn.models.Transform] :keyword match_values: The match value for the condition of the delivery rule. - :paramtype match_values: list[str or - ~azure.mgmt.cdn.models.RequestSchemeMatchConditionParametersMatchValuesItem] + :paramtype match_values: list[str or ~azure.mgmt.cdn.models.RequestSchemeMatchValue] """ super().__init__(**kwargs) - self.type_name = type_name + self.type_name: str = "DeliveryRuleRequestSchemeConditionParameters" self.operator = operator self.negate_condition = negate_condition self.transforms = transforms self.match_values = match_values -class RequestUriMatchConditionParameters(_serialization.Model): +class RequestUriMatchConditionParameters(DeliveryRuleConditionParameters): """Defines the parameters for RequestUri match conditions. All required parameters must be populated in order to send to server. - :ivar type_name: Required. "DeliveryRuleRequestUriConditionParameters" - :vartype type_name: str or ~azure.mgmt.cdn.models.RequestUriMatchConditionParametersTypeName + :ivar type_name: Required. Known values are: "DeliveryRuleRemoteAddressConditionParameters", + "DeliveryRuleRequestMethodConditionParameters", "DeliveryRuleQueryStringConditionParameters", + "DeliveryRulePostArgsConditionParameters", "DeliveryRuleRequestUriConditionParameters", + "DeliveryRuleRequestHeaderConditionParameters", "DeliveryRuleRequestBodyConditionParameters", + "DeliveryRuleRequestSchemeConditionParameters", "DeliveryRuleUrlPathMatchConditionParameters", + "DeliveryRuleUrlFileExtensionMatchConditionParameters", + "DeliveryRuleUrlFilenameConditionParameters", "DeliveryRuleHttpVersionConditionParameters", + "DeliveryRuleCookiesConditionParameters", "DeliveryRuleIsDeviceConditionParameters", + "DeliveryRuleSocketAddrConditionParameters", "DeliveryRuleClientPortConditionParameters", + "DeliveryRuleServerPortConditionParameters", "DeliveryRuleHostNameConditionParameters", and + "DeliveryRuleSslProtocolConditionParameters". + :vartype type_name: str or ~azure.mgmt.cdn.models.DeliveryRuleConditionParametersType :ivar operator: Describes operator to be matched. Required. Known values are: "Any", "Equal", "Contains", "BeginsWith", "EndsWith", "LessThan", "LessThanOrEqual", "GreaterThan", "GreaterThanOrEqual", and "RegEx". @@ -10121,7 +10482,6 @@ class RequestUriMatchConditionParameters(_serialization.Model): def __init__( self, *, - type_name: Union[str, "_models.RequestUriMatchConditionParametersTypeName"], operator: Union[str, "_models.RequestUriOperator"], negate_condition: bool = False, match_values: Optional[List[str]] = None, @@ -10129,8 +10489,6 @@ def __init__( **kwargs: Any ) -> None: """ - :keyword type_name: Required. "DeliveryRuleRequestUriConditionParameters" - :paramtype type_name: str or ~azure.mgmt.cdn.models.RequestUriMatchConditionParametersTypeName :keyword operator: Describes operator to be matched. Required. Known values are: "Any", "Equal", "Contains", "BeginsWith", "EndsWith", "LessThan", "LessThanOrEqual", "GreaterThan", "GreaterThanOrEqual", and "RegEx". @@ -10143,7 +10501,7 @@ def __init__( :paramtype transforms: list[str or ~azure.mgmt.cdn.models.Transform] """ super().__init__(**kwargs) - self.type_name = type_name + self.type_name: str = "DeliveryRuleRequestUriConditionParameters" self.operator = operator self.negate_condition = negate_condition self.match_values = match_values @@ -10614,14 +10972,18 @@ def __init__( self.deployment_status = None -class RouteConfigurationOverrideActionParameters(_serialization.Model): # pylint: disable=name-too-long +class RouteConfigurationOverrideActionParameters(DeliveryRuleActionParameters): # pylint: disable=name-too-long """Defines the parameters for the route configuration override action. All required parameters must be populated in order to send to server. - :ivar type_name: Required. "DeliveryRuleRouteConfigurationOverrideActionParameters" - :vartype type_name: str or - ~azure.mgmt.cdn.models.RouteConfigurationOverrideActionParametersTypeName + :ivar type_name: Required. Known values are: "DeliveryRuleUrlRedirectActionParameters", + "DeliveryRuleUrlSigningActionParameters", "DeliveryRuleOriginGroupOverrideActionParameters", + "DeliveryRuleUrlRewriteActionParameters", "DeliveryRuleHeaderActionParameters", + "DeliveryRuleCacheExpirationActionParameters", + "DeliveryRuleCacheKeyQueryStringBehaviorActionParameters", and + "DeliveryRuleRouteConfigurationOverrideActionParameters". + :vartype type_name: str or ~azure.mgmt.cdn.models.DeliveryRuleActionParametersType :ivar origin_group_override: A reference to the origin group override configuration. Leave empty to use the default origin group on route. :vartype origin_group_override: ~azure.mgmt.cdn.models.OriginGroupOverride @@ -10643,15 +11005,11 @@ class RouteConfigurationOverrideActionParameters(_serialization.Model): # pylin def __init__( self, *, - type_name: Union[str, "_models.RouteConfigurationOverrideActionParametersTypeName"], origin_group_override: Optional["_models.OriginGroupOverride"] = None, cache_configuration: Optional["_models.CacheConfiguration"] = None, **kwargs: Any ) -> None: """ - :keyword type_name: Required. "DeliveryRuleRouteConfigurationOverrideActionParameters" - :paramtype type_name: str or - ~azure.mgmt.cdn.models.RouteConfigurationOverrideActionParametersTypeName :keyword origin_group_override: A reference to the origin group override configuration. Leave empty to use the default origin group on route. :paramtype origin_group_override: ~azure.mgmt.cdn.models.OriginGroupOverride @@ -10660,7 +11018,7 @@ def __init__( :paramtype cache_configuration: ~azure.mgmt.cdn.models.CacheConfiguration """ super().__init__(**kwargs) - self.type_name = type_name + self.type_name: str = "DeliveryRuleRouteConfigurationOverrideActionParameters" self.origin_group_override = origin_group_override self.cache_configuration = cache_configuration @@ -11107,7 +11465,7 @@ class Rule(ProxyResource): # pylint: disable=too-many-instance-attributes :vartype actions: list[~azure.mgmt.cdn.models.DeliveryRuleAction] :ivar match_processing_behavior: If this rule is a match should the rules engine continue running the remaining rules or stop. If not present, defaults to Continue. Known values are: - "Continue" and "Stop". + "Continue", "Stop", and "Continue". :vartype match_processing_behavior: str or ~azure.mgmt.cdn.models.MatchProcessingBehavior :ivar provisioning_state: Provisioning status. Known values are: "Succeeded", "Failed", "Updating", "Deleting", and "Creating". @@ -11163,7 +11521,7 @@ def __init__( :paramtype actions: list[~azure.mgmt.cdn.models.DeliveryRuleAction] :keyword match_processing_behavior: If this rule is a match should the rules engine continue running the remaining rules or stop. If not present, defaults to Continue. Known values are: - "Continue" and "Stop". + "Continue", "Stop", and "Continue". :paramtype match_processing_behavior: str or ~azure.mgmt.cdn.models.MatchProcessingBehavior """ super().__init__(**kwargs) @@ -11226,7 +11584,7 @@ class RuleUpdatePropertiesParameters(_serialization.Model): :vartype actions: list[~azure.mgmt.cdn.models.DeliveryRuleAction] :ivar match_processing_behavior: If this rule is a match should the rules engine continue running the remaining rules or stop. If not present, defaults to Continue. Known values are: - "Continue" and "Stop". + "Continue", "Stop", and "Continue". :vartype match_processing_behavior: str or ~azure.mgmt.cdn.models.MatchProcessingBehavior """ @@ -11264,7 +11622,7 @@ def __init__( :paramtype actions: list[~azure.mgmt.cdn.models.DeliveryRuleAction] :keyword match_processing_behavior: If this rule is a match should the rules engine continue running the remaining rules or stop. If not present, defaults to Continue. Known values are: - "Continue" and "Stop". + "Continue", "Stop", and "Continue". :paramtype match_processing_behavior: str or ~azure.mgmt.cdn.models.MatchProcessingBehavior """ super().__init__(**kwargs) @@ -11300,7 +11658,7 @@ class RuleProperties(RuleUpdatePropertiesParameters, AFDStateProperties): :vartype actions: list[~azure.mgmt.cdn.models.DeliveryRuleAction] :ivar match_processing_behavior: If this rule is a match should the rules engine continue running the remaining rules or stop. If not present, defaults to Continue. Known values are: - "Continue" and "Stop". + "Continue", "Stop", and "Continue". :vartype match_processing_behavior: str or ~azure.mgmt.cdn.models.MatchProcessingBehavior """ @@ -11342,7 +11700,7 @@ def __init__( :paramtype actions: list[~azure.mgmt.cdn.models.DeliveryRuleAction] :keyword match_processing_behavior: If this rule is a match should the rules engine continue running the remaining rules or stop. If not present, defaults to Continue. Known values are: - "Continue" and "Stop". + "Continue", "Stop", and "Continue". :paramtype match_processing_behavior: str or ~azure.mgmt.cdn.models.MatchProcessingBehavior """ super().__init__( @@ -11495,7 +11853,7 @@ class RuleUpdateParameters(_serialization.Model): :vartype actions: list[~azure.mgmt.cdn.models.DeliveryRuleAction] :ivar match_processing_behavior: If this rule is a match should the rules engine continue running the remaining rules or stop. If not present, defaults to Continue. Known values are: - "Continue" and "Stop". + "Continue", "Stop", and "Continue". :vartype match_processing_behavior: str or ~azure.mgmt.cdn.models.MatchProcessingBehavior """ @@ -11533,7 +11891,7 @@ def __init__( :paramtype actions: list[~azure.mgmt.cdn.models.DeliveryRuleAction] :keyword match_processing_behavior: If this rule is a match should the rules engine continue running the remaining rules or stop. If not present, defaults to Continue. Known values are: - "Continue" and "Stop". + "Continue", "Stop", and "Continue". :paramtype match_processing_behavior: str or ~azure.mgmt.cdn.models.MatchProcessingBehavior """ super().__init__(**kwargs) @@ -11934,13 +12292,23 @@ def __init__( self.associations = associations -class ServerPortMatchConditionParameters(_serialization.Model): +class ServerPortMatchConditionParameters(DeliveryRuleConditionParameters): """Defines the parameters for ServerPort match conditions. All required parameters must be populated in order to send to server. - :ivar type_name: Required. "DeliveryRuleServerPortConditionParameters" - :vartype type_name: str or ~azure.mgmt.cdn.models.ServerPortMatchConditionParametersTypeName + :ivar type_name: Required. Known values are: "DeliveryRuleRemoteAddressConditionParameters", + "DeliveryRuleRequestMethodConditionParameters", "DeliveryRuleQueryStringConditionParameters", + "DeliveryRulePostArgsConditionParameters", "DeliveryRuleRequestUriConditionParameters", + "DeliveryRuleRequestHeaderConditionParameters", "DeliveryRuleRequestBodyConditionParameters", + "DeliveryRuleRequestSchemeConditionParameters", "DeliveryRuleUrlPathMatchConditionParameters", + "DeliveryRuleUrlFileExtensionMatchConditionParameters", + "DeliveryRuleUrlFilenameConditionParameters", "DeliveryRuleHttpVersionConditionParameters", + "DeliveryRuleCookiesConditionParameters", "DeliveryRuleIsDeviceConditionParameters", + "DeliveryRuleSocketAddrConditionParameters", "DeliveryRuleClientPortConditionParameters", + "DeliveryRuleServerPortConditionParameters", "DeliveryRuleHostNameConditionParameters", and + "DeliveryRuleSslProtocolConditionParameters". + :vartype type_name: str or ~azure.mgmt.cdn.models.DeliveryRuleConditionParametersType :ivar operator: Describes operator to be matched. Required. Known values are: "Any", "Equal", "Contains", "BeginsWith", "EndsWith", "LessThan", "LessThanOrEqual", "GreaterThan", "GreaterThanOrEqual", and "RegEx". @@ -11969,7 +12337,6 @@ class ServerPortMatchConditionParameters(_serialization.Model): def __init__( self, *, - type_name: Union[str, "_models.ServerPortMatchConditionParametersTypeName"], operator: Union[str, "_models.ServerPortOperator"], negate_condition: bool = False, match_values: Optional[List[str]] = None, @@ -11977,8 +12344,6 @@ def __init__( **kwargs: Any ) -> None: """ - :keyword type_name: Required. "DeliveryRuleServerPortConditionParameters" - :paramtype type_name: str or ~azure.mgmt.cdn.models.ServerPortMatchConditionParametersTypeName :keyword operator: Describes operator to be matched. Required. Known values are: "Any", "Equal", "Contains", "BeginsWith", "EndsWith", "LessThan", "LessThanOrEqual", "GreaterThan", "GreaterThanOrEqual", and "RegEx". @@ -11991,7 +12356,7 @@ def __init__( :paramtype transforms: list[str or ~azure.mgmt.cdn.models.Transform] """ super().__init__(**kwargs) - self.type_name = type_name + self.type_name: str = "DeliveryRuleServerPortConditionParameters" self.operator = operator self.negate_condition = negate_condition self.match_values = match_values @@ -12138,13 +12503,23 @@ def __init__(self, *, name: Optional[Union[str, "_models.SkuName"]] = None, **kw self.name = name -class SocketAddrMatchConditionParameters(_serialization.Model): +class SocketAddrMatchConditionParameters(DeliveryRuleConditionParameters): """Defines the parameters for SocketAddress match conditions. All required parameters must be populated in order to send to server. - :ivar type_name: Required. "DeliveryRuleSocketAddrConditionParameters" - :vartype type_name: str or ~azure.mgmt.cdn.models.SocketAddrMatchConditionParametersTypeName + :ivar type_name: Required. Known values are: "DeliveryRuleRemoteAddressConditionParameters", + "DeliveryRuleRequestMethodConditionParameters", "DeliveryRuleQueryStringConditionParameters", + "DeliveryRulePostArgsConditionParameters", "DeliveryRuleRequestUriConditionParameters", + "DeliveryRuleRequestHeaderConditionParameters", "DeliveryRuleRequestBodyConditionParameters", + "DeliveryRuleRequestSchemeConditionParameters", "DeliveryRuleUrlPathMatchConditionParameters", + "DeliveryRuleUrlFileExtensionMatchConditionParameters", + "DeliveryRuleUrlFilenameConditionParameters", "DeliveryRuleHttpVersionConditionParameters", + "DeliveryRuleCookiesConditionParameters", "DeliveryRuleIsDeviceConditionParameters", + "DeliveryRuleSocketAddrConditionParameters", "DeliveryRuleClientPortConditionParameters", + "DeliveryRuleServerPortConditionParameters", "DeliveryRuleHostNameConditionParameters", and + "DeliveryRuleSslProtocolConditionParameters". + :vartype type_name: str or ~azure.mgmt.cdn.models.DeliveryRuleConditionParametersType :ivar operator: Describes operator to be matched. Required. Known values are: "Any" and "IPMatch". :vartype operator: str or ~azure.mgmt.cdn.models.SocketAddrOperator @@ -12172,7 +12547,6 @@ class SocketAddrMatchConditionParameters(_serialization.Model): def __init__( self, *, - type_name: Union[str, "_models.SocketAddrMatchConditionParametersTypeName"], operator: Union[str, "_models.SocketAddrOperator"], negate_condition: bool = False, match_values: Optional[List[str]] = None, @@ -12180,8 +12554,6 @@ def __init__( **kwargs: Any ) -> None: """ - :keyword type_name: Required. "DeliveryRuleSocketAddrConditionParameters" - :paramtype type_name: str or ~azure.mgmt.cdn.models.SocketAddrMatchConditionParametersTypeName :keyword operator: Describes operator to be matched. Required. Known values are: "Any" and "IPMatch". :paramtype operator: str or ~azure.mgmt.cdn.models.SocketAddrOperator @@ -12193,20 +12565,30 @@ def __init__( :paramtype transforms: list[str or ~azure.mgmt.cdn.models.Transform] """ super().__init__(**kwargs) - self.type_name = type_name + self.type_name: str = "DeliveryRuleSocketAddrConditionParameters" self.operator = operator self.negate_condition = negate_condition self.match_values = match_values self.transforms = transforms -class SslProtocolMatchConditionParameters(_serialization.Model): +class SslProtocolMatchConditionParameters(DeliveryRuleConditionParameters): """Defines the parameters for SslProtocol match conditions. All required parameters must be populated in order to send to server. - :ivar type_name: Required. "DeliveryRuleSslProtocolConditionParameters" - :vartype type_name: str or ~azure.mgmt.cdn.models.SslProtocolMatchConditionParametersTypeName + :ivar type_name: Required. Known values are: "DeliveryRuleRemoteAddressConditionParameters", + "DeliveryRuleRequestMethodConditionParameters", "DeliveryRuleQueryStringConditionParameters", + "DeliveryRulePostArgsConditionParameters", "DeliveryRuleRequestUriConditionParameters", + "DeliveryRuleRequestHeaderConditionParameters", "DeliveryRuleRequestBodyConditionParameters", + "DeliveryRuleRequestSchemeConditionParameters", "DeliveryRuleUrlPathMatchConditionParameters", + "DeliveryRuleUrlFileExtensionMatchConditionParameters", + "DeliveryRuleUrlFilenameConditionParameters", "DeliveryRuleHttpVersionConditionParameters", + "DeliveryRuleCookiesConditionParameters", "DeliveryRuleIsDeviceConditionParameters", + "DeliveryRuleSocketAddrConditionParameters", "DeliveryRuleClientPortConditionParameters", + "DeliveryRuleServerPortConditionParameters", "DeliveryRuleHostNameConditionParameters", and + "DeliveryRuleSslProtocolConditionParameters". + :vartype type_name: str or ~azure.mgmt.cdn.models.DeliveryRuleConditionParametersType :ivar operator: Describes operator to be matched. Required. "Equal" :vartype operator: str or ~azure.mgmt.cdn.models.SslProtocolOperator :ivar negate_condition: Describes if this is negate condition or not. @@ -12233,7 +12615,6 @@ class SslProtocolMatchConditionParameters(_serialization.Model): def __init__( self, *, - type_name: Union[str, "_models.SslProtocolMatchConditionParametersTypeName"], operator: Union[str, "_models.SslProtocolOperator"], negate_condition: bool = False, match_values: Optional[List[Union[str, "_models.SslProtocol"]]] = None, @@ -12241,8 +12622,6 @@ def __init__( **kwargs: Any ) -> None: """ - :keyword type_name: Required. "DeliveryRuleSslProtocolConditionParameters" - :paramtype type_name: str or ~azure.mgmt.cdn.models.SslProtocolMatchConditionParametersTypeName :keyword operator: Describes operator to be matched. Required. "Equal" :paramtype operator: str or ~azure.mgmt.cdn.models.SslProtocolOperator :keyword negate_condition: Describes if this is negate condition or not. @@ -12253,7 +12632,7 @@ def __init__( :paramtype transforms: list[str or ~azure.mgmt.cdn.models.Transform] """ super().__init__(**kwargs) - self.type_name = type_name + self.type_name: str = "DeliveryRuleSslProtocolConditionParameters" self.operator = operator self.negate_condition = negate_condition self.match_values = match_values @@ -12370,14 +12749,23 @@ def __init__( self.last_modified_at = last_modified_at -class UrlFileExtensionMatchConditionParameters(_serialization.Model): +class UrlFileExtensionMatchConditionParameters(DeliveryRuleConditionParameters): """Defines the parameters for UrlFileExtension match conditions. All required parameters must be populated in order to send to server. - :ivar type_name: Required. "DeliveryRuleUrlFileExtensionMatchConditionParameters" - :vartype type_name: str or - ~azure.mgmt.cdn.models.UrlFileExtensionMatchConditionParametersTypeName + :ivar type_name: Required. Known values are: "DeliveryRuleRemoteAddressConditionParameters", + "DeliveryRuleRequestMethodConditionParameters", "DeliveryRuleQueryStringConditionParameters", + "DeliveryRulePostArgsConditionParameters", "DeliveryRuleRequestUriConditionParameters", + "DeliveryRuleRequestHeaderConditionParameters", "DeliveryRuleRequestBodyConditionParameters", + "DeliveryRuleRequestSchemeConditionParameters", "DeliveryRuleUrlPathMatchConditionParameters", + "DeliveryRuleUrlFileExtensionMatchConditionParameters", + "DeliveryRuleUrlFilenameConditionParameters", "DeliveryRuleHttpVersionConditionParameters", + "DeliveryRuleCookiesConditionParameters", "DeliveryRuleIsDeviceConditionParameters", + "DeliveryRuleSocketAddrConditionParameters", "DeliveryRuleClientPortConditionParameters", + "DeliveryRuleServerPortConditionParameters", "DeliveryRuleHostNameConditionParameters", and + "DeliveryRuleSslProtocolConditionParameters". + :vartype type_name: str or ~azure.mgmt.cdn.models.DeliveryRuleConditionParametersType :ivar operator: Describes operator to be matched. Required. Known values are: "Any", "Equal", "Contains", "BeginsWith", "EndsWith", "LessThan", "LessThanOrEqual", "GreaterThan", "GreaterThanOrEqual", and "RegEx". @@ -12406,7 +12794,6 @@ class UrlFileExtensionMatchConditionParameters(_serialization.Model): def __init__( self, *, - type_name: Union[str, "_models.UrlFileExtensionMatchConditionParametersTypeName"], operator: Union[str, "_models.UrlFileExtensionOperator"], negate_condition: bool = False, match_values: Optional[List[str]] = None, @@ -12414,9 +12801,6 @@ def __init__( **kwargs: Any ) -> None: """ - :keyword type_name: Required. "DeliveryRuleUrlFileExtensionMatchConditionParameters" - :paramtype type_name: str or - ~azure.mgmt.cdn.models.UrlFileExtensionMatchConditionParametersTypeName :keyword operator: Describes operator to be matched. Required. Known values are: "Any", "Equal", "Contains", "BeginsWith", "EndsWith", "LessThan", "LessThanOrEqual", "GreaterThan", "GreaterThanOrEqual", and "RegEx". @@ -12429,20 +12813,30 @@ def __init__( :paramtype transforms: list[str or ~azure.mgmt.cdn.models.Transform] """ super().__init__(**kwargs) - self.type_name = type_name + self.type_name: str = "DeliveryRuleUrlFileExtensionMatchConditionParameters" self.operator = operator self.negate_condition = negate_condition self.match_values = match_values self.transforms = transforms -class UrlFileNameMatchConditionParameters(_serialization.Model): +class UrlFileNameMatchConditionParameters(DeliveryRuleConditionParameters): """Defines the parameters for UrlFilename match conditions. All required parameters must be populated in order to send to server. - :ivar type_name: Required. "DeliveryRuleUrlFilenameConditionParameters" - :vartype type_name: str or ~azure.mgmt.cdn.models.UrlFileNameMatchConditionParametersTypeName + :ivar type_name: Required. Known values are: "DeliveryRuleRemoteAddressConditionParameters", + "DeliveryRuleRequestMethodConditionParameters", "DeliveryRuleQueryStringConditionParameters", + "DeliveryRulePostArgsConditionParameters", "DeliveryRuleRequestUriConditionParameters", + "DeliveryRuleRequestHeaderConditionParameters", "DeliveryRuleRequestBodyConditionParameters", + "DeliveryRuleRequestSchemeConditionParameters", "DeliveryRuleUrlPathMatchConditionParameters", + "DeliveryRuleUrlFileExtensionMatchConditionParameters", + "DeliveryRuleUrlFilenameConditionParameters", "DeliveryRuleHttpVersionConditionParameters", + "DeliveryRuleCookiesConditionParameters", "DeliveryRuleIsDeviceConditionParameters", + "DeliveryRuleSocketAddrConditionParameters", "DeliveryRuleClientPortConditionParameters", + "DeliveryRuleServerPortConditionParameters", "DeliveryRuleHostNameConditionParameters", and + "DeliveryRuleSslProtocolConditionParameters". + :vartype type_name: str or ~azure.mgmt.cdn.models.DeliveryRuleConditionParametersType :ivar operator: Describes operator to be matched. Required. Known values are: "Any", "Equal", "Contains", "BeginsWith", "EndsWith", "LessThan", "LessThanOrEqual", "GreaterThan", "GreaterThanOrEqual", and "RegEx". @@ -12471,7 +12865,6 @@ class UrlFileNameMatchConditionParameters(_serialization.Model): def __init__( self, *, - type_name: Union[str, "_models.UrlFileNameMatchConditionParametersTypeName"], operator: Union[str, "_models.UrlFileNameOperator"], negate_condition: bool = False, match_values: Optional[List[str]] = None, @@ -12479,8 +12872,6 @@ def __init__( **kwargs: Any ) -> None: """ - :keyword type_name: Required. "DeliveryRuleUrlFilenameConditionParameters" - :paramtype type_name: str or ~azure.mgmt.cdn.models.UrlFileNameMatchConditionParametersTypeName :keyword operator: Describes operator to be matched. Required. Known values are: "Any", "Equal", "Contains", "BeginsWith", "EndsWith", "LessThan", "LessThanOrEqual", "GreaterThan", "GreaterThanOrEqual", and "RegEx". @@ -12493,20 +12884,30 @@ def __init__( :paramtype transforms: list[str or ~azure.mgmt.cdn.models.Transform] """ super().__init__(**kwargs) - self.type_name = type_name + self.type_name: str = "DeliveryRuleUrlFilenameConditionParameters" self.operator = operator self.negate_condition = negate_condition self.match_values = match_values self.transforms = transforms -class UrlPathMatchConditionParameters(_serialization.Model): +class UrlPathMatchConditionParameters(DeliveryRuleConditionParameters): """Defines the parameters for UrlPath match conditions. All required parameters must be populated in order to send to server. - :ivar type_name: Required. "DeliveryRuleUrlPathMatchConditionParameters" - :vartype type_name: str or ~azure.mgmt.cdn.models.UrlPathMatchConditionParametersTypeName + :ivar type_name: Required. Known values are: "DeliveryRuleRemoteAddressConditionParameters", + "DeliveryRuleRequestMethodConditionParameters", "DeliveryRuleQueryStringConditionParameters", + "DeliveryRulePostArgsConditionParameters", "DeliveryRuleRequestUriConditionParameters", + "DeliveryRuleRequestHeaderConditionParameters", "DeliveryRuleRequestBodyConditionParameters", + "DeliveryRuleRequestSchemeConditionParameters", "DeliveryRuleUrlPathMatchConditionParameters", + "DeliveryRuleUrlFileExtensionMatchConditionParameters", + "DeliveryRuleUrlFilenameConditionParameters", "DeliveryRuleHttpVersionConditionParameters", + "DeliveryRuleCookiesConditionParameters", "DeliveryRuleIsDeviceConditionParameters", + "DeliveryRuleSocketAddrConditionParameters", "DeliveryRuleClientPortConditionParameters", + "DeliveryRuleServerPortConditionParameters", "DeliveryRuleHostNameConditionParameters", and + "DeliveryRuleSslProtocolConditionParameters". + :vartype type_name: str or ~azure.mgmt.cdn.models.DeliveryRuleConditionParametersType :ivar operator: Describes operator to be matched. Required. Known values are: "Any", "Equal", "Contains", "BeginsWith", "EndsWith", "LessThan", "LessThanOrEqual", "GreaterThan", "GreaterThanOrEqual", "Wildcard", and "RegEx". @@ -12535,7 +12936,6 @@ class UrlPathMatchConditionParameters(_serialization.Model): def __init__( self, *, - type_name: Union[str, "_models.UrlPathMatchConditionParametersTypeName"], operator: Union[str, "_models.UrlPathOperator"], negate_condition: bool = False, match_values: Optional[List[str]] = None, @@ -12543,8 +12943,6 @@ def __init__( **kwargs: Any ) -> None: """ - :keyword type_name: Required. "DeliveryRuleUrlPathMatchConditionParameters" - :paramtype type_name: str or ~azure.mgmt.cdn.models.UrlPathMatchConditionParametersTypeName :keyword operator: Describes operator to be matched. Required. Known values are: "Any", "Equal", "Contains", "BeginsWith", "EndsWith", "LessThan", "LessThanOrEqual", "GreaterThan", "GreaterThanOrEqual", "Wildcard", and "RegEx". @@ -12557,7 +12955,7 @@ def __init__( :paramtype transforms: list[str or ~azure.mgmt.cdn.models.Transform] """ super().__init__(**kwargs) - self.type_name = type_name + self.type_name: str = "DeliveryRuleUrlPathMatchConditionParameters" self.operator = operator self.negate_condition = negate_condition self.match_values = match_values @@ -12598,13 +12996,18 @@ def __init__(self, *, parameters: "_models.UrlRedirectActionParameters", **kwarg self.parameters = parameters -class UrlRedirectActionParameters(_serialization.Model): +class UrlRedirectActionParameters(DeliveryRuleActionParameters): """Defines the parameters for the url redirect action. All required parameters must be populated in order to send to server. - :ivar type_name: Required. "DeliveryRuleUrlRedirectActionParameters" - :vartype type_name: str or ~azure.mgmt.cdn.models.UrlRedirectActionParametersTypeName + :ivar type_name: Required. Known values are: "DeliveryRuleUrlRedirectActionParameters", + "DeliveryRuleUrlSigningActionParameters", "DeliveryRuleOriginGroupOverrideActionParameters", + "DeliveryRuleUrlRewriteActionParameters", "DeliveryRuleHeaderActionParameters", + "DeliveryRuleCacheExpirationActionParameters", + "DeliveryRuleCacheKeyQueryStringBehaviorActionParameters", and + "DeliveryRuleRouteConfigurationOverrideActionParameters". + :vartype type_name: str or ~azure.mgmt.cdn.models.DeliveryRuleActionParametersType :ivar redirect_type: The redirect type the rule will use when redirecting traffic. Required. Known values are: "Moved", "Found", "TemporaryRedirect", and "PermanentRedirect". :vartype redirect_type: str or ~azure.mgmt.cdn.models.RedirectType @@ -12645,7 +13048,6 @@ class UrlRedirectActionParameters(_serialization.Model): def __init__( self, *, - type_name: Union[str, "_models.UrlRedirectActionParametersTypeName"], redirect_type: Union[str, "_models.RedirectType"], destination_protocol: Optional[Union[str, "_models.DestinationProtocol"]] = None, custom_path: Optional[str] = None, @@ -12655,8 +13057,6 @@ def __init__( **kwargs: Any ) -> None: """ - :keyword type_name: Required. "DeliveryRuleUrlRedirectActionParameters" - :paramtype type_name: str or ~azure.mgmt.cdn.models.UrlRedirectActionParametersTypeName :keyword redirect_type: The redirect type the rule will use when redirecting traffic. Required. Known values are: "Moved", "Found", "TemporaryRedirect", and "PermanentRedirect". :paramtype redirect_type: str or ~azure.mgmt.cdn.models.RedirectType @@ -12679,7 +13079,7 @@ def __init__( :paramtype custom_fragment: str """ super().__init__(**kwargs) - self.type_name = type_name + self.type_name: str = "DeliveryRuleUrlRedirectActionParameters" self.redirect_type = redirect_type self.destination_protocol = destination_protocol self.custom_path = custom_path @@ -12722,13 +13122,18 @@ def __init__(self, *, parameters: "_models.UrlRewriteActionParameters", **kwargs self.parameters = parameters -class UrlRewriteActionParameters(_serialization.Model): +class UrlRewriteActionParameters(DeliveryRuleActionParameters): """Defines the parameters for the url rewrite action. All required parameters must be populated in order to send to server. - :ivar type_name: Required. "DeliveryRuleUrlRewriteActionParameters" - :vartype type_name: str or ~azure.mgmt.cdn.models.UrlRewriteActionParametersTypeName + :ivar type_name: Required. Known values are: "DeliveryRuleUrlRedirectActionParameters", + "DeliveryRuleUrlSigningActionParameters", "DeliveryRuleOriginGroupOverrideActionParameters", + "DeliveryRuleUrlRewriteActionParameters", "DeliveryRuleHeaderActionParameters", + "DeliveryRuleCacheExpirationActionParameters", + "DeliveryRuleCacheKeyQueryStringBehaviorActionParameters", and + "DeliveryRuleRouteConfigurationOverrideActionParameters". + :vartype type_name: str or ~azure.mgmt.cdn.models.DeliveryRuleActionParametersType :ivar source_pattern: define a request URI pattern that identifies the type of requests that may be rewritten. If value is blank, all strings are matched. Required. :vartype source_pattern: str @@ -12753,17 +13158,9 @@ class UrlRewriteActionParameters(_serialization.Model): } def __init__( - self, - *, - type_name: Union[str, "_models.UrlRewriteActionParametersTypeName"], - source_pattern: str, - destination: str, - preserve_unmatched_path: Optional[bool] = None, - **kwargs: Any + self, *, source_pattern: str, destination: str, preserve_unmatched_path: Optional[bool] = None, **kwargs: Any ) -> None: """ - :keyword type_name: Required. "DeliveryRuleUrlRewriteActionParameters" - :paramtype type_name: str or ~azure.mgmt.cdn.models.UrlRewriteActionParametersTypeName :keyword source_pattern: define a request URI pattern that identifies the type of requests that may be rewritten. If value is blank, all strings are matched. Required. :paramtype source_pattern: str @@ -12774,7 +13171,7 @@ def __init__( :paramtype preserve_unmatched_path: bool """ super().__init__(**kwargs) - self.type_name = type_name + self.type_name: str = "DeliveryRuleUrlRewriteActionParameters" self.source_pattern = source_pattern self.destination = destination self.preserve_unmatched_path = preserve_unmatched_path @@ -12814,13 +13211,18 @@ def __init__(self, *, parameters: "_models.UrlSigningActionParameters", **kwargs self.parameters = parameters -class UrlSigningActionParameters(_serialization.Model): +class UrlSigningActionParameters(DeliveryRuleActionParameters): """Defines the parameters for the Url Signing action. All required parameters must be populated in order to send to server. - :ivar type_name: Required. "DeliveryRuleUrlSigningActionParameters" - :vartype type_name: str or ~azure.mgmt.cdn.models.UrlSigningActionParametersTypeName + :ivar type_name: Required. Known values are: "DeliveryRuleUrlRedirectActionParameters", + "DeliveryRuleUrlSigningActionParameters", "DeliveryRuleOriginGroupOverrideActionParameters", + "DeliveryRuleUrlRewriteActionParameters", "DeliveryRuleHeaderActionParameters", + "DeliveryRuleCacheExpirationActionParameters", + "DeliveryRuleCacheKeyQueryStringBehaviorActionParameters", and + "DeliveryRuleRouteConfigurationOverrideActionParameters". + :vartype type_name: str or ~azure.mgmt.cdn.models.DeliveryRuleActionParametersType :ivar algorithm: Algorithm to use for URL signing. "SHA256" :vartype algorithm: str or ~azure.mgmt.cdn.models.Algorithm :ivar parameter_name_override: Defines which query string parameters in the url to be @@ -12841,14 +13243,11 @@ class UrlSigningActionParameters(_serialization.Model): def __init__( self, *, - type_name: Union[str, "_models.UrlSigningActionParametersTypeName"], algorithm: Optional[Union[str, "_models.Algorithm"]] = None, parameter_name_override: Optional[List["_models.UrlSigningParamIdentifier"]] = None, **kwargs: Any ) -> None: """ - :keyword type_name: Required. "DeliveryRuleUrlSigningActionParameters" - :paramtype type_name: str or ~azure.mgmt.cdn.models.UrlSigningActionParametersTypeName :keyword algorithm: Algorithm to use for URL signing. "SHA256" :paramtype algorithm: str or ~azure.mgmt.cdn.models.Algorithm :keyword parameter_name_override: Defines which query string parameters in the url to be @@ -12856,7 +13255,7 @@ def __init__( :paramtype parameter_name_override: list[~azure.mgmt.cdn.models.UrlSigningParamIdentifier] """ super().__init__(**kwargs) - self.type_name = type_name + self.type_name: str = "DeliveryRuleUrlSigningActionParameters" self.algorithm = algorithm self.parameter_name_override = parameter_name_override 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..6427dbf88769 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 @@ -26,6 +26,7 @@ from ._resource_usage_operations import ResourceUsageOperations from ._operations import Operations from ._edge_nodes_operations import EdgeNodesOperations +from ._cdn_profiles_operations import CdnProfilesOperations from ._policies_operations import PoliciesOperations from ._managed_rule_sets_operations import ManagedRuleSetsOperations @@ -54,6 +55,7 @@ "ResourceUsageOperations", "Operations", "EdgeNodesOperations", + "CdnProfilesOperations", "PoliciesOperations", "ManagedRuleSetsOperations", ] diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_afd_custom_domains_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_afd_custom_domains_operations.py index 43dffe70d382..ff209ed14ede 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_afd_custom_domains_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_afd_custom_domains_operations.py @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -17,13 +17,14 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -31,7 +32,6 @@ 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 @@ -50,7 +50,7 @@ def build_list_by_profile_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -83,7 +83,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -117,7 +117,7 @@ def build_create_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -154,7 +154,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -191,7 +191,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -225,7 +225,7 @@ def build_refresh_validation_token_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -312,7 +312,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -328,7 +327,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -400,7 +398,6 @@ def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -415,7 +412,7 @@ def get( error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AFDDomain", pipeline_response) + deserialized = self._deserialize("AFDDomain", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -429,7 +426,7 @@ def _create_initial( custom_domain_name: str, custom_domain: Union[_models.AFDDomain, IO[bytes]], **kwargs: Any - ) -> _models.AFDDomain: + ) -> Iterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -443,7 +440,7 @@ def _create_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AFDDomain] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -465,10 +462,10 @@ def _create_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -476,21 +473,19 @@ def _create_initial( response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("AFDDomain", pipeline_response) - if response.status_code == 201: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("AFDDomain", pipeline_response) - - if response.status_code == 202: - deserialized = self._deserialize("AFDDomain", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -607,10 +602,11 @@ def begin_create( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("AFDDomain", pipeline_response) + deserialized = self._deserialize("AFDDomain", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -641,7 +637,7 @@ def _update_initial( custom_domain_name: str, custom_domain_update_properties: Union[_models.AFDDomainUpdateParameters, IO[bytes]], **kwargs: Any - ) -> _models.AFDDomain: + ) -> Iterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -655,7 +651,7 @@ def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AFDDomain] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -677,10 +673,10 @@ def _update_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -688,18 +684,19 @@ def _update_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("AFDDomain", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("AFDDomain", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -817,10 +814,11 @@ def begin_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("AFDDomain", pipeline_response) + deserialized = self._deserialize("AFDDomain", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -844,9 +842,9 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - def _delete_initial( # pylint: disable=inconsistent-return-statements + def _delete_initial( self, resource_group_name: str, profile_name: str, custom_domain_name: str, **kwargs: Any - ) -> None: + ) -> Iterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -859,7 +857,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_delete_request( resource_group_name=resource_group_name, @@ -870,10 +868,10 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -881,6 +879,10 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -889,8 +891,12 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @distributed_trace def begin_delete( @@ -920,7 +926,7 @@ def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( # type: ignore + raw_result = self._delete_initial( resource_group_name=resource_group_name, profile_name=profile_name, custom_domain_name=custom_domain_name, @@ -930,6 +936,7 @@ def begin_delete( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements @@ -953,9 +960,9 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- ) return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _refresh_validation_token_initial( # pylint: disable=inconsistent-return-statements + def _refresh_validation_token_initial( self, resource_group_name: str, profile_name: str, custom_domain_name: str, **kwargs: Any - ) -> None: + ) -> Iterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -968,7 +975,7 @@ def _refresh_validation_token_initial( # pylint: disable=inconsistent-return-st _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_refresh_validation_token_request( resource_group_name=resource_group_name, @@ -979,10 +986,10 @@ def _refresh_validation_token_initial( # pylint: disable=inconsistent-return-st headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -990,6 +997,10 @@ def _refresh_validation_token_initial( # pylint: disable=inconsistent-return-st response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -998,8 +1009,12 @@ def _refresh_validation_token_initial( # pylint: disable=inconsistent-return-st if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @distributed_trace def begin_refresh_validation_token( @@ -1028,7 +1043,7 @@ def begin_refresh_validation_token( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._refresh_validation_token_initial( # type: ignore + raw_result = self._refresh_validation_token_initial( resource_group_name=resource_group_name, profile_name=profile_name, custom_domain_name=custom_domain_name, @@ -1038,6 +1053,7 @@ def begin_refresh_validation_token( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_afd_endpoints_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_afd_endpoints_operations.py index f4f0f3e5c5c8..651158a23d83 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_afd_endpoints_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_afd_endpoints_operations.py @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -17,13 +17,14 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -31,7 +32,6 @@ 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 @@ -50,7 +50,7 @@ def build_list_by_profile_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -83,7 +83,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -117,7 +117,7 @@ def build_create_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -154,7 +154,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -191,7 +191,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -225,7 +225,7 @@ def build_purge_content_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -262,7 +262,7 @@ def build_list_resource_usage_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -296,7 +296,7 @@ def build_validate_custom_domain_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -386,7 +386,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -402,7 +401,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -474,7 +472,6 @@ def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -489,7 +486,7 @@ def get( error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AFDEndpoint", pipeline_response) + deserialized = self._deserialize("AFDEndpoint", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -503,7 +500,7 @@ def _create_initial( endpoint_name: str, endpoint: Union[_models.AFDEndpoint, IO[bytes]], **kwargs: Any - ) -> _models.AFDEndpoint: + ) -> Iterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -517,7 +514,7 @@ def _create_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AFDEndpoint] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -539,10 +536,10 @@ def _create_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -550,21 +547,19 @@ def _create_initial( response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("AFDEndpoint", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("AFDEndpoint", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("AFDEndpoint", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -687,10 +682,11 @@ def begin_create( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("AFDEndpoint", pipeline_response) + deserialized = self._deserialize("AFDEndpoint", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -721,7 +717,7 @@ def _update_initial( endpoint_name: str, endpoint_update_properties: Union[_models.AFDEndpointUpdateParameters, IO[bytes]], **kwargs: Any - ) -> _models.AFDEndpoint: + ) -> Iterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -735,7 +731,7 @@ def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AFDEndpoint] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -757,10 +753,10 @@ def _update_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -768,18 +764,19 @@ def _update_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("AFDEndpoint", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("AFDEndpoint", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -909,10 +906,11 @@ def begin_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("AFDEndpoint", pipeline_response) + deserialized = self._deserialize("AFDEndpoint", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -936,9 +934,9 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - def _delete_initial( # pylint: disable=inconsistent-return-statements + def _delete_initial( self, resource_group_name: str, profile_name: str, endpoint_name: str, **kwargs: Any - ) -> None: + ) -> Iterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -951,7 +949,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_delete_request( resource_group_name=resource_group_name, @@ -962,10 +960,10 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -973,6 +971,10 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -981,8 +983,12 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @distributed_trace def begin_delete( @@ -1012,7 +1018,7 @@ def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( # type: ignore + raw_result = self._delete_initial( resource_group_name=resource_group_name, profile_name=profile_name, endpoint_name=endpoint_name, @@ -1022,6 +1028,7 @@ def begin_delete( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements @@ -1045,14 +1052,14 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- ) return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _purge_content_initial( # pylint: disable=inconsistent-return-statements + def _purge_content_initial( self, resource_group_name: str, profile_name: str, endpoint_name: str, contents: Union[_models.AfdPurgeParameters, IO[bytes]], **kwargs: Any - ) -> None: + ) -> Iterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -1066,7 +1073,7 @@ def _purge_content_initial( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -1088,10 +1095,10 @@ def _purge_content_initial( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -1099,6 +1106,10 @@ def _purge_content_initial( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -1107,8 +1118,12 @@ def _purge_content_initial( # pylint: disable=inconsistent-return-statements if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @overload def begin_purge_content( @@ -1216,7 +1231,7 @@ def begin_purge_content( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._purge_content_initial( # type: ignore + raw_result = self._purge_content_initial( resource_group_name=resource_group_name, profile_name=profile_name, endpoint_name=endpoint_name, @@ -1228,6 +1243,7 @@ def begin_purge_content( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements @@ -1295,7 +1311,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1311,7 +1326,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -1467,7 +1481,6 @@ def validate_custom_domain( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1482,7 +1495,7 @@ def validate_custom_domain( error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ValidateCustomDomainOutput", pipeline_response) + deserialized = self._deserialize("ValidateCustomDomainOutput", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_afd_origin_groups_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_afd_origin_groups_operations.py index 4280339143c6..688a51315da9 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_afd_origin_groups_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_afd_origin_groups_operations.py @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -17,13 +17,14 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -31,7 +32,6 @@ 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 @@ -50,7 +50,7 @@ def build_list_by_profile_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -83,7 +83,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -117,7 +117,7 @@ def build_create_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -154,7 +154,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -191,7 +191,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -225,7 +225,7 @@ def build_list_resource_usage_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -312,7 +312,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -328,7 +327,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -399,7 +397,6 @@ def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -414,7 +411,7 @@ def get( error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AFDOriginGroup", pipeline_response) + deserialized = self._deserialize("AFDOriginGroup", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -428,7 +425,7 @@ def _create_initial( origin_group_name: str, origin_group: Union[_models.AFDOriginGroup, IO[bytes]], **kwargs: Any - ) -> _models.AFDOriginGroup: + ) -> Iterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -442,7 +439,7 @@ def _create_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AFDOriginGroup] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -464,10 +461,10 @@ def _create_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -475,21 +472,19 @@ def _create_initial( response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("AFDOriginGroup", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("AFDOriginGroup", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("AFDOriginGroup", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -609,10 +604,11 @@ def begin_create( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("AFDOriginGroup", pipeline_response) + deserialized = self._deserialize("AFDOriginGroup", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -643,7 +639,7 @@ def _update_initial( origin_group_name: str, origin_group_update_properties: Union[_models.AFDOriginGroupUpdateParameters, IO[bytes]], **kwargs: Any - ) -> _models.AFDOriginGroup: + ) -> Iterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -657,7 +653,7 @@ def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AFDOriginGroup] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -679,10 +675,10 @@ def _update_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -690,18 +686,19 @@ def _update_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("AFDOriginGroup", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("AFDOriginGroup", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -822,10 +819,11 @@ def begin_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("AFDOriginGroup", pipeline_response) + deserialized = self._deserialize("AFDOriginGroup", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -849,9 +847,9 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - def _delete_initial( # pylint: disable=inconsistent-return-statements + def _delete_initial( self, resource_group_name: str, profile_name: str, origin_group_name: str, **kwargs: Any - ) -> None: + ) -> Iterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -864,7 +862,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_delete_request( resource_group_name=resource_group_name, @@ -875,10 +873,10 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -886,6 +884,10 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -894,8 +896,12 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @distributed_trace def begin_delete( @@ -924,7 +930,7 @@ def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( # type: ignore + raw_result = self._delete_initial( resource_group_name=resource_group_name, profile_name=profile_name, origin_group_name=origin_group_name, @@ -934,6 +940,7 @@ def begin_delete( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements @@ -1001,7 +1008,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1017,7 +1023,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_afd_origins_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_afd_origins_operations.py index 72245c2a7c7f..4417681639e4 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_afd_origins_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_afd_origins_operations.py @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -17,13 +17,14 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -31,7 +32,6 @@ 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 @@ -50,7 +50,7 @@ def build_list_by_origin_group_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -89,7 +89,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -129,7 +129,7 @@ def build_create_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -172,7 +172,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -215,7 +215,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -307,7 +307,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -323,7 +322,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -397,7 +395,6 @@ def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -412,7 +409,7 @@ def get( error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("AFDOrigin", pipeline_response) + deserialized = self._deserialize("AFDOrigin", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -427,7 +424,7 @@ def _create_initial( origin_name: str, origin: Union[_models.AFDOrigin, IO[bytes]], **kwargs: Any - ) -> _models.AFDOrigin: + ) -> Iterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -441,7 +438,7 @@ def _create_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AFDOrigin] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -464,10 +461,10 @@ def _create_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -475,21 +472,19 @@ def _create_initial( response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("AFDOrigin", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("AFDOrigin", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("AFDOrigin", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -615,10 +610,11 @@ def begin_create( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("AFDOrigin", pipeline_response) + deserialized = self._deserialize("AFDOrigin", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -650,7 +646,7 @@ def _update_initial( origin_name: str, origin_update_properties: Union[_models.AFDOriginUpdateParameters, IO[bytes]], **kwargs: Any - ) -> _models.AFDOrigin: + ) -> Iterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -664,7 +660,7 @@ def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AFDOrigin] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -687,10 +683,10 @@ def _update_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -698,18 +694,19 @@ def _update_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("AFDOrigin", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("AFDOrigin", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -836,10 +833,11 @@ def begin_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("AFDOrigin", pipeline_response) + deserialized = self._deserialize("AFDOrigin", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -863,9 +861,9 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - def _delete_initial( # pylint: disable=inconsistent-return-statements + def _delete_initial( self, resource_group_name: str, profile_name: str, origin_group_name: str, origin_name: str, **kwargs: Any - ) -> None: + ) -> Iterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -878,7 +876,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_delete_request( resource_group_name=resource_group_name, @@ -890,10 +888,10 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -901,6 +899,10 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -909,8 +911,12 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @distributed_trace def begin_delete( @@ -941,7 +947,7 @@ def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( # type: ignore + raw_result = self._delete_initial( resource_group_name=resource_group_name, profile_name=profile_name, origin_group_name=origin_group_name, @@ -952,6 +958,7 @@ def begin_delete( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_afd_profiles_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_afd_profiles_operations.py index fee3bbbd97ad..a10eb7b360bf 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_afd_profiles_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_afd_profiles_operations.py @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -17,13 +17,14 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -31,7 +32,6 @@ 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 @@ -50,7 +50,7 @@ def build_check_endpoint_name_availability_request( # pylint: disable=name-too- _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -88,7 +88,7 @@ def build_list_resource_usage_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -121,7 +121,7 @@ def build_check_host_name_availability_request( # pylint: disable=name-too-long _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -157,7 +157,7 @@ def build_validate_secret_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -195,7 +195,7 @@ def build_upgrade_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -361,7 +361,6 @@ def check_endpoint_name_availability( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -376,7 +375,7 @@ def check_endpoint_name_availability( error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("CheckEndpointNameAvailabilityOutput", pipeline_response) + deserialized = self._deserialize("CheckEndpointNameAvailabilityOutput", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -423,7 +422,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -439,7 +437,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -583,7 +580,6 @@ def check_host_name_availability( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -598,7 +594,7 @@ def check_host_name_availability( error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("CheckNameAvailabilityOutput", pipeline_response) + deserialized = self._deserialize("CheckNameAvailabilityOutput", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -715,7 +711,6 @@ def validate_secret( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -730,7 +725,7 @@ def validate_secret( error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ValidateSecretOutput", pipeline_response) + deserialized = self._deserialize("ValidateSecretOutput", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -743,7 +738,7 @@ def _upgrade_initial( profile_name: str, profile_upgrade_parameters: Union[_models.ProfileUpgradeParameters, IO[bytes]], **kwargs: Any - ) -> _models.Profile: + ) -> Iterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -757,7 +752,7 @@ def _upgrade_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Profile] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -778,10 +773,10 @@ def _upgrade_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -789,18 +784,19 @@ def _upgrade_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("Profile", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("Profile", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -904,10 +900,11 @@ def begin_upgrade( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Profile", pipeline_response) + deserialized = self._deserialize("Profile", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_cdn_management_client_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_cdn_management_client_operations.py index 0040b37a9a66..3bdb8cbeb20f 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_cdn_management_client_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_cdn_management_client_operations.py @@ -19,15 +19,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import CdnManagementClientMixinABC, _convert_request +from .._vendor import CdnManagementClientMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -46,7 +45,7 @@ def build_check_endpoint_name_availability_request( # pylint: disable=name-too- _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -79,7 +78,7 @@ def build_check_name_availability_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -103,7 +102,7 @@ def build_check_name_availability_with_subscription_request( # pylint: disable= _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -130,7 +129,7 @@ def build_validate_probe_request(subscription_id: str, **kwargs: Any) -> HttpReq _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -257,7 +256,6 @@ def check_endpoint_name_availability( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -272,7 +270,7 @@ def check_endpoint_name_availability( error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("CheckEndpointNameAvailabilityOutput", pipeline_response) + deserialized = self._deserialize("CheckEndpointNameAvailabilityOutput", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -363,7 +361,6 @@ def check_name_availability( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -378,7 +375,7 @@ def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("CheckNameAvailabilityOutput", pipeline_response) + deserialized = self._deserialize("CheckNameAvailabilityOutput", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -470,7 +467,6 @@ def check_name_availability_with_subscription( # pylint: disable=name-too-long headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -485,7 +481,7 @@ def check_name_availability_with_subscription( # pylint: disable=name-too-long error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("CheckNameAvailabilityOutput", pipeline_response) + deserialized = self._deserialize("CheckNameAvailabilityOutput", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -575,7 +571,6 @@ def validate_probe( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -590,7 +585,7 @@ def validate_probe( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ValidateProbeOutput", pipeline_response) + deserialized = self._deserialize("ValidateProbeOutput", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_cdn_profiles_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_cdn_profiles_operations.py new file mode 100644 index 000000000000..7e6882cac21d --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_cdn_profiles_operations.py @@ -0,0 +1,458 @@ +# 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, Iterator, Optional, Type, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_cdn_can_migrate_to_afd_request( + resource_group_name: str, profile_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/cdnCanMigrateToAfd", + ) # 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 + ), + "profileName": _SERIALIZER.url( + "profile_name", profile_name, "str", max_length=260, min_length=1, pattern=r"^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_cdn_migrate_to_afd_request( + resource_group_name: str, profile_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-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}/cdnMigrateToAfd", + ) # 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 + ), + "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) + + +class CdnProfilesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.cdn.CdnManagementClient`'s + :attr:`cdn_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") + + def _cdn_can_migrate_to_afd_initial( + self, resource_group_name: str, profile_name: str, **kwargs: Any + ) -> Iterator[bytes]: + 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[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_cdn_can_migrate_to_afd_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_cdn_can_migrate_to_afd( + self, resource_group_name: str, profile_name: str, **kwargs: Any + ) -> LROPoller[_models.CanMigrateResult]: + """Checks if CDN profile can be migrated to Azure Frontdoor(Standard/Premium) profile. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. + :type profile_name: str + :return: An instance of LROPoller that returns either CanMigrateResult or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.CanMigrateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.CanMigrateResult] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._cdn_can_migrate_to_afd_initial( + resource_group_name=resource_group_name, + profile_name=profile_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("CanMigrateResult", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.CanMigrateResult].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.CanMigrateResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _cdn_migrate_to_afd_initial( + self, + resource_group_name: str, + profile_name: str, + migration_parameters: Union[_models.CdnMigrationToAfdParameters, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping[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[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(migration_parameters, (IOBase, bytes)): + _content = migration_parameters + else: + _json = self._serialize.body(migration_parameters, "CdnMigrationToAfdParameters") + + _request = build_cdn_migrate_to_afd_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_cdn_migrate_to_afd( + self, + resource_group_name: str, + profile_name: str, + migration_parameters: _models.CdnMigrationToAfdParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.MigrateResult]: + """Migrate the CDN profile to Azure Frontdoor(Standard/Premium) profile. This step prepares the + profile for migration and will be followed by Commit to finalize the migration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. + :type profile_name: str + :param migration_parameters: Properties needed to migrate the profile. Required. + :type migration_parameters: ~azure.mgmt.cdn.models.CdnMigrationToAfdParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either MigrateResult or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.MigrateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_cdn_migrate_to_afd( + self, + resource_group_name: str, + profile_name: str, + migration_parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.MigrateResult]: + """Migrate the CDN profile to Azure Frontdoor(Standard/Premium) profile. This step prepares the + profile for migration and will be followed by Commit to finalize the migration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. + :type profile_name: str + :param migration_parameters: Properties needed to migrate the profile. Required. + :type migration_parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either MigrateResult or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.MigrateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_cdn_migrate_to_afd( + self, + resource_group_name: str, + profile_name: str, + migration_parameters: Union[_models.CdnMigrationToAfdParameters, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.MigrateResult]: + """Migrate the CDN profile to Azure Frontdoor(Standard/Premium) profile. This step prepares the + profile for migration and will be followed by Commit to finalize the migration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. + :type profile_name: str + :param migration_parameters: Properties needed to migrate the profile. Is either a + CdnMigrationToAfdParameters type or a IO[bytes] type. Required. + :type migration_parameters: ~azure.mgmt.cdn.models.CdnMigrationToAfdParameters or IO[bytes] + :return: An instance of LROPoller that returns either MigrateResult or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.MigrateResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.MigrateResult] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._cdn_migrate_to_afd_initial( + resource_group_name=resource_group_name, + profile_name=profile_name, + migration_parameters=migration_parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("MigrateResult", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.MigrateResult].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.MigrateResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_custom_domains_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_custom_domains_operations.py index 54de16bb9e4c..80786745fe21 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_custom_domains_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_custom_domains_operations.py @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -17,13 +17,14 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -31,7 +32,6 @@ 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 @@ -50,7 +50,7 @@ def build_list_by_endpoint_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -89,7 +89,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -129,7 +129,7 @@ def build_create_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -172,7 +172,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -212,7 +212,7 @@ def build_disable_custom_https_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -252,7 +252,7 @@ def build_enable_custom_https_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -347,7 +347,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -363,7 +362,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -437,7 +435,6 @@ def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -452,7 +449,7 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("CustomDomain", pipeline_response) + deserialized = self._deserialize("CustomDomain", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -467,7 +464,7 @@ def _create_initial( custom_domain_name: str, custom_domain_properties: Union[_models.CustomDomainParameters, IO[bytes]], **kwargs: Any - ) -> _models.CustomDomain: + ) -> Iterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -481,7 +478,7 @@ def _create_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.CustomDomain] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -504,10 +501,10 @@ def _create_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -515,21 +512,19 @@ def _create_initial( response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("CustomDomain", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("CustomDomain", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("CustomDomain", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -659,10 +654,11 @@ def begin_create( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("CustomDomain", pipeline_response) + deserialized = self._deserialize("CustomDomain", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -686,7 +682,7 @@ def get_long_running_output(pipeline_response): def _delete_initial( self, resource_group_name: str, profile_name: str, endpoint_name: str, custom_domain_name: str, **kwargs: Any - ) -> Optional[_models.CustomDomain]: + ) -> Iterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -699,7 +695,7 @@ def _delete_initial( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[Optional[_models.CustomDomain]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_delete_request( resource_group_name=resource_group_name, @@ -711,10 +707,10 @@ def _delete_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -722,16 +718,19 @@ def _delete_initial( response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("CustomDomain", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -779,6 +778,7 @@ def begin_delete( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): @@ -786,7 +786,7 @@ def get_long_running_output(pipeline_response): response = pipeline_response.http_response response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("CustomDomain", pipeline_response) + deserialized = self._deserialize("CustomDomain", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized @@ -810,7 +810,7 @@ def get_long_running_output(pipeline_response): def _disable_custom_https_initial( self, resource_group_name: str, profile_name: str, endpoint_name: str, custom_domain_name: str, **kwargs: Any - ) -> _models.CustomDomain: + ) -> Iterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -823,7 +823,7 @@ def _disable_custom_https_initial( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.CustomDomain] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_disable_custom_https_request( resource_group_name=resource_group_name, @@ -835,10 +835,10 @@ def _disable_custom_https_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -846,18 +846,19 @@ def _disable_custom_https_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("CustomDomain", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("CustomDomain", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -905,10 +906,11 @@ def begin_disable_custom_https( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("CustomDomain", pipeline_response) + deserialized = self._deserialize("CustomDomain", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -938,7 +940,7 @@ def _enable_custom_https_initial( custom_domain_name: str, custom_domain_https_parameters: Optional[Union[_models.CustomDomainHttpsParameters, IO[bytes]]] = None, **kwargs: Any - ) -> _models.CustomDomain: + ) -> Iterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -952,7 +954,7 @@ def _enable_custom_https_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.CustomDomain] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -978,10 +980,10 @@ def _enable_custom_https_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -989,18 +991,19 @@ def _enable_custom_https_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("CustomDomain", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("CustomDomain", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -1137,10 +1140,11 @@ def begin_enable_custom_https( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("CustomDomain", pipeline_response) + deserialized = self._deserialize("CustomDomain", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_edge_nodes_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_edge_nodes_operations.py index ac995df5bfcd..02e26278d506 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_edge_nodes_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_edge_nodes_operations.py @@ -20,15 +20,13 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import CdnManagementClientMixinABC, _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -45,7 +43,7 @@ def build_list_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -110,7 +108,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -126,7 +123,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_endpoints_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_endpoints_operations.py index 28c4bba440d6..6b667cedf194 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_endpoints_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_endpoints_operations.py @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -17,13 +17,14 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -31,7 +32,6 @@ 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 @@ -50,7 +50,7 @@ def build_list_by_profile_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -83,7 +83,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -117,7 +117,7 @@ def build_create_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -154,7 +154,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -191,7 +191,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -225,7 +225,7 @@ def build_start_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -259,7 +259,7 @@ def build_stop_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -293,7 +293,7 @@ def build_purge_content_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -330,7 +330,7 @@ def build_load_content_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -367,7 +367,7 @@ def build_validate_custom_domain_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -404,7 +404,7 @@ def build_list_resource_usage_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -491,7 +491,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -507,7 +506,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -577,7 +575,6 @@ def get(self, resource_group_name: str, profile_name: str, endpoint_name: str, * headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -592,7 +589,7 @@ def get(self, resource_group_name: str, profile_name: str, endpoint_name: str, * error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Endpoint", pipeline_response) + deserialized = self._deserialize("Endpoint", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -606,7 +603,7 @@ def _create_initial( endpoint_name: str, endpoint: Union[_models.Endpoint, IO[bytes]], **kwargs: Any - ) -> _models.Endpoint: + ) -> Iterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -620,7 +617,7 @@ def _create_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Endpoint] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -642,10 +639,10 @@ def _create_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -653,21 +650,19 @@ def _create_initial( response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("Endpoint", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Endpoint", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("Endpoint", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -786,10 +781,11 @@ def begin_create( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Endpoint", pipeline_response) + deserialized = self._deserialize("Endpoint", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -818,7 +814,7 @@ def _update_initial( endpoint_name: str, endpoint_update_properties: Union[_models.EndpointUpdateParameters, IO[bytes]], **kwargs: Any - ) -> _models.Endpoint: + ) -> Iterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -832,7 +828,7 @@ def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Endpoint] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -854,10 +850,10 @@ def _update_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -865,18 +861,19 @@ def _update_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("Endpoint", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("Endpoint", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -1002,10 +999,11 @@ def begin_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Endpoint", pipeline_response) + deserialized = self._deserialize("Endpoint", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -1027,9 +1025,9 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - def _delete_initial( # pylint: disable=inconsistent-return-statements + def _delete_initial( self, resource_group_name: str, profile_name: str, endpoint_name: str, **kwargs: Any - ) -> None: + ) -> Iterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -1042,7 +1040,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_delete_request( resource_group_name=resource_group_name, @@ -1053,10 +1051,10 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -1064,6 +1062,10 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -1072,8 +1074,12 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @distributed_trace def begin_delete( @@ -1103,7 +1109,7 @@ def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( # type: ignore + raw_result = self._delete_initial( resource_group_name=resource_group_name, profile_name=profile_name, endpoint_name=endpoint_name, @@ -1113,6 +1119,7 @@ def begin_delete( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements @@ -1136,7 +1143,7 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- def _start_initial( self, resource_group_name: str, profile_name: str, endpoint_name: str, **kwargs: Any - ) -> _models.Endpoint: + ) -> Iterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -1149,7 +1156,7 @@ def _start_initial( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.Endpoint] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_start_request( resource_group_name=resource_group_name, @@ -1160,10 +1167,10 @@ def _start_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -1171,18 +1178,19 @@ def _start_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("Endpoint", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("Endpoint", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -1226,10 +1234,11 @@ def begin_start( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Endpoint", pipeline_response) + deserialized = self._deserialize("Endpoint", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -1253,7 +1262,7 @@ def get_long_running_output(pipeline_response): def _stop_initial( self, resource_group_name: str, profile_name: str, endpoint_name: str, **kwargs: Any - ) -> _models.Endpoint: + ) -> Iterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -1266,7 +1275,7 @@ def _stop_initial( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.Endpoint] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_stop_request( resource_group_name=resource_group_name, @@ -1277,10 +1286,10 @@ def _stop_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -1288,18 +1297,19 @@ def _stop_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("Endpoint", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("Endpoint", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -1343,10 +1353,11 @@ def begin_stop( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Endpoint", pipeline_response) + deserialized = self._deserialize("Endpoint", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -1368,14 +1379,14 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - def _purge_content_initial( # pylint: disable=inconsistent-return-statements + def _purge_content_initial( self, resource_group_name: str, profile_name: str, endpoint_name: str, content_file_paths: Union[_models.PurgeParameters, IO[bytes]], **kwargs: Any - ) -> None: + ) -> Iterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -1389,7 +1400,7 @@ def _purge_content_initial( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -1411,10 +1422,10 @@ def _purge_content_initial( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -1422,6 +1433,10 @@ def _purge_content_initial( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -1430,8 +1445,12 @@ def _purge_content_initial( # pylint: disable=inconsistent-return-statements if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @overload def begin_purge_content( @@ -1537,7 +1556,7 @@ def begin_purge_content( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._purge_content_initial( # type: ignore + raw_result = self._purge_content_initial( resource_group_name=resource_group_name, profile_name=profile_name, endpoint_name=endpoint_name, @@ -1549,6 +1568,7 @@ def begin_purge_content( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements @@ -1570,14 +1590,14 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- ) return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _load_content_initial( # pylint: disable=inconsistent-return-statements + def _load_content_initial( self, resource_group_name: str, profile_name: str, endpoint_name: str, content_file_paths: Union[_models.LoadParameters, IO[bytes]], **kwargs: Any - ) -> None: + ) -> Iterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -1591,7 +1611,7 @@ def _load_content_initial( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -1613,10 +1633,10 @@ def _load_content_initial( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -1624,6 +1644,10 @@ def _load_content_initial( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -1632,8 +1656,12 @@ def _load_content_initial( # pylint: disable=inconsistent-return-statements if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @overload def begin_load_content( @@ -1736,7 +1764,7 @@ def begin_load_content( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._load_content_initial( # type: ignore + raw_result = self._load_content_initial( resource_group_name=resource_group_name, profile_name=profile_name, endpoint_name=endpoint_name, @@ -1748,6 +1776,7 @@ def begin_load_content( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements @@ -1892,7 +1921,6 @@ def validate_custom_domain( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1907,7 +1935,7 @@ def validate_custom_domain( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ValidateCustomDomainOutput", pipeline_response) + deserialized = self._deserialize("ValidateCustomDomainOutput", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -1958,7 +1986,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1974,7 +2001,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_log_analytics_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_log_analytics_operations.py index da8ececd9538..211e6187a971 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_log_analytics_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_log_analytics_operations.py @@ -19,15 +19,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import CdnManagementClientMixinABC, _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -59,7 +57,7 @@ def build_get_log_analytics_metrics_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -118,7 +116,7 @@ def build_get_log_analytics_rankings_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -160,7 +158,7 @@ def build_get_log_analytics_locations_request( # pylint: disable=name-too-long _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -193,7 +191,7 @@ def build_get_log_analytics_resources_request( # pylint: disable=name-too-long _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -237,7 +235,7 @@ def build_get_waf_log_analytics_metrics_request( # pylint: disable=name-too-lon _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -291,7 +289,7 @@ def build_get_waf_log_analytics_rankings_request( # pylint: disable=name-too-lo _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -422,7 +420,6 @@ def get_log_analytics_metrics( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -437,7 +434,7 @@ def get_log_analytics_metrics( error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("MetricsResponse", pipeline_response) + deserialized = self._deserialize("MetricsResponse", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -508,7 +505,6 @@ def get_log_analytics_rankings( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -523,7 +519,7 @@ def get_log_analytics_rankings( error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("RankingsResponse", pipeline_response) + deserialized = self._deserialize("RankingsResponse", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -567,7 +563,6 @@ def get_log_analytics_locations( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -582,7 +577,7 @@ def get_log_analytics_locations( error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ContinentsResponse", pipeline_response) + deserialized = self._deserialize("ContinentsResponse", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -626,7 +621,6 @@ def get_log_analytics_resources( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -641,7 +635,7 @@ def get_log_analytics_resources( error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ResourcesResponse", pipeline_response) + deserialized = self._deserialize("ResourcesResponse", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -716,7 +710,6 @@ def get_waf_log_analytics_metrics( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -731,7 +724,7 @@ def get_waf_log_analytics_metrics( error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("WafMetricsResponse", pipeline_response) + deserialized = self._deserialize("WafMetricsResponse", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -806,7 +799,6 @@ def get_waf_log_analytics_rankings( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -821,7 +813,7 @@ def get_waf_log_analytics_rankings( error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("WafRankingsResponse", pipeline_response) + deserialized = self._deserialize("WafRankingsResponse", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_managed_rule_sets_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_managed_rule_sets_operations.py index 4d8243ab3d6e..40cd829ea8c9 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_managed_rule_sets_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_managed_rule_sets_operations.py @@ -20,15 +20,13 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import CdnManagementClientMixinABC, _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -45,7 +43,7 @@ def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -119,7 +117,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -135,7 +132,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_operations.py index 10d99a59fca4..ba994b5c8623 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 @@ -20,15 +20,13 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import CdnManagementClientMixinABC, _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -45,7 +43,7 @@ def build_list_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -109,7 +107,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -125,7 +122,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_origin_groups_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_origin_groups_operations.py index aeca4d14e338..d920ed3d4e9e 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_origin_groups_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_origin_groups_operations.py @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -17,13 +17,14 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -31,7 +32,6 @@ 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 @@ -50,7 +50,7 @@ def build_list_by_endpoint_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -89,7 +89,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -129,7 +129,7 @@ def build_create_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -172,7 +172,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -215,7 +215,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -307,7 +307,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -323,7 +322,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -398,7 +396,6 @@ def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -413,7 +410,7 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("OriginGroup", pipeline_response) + deserialized = self._deserialize("OriginGroup", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -428,7 +425,7 @@ def _create_initial( origin_group_name: str, origin_group: Union[_models.OriginGroup, IO[bytes]], **kwargs: Any - ) -> _models.OriginGroup: + ) -> Iterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -442,7 +439,7 @@ def _create_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.OriginGroup] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -465,10 +462,10 @@ def _create_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -476,21 +473,19 @@ def _create_initial( response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("OriginGroup", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("OriginGroup", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("OriginGroup", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -623,10 +618,11 @@ def begin_create( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("OriginGroup", pipeline_response) + deserialized = self._deserialize("OriginGroup", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -656,7 +652,7 @@ def _update_initial( origin_group_name: str, origin_group_update_properties: Union[_models.OriginGroupUpdateParameters, IO[bytes]], **kwargs: Any - ) -> _models.OriginGroup: + ) -> Iterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -670,7 +666,7 @@ def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.OriginGroup] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -693,10 +689,10 @@ def _update_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -704,18 +700,19 @@ def _update_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("OriginGroup", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("OriginGroup", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -849,10 +846,11 @@ def begin_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("OriginGroup", pipeline_response) + deserialized = self._deserialize("OriginGroup", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -874,9 +872,9 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - def _delete_initial( # pylint: disable=inconsistent-return-statements + def _delete_initial( self, resource_group_name: str, profile_name: str, endpoint_name: str, origin_group_name: str, **kwargs: Any - ) -> None: + ) -> Iterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -889,7 +887,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_delete_request( resource_group_name=resource_group_name, @@ -901,10 +899,10 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -912,6 +910,10 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -920,8 +922,12 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @distributed_trace def begin_delete( @@ -953,7 +959,7 @@ def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( # type: ignore + raw_result = self._delete_initial( resource_group_name=resource_group_name, profile_name=profile_name, endpoint_name=endpoint_name, @@ -964,6 +970,7 @@ def begin_delete( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_origins_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_origins_operations.py index 3f181ef33b4b..381d4ef9bfef 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_origins_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_origins_operations.py @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -17,13 +17,14 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -31,7 +32,6 @@ 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 @@ -50,7 +50,7 @@ def build_list_by_endpoint_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -89,7 +89,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -129,7 +129,7 @@ def build_create_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -172,7 +172,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -215,7 +215,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -307,7 +307,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -323,7 +322,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -397,7 +395,6 @@ def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -412,7 +409,7 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Origin", pipeline_response) + deserialized = self._deserialize("Origin", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -427,7 +424,7 @@ def _create_initial( origin_name: str, origin: Union[_models.Origin, IO[bytes]], **kwargs: Any - ) -> _models.Origin: + ) -> Iterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -441,7 +438,7 @@ def _create_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Origin] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -464,10 +461,10 @@ def _create_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -475,21 +472,19 @@ def _create_initial( response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("Origin", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Origin", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("Origin", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -615,10 +610,11 @@ def begin_create( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Origin", pipeline_response) + deserialized = self._deserialize("Origin", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -648,7 +644,7 @@ def _update_initial( origin_name: str, origin_update_properties: Union[_models.OriginUpdateParameters, IO[bytes]], **kwargs: Any - ) -> _models.Origin: + ) -> Iterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -662,7 +658,7 @@ def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Origin] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -685,10 +681,10 @@ def _update_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -696,18 +692,19 @@ def _update_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("Origin", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("Origin", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -834,10 +831,11 @@ def begin_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Origin", pipeline_response) + deserialized = self._deserialize("Origin", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -859,9 +857,9 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - def _delete_initial( # pylint: disable=inconsistent-return-statements + def _delete_initial( self, resource_group_name: str, profile_name: str, endpoint_name: str, origin_name: str, **kwargs: Any - ) -> None: + ) -> Iterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -874,7 +872,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_delete_request( resource_group_name=resource_group_name, @@ -886,10 +884,10 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -897,6 +895,10 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -905,8 +907,12 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @distributed_trace def begin_delete( @@ -937,7 +943,7 @@ def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( # type: ignore + raw_result = self._delete_initial( resource_group_name=resource_group_name, profile_name=profile_name, endpoint_name=endpoint_name, @@ -948,6 +954,7 @@ def begin_delete( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_policies_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_policies_operations.py index a0594244f2de..e44de2bac276 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_policies_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_policies_operations.py @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -17,13 +17,14 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -31,7 +32,6 @@ 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 @@ -48,7 +48,7 @@ def build_list_request(resource_group_name: str, subscription_id: str, **kwargs: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -83,7 +83,7 @@ def build_get_request(resource_group_name: str, policy_name: str, subscription_i _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -121,7 +121,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -162,7 +162,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -203,7 +203,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -289,7 +289,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -305,7 +304,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -369,7 +367,6 @@ def get(self, resource_group_name: str, policy_name: str, **kwargs: Any) -> _mod headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -384,7 +381,7 @@ def get(self, resource_group_name: str, policy_name: str, **kwargs: Any) -> _mod error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("CdnWebApplicationFirewallPolicy", pipeline_response) + deserialized = self._deserialize("CdnWebApplicationFirewallPolicy", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -397,7 +394,7 @@ def _create_or_update_initial( policy_name: str, cdn_web_application_firewall_policy: Union[_models.CdnWebApplicationFirewallPolicy, IO[bytes]], **kwargs: Any - ) -> _models.CdnWebApplicationFirewallPolicy: + ) -> Iterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -411,7 +408,7 @@ def _create_or_update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.CdnWebApplicationFirewallPolicy] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -432,10 +429,10 @@ def _create_or_update_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -443,21 +440,19 @@ def _create_or_update_initial( response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("CdnWebApplicationFirewallPolicy", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("CdnWebApplicationFirewallPolicy", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("CdnWebApplicationFirewallPolicy", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -563,10 +558,11 @@ def begin_create_or_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("CdnWebApplicationFirewallPolicy", pipeline_response) + deserialized = self._deserialize("CdnWebApplicationFirewallPolicy", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -596,7 +592,7 @@ def _update_initial( _models.CdnWebApplicationFirewallPolicyPatchParameters, IO[bytes] ], **kwargs: Any - ) -> _models.CdnWebApplicationFirewallPolicy: + ) -> Iterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -610,7 +606,7 @@ def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.CdnWebApplicationFirewallPolicy] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -633,10 +629,10 @@ def _update_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -644,18 +640,19 @@ def _update_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("CdnWebApplicationFirewallPolicy", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("CdnWebApplicationFirewallPolicy", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -769,10 +766,11 @@ def begin_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("CdnWebApplicationFirewallPolicy", pipeline_response) + deserialized = self._deserialize("CdnWebApplicationFirewallPolicy", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -830,7 +828,6 @@ def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_profiles_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_profiles_operations.py index 6a16d3bf4d1d..d19ab1ed2f97 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_profiles_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_profiles_operations.py @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -17,13 +17,14 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -31,7 +32,6 @@ 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 @@ -48,7 +48,7 @@ def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -72,7 +72,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -102,7 +102,7 @@ def build_get_request(resource_group_name: str, profile_name: str, subscription_ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -135,7 +135,7 @@ def build_create_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -171,7 +171,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -207,7 +207,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -238,7 +238,7 @@ def build_can_migrate_request(resource_group_name: str, subscription_id: str, ** _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -271,7 +271,7 @@ def build_migrate_request(resource_group_name: str, subscription_id: str, **kwar _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -306,7 +306,7 @@ def build_migration_commit_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -339,7 +339,7 @@ def build_generate_sso_uri_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -372,7 +372,7 @@ def build_list_supported_optimization_types_request( # pylint: disable=name-too _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -405,7 +405,7 @@ def build_list_resource_usage_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -432,6 +432,41 @@ def build_list_resource_usage_request( return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) +def build_migration_abort_request( + resource_group_name: str, profile_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/migrationAbort", + ) # 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 + ), + "profileName": _SERIALIZER.url( + "profile_name", profile_name, "str", max_length=260, min_length=1, pattern=r"^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + class ProfilesOperations: """ .. warning:: @@ -483,7 +518,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -499,7 +533,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -564,7 +597,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -580,7 +612,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -646,7 +677,6 @@ def get(self, resource_group_name: str, profile_name: str, **kwargs: Any) -> _mo headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -661,7 +691,7 @@ def get(self, resource_group_name: str, profile_name: str, **kwargs: Any) -> _mo error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Profile", pipeline_response) + deserialized = self._deserialize("Profile", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -670,7 +700,7 @@ def get(self, resource_group_name: str, profile_name: str, **kwargs: Any) -> _mo def _create_initial( self, resource_group_name: str, profile_name: str, profile: Union[_models.Profile, IO[bytes]], **kwargs: Any - ) -> _models.Profile: + ) -> Iterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -684,7 +714,7 @@ def _create_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Profile] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -705,10 +735,10 @@ def _create_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -716,21 +746,19 @@ def _create_initial( response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("Profile", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Profile", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("Profile", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -833,10 +861,11 @@ def begin_create( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Profile", pipeline_response) + deserialized = self._deserialize("Profile", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -864,7 +893,7 @@ def _update_initial( profile_name: str, profile_update_parameters: Union[_models.ProfileUpdateParameters, IO[bytes]], **kwargs: Any - ) -> _models.Profile: + ) -> Iterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -878,7 +907,7 @@ def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Profile] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -899,10 +928,10 @@ def _update_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -910,18 +939,19 @@ def _update_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("Profile", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("Profile", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -1030,10 +1060,11 @@ def begin_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Profile", pipeline_response) + deserialized = self._deserialize("Profile", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -1055,9 +1086,7 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - def _delete_initial( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, profile_name: str, **kwargs: Any - ) -> None: + def _delete_initial(self, resource_group_name: str, profile_name: str, **kwargs: Any) -> Iterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -1070,7 +1099,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_delete_request( resource_group_name=resource_group_name, @@ -1080,10 +1109,10 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -1091,6 +1120,10 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -1099,8 +1132,12 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @distributed_trace def begin_delete(self, resource_group_name: str, profile_name: str, **kwargs: Any) -> LROPoller[None]: @@ -1126,7 +1163,7 @@ def begin_delete(self, resource_group_name: str, profile_name: str, **kwargs: An lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( # type: ignore + raw_result = self._delete_initial( resource_group_name=resource_group_name, profile_name=profile_name, api_version=api_version, @@ -1135,6 +1172,7 @@ def begin_delete(self, resource_group_name: str, profile_name: str, **kwargs: An params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements @@ -1161,7 +1199,7 @@ def _can_migrate_initial( resource_group_name: str, can_migrate_parameters: Union[_models.CanMigrateParameters, IO[bytes]], **kwargs: Any - ) -> Optional[_models.CanMigrateResult]: + ) -> Iterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -1175,7 +1213,7 @@ def _can_migrate_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.CanMigrateResult]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -1195,10 +1233,10 @@ def _can_migrate_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -1206,18 +1244,20 @@ def _can_migrate_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("CanMigrateResult", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -1312,10 +1352,11 @@ def begin_can_migrate( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("CanMigrateResult", pipeline_response) + deserialized = self._deserialize("CanMigrateResult", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -1344,7 +1385,7 @@ def _migrate_initial( resource_group_name: str, migration_parameters: Union[_models.MigrationParameters, IO[bytes]], **kwargs: Any - ) -> _models.MigrateResult: + ) -> Iterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -1358,7 +1399,7 @@ def _migrate_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.MigrateResult] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -1378,10 +1419,10 @@ def _migrate_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -1389,18 +1430,19 @@ def _migrate_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("MigrateResult", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("MigrateResult", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -1497,10 +1539,11 @@ def begin_migrate( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("MigrateResult", pipeline_response) + deserialized = self._deserialize("MigrateResult", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -1524,9 +1567,7 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - def _migration_commit_initial( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, profile_name: str, **kwargs: Any - ) -> None: + def _migration_commit_initial(self, resource_group_name: str, profile_name: str, **kwargs: Any) -> Iterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -1539,7 +1580,7 @@ def _migration_commit_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_migration_commit_request( resource_group_name=resource_group_name, @@ -1549,10 +1590,10 @@ def _migration_commit_initial( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -1560,6 +1601,10 @@ def _migration_commit_initial( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -1568,8 +1613,12 @@ def _migration_commit_initial( # pylint: disable=inconsistent-return-statements if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @distributed_trace def begin_migration_commit(self, resource_group_name: str, profile_name: str, **kwargs: Any) -> LROPoller[None]: @@ -1593,7 +1642,7 @@ def begin_migration_commit(self, resource_group_name: str, profile_name: str, ** lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._migration_commit_initial( # type: ignore + raw_result = self._migration_commit_initial( resource_group_name=resource_group_name, profile_name=profile_name, api_version=api_version, @@ -1602,6 +1651,7 @@ def begin_migration_commit(self, resource_group_name: str, profile_name: str, ** params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements @@ -1664,7 +1714,6 @@ def generate_sso_uri(self, resource_group_name: str, profile_name: str, **kwargs headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1679,7 +1728,7 @@ def generate_sso_uri(self, resource_group_name: str, profile_name: str, **kwargs error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("SsoUri", pipeline_response) + deserialized = self._deserialize("SsoUri", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -1724,7 +1773,6 @@ def list_supported_optimization_types( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1739,7 +1787,7 @@ def list_supported_optimization_types( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("SupportedOptimizationTypesListResult", pipeline_response) + deserialized = self._deserialize("SupportedOptimizationTypesListResult", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -1787,7 +1835,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -1803,7 +1850,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -1832,3 +1878,112 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) + + def _migration_abort_initial(self, resource_group_name: str, profile_name: str, **kwargs: Any) -> Iterator[bytes]: + 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[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_migration_abort_request( + resource_group_name=resource_group_name, + profile_name=profile_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_migration_abort(self, resource_group_name: str, profile_name: str, **kwargs: Any) -> LROPoller[None]: + """Abort the migration to Azure Frontdoor Premium/Standard. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is + unique within the resource group. Required. + :type profile_name: str + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._migration_abort_initial( + resource_group_name=resource_group_name, + profile_name=profile_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "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/_resource_usage_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_resource_usage_operations.py index cadf0a85721a..e67a47ba1bb8 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_resource_usage_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_resource_usage_operations.py @@ -20,15 +20,13 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import CdnManagementClientMixinABC, _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -45,7 +43,7 @@ def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -115,7 +113,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -131,7 +128,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_routes_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_routes_operations.py index 0b9de673cfe5..28f7fed4b321 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_routes_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_routes_operations.py @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -17,13 +17,14 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -31,7 +32,6 @@ 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 @@ -50,7 +50,7 @@ def build_list_by_endpoint_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -89,7 +89,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -129,7 +129,7 @@ def build_create_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -172,7 +172,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -215,7 +215,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -307,7 +307,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -323,7 +322,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -398,7 +396,6 @@ def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -413,7 +410,7 @@ def get( error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Route", pipeline_response) + deserialized = self._deserialize("Route", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -428,7 +425,7 @@ def _create_initial( route_name: str, route: Union[_models.Route, IO[bytes]], **kwargs: Any - ) -> _models.Route: + ) -> Iterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -442,7 +439,7 @@ def _create_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Route] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -465,10 +462,10 @@ def _create_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -476,21 +473,19 @@ def _create_initial( response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("Route", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Route", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("Route", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -619,10 +614,11 @@ def begin_create( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Route", pipeline_response) + deserialized = self._deserialize("Route", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -654,7 +650,7 @@ def _update_initial( route_name: str, route_update_properties: Union[_models.RouteUpdateParameters, IO[bytes]], **kwargs: Any - ) -> _models.Route: + ) -> Iterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -668,7 +664,7 @@ def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Route] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -691,10 +687,10 @@ def _update_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -702,18 +698,19 @@ def _update_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("Route", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("Route", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -843,10 +840,11 @@ def begin_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Route", pipeline_response) + deserialized = self._deserialize("Route", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -870,9 +868,9 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - def _delete_initial( # pylint: disable=inconsistent-return-statements + def _delete_initial( self, resource_group_name: str, profile_name: str, endpoint_name: str, route_name: str, **kwargs: Any - ) -> None: + ) -> Iterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -885,7 +883,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_delete_request( resource_group_name=resource_group_name, @@ -897,10 +895,10 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -908,6 +906,10 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -916,8 +918,12 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @distributed_trace def begin_delete( @@ -949,7 +955,7 @@ def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( # type: ignore + raw_result = self._delete_initial( resource_group_name=resource_group_name, profile_name=profile_name, endpoint_name=endpoint_name, @@ -960,6 +966,7 @@ def begin_delete( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_rule_sets_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_rule_sets_operations.py index 4f4fb842dd03..c55a0d825cf7 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_rule_sets_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_rule_sets_operations.py @@ -7,7 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar, Union, cast +from typing import Any, Callable, Dict, Iterable, Iterator, Optional, Type, TypeVar, Union, cast import urllib.parse from azure.core.exceptions import ( @@ -16,13 +16,14 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -30,7 +31,6 @@ 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 @@ -49,7 +49,7 @@ def build_list_by_profile_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -82,7 +82,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -116,7 +116,7 @@ def build_create_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -150,7 +150,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -184,7 +184,7 @@ def build_list_resource_usage_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -271,7 +271,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -287,7 +286,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -357,7 +355,6 @@ def get(self, resource_group_name: str, profile_name: str, rule_set_name: str, * headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -372,7 +369,7 @@ def get(self, resource_group_name: str, profile_name: str, rule_set_name: str, * error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("RuleSet", pipeline_response) + deserialized = self._deserialize("RuleSet", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -418,7 +415,6 @@ def create(self, resource_group_name: str, profile_name: str, rule_set_name: str headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -433,20 +429,16 @@ def create(self, resource_group_name: str, profile_name: str, rule_set_name: str error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("RuleSet", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("RuleSet", pipeline_response) + deserialized = self._deserialize("RuleSet", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - def _delete_initial( # pylint: disable=inconsistent-return-statements + def _delete_initial( self, resource_group_name: str, profile_name: str, rule_set_name: str, **kwargs: Any - ) -> None: + ) -> Iterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -459,7 +451,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_delete_request( resource_group_name=resource_group_name, @@ -470,10 +462,10 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -481,6 +473,10 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -489,8 +485,12 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @distributed_trace def begin_delete( @@ -520,7 +520,7 @@ def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( # type: ignore + raw_result = self._delete_initial( resource_group_name=resource_group_name, profile_name=profile_name, rule_set_name=rule_set_name, @@ -530,6 +530,7 @@ def begin_delete( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements @@ -597,7 +598,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -613,7 +613,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_rules_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_rules_operations.py index 02f15c6f1378..dc07f56b4ee8 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_rules_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_rules_operations.py @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -17,13 +17,14 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -31,7 +32,6 @@ 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 @@ -50,7 +50,7 @@ def build_list_by_rule_set_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -84,7 +84,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -119,7 +119,7 @@ def build_create_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -157,7 +157,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -195,7 +195,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -286,7 +286,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -302,7 +301,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -375,7 +373,6 @@ def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -390,7 +387,7 @@ def get( error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Rule", pipeline_response) + deserialized = self._deserialize("Rule", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -405,7 +402,7 @@ def _create_initial( rule_name: str, rule: Union[_models.Rule, IO[bytes]], **kwargs: Any - ) -> _models.Rule: + ) -> Iterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -419,7 +416,7 @@ def _create_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Rule] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -442,10 +439,10 @@ def _create_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -453,21 +450,19 @@ def _create_initial( response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("Rule", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Rule", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("Rule", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -590,10 +585,11 @@ def begin_create( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Rule", pipeline_response) + deserialized = self._deserialize("Rule", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -625,7 +621,7 @@ def _update_initial( rule_name: str, rule_update_properties: Union[_models.RuleUpdateParameters, IO[bytes]], **kwargs: Any - ) -> _models.Rule: + ) -> Iterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -639,7 +635,7 @@ def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Rule] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -662,10 +658,10 @@ def _update_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -673,18 +669,19 @@ def _update_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("Rule", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("Rule", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -808,10 +805,11 @@ def begin_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Rule", pipeline_response) + deserialized = self._deserialize("Rule", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -835,9 +833,9 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - def _delete_initial( # pylint: disable=inconsistent-return-statements + def _delete_initial( self, resource_group_name: str, profile_name: str, rule_set_name: str, rule_name: str, **kwargs: Any - ) -> None: + ) -> Iterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -850,7 +848,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_delete_request( resource_group_name=resource_group_name, @@ -862,10 +860,10 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -873,6 +871,10 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -881,8 +883,12 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @distributed_trace def begin_delete( @@ -912,7 +918,7 @@ def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( # type: ignore + raw_result = self._delete_initial( resource_group_name=resource_group_name, profile_name=profile_name, rule_set_name=rule_set_name, @@ -923,6 +929,7 @@ def begin_delete( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_secrets_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_secrets_operations.py index 8f2d121d8a8b..e26ea21f7771 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_secrets_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_secrets_operations.py @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -17,13 +17,14 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -31,7 +32,6 @@ 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 @@ -50,7 +50,7 @@ def build_list_by_profile_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -83,7 +83,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -117,7 +117,7 @@ def build_create_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -154,7 +154,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -239,7 +239,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -255,7 +254,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -323,7 +321,6 @@ def get(self, resource_group_name: str, profile_name: str, secret_name: str, **k headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -338,7 +335,7 @@ def get(self, resource_group_name: str, profile_name: str, secret_name: str, **k error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Secret", pipeline_response) + deserialized = self._deserialize("Secret", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -352,7 +349,7 @@ def _create_initial( secret_name: str, secret: Union[_models.Secret, IO[bytes]], **kwargs: Any - ) -> _models.Secret: + ) -> Iterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -366,7 +363,7 @@ def _create_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Secret] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -388,10 +385,10 @@ def _create_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -399,21 +396,19 @@ def _create_initial( response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("Secret", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Secret", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("Secret", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -526,10 +521,11 @@ def begin_create( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Secret", pipeline_response) + deserialized = self._deserialize("Secret", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -553,9 +549,9 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - def _delete_initial( # pylint: disable=inconsistent-return-statements + def _delete_initial( self, resource_group_name: str, profile_name: str, secret_name: str, **kwargs: Any - ) -> None: + ) -> Iterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -568,7 +564,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_delete_request( resource_group_name=resource_group_name, @@ -579,10 +575,10 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -590,6 +586,10 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -598,8 +598,12 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @distributed_trace def begin_delete( @@ -627,7 +631,7 @@ def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( # type: ignore + raw_result = self._delete_initial( resource_group_name=resource_group_name, profile_name=profile_name, secret_name=secret_name, @@ -637,6 +641,7 @@ def begin_delete( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_security_policies_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_security_policies_operations.py index 6d5a448a343f..e569d4f2a99d 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_security_policies_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_security_policies_operations.py @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -17,13 +17,14 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -31,7 +32,6 @@ 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 @@ -50,7 +50,7 @@ def build_list_by_profile_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -83,7 +83,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -117,7 +117,7 @@ def build_create_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -154,7 +154,7 @@ def build_patch_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -191,7 +191,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -278,7 +278,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -294,7 +293,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -364,7 +362,6 @@ def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -379,7 +376,7 @@ def get( error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("SecurityPolicy", pipeline_response) + deserialized = self._deserialize("SecurityPolicy", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -393,7 +390,7 @@ def _create_initial( security_policy_name: str, security_policy: Union[_models.SecurityPolicy, IO[bytes]], **kwargs: Any - ) -> _models.SecurityPolicy: + ) -> Iterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -407,7 +404,7 @@ def _create_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.SecurityPolicy] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -429,10 +426,10 @@ def _create_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -440,21 +437,19 @@ def _create_initial( response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("SecurityPolicy", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("SecurityPolicy", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("SecurityPolicy", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -571,10 +566,11 @@ def begin_create( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("SecurityPolicy", pipeline_response) + deserialized = self._deserialize("SecurityPolicy", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -605,7 +601,7 @@ def _patch_initial( security_policy_name: str, security_policy_update_properties: Union[_models.SecurityPolicyUpdateParameters, IO[bytes]], **kwargs: Any - ) -> _models.SecurityPolicy: + ) -> Iterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -619,7 +615,7 @@ def _patch_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.SecurityPolicy] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -641,10 +637,10 @@ def _patch_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -652,18 +648,19 @@ def _patch_initial( response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("SecurityPolicy", pipeline_response) - if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) - deserialized = self._deserialize("SecurityPolicy", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -781,10 +778,11 @@ def begin_patch( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("SecurityPolicy", pipeline_response) + deserialized = self._deserialize("SecurityPolicy", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -808,9 +806,9 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - def _delete_initial( # pylint: disable=inconsistent-return-statements + def _delete_initial( self, resource_group_name: str, profile_name: str, security_policy_name: str, **kwargs: Any - ) -> None: + ) -> Iterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -823,7 +821,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_delete_request( resource_group_name=resource_group_name, @@ -834,10 +832,10 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -845,6 +843,10 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.AfdErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -853,8 +855,12 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if response.status_code == 202: response_headers["location"] = self._deserialize("str", response.headers.get("location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @distributed_trace def begin_delete( @@ -882,7 +888,7 @@ def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( # type: ignore + raw_result = self._delete_initial( resource_group_name=resource_group_name, profile_name=profile_name, security_policy_name=security_policy_name, @@ -892,6 +898,7 @@ def begin_delete( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_custom_domains_create.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_custom_domains_create.py index 232c2e014f9f..e9efcba51737 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 @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -47,6 +45,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDCustomDomains_Create.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/AFDCustomDomains_Create.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_custom_domains_delete.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_custom_domains_delete.py index cdde1ccd7199..a1856333545d 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 @@ -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: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/AFDCustomDomains_Delete.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_custom_domains_get.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_custom_domains_get.py index c529ac66adb1..3d6e56de8891 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 @@ -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: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/AFDCustomDomains_Get.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_custom_domains_list_by_profile.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_custom_domains_list_by_profile.py index 9838f20f9aa9..85680dd9e2d3 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 @@ -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: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/AFDCustomDomains_ListByProfile.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_custom_domains_refresh_validation_token.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_custom_domains_refresh_validation_token.py index 14687b97d07d..94388946e453 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 @@ -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: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/AFDCustomDomains_RefreshValidationToken.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_custom_domains_update.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_custom_domains_update.py index 383d3fee790e..19b23bcd31c1 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 @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -46,6 +44,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDCustomDomains_Update.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/AFDCustomDomains_Update.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_endpoints_create.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_endpoints_create.py index 6c47e4ba6e73..b5c3dfad72b3 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 @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -45,6 +43,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDEndpoints_Create.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/AFDEndpoints_Create.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_endpoints_delete.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_endpoints_delete.py index 2d4f28011117..26e623b3b194 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 @@ -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: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/AFDEndpoints_Delete.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_endpoints_get.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_endpoints_get.py index eca25cfe859c..ba1a481e4051 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_endpoints_get.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_endpoints_get.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDEndpoints_Get.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/AFDEndpoints_Get.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_endpoints_list_by_profile.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_endpoints_list_by_profile.py index b678db5bb2db..9f95d308a49c 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 @@ -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: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/AFDEndpoints_ListByProfile.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_endpoints_list_resource_usage.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_endpoints_list_resource_usage.py index 656ee738021c..e407bd15bfe8 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 @@ -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: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/AFDEndpoints_ListResourceUsage.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_endpoints_purge_content.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_endpoints_purge_content.py index aebb6dbb77e8..ba7225b813bf 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 @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -40,6 +38,6 @@ def main(): ).result() -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDEndpoints_PurgeContent.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/AFDEndpoints_PurgeContent.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_endpoints_update.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_endpoints_update.py index f84366b6e02e..41263a29a7e9 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 @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -41,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDEndpoints_Update.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/AFDEndpoints_Update.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_endpoints_validate_custom_domain.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_endpoints_validate_custom_domain.py index 37fd7a89af3f..f4098d6250fa 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 @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -41,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDEndpoints_ValidateCustomDomain.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/AFDEndpoints_ValidateCustomDomain.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origin_groups_create.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origin_groups_create.py index 5f1a41348821..e01ceafce06f 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 @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -56,6 +54,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDOriginGroups_Create.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/AFDOriginGroups_Create.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origin_groups_delete.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origin_groups_delete.py index 79952a91120c..a2531a2269d8 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 @@ -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: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/AFDOriginGroups_Delete.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origin_groups_get.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origin_groups_get.py index 606b8be50db8..7615fae507f2 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 @@ -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: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/AFDOriginGroups_Get.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origin_groups_list_by_profile.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origin_groups_list_by_profile.py index de8a9f7f5725..f4ee79424d06 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 @@ -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: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/AFDOriginGroups_ListByProfile.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origin_groups_list_resource_usage.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origin_groups_list_resource_usage.py index 0297a249bcdb..c34d67194c73 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 @@ -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: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/AFDOriginGroups_ListResourceUsage.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origin_groups_update.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origin_groups_update.py index 0a17f8587bb0..4ec8a08c25f7 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 @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -56,6 +54,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDOriginGroups_Update.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/AFDOriginGroups_Update.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origins_create.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origins_create.py index c42baa3cadc9..5051fca340d9 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origins_create.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origins_create.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -50,6 +48,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDOrigins_Create.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/AFDOrigins_Create.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origins_delete.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origins_delete.py index d8e79eddaa4a..baad17f47ad7 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origins_delete.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origins_delete.py @@ -38,6 +38,6 @@ def main(): ).result() -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDOrigins_Delete.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/AFDOrigins_Delete.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origins_get.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origins_get.py index 4216fff73b9d..f51a5d2b7b5c 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origins_get.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origins_get.py @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDOrigins_Get.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/AFDOrigins_Get.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origins_list_by_origin_group.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origins_list_by_origin_group.py index 8aca66fa1ea7..f12345e38811 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 @@ -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: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/AFDOrigins_ListByOriginGroup.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origins_update.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origins_update.py index ffdd1c9eb0c4..f26b4334f122 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origins_update.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origins_update.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -49,6 +47,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDOrigins_Update.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/AFDOrigins_Update.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_profiles_check_endpoint_name_availability.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_profiles_check_endpoint_name_availability.py index 3cd89e63f42a..49f77c9501ad 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 @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -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: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/AFDProfiles_CheckEndpointNameAvailability.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_profiles_check_host_name_availability.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_profiles_check_host_name_availability.py index 0c58ab223c3d..6cc59cd46039 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 @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -40,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDProfiles_CheckHostNameAvailability.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/AFDProfiles_CheckHostNameAvailability.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_profiles_list_resource_usage.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_profiles_list_resource_usage.py index 7d952f353b0f..ca3c24150079 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 @@ -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: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/AFDProfiles_ListResourceUsage.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_profiles_upgrade.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_profiles_upgrade.py index 183a03ed50d9..77413514a5c8 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 @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -49,6 +47,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDProfiles_Upgrade.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/AFDProfiles_Upgrade.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_profiles_validate_secret.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_profiles_validate_secret.py index 66b34e4ba7d8..425b69f07f3d 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 @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -45,6 +43,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDProfiles_ValidateSecret.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/AFDProfiles_ValidateSecret.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/cdn_profiles_can_migrate.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/cdn_profiles_can_migrate.py new file mode 100644 index 000000000000..4919527bf0f1 --- /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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.cdn import CdnManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-cdn +# USAGE + python cdn_profiles_can_migrate.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = CdnManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.cdn_profiles.begin_cdn_can_migrate_to_afd( + resource_group_name="RG", + profile_name="profile1", + ).result() + print(response) + + +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/CdnProfiles_CanMigrate.json +if __name__ == "__main__": + main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/cdn_profiles_migrate.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/cdn_profiles_migrate.py new file mode 100644 index 000000000000..28fd8aa290ae --- /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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.cdn import CdnManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-cdn +# USAGE + python cdn_profiles_migrate.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = CdnManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.cdn_profiles.begin_cdn_migrate_to_afd( + resource_group_name="RG", + profile_name="profile1", + migration_parameters={"sku": {"name": "Standard_AzureFrontDoor"}}, + ).result() + print(response) + + +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/CdnProfiles_Migrate.json +if __name__ == "__main__": + main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/check_endpoint_name_availability.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/check_endpoint_name_availability.py index e674cea2011f..16602a47f478 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 @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -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: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/CheckEndpointNameAvailability.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/check_name_availability.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/check_name_availability.py index ef2972396a83..c6af8fba0aec 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 @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -38,6 +36,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/CheckNameAvailability.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/CheckNameAvailability.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/check_name_availability_with_subscription.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/check_name_availability_with_subscription.py index dafc98d6dee6..6ac9841d9c3e 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 @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -38,6 +36,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/CheckNameAvailabilityWithSubscription.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/CheckNameAvailabilityWithSubscription.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/custom_domains_create.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/custom_domains_create.py index 7f0e634b4aa4..3287d248e476 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 @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -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: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/CustomDomains_Create.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/custom_domains_delete.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/custom_domains_delete.py index 7861318578bd..3c83ce7ba4e0 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 @@ -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: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/CustomDomains_Delete.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/custom_domains_disable_custom_https.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/custom_domains_disable_custom_https.py index f9194bef7069..9d27bbb8a5cf 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 @@ -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: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/CustomDomains_DisableCustomHttps.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/custom_domains_enable_custom_https_using_byoc.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/custom_domains_enable_custom_https_using_byoc.py index 4f88e220d426..771f532d7063 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 @@ -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: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/CustomDomains_EnableCustomHttpsUsingBYOC.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/custom_domains_enable_custom_https_using_cdn_managed_certificate.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/custom_domains_enable_custom_https_using_cdn_managed_certificate.py index c62b5e115f17..ddbd6d19b5d0 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 @@ -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: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/CustomDomains_EnableCustomHttpsUsingCDNManagedCertificate.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/custom_domains_get.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/custom_domains_get.py index 09b7e305b0e2..70c3c8498677 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/custom_domains_get.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/custom_domains_get.py @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/CustomDomains_Get.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/CustomDomains_Get.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/custom_domains_list_by_endpoint.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/custom_domains_list_by_endpoint.py index 13a26666662b..7e72444124d0 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 @@ -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: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/CustomDomains_ListByEndpoint.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/edge_nodes_list.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/edge_nodes_list.py index c7e2062ae372..c3754ffab78d 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/edge_nodes_list.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/edge_nodes_list.py @@ -35,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/EdgeNodes_List.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/EdgeNodes_List.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_create.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_create.py index 9168c89ae5a4..a083185a6af6 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_create.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_create.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -156,6 +154,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Endpoints_Create.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/Endpoints_Create.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_delete.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_delete.py index 39a54278d76d..e598caa2ae36 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_delete.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_delete.py @@ -37,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Endpoints_Delete.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/Endpoints_Delete.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_get.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_get.py index 301f9f733c6a..ab4fbafd648d 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_get.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_get.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Endpoints_Get.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/Endpoints_Get.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_list_by_profile.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_list_by_profile.py index f5461c728bc4..b6b4d5cb9154 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 @@ -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: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/Endpoints_ListByProfile.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_list_resource_usage.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_list_resource_usage.py index 405675b567fe..dc19cc9be51e 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 @@ -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: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/Endpoints_ListResourceUsage.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_load_content.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_load_content.py index 1cf246f15099..4e5b594cc9fe 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 @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -40,6 +38,6 @@ def main(): ).result() -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Endpoints_LoadContent.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/Endpoints_LoadContent.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_purge_content.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_purge_content.py index 57adb262b0fa..85e6a0b83ba0 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 @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -40,6 +38,6 @@ def main(): ).result() -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Endpoints_PurgeContent.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/Endpoints_PurgeContent.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_start.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_start.py index 87f3f2134ca8..9f1ffb54fa1a 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_start.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_start.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Endpoints_Start.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/Endpoints_Start.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_stop.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_stop.py index d8ec097a2211..0b864a93acd3 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_stop.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_stop.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Endpoints_Stop.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/Endpoints_Stop.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_update.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_update.py index 828459ba88ef..582beee76f9a 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_update.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_update.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -41,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Endpoints_Update.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/Endpoints_Update.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_validate_custom_domain.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_validate_custom_domain.py index af88a31d15c6..afdbd8894942 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 @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -41,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Endpoints_ValidateCustomDomain.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/Endpoints_ValidateCustomDomain.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/log_analytics_get_log_analytics_locations.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/log_analytics_get_log_analytics_locations.py index 3a8bd6124731..9da096de432a 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 @@ -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: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/LogAnalytics_GetLogAnalyticsLocations.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/log_analytics_get_log_analytics_metrics.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/log_analytics_get_log_analytics_metrics.py index 99792edff08a..2afd13390a90 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 @@ -6,17 +6,12 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import datetime import isodate -from typing import List, TYPE_CHECKING, Union from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models """ # PREREQUISITES pip install azure-identity @@ -50,6 +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: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/LogAnalytics_GetLogAnalyticsMetrics.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/log_analytics_get_log_analytics_rankings.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/log_analytics_get_log_analytics_rankings.py index 1b476cdd4515..c038a284dfb0 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 @@ -6,17 +6,12 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import datetime import isodate -from typing import List, TYPE_CHECKING, Union from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models """ # PREREQUISITES pip install azure-identity @@ -49,6 +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: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/LogAnalytics_GetLogAnalyticsRankings.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/log_analytics_get_log_analytics_resources.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/log_analytics_get_log_analytics_resources.py index ba65e42c3cef..99e42b4e54d7 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 @@ -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: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/LogAnalytics_GetLogAnalyticsResources.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/log_analytics_get_waf_log_analytics_metrics.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/log_analytics_get_waf_log_analytics_metrics.py index bd7f9b3079db..a4ac4698cf26 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 @@ -6,17 +6,12 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import datetime import isodate -from typing import List, TYPE_CHECKING, Union from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models """ # PREREQUISITES pip install azure-identity @@ -48,6 +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: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/LogAnalytics_GetWafLogAnalyticsMetrics.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/log_analytics_get_waf_log_analytics_rankings.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/log_analytics_get_waf_log_analytics_rankings.py index d6c05717d1e6..c6ef0e4bd9bb 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 @@ -6,17 +6,12 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import datetime import isodate -from typing import List, TYPE_CHECKING, Union from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models """ # PREREQUISITES pip install azure-identity @@ -49,6 +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: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/LogAnalytics_GetWafLogAnalyticsRankings.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/operations_list.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/operations_list.py index 60380404b906..bef1a27abb5a 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/operations_list.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/operations_list.py @@ -35,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Operations_List.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/Operations_List.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/origin_groups_create.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/origin_groups_create.py index 8fc8ae01c77a..0e73616ad755 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 @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -60,6 +58,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/OriginGroups_Create.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/OriginGroups_Create.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/origin_groups_delete.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/origin_groups_delete.py index 16263ab85319..8647ef0b2454 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 @@ -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: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/OriginGroups_Delete.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/origin_groups_get.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/origin_groups_get.py index e0e64c28f83d..f6863e27f5a0 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/origin_groups_get.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/origin_groups_get.py @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/OriginGroups_Get.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/OriginGroups_Get.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/origin_groups_list_by_endpoint.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/origin_groups_list_by_endpoint.py index 59a0711ca5a5..3c77dc4bf497 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 @@ -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: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/OriginGroups_ListByEndpoint.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/origin_groups_update.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/origin_groups_update.py index 9ca87890ab2c..2053503e2ea9 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 @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -56,6 +54,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/OriginGroups_Update.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/OriginGroups_Update.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/origins_create.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/origins_create.py index df360fce2549..ca01cc69a8c0 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/origins_create.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/origins_create.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -55,6 +53,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Origins_Create.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/Origins_Create.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/origins_delete.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/origins_delete.py index 2e0262ae7112..ef3ab7ad9bc6 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/origins_delete.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/origins_delete.py @@ -38,6 +38,6 @@ def main(): ).result() -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Origins_Delete.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/Origins_Delete.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/origins_get.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/origins_get.py index babb5673bbf7..ee39e5a0697b 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/origins_get.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/origins_get.py @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Origins_Get.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/Origins_Get.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/origins_list_by_endpoint.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/origins_list_by_endpoint.py index 9841934192fd..a4b4e6593c21 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 @@ -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: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/Origins_ListByEndpoint.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/origins_update.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/origins_update.py index 048a05562201..60c8559decd2 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/origins_update.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/origins_update.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -52,6 +50,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Origins_Update.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/Origins_Update.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_can_migrate.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_can_migrate.py index 61208bef63d0..c715b187fcc3 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 @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -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: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/Profiles_CanMigrate.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_create.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_create.py index 139587290691..7f857ea0cb74 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_create.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_create.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -40,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Profiles_Create.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/Profiles_Create.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_delete.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_delete.py index e15c08f6a878..ccf113e6ff68 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_delete.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_delete.py @@ -36,6 +36,6 @@ def main(): ).result() -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Profiles_Delete.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/Profiles_Delete.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_generate_sso_uri.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_generate_sso_uri.py index ccbc01208071..3985838cdf25 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 @@ -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: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/Profiles_GenerateSsoUri.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_get.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_get.py index 172c69425889..fd91f55e1b3c 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_get.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_get.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Profiles_Get.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/Profiles_Get.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_list.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_list.py index d14470182ced..65c2750fbe72 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_list.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_list.py @@ -35,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Profiles_List.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/Profiles_List.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_list_by_resource_group.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_list_by_resource_group.py index b97c6fa4f15c..c471fdb8a308 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 @@ -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: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/Profiles_ListByResourceGroup.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_list_resource_usage.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_list_resource_usage.py index b4d07330bcbe..e18193d0cae0 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 @@ -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: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/Profiles_ListResourceUsage.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_list_supported_optimization_types.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_list_supported_optimization_types.py index 2f16d6104d98..74b8876bc739 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 @@ -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: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/Profiles_ListSupportedOptimizationTypes.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_migrate.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_migrate.py index ff448f96f765..84efa9d1bc07 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_migrate.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_migrate.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -45,6 +43,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Profiles_Migrate.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/Profiles_Migrate.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_migration_abort.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_migration_abort.py new file mode 100644 index 000000000000..bc3fece348fc --- /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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.cdn import CdnManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-cdn +# USAGE + python profiles_migration_abort.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = CdnManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + client.profiles.begin_migration_abort( + resource_group_name="RG", + profile_name="profile1", + ).result() + + +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/Profiles_MigrationAbort.json +if __name__ == "__main__": + main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_migration_commit.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_migration_commit.py index 39880c2a7040..65842491140e 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 @@ -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: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/Profiles_MigrationCommit.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_update.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_update.py index 7a77aa5cf83a..96b8cbbcf2e0 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_update.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_update.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -40,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Profiles_Update.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/Profiles_Update.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/resource_usage_list.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/resource_usage_list.py index f13ebbc36df5..8a2868238273 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 @@ -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: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/ResourceUsage_List.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/routes_create.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/routes_create.py index ac4b9aac1942..09872d483ac5 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/routes_create.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/routes_create.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -73,6 +71,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Routes_Create.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/Routes_Create.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/routes_delete.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/routes_delete.py index 005a5640be13..e07d14cda804 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/routes_delete.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/routes_delete.py @@ -38,6 +38,6 @@ def main(): ).result() -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Routes_Delete.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/Routes_Delete.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/routes_get.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/routes_get.py index 97d3bbb4ffed..d27dc0de515b 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/routes_get.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/routes_get.py @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Routes_Get.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/Routes_Get.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/routes_list_by_endpoint.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/routes_list_by_endpoint.py index 975bbf16c82e..8231cc4acf16 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 @@ -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: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/Routes_ListByEndpoint.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/routes_update.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/routes_update.py index 2e1431b0c52d..e521cd6b086f 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/routes_update.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/routes_update.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -72,6 +70,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Routes_Update.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/Routes_Update.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/rule_sets_create.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/rule_sets_create.py index e3c4d5ab619a..9dda12b45f8e 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/rule_sets_create.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/rule_sets_create.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/RuleSets_Create.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/RuleSets_Create.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/rule_sets_delete.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/rule_sets_delete.py index 129ba69060cb..e3ea9de1658f 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/rule_sets_delete.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/rule_sets_delete.py @@ -37,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/RuleSets_Delete.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/RuleSets_Delete.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/rule_sets_get.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/rule_sets_get.py index 4108b7daa08e..e52b414fb0fa 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/rule_sets_get.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/rule_sets_get.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/RuleSets_Get.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/RuleSets_Get.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/rule_sets_list_by_profile.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/rule_sets_list_by_profile.py index 30b1fd7b2c27..802c7aabd505 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 @@ -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: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/RuleSets_ListByProfile.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/rule_sets_list_resource_usage.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/rule_sets_list_resource_usage.py index 310c77ba4f71..138c5267883c 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 @@ -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: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/RuleSets_ListResourceUsage.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/rules_create.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/rules_create.py index 07e893135dd6..c507526644c5 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/rules_create.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/rules_create.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -68,6 +66,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Rules_Create.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/Rules_Create.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/rules_delete.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/rules_delete.py index bae4e0fabfe8..2b4eef593b15 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/rules_delete.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/rules_delete.py @@ -38,6 +38,6 @@ def main(): ).result() -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Rules_Delete.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/Rules_Delete.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/rules_get.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/rules_get.py index 2e2505d9f09f..39f2db8f9c2d 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/rules_get.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/rules_get.py @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Rules_Get.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/Rules_Get.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/rules_list_by_rule_set.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/rules_list_by_rule_set.py index f096b56e948a..cdb63956c265 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 @@ -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: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/Rules_ListByRuleSet.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/rules_update.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/rules_update.py index ab1eb23507e3..214df120a804 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/rules_update.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/rules_update.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -57,6 +55,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Rules_Update.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/Rules_Update.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/secrets_create.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/secrets_create.py index ce98279c2883..6b8c55e05e1e 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/secrets_create.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/secrets_create.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -52,6 +50,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Secrets_Create.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/Secrets_Create.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/secrets_delete.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/secrets_delete.py index 247d04c46c71..b32fd0a7fad1 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/secrets_delete.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/secrets_delete.py @@ -37,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Secrets_Delete.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/Secrets_Delete.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/secrets_get.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/secrets_get.py index 18e6df120ff9..d3605ab9c0d8 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/secrets_get.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/secrets_get.py @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Secrets_Get.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/Secrets_Get.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/secrets_list_by_profile.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/secrets_list_by_profile.py index a23988e572f4..7eced00e617e 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 @@ -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: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/Secrets_ListByProfile.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/security_policies_create.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/security_policies_create.py index 007ffa21a147..c2248eb7911d 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 @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -63,6 +61,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/SecurityPolicies_Create.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/SecurityPolicies_Create.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/security_policies_delete.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/security_policies_delete.py index 53a393cf71b8..23ff4baf7e47 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 @@ -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: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/SecurityPolicies_Delete.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/security_policies_get.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/security_policies_get.py index 9ffd420f9622..bae820870d65 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 @@ -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: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/SecurityPolicies_Get.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/security_policies_list_by_profile.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/security_policies_list_by_profile.py index a73aab33dff3..956b822a62ca 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 @@ -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: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/SecurityPolicies_ListByProfile.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/security_policies_patch.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/security_policies_patch.py index 9bc7789afd81..d536629f1f02 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 @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -63,6 +61,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/SecurityPolicies_Patch.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/SecurityPolicies_Patch.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/validate_probe.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/validate_probe.py index eb0e8b8c8ad5..9f67a847f51f 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/validate_probe.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/validate_probe.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -38,6 +36,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/ValidateProbe.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/ValidateProbe.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/waf_list_managed_rule_sets.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/waf_list_managed_rule_sets.py index 8d0ee8e8fcb0..1f51e2faf0ed 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 @@ -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: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/WafListManagedRuleSets.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/waf_list_policies.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/waf_list_policies.py index 94470f323fe4..163c4711c2c1 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/waf_list_policies.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/waf_list_policies.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/WafListPolicies.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/WafListPolicies.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/waf_patch_policy.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/waf_patch_policy.py index 0478923b8574..d6a3848a904b 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/waf_patch_policy.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/waf_patch_policy.py @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -40,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/WafPatchPolicy.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/WafPatchPolicy.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/waf_policy_create_or_update.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/waf_policy_create_or_update.py index 63b8ee7c267d..81fbe7143fab 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 @@ -6,8 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, IO, Union - from azure.identity import DefaultAzureCredential from azure.mgmt.cdn import CdnManagementClient @@ -125,6 +123,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/WafPolicyCreateOrUpdate.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/WafPolicyCreateOrUpdate.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/waf_policy_delete.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/waf_policy_delete.py index c0b10e7d8496..a85dcde3c14f 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/waf_policy_delete.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/waf_policy_delete.py @@ -36,6 +36,6 @@ def main(): ) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/WafPolicyDelete.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/WafPolicyDelete.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/waf_policy_get.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/waf_policy_get.py index eecc00b102f2..e2853d3cc97f 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/waf_policy_get.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/waf_policy_get.py @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/WafPolicyGet.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-09-01/examples/WafPolicyGet.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_tests/conftest.py b/sdk/cdn/azure-mgmt-cdn/generated_tests/conftest.py new file mode 100644 index 000000000000..6b5a2293c139 --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/conftest.py @@ -0,0 +1,35 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import os +import pytest +from dotenv import load_dotenv +from devtools_testutils import ( + test_proxy, + add_general_regex_sanitizer, + add_body_key_sanitizer, + add_header_regex_sanitizer, +) + +load_dotenv() + + +# aovid 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..bbf8301b7604 --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management.py @@ -0,0 +1,68 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.cdn import CdnManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestCdnManagement(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(CdnManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_check_endpoint_name_availability(self, resource_group): + response = self.client.check_endpoint_name_availability( + resource_group_name=resource_group.name, + check_endpoint_name_availability_input={ + "name": "str", + "type": "str", + "autoGeneratedDomainNameLabelScope": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_check_name_availability(self, resource_group): + response = self.client.check_name_availability( + check_name_availability_input={"name": "str", "type": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_check_name_availability_with_subscription(self, resource_group): + response = self.client.check_name_availability_with_subscription( + check_name_availability_input={"name": "str", "type": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_validate_probe(self, resource_group): + response = self.client.validate_probe( + validate_probe_input={"probeURL": "str"}, + api_version="2024-09-01", + ) + + # 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..1785c91571bd --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_afd_custom_domains_operations.py @@ -0,0 +1,125 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +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_list_by_profile(self, resource_group): + response = self.client.afd_custom_domains.list_by_profile( + resource_group_name=resource_group.name, + profile_name="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.afd_custom_domains.get( + resource_group_name=resource_group.name, + profile_name="str", + custom_domain_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create(self, resource_group): + response = self.client.afd_custom_domains.begin_create( + resource_group_name=resource_group.name, + profile_name="str", + custom_domain_name="str", + custom_domain={ + "azureDnsZone": {"id": "str"}, + "deploymentStatus": "str", + "domainValidationState": "str", + "extendedProperties": {"str": "str"}, + "hostName": "str", + "id": "str", + "name": "str", + "preValidatedCustomDomainResourceId": {"id": "str"}, + "profileName": "str", + "provisioningState": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tlsSettings": {"certificateType": "str", "minimumTlsVersion": "str", "secret": {"id": "str"}}, + "type": "str", + "validationProperties": {"expirationDate": "str", "validationToken": "str"}, + }, + api_version="2024-09-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_update(self, resource_group): + response = self.client.afd_custom_domains.begin_update( + resource_group_name=resource_group.name, + profile_name="str", + custom_domain_name="str", + custom_domain_update_properties={ + "azureDnsZone": {"id": "str"}, + "preValidatedCustomDomainResourceId": {"id": "str"}, + "profileName": "str", + "tlsSettings": {"certificateType": "str", "minimumTlsVersion": "str", "secret": {"id": "str"}}, + }, + api_version="2024-09-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_delete(self, resource_group): + response = self.client.afd_custom_domains.begin_delete( + resource_group_name=resource_group.name, + profile_name="str", + custom_domain_name="str", + api_version="2024-09-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_refresh_validation_token(self, resource_group): + response = self.client.afd_custom_domains.begin_refresh_validation_token( + resource_group_name=resource_group.name, + profile_name="str", + custom_domain_name="str", + api_version="2024-09-01", + ).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..f7bd6bf523f5 --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_afd_custom_domains_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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.cdn.aio import CdnManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestCdnManagementAFDCustomDomainsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(CdnManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_profile(self, resource_group): + response = self.client.afd_custom_domains.list_by_profile( + resource_group_name=resource_group.name, + profile_name="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.afd_custom_domains.get( + resource_group_name=resource_group.name, + profile_name="str", + custom_domain_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create(self, resource_group): + response = await ( + await self.client.afd_custom_domains.begin_create( + resource_group_name=resource_group.name, + profile_name="str", + custom_domain_name="str", + custom_domain={ + "azureDnsZone": {"id": "str"}, + "deploymentStatus": "str", + "domainValidationState": "str", + "extendedProperties": {"str": "str"}, + "hostName": "str", + "id": "str", + "name": "str", + "preValidatedCustomDomainResourceId": {"id": "str"}, + "profileName": "str", + "provisioningState": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tlsSettings": {"certificateType": "str", "minimumTlsVersion": "str", "secret": {"id": "str"}}, + "type": "str", + "validationProperties": {"expirationDate": "str", "validationToken": "str"}, + }, + api_version="2024-09-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_update(self, resource_group): + response = await ( + await self.client.afd_custom_domains.begin_update( + resource_group_name=resource_group.name, + profile_name="str", + custom_domain_name="str", + custom_domain_update_properties={ + "azureDnsZone": {"id": "str"}, + "preValidatedCustomDomainResourceId": {"id": "str"}, + "profileName": "str", + "tlsSettings": {"certificateType": "str", "minimumTlsVersion": "str", "secret": {"id": "str"}}, + }, + api_version="2024-09-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_delete(self, resource_group): + response = await ( + await self.client.afd_custom_domains.begin_delete( + resource_group_name=resource_group.name, + profile_name="str", + custom_domain_name="str", + api_version="2024-09-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_refresh_validation_token(self, resource_group): + response = await ( + await self.client.afd_custom_domains.begin_refresh_validation_token( + resource_group_name=resource_group.name, + profile_name="str", + custom_domain_name="str", + api_version="2024-09-01", + ) + ).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..1866f6d5b8aa --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_afd_endpoints_operations.py @@ -0,0 +1,146 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.cdn import CdnManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestCdnManagementAFDEndpointsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(CdnManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_profile(self, resource_group): + response = self.client.afd_endpoints.list_by_profile( + resource_group_name=resource_group.name, + profile_name="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.afd_endpoints.get( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create(self, resource_group): + response = self.client.afd_endpoints.begin_create( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + endpoint={ + "location": "str", + "autoGeneratedDomainNameLabelScope": "str", + "deploymentStatus": "str", + "enabledState": "str", + "hostName": "str", + "id": "str", + "name": "str", + "profileName": "str", + "provisioningState": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2024-09-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_update(self, resource_group): + response = self.client.afd_endpoints.begin_update( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + endpoint_update_properties={"enabledState": "str", "profileName": "str", "tags": {"str": "str"}}, + api_version="2024-09-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_delete(self, resource_group): + response = self.client.afd_endpoints.begin_delete( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + api_version="2024-09-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_purge_content(self, resource_group): + response = self.client.afd_endpoints.begin_purge_content( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + contents={"contentPaths": ["str"], "domains": ["str"]}, + api_version="2024-09-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_resource_usage(self, resource_group): + response = self.client.afd_endpoints.list_resource_usage( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_validate_custom_domain(self, resource_group): + response = self.client.afd_endpoints.validate_custom_domain( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + custom_domain_properties={"hostName": "str"}, + api_version="2024-09-01", + ) + + # 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..576d678ba4be --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_afd_endpoints_operations_async.py @@ -0,0 +1,155 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.cdn.aio import CdnManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestCdnManagementAFDEndpointsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(CdnManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_profile(self, resource_group): + response = self.client.afd_endpoints.list_by_profile( + resource_group_name=resource_group.name, + profile_name="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.afd_endpoints.get( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create(self, resource_group): + response = await ( + await self.client.afd_endpoints.begin_create( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + endpoint={ + "location": "str", + "autoGeneratedDomainNameLabelScope": "str", + "deploymentStatus": "str", + "enabledState": "str", + "hostName": "str", + "id": "str", + "name": "str", + "profileName": "str", + "provisioningState": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2024-09-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_update(self, resource_group): + response = await ( + await self.client.afd_endpoints.begin_update( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + endpoint_update_properties={"enabledState": "str", "profileName": "str", "tags": {"str": "str"}}, + api_version="2024-09-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_delete(self, resource_group): + response = await ( + await self.client.afd_endpoints.begin_delete( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + api_version="2024-09-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_purge_content(self, resource_group): + response = await ( + await self.client.afd_endpoints.begin_purge_content( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + contents={"contentPaths": ["str"], "domains": ["str"]}, + api_version="2024-09-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_resource_usage(self, resource_group): + response = self.client.afd_endpoints.list_resource_usage( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_validate_custom_domain(self, resource_group): + response = await self.client.afd_endpoints.validate_custom_domain( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + custom_domain_properties={"hostName": "str"}, + api_version="2024-09-01", + ) + + # 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..79e06157b958 --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_afd_origin_groups_operations.py @@ -0,0 +1,141 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.cdn import CdnManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestCdnManagementAFDOriginGroupsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(CdnManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_profile(self, resource_group): + response = self.client.afd_origin_groups.list_by_profile( + resource_group_name=resource_group.name, + profile_name="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.afd_origin_groups.get( + resource_group_name=resource_group.name, + profile_name="str", + origin_group_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create(self, resource_group): + response = self.client.afd_origin_groups.begin_create( + resource_group_name=resource_group.name, + profile_name="str", + origin_group_name="str", + origin_group={ + "deploymentStatus": "str", + "healthProbeSettings": { + "probeIntervalInSeconds": 0, + "probePath": "str", + "probeProtocol": "str", + "probeRequestType": "str", + }, + "id": "str", + "loadBalancingSettings": { + "additionalLatencyInMilliseconds": 0, + "sampleSize": 0, + "successfulSamplesRequired": 0, + }, + "name": "str", + "profileName": "str", + "provisioningState": "str", + "sessionAffinityState": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "trafficRestorationTimeToHealedOrNewEndpointsInMinutes": 0, + "type": "str", + }, + api_version="2024-09-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_update(self, resource_group): + response = self.client.afd_origin_groups.begin_update( + resource_group_name=resource_group.name, + profile_name="str", + origin_group_name="str", + origin_group_update_properties={ + "healthProbeSettings": { + "probeIntervalInSeconds": 0, + "probePath": "str", + "probeProtocol": "str", + "probeRequestType": "str", + }, + "loadBalancingSettings": { + "additionalLatencyInMilliseconds": 0, + "sampleSize": 0, + "successfulSamplesRequired": 0, + }, + "profileName": "str", + "sessionAffinityState": "str", + "trafficRestorationTimeToHealedOrNewEndpointsInMinutes": 0, + }, + api_version="2024-09-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_delete(self, resource_group): + response = self.client.afd_origin_groups.begin_delete( + resource_group_name=resource_group.name, + profile_name="str", + origin_group_name="str", + api_version="2024-09-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_resource_usage(self, resource_group): + response = self.client.afd_origin_groups.list_resource_usage( + resource_group_name=resource_group.name, + profile_name="str", + origin_group_name="str", + api_version="2024-09-01", + ) + 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..bab6a72e8536 --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_afd_origin_groups_operations_async.py @@ -0,0 +1,148 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.cdn.aio import CdnManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestCdnManagementAFDOriginGroupsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(CdnManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_profile(self, resource_group): + response = self.client.afd_origin_groups.list_by_profile( + resource_group_name=resource_group.name, + profile_name="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.afd_origin_groups.get( + resource_group_name=resource_group.name, + profile_name="str", + origin_group_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create(self, resource_group): + response = await ( + await self.client.afd_origin_groups.begin_create( + resource_group_name=resource_group.name, + profile_name="str", + origin_group_name="str", + origin_group={ + "deploymentStatus": "str", + "healthProbeSettings": { + "probeIntervalInSeconds": 0, + "probePath": "str", + "probeProtocol": "str", + "probeRequestType": "str", + }, + "id": "str", + "loadBalancingSettings": { + "additionalLatencyInMilliseconds": 0, + "sampleSize": 0, + "successfulSamplesRequired": 0, + }, + "name": "str", + "profileName": "str", + "provisioningState": "str", + "sessionAffinityState": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "trafficRestorationTimeToHealedOrNewEndpointsInMinutes": 0, + "type": "str", + }, + api_version="2024-09-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_update(self, resource_group): + response = await ( + await self.client.afd_origin_groups.begin_update( + resource_group_name=resource_group.name, + profile_name="str", + origin_group_name="str", + origin_group_update_properties={ + "healthProbeSettings": { + "probeIntervalInSeconds": 0, + "probePath": "str", + "probeProtocol": "str", + "probeRequestType": "str", + }, + "loadBalancingSettings": { + "additionalLatencyInMilliseconds": 0, + "sampleSize": 0, + "successfulSamplesRequired": 0, + }, + "profileName": "str", + "sessionAffinityState": "str", + "trafficRestorationTimeToHealedOrNewEndpointsInMinutes": 0, + }, + api_version="2024-09-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_delete(self, resource_group): + response = await ( + await self.client.afd_origin_groups.begin_delete( + resource_group_name=resource_group.name, + profile_name="str", + origin_group_name="str", + api_version="2024-09-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_resource_usage(self, resource_group): + response = self.client.afd_origin_groups.list_resource_usage( + resource_group_name=resource_group.name, + profile_name="str", + origin_group_name="str", + api_version="2024-09-01", + ) + 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..3cdf669e977e --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_afd_origins_operations.py @@ -0,0 +1,139 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.cdn import CdnManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestCdnManagementAFDOriginsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(CdnManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_origin_group(self, resource_group): + response = self.client.afd_origins.list_by_origin_group( + resource_group_name=resource_group.name, + profile_name="str", + origin_group_name="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.afd_origins.get( + resource_group_name=resource_group.name, + profile_name="str", + origin_group_name="str", + origin_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create(self, resource_group): + response = self.client.afd_origins.begin_create( + resource_group_name=resource_group.name, + profile_name="str", + origin_group_name="str", + origin_name="str", + origin={ + "azureOrigin": {"id": "str"}, + "deploymentStatus": "str", + "enabledState": "str", + "enforceCertificateNameCheck": True, + "hostName": "str", + "httpPort": 80, + "httpsPort": 443, + "id": "str", + "name": "str", + "originGroupName": "str", + "originHostHeader": "str", + "priority": 0, + "provisioningState": "str", + "sharedPrivateLinkResource": { + "groupId": "str", + "privateLink": {"id": "str"}, + "privateLinkLocation": "str", + "requestMessage": "str", + "status": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + "weight": 0, + }, + api_version="2024-09-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_update(self, resource_group): + response = self.client.afd_origins.begin_update( + resource_group_name=resource_group.name, + profile_name="str", + origin_group_name="str", + origin_name="str", + origin_update_properties={ + "azureOrigin": {"id": "str"}, + "enabledState": "str", + "enforceCertificateNameCheck": True, + "hostName": "str", + "httpPort": 80, + "httpsPort": 443, + "originGroupName": "str", + "originHostHeader": "str", + "priority": 0, + "sharedPrivateLinkResource": { + "groupId": "str", + "privateLink": {"id": "str"}, + "privateLinkLocation": "str", + "requestMessage": "str", + "status": "str", + }, + "weight": 0, + }, + api_version="2024-09-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_delete(self, resource_group): + response = self.client.afd_origins.begin_delete( + resource_group_name=resource_group.name, + profile_name="str", + origin_group_name="str", + origin_name="str", + api_version="2024-09-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_afd_origins_operations_async.py b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_afd_origins_operations_async.py new file mode 100644 index 000000000000..ddd53f6f7a6d --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_afd_origins_operations_async.py @@ -0,0 +1,146 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.cdn.aio import CdnManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestCdnManagementAFDOriginsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(CdnManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_origin_group(self, resource_group): + response = self.client.afd_origins.list_by_origin_group( + resource_group_name=resource_group.name, + profile_name="str", + origin_group_name="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.afd_origins.get( + resource_group_name=resource_group.name, + profile_name="str", + origin_group_name="str", + origin_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create(self, resource_group): + response = await ( + await self.client.afd_origins.begin_create( + resource_group_name=resource_group.name, + profile_name="str", + origin_group_name="str", + origin_name="str", + origin={ + "azureOrigin": {"id": "str"}, + "deploymentStatus": "str", + "enabledState": "str", + "enforceCertificateNameCheck": True, + "hostName": "str", + "httpPort": 80, + "httpsPort": 443, + "id": "str", + "name": "str", + "originGroupName": "str", + "originHostHeader": "str", + "priority": 0, + "provisioningState": "str", + "sharedPrivateLinkResource": { + "groupId": "str", + "privateLink": {"id": "str"}, + "privateLinkLocation": "str", + "requestMessage": "str", + "status": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + "weight": 0, + }, + api_version="2024-09-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_update(self, resource_group): + response = await ( + await self.client.afd_origins.begin_update( + resource_group_name=resource_group.name, + profile_name="str", + origin_group_name="str", + origin_name="str", + origin_update_properties={ + "azureOrigin": {"id": "str"}, + "enabledState": "str", + "enforceCertificateNameCheck": True, + "hostName": "str", + "httpPort": 80, + "httpsPort": 443, + "originGroupName": "str", + "originHostHeader": "str", + "priority": 0, + "sharedPrivateLinkResource": { + "groupId": "str", + "privateLink": {"id": "str"}, + "privateLinkLocation": "str", + "requestMessage": "str", + "status": "str", + }, + "weight": 0, + }, + api_version="2024-09-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_delete(self, resource_group): + response = await ( + await self.client.afd_origins.begin_delete( + resource_group_name=resource_group.name, + profile_name="str", + origin_group_name="str", + origin_name="str", + api_version="2024-09-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_afd_profiles_operations.py b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_afd_profiles_operations.py new file mode 100644 index 000000000000..662806af9aab --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_afd_profiles_operations.py @@ -0,0 +1,89 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.cdn import CdnManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestCdnManagementAFDProfilesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(CdnManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_check_endpoint_name_availability(self, resource_group): + response = self.client.afd_profiles.check_endpoint_name_availability( + resource_group_name=resource_group.name, + profile_name="str", + check_endpoint_name_availability_input={ + "name": "str", + "type": "str", + "autoGeneratedDomainNameLabelScope": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_resource_usage(self, resource_group): + response = self.client.afd_profiles.list_resource_usage( + resource_group_name=resource_group.name, + profile_name="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_check_host_name_availability(self, resource_group): + response = self.client.afd_profiles.check_host_name_availability( + resource_group_name=resource_group.name, + profile_name="str", + check_host_name_availability_input={"hostName": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_validate_secret(self, resource_group): + response = self.client.afd_profiles.validate_secret( + resource_group_name=resource_group.name, + profile_name="str", + validate_secret_input={"secretSource": {"id": "str"}, "secretType": "str", "secretVersion": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_upgrade(self, resource_group): + response = self.client.afd_profiles.begin_upgrade( + resource_group_name=resource_group.name, + profile_name="str", + profile_upgrade_parameters={ + "wafMappingList": [{"changeToWafPolicy": {"id": "str"}, "securityPolicyName": "str"}] + }, + api_version="2024-09-01", + ).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..7c9d21bd250d --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_afd_profiles_operations_async.py @@ -0,0 +1,92 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.cdn.aio import CdnManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestCdnManagementAFDProfilesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(CdnManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_check_endpoint_name_availability(self, resource_group): + response = await self.client.afd_profiles.check_endpoint_name_availability( + resource_group_name=resource_group.name, + profile_name="str", + check_endpoint_name_availability_input={ + "name": "str", + "type": "str", + "autoGeneratedDomainNameLabelScope": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_resource_usage(self, resource_group): + response = self.client.afd_profiles.list_resource_usage( + resource_group_name=resource_group.name, + profile_name="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_check_host_name_availability(self, resource_group): + response = await self.client.afd_profiles.check_host_name_availability( + resource_group_name=resource_group.name, + profile_name="str", + check_host_name_availability_input={"hostName": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_validate_secret(self, resource_group): + response = await self.client.afd_profiles.validate_secret( + resource_group_name=resource_group.name, + profile_name="str", + validate_secret_input={"secretSource": {"id": "str"}, "secretType": "str", "secretVersion": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_upgrade(self, resource_group): + response = await ( + await self.client.afd_profiles.begin_upgrade( + resource_group_name=resource_group.name, + profile_name="str", + profile_upgrade_parameters={ + "wafMappingList": [{"changeToWafPolicy": {"id": "str"}, "securityPolicyName": "str"}] + }, + api_version="2024-09-01", + ) + ).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..673776824276 --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_async.py @@ -0,0 +1,69 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.cdn.aio import CdnManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestCdnManagementAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(CdnManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_check_endpoint_name_availability(self, resource_group): + response = await self.client.check_endpoint_name_availability( + resource_group_name=resource_group.name, + check_endpoint_name_availability_input={ + "name": "str", + "type": "str", + "autoGeneratedDomainNameLabelScope": "str", + }, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_check_name_availability(self, resource_group): + response = await self.client.check_name_availability( + check_name_availability_input={"name": "str", "type": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_check_name_availability_with_subscription(self, resource_group): + response = await self.client.check_name_availability_with_subscription( + check_name_availability_input={"name": "str", "type": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_validate_probe(self, resource_group): + response = await self.client.validate_probe( + validate_probe_input={"probeURL": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_cdn_profiles_operations.py b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_cdn_profiles_operations.py new file mode 100644 index 000000000000..37714033bed3 --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_cdn_profiles_operations.py @@ -0,0 +1,47 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.cdn import CdnManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestCdnManagementCdnProfilesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(CdnManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_cdn_can_migrate_to_afd(self, resource_group): + response = self.client.cdn_profiles.begin_cdn_can_migrate_to_afd( + resource_group_name=resource_group.name, + profile_name="str", + api_version="2024-09-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_cdn_migrate_to_afd(self, resource_group): + response = self.client.cdn_profiles.begin_cdn_migrate_to_afd( + resource_group_name=resource_group.name, + profile_name="str", + migration_parameters={ + "sku": {"name": "str"}, + "migrationEndpointMappings": [{"migratedFrom": "str", "migratedTo": "str"}], + }, + api_version="2024-09-01", + ).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_cdn_profiles_operations_async.py b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_cdn_profiles_operations_async.py new file mode 100644 index 000000000000..fe7bf0797118 --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_cdn_profiles_operations_async.py @@ -0,0 +1,52 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.cdn.aio import CdnManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestCdnManagementCdnProfilesOperationsAsync(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_begin_cdn_can_migrate_to_afd(self, resource_group): + response = await ( + await self.client.cdn_profiles.begin_cdn_can_migrate_to_afd( + resource_group_name=resource_group.name, + profile_name="str", + api_version="2024-09-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_cdn_migrate_to_afd(self, resource_group): + response = await ( + await self.client.cdn_profiles.begin_cdn_migrate_to_afd( + resource_group_name=resource_group.name, + profile_name="str", + migration_parameters={ + "sku": {"name": "str"}, + "migrationEndpointMappings": [{"migratedFrom": "str", "migratedTo": "str"}], + }, + api_version="2024-09-01", + ) + ).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.py b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_custom_domains_operations.py new file mode 100644 index 000000000000..d10ce8d6d434 --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_custom_domains_operations.py @@ -0,0 +1,103 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.cdn import CdnManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestCdnManagementCustomDomainsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(CdnManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_endpoint(self, resource_group): + response = self.client.custom_domains.list_by_endpoint( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.custom_domains.get( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + custom_domain_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create(self, resource_group): + response = self.client.custom_domains.begin_create( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + custom_domain_name="str", + custom_domain_properties={"hostName": "str"}, + api_version="2024-09-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_delete(self, resource_group): + response = self.client.custom_domains.begin_delete( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + custom_domain_name="str", + api_version="2024-09-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_disable_custom_https(self, resource_group): + response = self.client.custom_domains.begin_disable_custom_https( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + custom_domain_name="str", + api_version="2024-09-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_enable_custom_https(self, resource_group): + response = self.client.custom_domains.begin_enable_custom_https( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + custom_domain_name="str", + api_version="2024-09-01", + ).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..c0632d99da9d --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_custom_domains_operations_async.py @@ -0,0 +1,112 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.cdn.aio import CdnManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestCdnManagementCustomDomainsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(CdnManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_endpoint(self, resource_group): + response = self.client.custom_domains.list_by_endpoint( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.custom_domains.get( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + custom_domain_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create(self, resource_group): + response = await ( + await self.client.custom_domains.begin_create( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + custom_domain_name="str", + custom_domain_properties={"hostName": "str"}, + api_version="2024-09-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_delete(self, resource_group): + response = await ( + await self.client.custom_domains.begin_delete( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + custom_domain_name="str", + api_version="2024-09-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_disable_custom_https(self, resource_group): + response = await ( + await self.client.custom_domains.begin_disable_custom_https( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + custom_domain_name="str", + api_version="2024-09-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_enable_custom_https(self, resource_group): + response = await ( + await self.client.custom_domains.begin_enable_custom_https( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + custom_domain_name="str", + api_version="2024-09-01", + ) + ).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..7bebd551aa2e --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_edge_nodes_operations.py @@ -0,0 +1,29 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.cdn import CdnManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestCdnManagementEdgeNodesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(CdnManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.edge_nodes.list( + api_version="2024-09-01", + ) + 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..5dfb2d90b6b8 --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_edge_nodes_operations_async.py @@ -0,0 +1,30 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.cdn.aio import CdnManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestCdnManagementEdgeNodesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(CdnManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.edge_nodes.list( + api_version="2024-09-01", + ) + 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..9a566a588f28 --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_endpoints_operations.py @@ -0,0 +1,293 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.cdn import CdnManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestCdnManagementEndpointsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(CdnManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_profile(self, resource_group): + response = self.client.endpoints.list_by_profile( + resource_group_name=resource_group.name, + profile_name="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.endpoints.get( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create(self, resource_group): + response = self.client.endpoints.begin_create( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + endpoint={ + "location": "str", + "contentTypesToCompress": ["str"], + "customDomains": [{"name": "str", "hostName": "str", "validationData": "str"}], + "defaultOriginGroup": {"id": "str"}, + "deliveryPolicy": { + "rules": [ + { + "actions": ["delivery_rule_action"], + "order": 0, + "conditions": ["delivery_rule_condition"], + "name": "str", + } + ], + "description": "str", + }, + "geoFilters": [{"action": "str", "countryCodes": ["str"], "relativePath": "str"}], + "hostName": "str", + "id": "str", + "isCompressionEnabled": bool, + "isHttpAllowed": True, + "isHttpsAllowed": True, + "name": "str", + "optimizationType": "str", + "originGroups": [ + { + "name": "str", + "healthProbeSettings": { + "probeIntervalInSeconds": 0, + "probePath": "str", + "probeProtocol": "str", + "probeRequestType": "str", + }, + "origins": [{"id": "str"}], + "responseBasedOriginErrorDetectionSettings": { + "httpErrorRanges": [{"begin": 0, "end": 0}], + "responseBasedDetectedErrorTypes": "str", + "responseBasedFailoverThresholdPercentage": 0, + }, + "trafficRestorationTimeToHealedOrNewEndpointsInMinutes": 0, + } + ], + "originHostHeader": "str", + "originPath": "str", + "origins": [ + { + "name": "str", + "enabled": bool, + "hostName": "str", + "httpPort": 0, + "httpsPort": 0, + "originHostHeader": "str", + "priority": 0, + "privateEndpointStatus": "str", + "privateLinkAlias": "str", + "privateLinkApprovalMessage": "str", + "privateLinkLocation": "str", + "privateLinkResourceId": "str", + "weight": 0, + } + ], + "probePath": "str", + "provisioningState": "str", + "queryStringCachingBehavior": "str", + "resourceState": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "type": "str", + "urlSigningKeys": [ + { + "keyId": "str", + "keySourceParameters": { + "resourceGroupName": "str", + "secretName": "str", + "secretVersion": "str", + "subscriptionId": "str", + "typeName": "str", + "vaultName": "str", + }, + } + ], + "webApplicationFirewallPolicyLink": {"id": "str"}, + }, + api_version="2024-09-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_update(self, resource_group): + response = self.client.endpoints.begin_update( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + endpoint_update_properties={ + "contentTypesToCompress": ["str"], + "defaultOriginGroup": {"id": "str"}, + "deliveryPolicy": { + "rules": [ + { + "actions": ["delivery_rule_action"], + "order": 0, + "conditions": ["delivery_rule_condition"], + "name": "str", + } + ], + "description": "str", + }, + "geoFilters": [{"action": "str", "countryCodes": ["str"], "relativePath": "str"}], + "isCompressionEnabled": bool, + "isHttpAllowed": True, + "isHttpsAllowed": True, + "optimizationType": "str", + "originHostHeader": "str", + "originPath": "str", + "probePath": "str", + "queryStringCachingBehavior": "str", + "tags": {"str": "str"}, + "urlSigningKeys": [ + { + "keyId": "str", + "keySourceParameters": { + "resourceGroupName": "str", + "secretName": "str", + "secretVersion": "str", + "subscriptionId": "str", + "typeName": "str", + "vaultName": "str", + }, + } + ], + "webApplicationFirewallPolicyLink": {"id": "str"}, + }, + api_version="2024-09-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_delete(self, resource_group): + response = self.client.endpoints.begin_delete( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + api_version="2024-09-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_start(self, resource_group): + response = self.client.endpoints.begin_start( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + api_version="2024-09-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_stop(self, resource_group): + response = self.client.endpoints.begin_stop( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + api_version="2024-09-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_purge_content(self, resource_group): + response = self.client.endpoints.begin_purge_content( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + content_file_paths={"contentPaths": ["str"]}, + api_version="2024-09-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_load_content(self, resource_group): + response = self.client.endpoints.begin_load_content( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + content_file_paths={"contentPaths": ["str"]}, + api_version="2024-09-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_validate_custom_domain(self, resource_group): + response = self.client.endpoints.validate_custom_domain( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + custom_domain_properties={"hostName": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_resource_usage(self, resource_group): + response = self.client.endpoints.list_resource_usage( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + api_version="2024-09-01", + ) + 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..be55802ae0c3 --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_endpoints_operations_async.py @@ -0,0 +1,308 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.cdn.aio import CdnManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestCdnManagementEndpointsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(CdnManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_profile(self, resource_group): + response = self.client.endpoints.list_by_profile( + resource_group_name=resource_group.name, + profile_name="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.endpoints.get( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create(self, resource_group): + response = await ( + await self.client.endpoints.begin_create( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + endpoint={ + "location": "str", + "contentTypesToCompress": ["str"], + "customDomains": [{"name": "str", "hostName": "str", "validationData": "str"}], + "defaultOriginGroup": {"id": "str"}, + "deliveryPolicy": { + "rules": [ + { + "actions": ["delivery_rule_action"], + "order": 0, + "conditions": ["delivery_rule_condition"], + "name": "str", + } + ], + "description": "str", + }, + "geoFilters": [{"action": "str", "countryCodes": ["str"], "relativePath": "str"}], + "hostName": "str", + "id": "str", + "isCompressionEnabled": bool, + "isHttpAllowed": True, + "isHttpsAllowed": True, + "name": "str", + "optimizationType": "str", + "originGroups": [ + { + "name": "str", + "healthProbeSettings": { + "probeIntervalInSeconds": 0, + "probePath": "str", + "probeProtocol": "str", + "probeRequestType": "str", + }, + "origins": [{"id": "str"}], + "responseBasedOriginErrorDetectionSettings": { + "httpErrorRanges": [{"begin": 0, "end": 0}], + "responseBasedDetectedErrorTypes": "str", + "responseBasedFailoverThresholdPercentage": 0, + }, + "trafficRestorationTimeToHealedOrNewEndpointsInMinutes": 0, + } + ], + "originHostHeader": "str", + "originPath": "str", + "origins": [ + { + "name": "str", + "enabled": bool, + "hostName": "str", + "httpPort": 0, + "httpsPort": 0, + "originHostHeader": "str", + "priority": 0, + "privateEndpointStatus": "str", + "privateLinkAlias": "str", + "privateLinkApprovalMessage": "str", + "privateLinkLocation": "str", + "privateLinkResourceId": "str", + "weight": 0, + } + ], + "probePath": "str", + "provisioningState": "str", + "queryStringCachingBehavior": "str", + "resourceState": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "type": "str", + "urlSigningKeys": [ + { + "keyId": "str", + "keySourceParameters": { + "resourceGroupName": "str", + "secretName": "str", + "secretVersion": "str", + "subscriptionId": "str", + "typeName": "str", + "vaultName": "str", + }, + } + ], + "webApplicationFirewallPolicyLink": {"id": "str"}, + }, + api_version="2024-09-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_update(self, resource_group): + response = await ( + await self.client.endpoints.begin_update( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + endpoint_update_properties={ + "contentTypesToCompress": ["str"], + "defaultOriginGroup": {"id": "str"}, + "deliveryPolicy": { + "rules": [ + { + "actions": ["delivery_rule_action"], + "order": 0, + "conditions": ["delivery_rule_condition"], + "name": "str", + } + ], + "description": "str", + }, + "geoFilters": [{"action": "str", "countryCodes": ["str"], "relativePath": "str"}], + "isCompressionEnabled": bool, + "isHttpAllowed": True, + "isHttpsAllowed": True, + "optimizationType": "str", + "originHostHeader": "str", + "originPath": "str", + "probePath": "str", + "queryStringCachingBehavior": "str", + "tags": {"str": "str"}, + "urlSigningKeys": [ + { + "keyId": "str", + "keySourceParameters": { + "resourceGroupName": "str", + "secretName": "str", + "secretVersion": "str", + "subscriptionId": "str", + "typeName": "str", + "vaultName": "str", + }, + } + ], + "webApplicationFirewallPolicyLink": {"id": "str"}, + }, + api_version="2024-09-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_delete(self, resource_group): + response = await ( + await self.client.endpoints.begin_delete( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + api_version="2024-09-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_start(self, resource_group): + response = await ( + await self.client.endpoints.begin_start( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + api_version="2024-09-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_stop(self, resource_group): + response = await ( + await self.client.endpoints.begin_stop( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + api_version="2024-09-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_purge_content(self, resource_group): + response = await ( + await self.client.endpoints.begin_purge_content( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + content_file_paths={"contentPaths": ["str"]}, + api_version="2024-09-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_load_content(self, resource_group): + response = await ( + await self.client.endpoints.begin_load_content( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + content_file_paths={"contentPaths": ["str"]}, + api_version="2024-09-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_validate_custom_domain(self, resource_group): + response = await self.client.endpoints.validate_custom_domain( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + custom_domain_properties={"hostName": "str"}, + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_resource_usage(self, resource_group): + response = self.client.endpoints.list_resource_usage( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + api_version="2024-09-01", + ) + 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..4bd0be1fcc4f --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_log_analytics_operations.py @@ -0,0 +1,111 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.cdn import CdnManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestCdnManagementLogAnalyticsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(CdnManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_log_analytics_metrics(self, resource_group): + response = self.client.log_analytics.get_log_analytics_metrics( + resource_group_name=resource_group.name, + profile_name="str", + metrics=["str"], + date_time_begin="2020-02-20 00:00:00", + date_time_end="2020-02-20 00:00:00", + granularity="str", + custom_domains=["str"], + protocols=["str"], + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_log_analytics_rankings(self, resource_group): + response = self.client.log_analytics.get_log_analytics_rankings( + resource_group_name=resource_group.name, + profile_name="str", + rankings=["str"], + metrics=["str"], + max_ranking=0, + date_time_begin="2020-02-20 00:00:00", + date_time_end="2020-02-20 00:00:00", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_log_analytics_locations(self, resource_group): + response = self.client.log_analytics.get_log_analytics_locations( + resource_group_name=resource_group.name, + profile_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_log_analytics_resources(self, resource_group): + response = self.client.log_analytics.get_log_analytics_resources( + resource_group_name=resource_group.name, + profile_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_waf_log_analytics_metrics(self, resource_group): + response = self.client.log_analytics.get_waf_log_analytics_metrics( + resource_group_name=resource_group.name, + profile_name="str", + metrics=["str"], + date_time_begin="2020-02-20 00:00:00", + date_time_end="2020-02-20 00:00:00", + granularity="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_waf_log_analytics_rankings(self, resource_group): + response = self.client.log_analytics.get_waf_log_analytics_rankings( + resource_group_name=resource_group.name, + profile_name="str", + metrics=["str"], + date_time_begin="2020-02-20 00:00:00", + date_time_end="2020-02-20 00:00:00", + max_ranking=0, + rankings=["str"], + api_version="2024-09-01", + ) + + # 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..b7c0d6420d4c --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_log_analytics_operations_async.py @@ -0,0 +1,112 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.cdn.aio import CdnManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestCdnManagementLogAnalyticsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(CdnManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_log_analytics_metrics(self, resource_group): + response = await self.client.log_analytics.get_log_analytics_metrics( + resource_group_name=resource_group.name, + profile_name="str", + metrics=["str"], + date_time_begin="2020-02-20 00:00:00", + date_time_end="2020-02-20 00:00:00", + granularity="str", + custom_domains=["str"], + protocols=["str"], + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_log_analytics_rankings(self, resource_group): + response = await self.client.log_analytics.get_log_analytics_rankings( + resource_group_name=resource_group.name, + profile_name="str", + rankings=["str"], + metrics=["str"], + max_ranking=0, + date_time_begin="2020-02-20 00:00:00", + date_time_end="2020-02-20 00:00:00", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_log_analytics_locations(self, resource_group): + response = await self.client.log_analytics.get_log_analytics_locations( + resource_group_name=resource_group.name, + profile_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_log_analytics_resources(self, resource_group): + response = await self.client.log_analytics.get_log_analytics_resources( + resource_group_name=resource_group.name, + profile_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_waf_log_analytics_metrics(self, resource_group): + response = await self.client.log_analytics.get_waf_log_analytics_metrics( + resource_group_name=resource_group.name, + profile_name="str", + metrics=["str"], + date_time_begin="2020-02-20 00:00:00", + date_time_end="2020-02-20 00:00:00", + granularity="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_waf_log_analytics_rankings(self, resource_group): + response = await self.client.log_analytics.get_waf_log_analytics_rankings( + resource_group_name=resource_group.name, + profile_name="str", + metrics=["str"], + date_time_begin="2020-02-20 00:00:00", + date_time_end="2020-02-20 00:00:00", + max_ranking=0, + rankings=["str"], + api_version="2024-09-01", + ) + + # 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..27f50c80d6f5 --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_managed_rule_sets_operations.py @@ -0,0 +1,29 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.cdn import CdnManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestCdnManagementManagedRuleSetsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(CdnManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.managed_rule_sets.list( + api_version="2024-09-01", + ) + 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..8f8000c2fe76 --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_managed_rule_sets_operations_async.py @@ -0,0 +1,30 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.cdn.aio import CdnManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestCdnManagementManagedRuleSetsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(CdnManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.managed_rule_sets.list( + api_version="2024-09-01", + ) + 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..6ee18e26fe8d --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_operations.py @@ -0,0 +1,29 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.cdn import CdnManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestCdnManagementOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(CdnManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.operations.list( + api_version="2024-09-01", + ) + 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..431963981e94 --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_operations_async.py @@ -0,0 +1,30 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.cdn.aio import CdnManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestCdnManagementOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(CdnManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.operations.list( + api_version="2024-09-01", + ) + 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..729cd017d5f9 --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_origin_groups_operations.py @@ -0,0 +1,131 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.cdn import CdnManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestCdnManagementOriginGroupsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(CdnManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_endpoint(self, resource_group): + response = self.client.origin_groups.list_by_endpoint( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.origin_groups.get( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + origin_group_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create(self, resource_group): + response = self.client.origin_groups.begin_create( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + origin_group_name="str", + origin_group={ + "healthProbeSettings": { + "probeIntervalInSeconds": 0, + "probePath": "str", + "probeProtocol": "str", + "probeRequestType": "str", + }, + "id": "str", + "name": "str", + "origins": [{"id": "str"}], + "provisioningState": "str", + "resourceState": "str", + "responseBasedOriginErrorDetectionSettings": { + "httpErrorRanges": [{"begin": 0, "end": 0}], + "responseBasedDetectedErrorTypes": "str", + "responseBasedFailoverThresholdPercentage": 0, + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "trafficRestorationTimeToHealedOrNewEndpointsInMinutes": 0, + "type": "str", + }, + api_version="2024-09-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_update(self, resource_group): + response = self.client.origin_groups.begin_update( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + origin_group_name="str", + origin_group_update_properties={ + "healthProbeSettings": { + "probeIntervalInSeconds": 0, + "probePath": "str", + "probeProtocol": "str", + "probeRequestType": "str", + }, + "origins": [{"id": "str"}], + "responseBasedOriginErrorDetectionSettings": { + "httpErrorRanges": [{"begin": 0, "end": 0}], + "responseBasedDetectedErrorTypes": "str", + "responseBasedFailoverThresholdPercentage": 0, + }, + "trafficRestorationTimeToHealedOrNewEndpointsInMinutes": 0, + }, + api_version="2024-09-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_delete(self, resource_group): + response = self.client.origin_groups.begin_delete( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + origin_group_name="str", + api_version="2024-09-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_origin_groups_operations_async.py b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_origin_groups_operations_async.py new file mode 100644 index 000000000000..dbc185d9032d --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_origin_groups_operations_async.py @@ -0,0 +1,138 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.cdn.aio import CdnManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestCdnManagementOriginGroupsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(CdnManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_endpoint(self, resource_group): + response = self.client.origin_groups.list_by_endpoint( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.origin_groups.get( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + origin_group_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create(self, resource_group): + response = await ( + await self.client.origin_groups.begin_create( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + origin_group_name="str", + origin_group={ + "healthProbeSettings": { + "probeIntervalInSeconds": 0, + "probePath": "str", + "probeProtocol": "str", + "probeRequestType": "str", + }, + "id": "str", + "name": "str", + "origins": [{"id": "str"}], + "provisioningState": "str", + "resourceState": "str", + "responseBasedOriginErrorDetectionSettings": { + "httpErrorRanges": [{"begin": 0, "end": 0}], + "responseBasedDetectedErrorTypes": "str", + "responseBasedFailoverThresholdPercentage": 0, + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "trafficRestorationTimeToHealedOrNewEndpointsInMinutes": 0, + "type": "str", + }, + api_version="2024-09-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_update(self, resource_group): + response = await ( + await self.client.origin_groups.begin_update( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + origin_group_name="str", + origin_group_update_properties={ + "healthProbeSettings": { + "probeIntervalInSeconds": 0, + "probePath": "str", + "probeProtocol": "str", + "probeRequestType": "str", + }, + "origins": [{"id": "str"}], + "responseBasedOriginErrorDetectionSettings": { + "httpErrorRanges": [{"begin": 0, "end": 0}], + "responseBasedDetectedErrorTypes": "str", + "responseBasedFailoverThresholdPercentage": 0, + }, + "trafficRestorationTimeToHealedOrNewEndpointsInMinutes": 0, + }, + api_version="2024-09-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_delete(self, resource_group): + response = await ( + await self.client.origin_groups.begin_delete( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + origin_group_name="str", + api_version="2024-09-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_origins_operations.py b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_origins_operations.py new file mode 100644 index 000000000000..f41f28478f2e --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_origins_operations.py @@ -0,0 +1,128 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.cdn import CdnManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestCdnManagementOriginsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(CdnManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_endpoint(self, resource_group): + response = self.client.origins.list_by_endpoint( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.origins.get( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + origin_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create(self, resource_group): + response = self.client.origins.begin_create( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + origin_name="str", + origin={ + "enabled": bool, + "hostName": "str", + "httpPort": 0, + "httpsPort": 0, + "id": "str", + "name": "str", + "originHostHeader": "str", + "priority": 0, + "privateEndpointStatus": "str", + "privateLinkAlias": "str", + "privateLinkApprovalMessage": "str", + "privateLinkLocation": "str", + "privateLinkResourceId": "str", + "provisioningState": "str", + "resourceState": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + "weight": 0, + }, + api_version="2024-09-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_update(self, resource_group): + response = self.client.origins.begin_update( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + origin_name="str", + origin_update_properties={ + "enabled": bool, + "hostName": "str", + "httpPort": 0, + "httpsPort": 0, + "originHostHeader": "str", + "priority": 0, + "privateLinkAlias": "str", + "privateLinkApprovalMessage": "str", + "privateLinkLocation": "str", + "privateLinkResourceId": "str", + "weight": 0, + }, + api_version="2024-09-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_delete(self, resource_group): + response = self.client.origins.begin_delete( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + origin_name="str", + api_version="2024-09-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_origins_operations_async.py b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_origins_operations_async.py new file mode 100644 index 000000000000..6aa3cbfec679 --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_origins_operations_async.py @@ -0,0 +1,135 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.cdn.aio import CdnManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestCdnManagementOriginsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(CdnManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_endpoint(self, resource_group): + response = self.client.origins.list_by_endpoint( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.origins.get( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + origin_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create(self, resource_group): + response = await ( + await self.client.origins.begin_create( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + origin_name="str", + origin={ + "enabled": bool, + "hostName": "str", + "httpPort": 0, + "httpsPort": 0, + "id": "str", + "name": "str", + "originHostHeader": "str", + "priority": 0, + "privateEndpointStatus": "str", + "privateLinkAlias": "str", + "privateLinkApprovalMessage": "str", + "privateLinkLocation": "str", + "privateLinkResourceId": "str", + "provisioningState": "str", + "resourceState": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + "weight": 0, + }, + api_version="2024-09-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_update(self, resource_group): + response = await ( + await self.client.origins.begin_update( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + origin_name="str", + origin_update_properties={ + "enabled": bool, + "hostName": "str", + "httpPort": 0, + "httpsPort": 0, + "originHostHeader": "str", + "priority": 0, + "privateLinkAlias": "str", + "privateLinkApprovalMessage": "str", + "privateLinkLocation": "str", + "privateLinkResourceId": "str", + "weight": 0, + }, + api_version="2024-09-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_delete(self, resource_group): + response = await ( + await self.client.origins.begin_delete( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + origin_name="str", + api_version="2024-09-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_policies_operations.py b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_policies_operations.py new file mode 100644 index 000000000000..dd9405c13ce7 --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_policies_operations.py @@ -0,0 +1,164 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.cdn import CdnManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestCdnManagementPoliciesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(CdnManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.policies.list( + resource_group_name=resource_group.name, + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.policies.get( + resource_group_name=resource_group.name, + policy_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create_or_update(self, resource_group): + response = self.client.policies.begin_create_or_update( + resource_group_name=resource_group.name, + policy_name="str", + cdn_web_application_firewall_policy={ + "location": "str", + "sku": {"name": "str"}, + "customRules": { + "rules": [ + { + "action": "str", + "matchConditions": [ + { + "matchValue": ["str"], + "matchVariable": "str", + "operator": "str", + "negateCondition": bool, + "selector": "str", + "transforms": ["str"], + } + ], + "name": "str", + "priority": 0, + "enabledState": "str", + } + ] + }, + "endpointLinks": [{"id": "str"}], + "etag": "str", + "extendedProperties": {"str": "str"}, + "id": "str", + "managedRules": { + "managedRuleSets": [ + { + "ruleSetType": "str", + "ruleSetVersion": "str", + "anomalyScore": 0, + "ruleGroupOverrides": [ + { + "ruleGroupName": "str", + "rules": [{"ruleId": "str", "action": "str", "enabledState": "str"}], + } + ], + } + ] + }, + "name": "str", + "policySettings": { + "defaultCustomBlockResponseBody": "str", + "defaultCustomBlockResponseStatusCode": 0, + "defaultRedirectUrl": "str", + "enabledState": "str", + "mode": "str", + }, + "provisioningState": "str", + "rateLimitRules": { + "rules": [ + { + "action": "str", + "matchConditions": [ + { + "matchValue": ["str"], + "matchVariable": "str", + "operator": "str", + "negateCondition": bool, + "selector": "str", + "transforms": ["str"], + } + ], + "name": "str", + "priority": 0, + "rateLimitDurationInMinutes": 0, + "rateLimitThreshold": 0, + "enabledState": "str", + } + ] + }, + "resourceState": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2024-09-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_update(self, resource_group): + response = self.client.policies.begin_update( + resource_group_name=resource_group.name, + policy_name="str", + cdn_web_application_firewall_policy_patch_parameters={"tags": {"str": "str"}}, + api_version="2024-09-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.policies.delete( + resource_group_name=resource_group.name, + policy_name="str", + api_version="2024-09-01", + ) + + # 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..ff048e76aabb --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_policies_operations_async.py @@ -0,0 +1,169 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.cdn.aio import CdnManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestCdnManagementPoliciesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(CdnManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.policies.list( + resource_group_name=resource_group.name, + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.policies.get( + resource_group_name=resource_group.name, + policy_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create_or_update(self, resource_group): + response = await ( + await self.client.policies.begin_create_or_update( + resource_group_name=resource_group.name, + policy_name="str", + cdn_web_application_firewall_policy={ + "location": "str", + "sku": {"name": "str"}, + "customRules": { + "rules": [ + { + "action": "str", + "matchConditions": [ + { + "matchValue": ["str"], + "matchVariable": "str", + "operator": "str", + "negateCondition": bool, + "selector": "str", + "transforms": ["str"], + } + ], + "name": "str", + "priority": 0, + "enabledState": "str", + } + ] + }, + "endpointLinks": [{"id": "str"}], + "etag": "str", + "extendedProperties": {"str": "str"}, + "id": "str", + "managedRules": { + "managedRuleSets": [ + { + "ruleSetType": "str", + "ruleSetVersion": "str", + "anomalyScore": 0, + "ruleGroupOverrides": [ + { + "ruleGroupName": "str", + "rules": [{"ruleId": "str", "action": "str", "enabledState": "str"}], + } + ], + } + ] + }, + "name": "str", + "policySettings": { + "defaultCustomBlockResponseBody": "str", + "defaultCustomBlockResponseStatusCode": 0, + "defaultRedirectUrl": "str", + "enabledState": "str", + "mode": "str", + }, + "provisioningState": "str", + "rateLimitRules": { + "rules": [ + { + "action": "str", + "matchConditions": [ + { + "matchValue": ["str"], + "matchVariable": "str", + "operator": "str", + "negateCondition": bool, + "selector": "str", + "transforms": ["str"], + } + ], + "name": "str", + "priority": 0, + "rateLimitDurationInMinutes": 0, + "rateLimitThreshold": 0, + "enabledState": "str", + } + ] + }, + "resourceState": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2024-09-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_update(self, resource_group): + response = await ( + await self.client.policies.begin_update( + resource_group_name=resource_group.name, + policy_name="str", + cdn_web_application_firewall_policy_patch_parameters={"tags": {"str": "str"}}, + api_version="2024-09-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.policies.delete( + resource_group_name=resource_group.name, + policy_name="str", + api_version="2024-09-01", + ) + + # 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..5c7090318f13 --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_profiles_operations.py @@ -0,0 +1,229 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.cdn import CdnManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestCdnManagementProfilesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(CdnManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.profiles.list( + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_resource_group(self, resource_group): + response = self.client.profiles.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.profiles.get( + resource_group_name=resource_group.name, + profile_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create(self, resource_group): + response = self.client.profiles.begin_create( + resource_group_name=resource_group.name, + profile_name="str", + profile={ + "location": "str", + "sku": {"name": "str"}, + "extendedProperties": {"str": "str"}, + "frontDoorId": "str", + "id": "str", + "identity": { + "type": "str", + "principalId": "str", + "tenantId": "str", + "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, + }, + "kind": "str", + "logScrubbing": { + "scrubbingRules": [ + {"matchVariable": "str", "selectorMatchOperator": "str", "selector": "str", "state": "str"} + ], + "state": "str", + }, + "name": "str", + "originResponseTimeoutSeconds": 0, + "provisioningState": "str", + "resourceState": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2024-09-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_update(self, resource_group): + response = self.client.profiles.begin_update( + resource_group_name=resource_group.name, + profile_name="str", + profile_update_parameters={ + "identity": { + "type": "str", + "principalId": "str", + "tenantId": "str", + "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, + }, + "logScrubbing": { + "scrubbingRules": [ + {"matchVariable": "str", "selectorMatchOperator": "str", "selector": "str", "state": "str"} + ], + "state": "str", + }, + "originResponseTimeoutSeconds": 0, + "tags": {"str": "str"}, + }, + api_version="2024-09-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_delete(self, resource_group): + response = self.client.profiles.begin_delete( + resource_group_name=resource_group.name, + profile_name="str", + api_version="2024-09-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_can_migrate(self, resource_group): + response = self.client.profiles.begin_can_migrate( + resource_group_name=resource_group.name, + can_migrate_parameters={"classicResourceReference": {"id": "str"}}, + api_version="2024-09-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_migrate(self, resource_group): + response = self.client.profiles.begin_migrate( + resource_group_name=resource_group.name, + migration_parameters={ + "classicResourceReference": {"id": "str"}, + "profileName": "str", + "sku": {"name": "str"}, + "migrationWebApplicationFirewallMappings": [ + {"migratedFrom": {"id": "str"}, "migratedTo": {"id": "str"}} + ], + }, + api_version="2024-09-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_migration_commit(self, resource_group): + response = self.client.profiles.begin_migration_commit( + resource_group_name=resource_group.name, + profile_name="str", + api_version="2024-09-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_generate_sso_uri(self, resource_group): + response = self.client.profiles.generate_sso_uri( + resource_group_name=resource_group.name, + profile_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_supported_optimization_types(self, resource_group): + response = self.client.profiles.list_supported_optimization_types( + resource_group_name=resource_group.name, + profile_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_resource_usage(self, resource_group): + response = self.client.profiles.list_resource_usage( + resource_group_name=resource_group.name, + profile_name="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_migration_abort(self, resource_group): + response = self.client.profiles.begin_migration_abort( + resource_group_name=resource_group.name, + profile_name="str", + api_version="2024-09-01", + ).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..38ddcd3c9beb --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_profiles_operations_async.py @@ -0,0 +1,244 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.cdn.aio import CdnManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestCdnManagementProfilesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(CdnManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.profiles.list( + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_resource_group(self, resource_group): + response = self.client.profiles.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.profiles.get( + resource_group_name=resource_group.name, + profile_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create(self, resource_group): + response = await ( + await self.client.profiles.begin_create( + resource_group_name=resource_group.name, + profile_name="str", + profile={ + "location": "str", + "sku": {"name": "str"}, + "extendedProperties": {"str": "str"}, + "frontDoorId": "str", + "id": "str", + "identity": { + "type": "str", + "principalId": "str", + "tenantId": "str", + "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, + }, + "kind": "str", + "logScrubbing": { + "scrubbingRules": [ + {"matchVariable": "str", "selectorMatchOperator": "str", "selector": "str", "state": "str"} + ], + "state": "str", + }, + "name": "str", + "originResponseTimeoutSeconds": 0, + "provisioningState": "str", + "resourceState": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2024-09-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_update(self, resource_group): + response = await ( + await self.client.profiles.begin_update( + resource_group_name=resource_group.name, + profile_name="str", + profile_update_parameters={ + "identity": { + "type": "str", + "principalId": "str", + "tenantId": "str", + "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, + }, + "logScrubbing": { + "scrubbingRules": [ + {"matchVariable": "str", "selectorMatchOperator": "str", "selector": "str", "state": "str"} + ], + "state": "str", + }, + "originResponseTimeoutSeconds": 0, + "tags": {"str": "str"}, + }, + api_version="2024-09-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_delete(self, resource_group): + response = await ( + await self.client.profiles.begin_delete( + resource_group_name=resource_group.name, + profile_name="str", + api_version="2024-09-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_can_migrate(self, resource_group): + response = await ( + await self.client.profiles.begin_can_migrate( + resource_group_name=resource_group.name, + can_migrate_parameters={"classicResourceReference": {"id": "str"}}, + api_version="2024-09-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_migrate(self, resource_group): + response = await ( + await self.client.profiles.begin_migrate( + resource_group_name=resource_group.name, + migration_parameters={ + "classicResourceReference": {"id": "str"}, + "profileName": "str", + "sku": {"name": "str"}, + "migrationWebApplicationFirewallMappings": [ + {"migratedFrom": {"id": "str"}, "migratedTo": {"id": "str"}} + ], + }, + api_version="2024-09-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_migration_commit(self, resource_group): + response = await ( + await self.client.profiles.begin_migration_commit( + resource_group_name=resource_group.name, + profile_name="str", + api_version="2024-09-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_generate_sso_uri(self, resource_group): + response = await self.client.profiles.generate_sso_uri( + resource_group_name=resource_group.name, + profile_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_supported_optimization_types(self, resource_group): + response = await self.client.profiles.list_supported_optimization_types( + resource_group_name=resource_group.name, + profile_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_resource_usage(self, resource_group): + response = self.client.profiles.list_resource_usage( + resource_group_name=resource_group.name, + profile_name="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_migration_abort(self, resource_group): + response = await ( + await self.client.profiles.begin_migration_abort( + resource_group_name=resource_group.name, + profile_name="str", + api_version="2024-09-01", + ) + ).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..92137f188376 --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_resource_usage_operations.py @@ -0,0 +1,29 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.cdn import CdnManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestCdnManagementResourceUsageOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(CdnManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.resource_usage.list( + api_version="2024-09-01", + ) + 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..5d56c446e9f3 --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_resource_usage_operations_async.py @@ -0,0 +1,30 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.cdn.aio import CdnManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestCdnManagementResourceUsageOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(CdnManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.resource_usage.list( + api_version="2024-09-01", + ) + 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..efd88ddf54fe --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_routes_operations.py @@ -0,0 +1,137 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.cdn import CdnManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestCdnManagementRoutesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(CdnManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_endpoint(self, resource_group): + response = self.client.routes.list_by_endpoint( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.routes.get( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + route_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create(self, resource_group): + response = self.client.routes.begin_create( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + route_name="str", + route={ + "cacheConfiguration": { + "compressionSettings": {"contentTypesToCompress": ["str"], "isCompressionEnabled": bool}, + "queryParameters": "str", + "queryStringCachingBehavior": "str", + }, + "customDomains": [{"id": "str", "isActive": bool}], + "deploymentStatus": "str", + "enabledState": "str", + "endpointName": "str", + "forwardingProtocol": "str", + "httpsRedirect": "Disabled", + "id": "str", + "linkToDefaultDomain": "Disabled", + "name": "str", + "originGroup": {"id": "str"}, + "originPath": "str", + "patternsToMatch": ["str"], + "provisioningState": "str", + "ruleSets": [{"id": "str"}], + "supportedProtocols": [["Http", "Https"]], + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2024-09-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_update(self, resource_group): + response = self.client.routes.begin_update( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + route_name="str", + route_update_properties={ + "cacheConfiguration": { + "compressionSettings": {"contentTypesToCompress": ["str"], "isCompressionEnabled": bool}, + "queryParameters": "str", + "queryStringCachingBehavior": "str", + }, + "customDomains": [{"id": "str", "isActive": bool}], + "enabledState": "str", + "endpointName": "str", + "forwardingProtocol": "str", + "httpsRedirect": "Disabled", + "linkToDefaultDomain": "Disabled", + "originGroup": {"id": "str"}, + "originPath": "str", + "patternsToMatch": ["str"], + "ruleSets": [{"id": "str"}], + "supportedProtocols": [["Http", "Https"]], + }, + api_version="2024-09-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_delete(self, resource_group): + response = self.client.routes.begin_delete( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + route_name="str", + api_version="2024-09-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_routes_operations_async.py b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_routes_operations_async.py new file mode 100644 index 000000000000..5fcf534ea3c4 --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_routes_operations_async.py @@ -0,0 +1,144 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.cdn.aio import CdnManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestCdnManagementRoutesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(CdnManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_endpoint(self, resource_group): + response = self.client.routes.list_by_endpoint( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.routes.get( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + route_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create(self, resource_group): + response = await ( + await self.client.routes.begin_create( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + route_name="str", + route={ + "cacheConfiguration": { + "compressionSettings": {"contentTypesToCompress": ["str"], "isCompressionEnabled": bool}, + "queryParameters": "str", + "queryStringCachingBehavior": "str", + }, + "customDomains": [{"id": "str", "isActive": bool}], + "deploymentStatus": "str", + "enabledState": "str", + "endpointName": "str", + "forwardingProtocol": "str", + "httpsRedirect": "Disabled", + "id": "str", + "linkToDefaultDomain": "Disabled", + "name": "str", + "originGroup": {"id": "str"}, + "originPath": "str", + "patternsToMatch": ["str"], + "provisioningState": "str", + "ruleSets": [{"id": "str"}], + "supportedProtocols": [["Http", "Https"]], + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2024-09-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_update(self, resource_group): + response = await ( + await self.client.routes.begin_update( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + route_name="str", + route_update_properties={ + "cacheConfiguration": { + "compressionSettings": {"contentTypesToCompress": ["str"], "isCompressionEnabled": bool}, + "queryParameters": "str", + "queryStringCachingBehavior": "str", + }, + "customDomains": [{"id": "str", "isActive": bool}], + "enabledState": "str", + "endpointName": "str", + "forwardingProtocol": "str", + "httpsRedirect": "Disabled", + "linkToDefaultDomain": "Disabled", + "originGroup": {"id": "str"}, + "originPath": "str", + "patternsToMatch": ["str"], + "ruleSets": [{"id": "str"}], + "supportedProtocols": [["Http", "Https"]], + }, + api_version="2024-09-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_delete(self, resource_group): + response = await ( + await self.client.routes.begin_delete( + resource_group_name=resource_group.name, + profile_name="str", + endpoint_name="str", + route_name="str", + api_version="2024-09-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_rule_sets_operations.py b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_rule_sets_operations.py new file mode 100644 index 000000000000..f03ab0533fee --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_rule_sets_operations.py @@ -0,0 +1,83 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.cdn import CdnManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestCdnManagementRuleSetsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(CdnManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_profile(self, resource_group): + response = self.client.rule_sets.list_by_profile( + resource_group_name=resource_group.name, + profile_name="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.rule_sets.get( + resource_group_name=resource_group.name, + profile_name="str", + rule_set_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create(self, resource_group): + response = self.client.rule_sets.create( + resource_group_name=resource_group.name, + profile_name="str", + rule_set_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_delete(self, resource_group): + response = self.client.rule_sets.begin_delete( + resource_group_name=resource_group.name, + profile_name="str", + rule_set_name="str", + api_version="2024-09-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_resource_usage(self, resource_group): + response = self.client.rule_sets.list_resource_usage( + resource_group_name=resource_group.name, + profile_name="str", + rule_set_name="str", + api_version="2024-09-01", + ) + 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..a8e87c631fe2 --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_rule_sets_operations_async.py @@ -0,0 +1,86 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.cdn.aio import CdnManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestCdnManagementRuleSetsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(CdnManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_profile(self, resource_group): + response = self.client.rule_sets.list_by_profile( + resource_group_name=resource_group.name, + profile_name="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.rule_sets.get( + resource_group_name=resource_group.name, + profile_name="str", + rule_set_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create(self, resource_group): + response = await self.client.rule_sets.create( + resource_group_name=resource_group.name, + profile_name="str", + rule_set_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_delete(self, resource_group): + response = await ( + await self.client.rule_sets.begin_delete( + resource_group_name=resource_group.name, + profile_name="str", + rule_set_name="str", + api_version="2024-09-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_resource_usage(self, resource_group): + response = self.client.rule_sets.list_resource_usage( + resource_group_name=resource_group.name, + profile_name="str", + rule_set_name="str", + api_version="2024-09-01", + ) + 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..3ca05c3d9afe --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_rules_operations.py @@ -0,0 +1,115 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.cdn import CdnManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestCdnManagementRulesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(CdnManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_rule_set(self, resource_group): + response = self.client.rules.list_by_rule_set( + resource_group_name=resource_group.name, + profile_name="str", + rule_set_name="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.rules.get( + resource_group_name=resource_group.name, + profile_name="str", + rule_set_name="str", + rule_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create(self, resource_group): + response = self.client.rules.begin_create( + resource_group_name=resource_group.name, + profile_name="str", + rule_set_name="str", + rule_name="str", + rule={ + "actions": ["delivery_rule_action"], + "conditions": ["delivery_rule_condition"], + "deploymentStatus": "str", + "id": "str", + "matchProcessingBehavior": "Continue", + "name": "str", + "order": 0, + "provisioningState": "str", + "ruleSetName": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2024-09-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_update(self, resource_group): + response = self.client.rules.begin_update( + resource_group_name=resource_group.name, + profile_name="str", + rule_set_name="str", + rule_name="str", + rule_update_properties={ + "actions": ["delivery_rule_action"], + "conditions": ["delivery_rule_condition"], + "matchProcessingBehavior": "Continue", + "order": 0, + "ruleSetName": "str", + }, + api_version="2024-09-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_delete(self, resource_group): + response = self.client.rules.begin_delete( + resource_group_name=resource_group.name, + profile_name="str", + rule_set_name="str", + rule_name="str", + api_version="2024-09-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_rules_operations_async.py b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_rules_operations_async.py new file mode 100644 index 000000000000..2e7ea0ff692d --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_rules_operations_async.py @@ -0,0 +1,122 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.cdn.aio import CdnManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestCdnManagementRulesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(CdnManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_rule_set(self, resource_group): + response = self.client.rules.list_by_rule_set( + resource_group_name=resource_group.name, + profile_name="str", + rule_set_name="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.rules.get( + resource_group_name=resource_group.name, + profile_name="str", + rule_set_name="str", + rule_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create(self, resource_group): + response = await ( + await self.client.rules.begin_create( + resource_group_name=resource_group.name, + profile_name="str", + rule_set_name="str", + rule_name="str", + rule={ + "actions": ["delivery_rule_action"], + "conditions": ["delivery_rule_condition"], + "deploymentStatus": "str", + "id": "str", + "matchProcessingBehavior": "Continue", + "name": "str", + "order": 0, + "provisioningState": "str", + "ruleSetName": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2024-09-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_update(self, resource_group): + response = await ( + await self.client.rules.begin_update( + resource_group_name=resource_group.name, + profile_name="str", + rule_set_name="str", + rule_name="str", + rule_update_properties={ + "actions": ["delivery_rule_action"], + "conditions": ["delivery_rule_condition"], + "matchProcessingBehavior": "Continue", + "order": 0, + "ruleSetName": "str", + }, + api_version="2024-09-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_delete(self, resource_group): + response = await ( + await self.client.rules.begin_delete( + resource_group_name=resource_group.name, + profile_name="str", + rule_set_name="str", + rule_name="str", + api_version="2024-09-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_secrets_operations.py b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_secrets_operations.py new file mode 100644 index 000000000000..43c031a40f41 --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_secrets_operations.py @@ -0,0 +1,87 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.cdn import CdnManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestCdnManagementSecretsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(CdnManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_profile(self, resource_group): + response = self.client.secrets.list_by_profile( + resource_group_name=resource_group.name, + profile_name="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.secrets.get( + resource_group_name=resource_group.name, + profile_name="str", + secret_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create(self, resource_group): + response = self.client.secrets.begin_create( + resource_group_name=resource_group.name, + profile_name="str", + secret_name="str", + secret={ + "deploymentStatus": "str", + "id": "str", + "name": "str", + "parameters": "secret_parameters", + "profileName": "str", + "provisioningState": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2024-09-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_delete(self, resource_group): + response = self.client.secrets.begin_delete( + resource_group_name=resource_group.name, + profile_name="str", + secret_name="str", + api_version="2024-09-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_secrets_operations_async.py b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_secrets_operations_async.py new file mode 100644 index 000000000000..23a6385cf9a9 --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_secrets_operations_async.py @@ -0,0 +1,92 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.cdn.aio import CdnManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestCdnManagementSecretsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(CdnManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_profile(self, resource_group): + response = self.client.secrets.list_by_profile( + resource_group_name=resource_group.name, + profile_name="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.secrets.get( + resource_group_name=resource_group.name, + profile_name="str", + secret_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create(self, resource_group): + response = await ( + await self.client.secrets.begin_create( + resource_group_name=resource_group.name, + profile_name="str", + secret_name="str", + secret={ + "deploymentStatus": "str", + "id": "str", + "name": "str", + "parameters": "secret_parameters", + "profileName": "str", + "provisioningState": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2024-09-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_delete(self, resource_group): + response = await ( + await self.client.secrets.begin_delete( + resource_group_name=resource_group.name, + profile_name="str", + secret_name="str", + api_version="2024-09-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_security_policies_operations.py b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_security_policies_operations.py new file mode 100644 index 000000000000..87341d0891a2 --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_security_policies_operations.py @@ -0,0 +1,101 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.cdn import CdnManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestCdnManagementSecurityPoliciesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(CdnManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_profile(self, resource_group): + response = self.client.security_policies.list_by_profile( + resource_group_name=resource_group.name, + profile_name="str", + api_version="2024-09-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.security_policies.get( + resource_group_name=resource_group.name, + profile_name="str", + security_policy_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create(self, resource_group): + response = self.client.security_policies.begin_create( + resource_group_name=resource_group.name, + profile_name="str", + security_policy_name="str", + security_policy={ + "deploymentStatus": "str", + "id": "str", + "name": "str", + "parameters": "security_policy_properties_parameters", + "profileName": "str", + "provisioningState": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2024-09-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_patch(self, resource_group): + response = self.client.security_policies.begin_patch( + resource_group_name=resource_group.name, + profile_name="str", + security_policy_name="str", + security_policy_update_properties={"parameters": "security_policy_properties_parameters"}, + api_version="2024-09-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_delete(self, resource_group): + response = self.client.security_policies.begin_delete( + resource_group_name=resource_group.name, + profile_name="str", + security_policy_name="str", + api_version="2024-09-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_security_policies_operations_async.py b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_security_policies_operations_async.py new file mode 100644 index 000000000000..625e73c9bbe4 --- /dev/null +++ b/sdk/cdn/azure-mgmt-cdn/generated_tests/test_cdn_management_security_policies_operations_async.py @@ -0,0 +1,108 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.cdn.aio import CdnManagementClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestCdnManagementSecurityPoliciesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(CdnManagementClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_profile(self, resource_group): + response = self.client.security_policies.list_by_profile( + resource_group_name=resource_group.name, + profile_name="str", + api_version="2024-09-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.security_policies.get( + resource_group_name=resource_group.name, + profile_name="str", + security_policy_name="str", + api_version="2024-09-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create(self, resource_group): + response = await ( + await self.client.security_policies.begin_create( + resource_group_name=resource_group.name, + profile_name="str", + security_policy_name="str", + security_policy={ + "deploymentStatus": "str", + "id": "str", + "name": "str", + "parameters": "security_policy_properties_parameters", + "profileName": "str", + "provisioningState": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2024-09-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_patch(self, resource_group): + response = await ( + await self.client.security_policies.begin_patch( + resource_group_name=resource_group.name, + profile_name="str", + security_policy_name="str", + security_policy_update_properties={"parameters": "security_policy_properties_parameters"}, + api_version="2024-09-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_delete(self, resource_group): + response = await ( + await self.client.security_policies.begin_delete( + resource_group_name=resource_group.name, + profile_name="str", + security_policy_name="str", + api_version="2024-09-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/cdn/azure-mgmt-cdn/setup.py b/sdk/cdn/azure-mgmt-cdn/setup.py index c0f0a3ca2878..c01da81e3982 100644 --- a/sdk/cdn/azure-mgmt-cdn/setup.py +++ b/sdk/cdn/azure-mgmt-cdn/setup.py @@ -75,6 +75,7 @@ }, install_requires=[ "isodate>=0.6.1", + "typing-extensions>=4.6.0", "azure-common>=1.1", "azure-mgmt-core>=1.3.2", ],