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
11
from typing_extensions import Self
12
12
13
13
from azure .core .pipeline import policies
14
14
from azure .core .rest import HttpRequest , HttpResponse
15
+ from azure .core .settings import settings
15
16
from azure .mgmt .core import ARMPipelineClient
16
17
from azure .mgmt .core .policies import ARMAutoResourceProviderRegistrationPolicy
18
+ from azure .mgmt .core .tools import get_arm_endpoints
17
19
18
20
from . import models as _models
19
21
from ._configuration import BillingManagementClientConfiguration
52
54
)
53
55
54
56
if TYPE_CHECKING :
55
- # pylint: disable=unused-import,ungrouped-imports
56
57
from azure .core .credentials import TokenCredential
57
58
58
59
59
- class BillingManagementClient : # pylint: disable=client-accepts-api-version-keyword, too-many-instance-attributes
60
+ class BillingManagementClient : # pylint: disable=too-many-instance-attributes
60
61
"""Billing Client.
61
62
62
63
:ivar agreements: AgreementsOperations operations
@@ -125,7 +126,7 @@ class BillingManagementClient: # pylint: disable=client-accepts-api-version-key
125
126
:type credential: ~azure.core.credentials.TokenCredential
126
127
:param subscription_id: The ID that uniquely identifies a billing subscription. Required.
127
128
:type subscription_id: str
128
- :param base_url: Service URL. Default value is "https://management.azure.com" .
129
+ :param base_url: Service URL. Default value is None .
129
130
:type base_url: str
130
131
:keyword api_version: Api Version. Default value is "2024-04-01". Note that overriding this
131
132
default value may result in unsupported behavior.
@@ -135,15 +136,17 @@ class BillingManagementClient: # pylint: disable=client-accepts-api-version-key
135
136
"""
136
137
137
138
def __init__ (
138
- self ,
139
- credential : "TokenCredential" ,
140
- subscription_id : str ,
141
- base_url : str = "https://management.azure.com" ,
142
- ** kwargs : Any
139
+ self , credential : "TokenCredential" , subscription_id : str , base_url : Optional [str ] = None , ** kwargs : Any
143
140
) -> None :
141
+ _cloud = kwargs .pop ("cloud_setting" , None ) or settings .current .azure_cloud # type: ignore
142
+ _endpoints = get_arm_endpoints (_cloud )
143
+ if not base_url :
144
+ base_url = _endpoints ["resource_manager" ]
145
+ credential_scopes = kwargs .pop ("credential_scopes" , _endpoints ["credential_scopes" ])
144
146
self ._config = BillingManagementClientConfiguration (
145
- credential = credential , subscription_id = subscription_id , ** kwargs
147
+ credential = credential , subscription_id = subscription_id , credential_scopes = credential_scopes , ** kwargs
146
148
)
149
+
147
150
_policies = kwargs .pop ("policies" , None )
148
151
if _policies is None :
149
152
_policies = [
@@ -162,7 +165,7 @@ def __init__(
162
165
policies .SensitiveHeaderCleanupPolicy (** kwargs ) if self ._config .redirect_policy else None ,
163
166
self ._config .http_logging_policy ,
164
167
]
165
- self ._client : ARMPipelineClient = ARMPipelineClient (base_url = base_url , policies = _policies , ** kwargs )
168
+ self ._client : ARMPipelineClient = ARMPipelineClient (base_url = cast ( str , base_url ) , policies = _policies , ** kwargs )
166
169
167
170
client_models = {k : v for k , v in _models .__dict__ .items () if isinstance (v , type )}
168
171
self ._serialize = Serializer (client_models )
0 commit comments