7
7
# --------------------------------------------------------------------------
8
8
9
9
from 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
11
12
12
13
from azure .core .pipeline import policies
13
14
from azure .core .rest import HttpRequest , HttpResponse
15
+ from azure .core .settings import settings
14
16
from azure .mgmt .core import ARMPipelineClient
15
17
from azure .mgmt .core .policies import ARMAutoResourceProviderRegistrationPolicy
18
+ from azure .mgmt .core .tools import get_arm_endpoints
16
19
17
20
from . import models as _models
18
21
from ._configuration import FrontDoorManagementClientConfiguration
19
- from ._serialization import Deserializer , Serializer
22
+ from ._utils . serialization import Deserializer , Serializer
20
23
from .operations import (
21
24
EndpointsOperations ,
22
25
ExperimentsOperations ,
33
36
)
34
37
35
38
if TYPE_CHECKING :
36
- # pylint: disable=unused-import,ungrouped-imports
37
39
from azure .core .credentials import TokenCredential
38
40
39
41
@@ -74,22 +76,24 @@ class FrontDoorManagementClient: # pylint: disable=client-accepts-api-version-k
74
76
:param subscription_id: The subscription credentials which uniquely identify the Microsoft
75
77
Azure subscription. The subscription ID forms part of the URI for every service call. Required.
76
78
:type subscription_id: str
77
- :param base_url: Service URL. Default value is "https://management.azure.com" .
79
+ :param base_url: Service URL. Default value is None .
78
80
:type base_url: str
79
81
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
80
82
Retry-After header is present.
81
83
"""
82
84
83
85
def __init__ (
84
- self ,
85
- credential : "TokenCredential" ,
86
- subscription_id : str ,
87
- base_url : str = "https://management.azure.com" ,
88
- ** kwargs : Any
86
+ self , credential : "TokenCredential" , subscription_id : str , base_url : Optional [str ] = None , ** kwargs : Any
89
87
) -> None :
88
+ _cloud = kwargs .pop ("cloud_setting" , None ) or settings .current .azure_cloud # type: ignore
89
+ _endpoints = get_arm_endpoints (_cloud )
90
+ if not base_url :
91
+ base_url = _endpoints ["resource_manager" ]
92
+ credential_scopes = kwargs .pop ("credential_scopes" , _endpoints ["credential_scopes" ])
90
93
self ._config = FrontDoorManagementClientConfiguration (
91
- credential = credential , subscription_id = subscription_id , ** kwargs
94
+ credential = credential , subscription_id = subscription_id , credential_scopes = credential_scopes , ** kwargs
92
95
)
96
+
93
97
_policies = kwargs .pop ("policies" , None )
94
98
if _policies is None :
95
99
_policies = [
@@ -108,7 +112,7 @@ def __init__(
108
112
policies .SensitiveHeaderCleanupPolicy (** kwargs ) if self ._config .redirect_policy else None ,
109
113
self ._config .http_logging_policy ,
110
114
]
111
- self ._client : ARMPipelineClient = ARMPipelineClient (base_url = base_url , policies = _policies , ** kwargs )
115
+ self ._client : ARMPipelineClient = ARMPipelineClient (base_url = cast ( str , base_url ) , policies = _policies , ** kwargs )
112
116
113
117
client_models = {k : v for k , v in _models .__dict__ .items () if isinstance (v , type )}
114
118
self ._serialize = Serializer (client_models )
@@ -164,7 +168,7 @@ def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs:
164
168
def close (self ) -> None :
165
169
self ._client .close ()
166
170
167
- def __enter__ (self ) -> "FrontDoorManagementClient" :
171
+ def __enter__ (self ) -> Self :
168
172
self ._client .__enter__ ()
169
173
return self
170
174
0 commit comments