77# --------------------------------------------------------------------------
88
99from copy import deepcopy
10- from typing import Any , TYPE_CHECKING
10+ from typing import Any , Optional , TYPE_CHECKING , cast
11+ from typing_extensions import Self
1112
1213from azure .core .pipeline import policies
1314from azure .core .rest import HttpRequest , HttpResponse
15+ from azure .core .settings import settings
1416from azure .mgmt .core import ARMPipelineClient
1517from azure .mgmt .core .policies import ARMAutoResourceProviderRegistrationPolicy
18+ from azure .mgmt .core .tools import get_arm_endpoints
1619
1720from . import models as _models
1821from ._configuration import CdnManagementClientConfiguration
19- from ._serialization import Deserializer , Serializer
22+ from ._utils . serialization import Deserializer , Serializer
2023from .operations import (
2124 AFDCustomDomainsOperations ,
2225 AFDEndpointsOperations ,
4346)
4447
4548if TYPE_CHECKING :
46- # pylint: disable=unused-import,ungrouped-imports
4749 from azure .core .credentials import TokenCredential
4850
4951
50- class CdnManagementClient (
51- CdnManagementClientOperationsMixin
52- ): # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes
52+ class CdnManagementClient (CdnManagementClientOperationsMixin ): # pylint: disable=too-many-instance-attributes
5353 """Cdn Management Client.
5454
5555 :ivar afd_profiles: AFDProfilesOperations operations
@@ -98,25 +98,27 @@ class CdnManagementClient(
9898 :type credential: ~azure.core.credentials.TokenCredential
9999 :param subscription_id: Azure Subscription ID. Required.
100100 :type subscription_id: str
101- :param base_url: Service URL. Default value is "https://management.azure.com" .
101+ :param base_url: Service URL. Default value is None .
102102 :type base_url: str
103- :keyword api_version: Api Version. Default value is "2024-02-01 ". Note that overriding this
103+ :keyword api_version: Api Version. Default value is "2025-04-15 ". Note that overriding this
104104 default value may result in unsupported behavior.
105105 :paramtype api_version: str
106106 :keyword int polling_interval: Default waiting time between two polls for LRO operations if no
107107 Retry-After header is present.
108108 """
109109
110110 def __init__ (
111- self ,
112- credential : "TokenCredential" ,
113- subscription_id : str ,
114- base_url : str = "https://management.azure.com" ,
115- ** kwargs : Any
111+ self , credential : "TokenCredential" , subscription_id : str , base_url : Optional [str ] = None , ** kwargs : Any
116112 ) -> None :
113+ _cloud = kwargs .pop ("cloud_setting" , None ) or settings .current .azure_cloud # type: ignore
114+ _endpoints = get_arm_endpoints (_cloud )
115+ if not base_url :
116+ base_url = _endpoints ["resource_manager" ]
117+ credential_scopes = kwargs .pop ("credential_scopes" , _endpoints ["credential_scopes" ])
117118 self ._config = CdnManagementClientConfiguration (
118- credential = credential , subscription_id = subscription_id , ** kwargs
119+ credential = credential , subscription_id = subscription_id , credential_scopes = credential_scopes , ** kwargs
119120 )
121+
120122 _policies = kwargs .pop ("policies" , None )
121123 if _policies is None :
122124 _policies = [
@@ -135,7 +137,7 @@ def __init__(
135137 policies .SensitiveHeaderCleanupPolicy (** kwargs ) if self ._config .redirect_policy else None ,
136138 self ._config .http_logging_policy ,
137139 ]
138- self ._client : ARMPipelineClient = ARMPipelineClient (base_url = base_url , policies = _policies , ** kwargs )
140+ self ._client : ARMPipelineClient = ARMPipelineClient (base_url = cast ( str , base_url ) , policies = _policies , ** kwargs )
139141
140142 client_models = {k : v for k , v in _models .__dict__ .items () if isinstance (v , type )}
141143 self ._serialize = Serializer (client_models )
@@ -196,7 +198,7 @@ def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs:
196198 def close (self ) -> None :
197199 self ._client .close ()
198200
199- def __enter__ (self ) -> "CdnManagementClient" :
201+ def __enter__ (self ) -> Self :
200202 self ._client .__enter__ ()
201203 return self
202204
0 commit comments