22# --------------------------------------------------------------------------
33# Copyright (c) Microsoft Corporation. All rights reserved.
44# Licensed under the MIT License. See License.txt in the project root for license information.
5- # Code generated by Microsoft (R) AutoRest Code Generator.
5+ # Code generated by Microsoft (R) Python Code Generator.
66# Changes may cause incorrect behavior and will be lost if the code is regenerated.
77# --------------------------------------------------------------------------
88
99from copy import deepcopy
10- from typing import Any , TYPE_CHECKING
10+ import sys
11+ from typing import Any , Optional , TYPE_CHECKING , cast
1112
13+ from azure .core .pipeline import policies
1214from azure .core .rest import HttpRequest , HttpResponse
15+ from azure .core .settings import settings
1316from azure .mgmt .core import ARMPipelineClient
17+ from azure .mgmt .core .policies import ARMAutoResourceProviderRegistrationPolicy
18+ from azure .mgmt .core .tools import get_arm_endpoints
1419
15- from . import models as _models
1620from ._configuration import ConsumptionManagementClientConfiguration
17- from ._serialization import Deserializer , Serializer
21+ from ._utils . serialization import Deserializer , Serializer
1822from .operations import (
1923 AggregatedCostOperations ,
2024 BalancesOperations ,
3539 UsageDetailsOperations ,
3640)
3741
42+ if sys .version_info >= (3 , 11 ):
43+ from typing import Self
44+ else :
45+ from typing_extensions import Self # type: ignore
46+
3847if TYPE_CHECKING :
39- # pylint: disable=unused- import,ungrouped-imports
48+ from azure . core import AzureClouds
4049 from azure .core .credentials import TokenCredential
4150
4251
43- class ConsumptionManagementClient : # pylint: disable=client-accepts-api-version-keyword, too-many-instance-attributes
52+ class ConsumptionManagementClient : # pylint: disable=too-many-instance-attributes
4453 """Consumption management client provides access to consumption resources for Azure Enterprise
4554 Subscriptions.
4655
56+ :ivar operations: Operations operations
57+ :vartype operations: azure.mgmt.consumption.operations.Operations
58+ :ivar price_sheet: PriceSheetOperations operations
59+ :vartype price_sheet: azure.mgmt.consumption.operations.PriceSheetOperations
60+ :ivar budgets: BudgetsOperations operations
61+ :vartype budgets: azure.mgmt.consumption.operations.BudgetsOperations
62+ :ivar credits: CreditsOperations operations
63+ :vartype credits: azure.mgmt.consumption.operations.CreditsOperations
4764 :ivar usage_details: UsageDetailsOperations operations
4865 :vartype usage_details: azure.mgmt.consumption.operations.UsageDetailsOperations
4966 :ivar marketplaces: MarketplacesOperations operations
5067 :vartype marketplaces: azure.mgmt.consumption.operations.MarketplacesOperations
51- :ivar budgets: BudgetsOperations operations
52- :vartype budgets: azure.mgmt.consumption.operations.BudgetsOperations
5368 :ivar tags: TagsOperations operations
5469 :vartype tags: azure.mgmt.consumption.operations.TagsOperations
5570 :ivar charges: ChargesOperations operations
@@ -70,48 +85,82 @@ class ConsumptionManagementClient: # pylint: disable=client-accepts-api-version
7085 :ivar reservation_transactions: ReservationTransactionsOperations operations
7186 :vartype reservation_transactions:
7287 azure.mgmt.consumption.operations.ReservationTransactionsOperations
73- :ivar price_sheet: PriceSheetOperations operations
74- :vartype price_sheet: azure.mgmt.consumption.operations.PriceSheetOperations
75- :ivar operations: Operations operations
76- :vartype operations: azure.mgmt.consumption.operations.Operations
7788 :ivar aggregated_cost: AggregatedCostOperations operations
7889 :vartype aggregated_cost: azure.mgmt.consumption.operations.AggregatedCostOperations
7990 :ivar events: EventsOperations operations
8091 :vartype events: azure.mgmt.consumption.operations.EventsOperations
8192 :ivar lots: LotsOperations operations
8293 :vartype lots: azure.mgmt.consumption.operations.LotsOperations
83- :ivar credits: CreditsOperations operations
84- :vartype credits: azure.mgmt.consumption.operations.CreditsOperations
85- :param credential: Credential needed for the client to connect to Azure. Required.
94+ :param credential: Credential used to authenticate requests to the service. Required.
8695 :type credential: ~azure.core.credentials.TokenCredential
87- :param subscription_id: Azure Subscription ID . Required.
96+ :param subscription_id: The ID of the target subscription. The value must be an UUID . Required.
8897 :type subscription_id: str
89- :param base_url: Service URL . Default value is "https://management.azure.com" .
98+ :param base_url: Service host . Default value is None .
9099 :type base_url: str
91- :keyword api_version: Api Version. Default value is "2021-10-01". Note that overriding this
92- default value may result in unsupported behavior.
100+ :keyword cloud_setting: The cloud setting for which to get the ARM endpoint. Default value is
101+ None.
102+ :paramtype cloud_setting: ~azure.core.AzureClouds
103+ :keyword api_version: The API version to use for this operation. Known values are "2024-08-01"
104+ and None. Default value is None. If not set, the operation's default API version will be used.
105+ Note that overriding this default value may result in unsupported behavior.
93106 :paramtype api_version: str
107+ :keyword int polling_interval: Default waiting time between two polls for LRO operations if no
108+ Retry-After header is present.
94109 """
95110
96111 def __init__ (
97112 self ,
98113 credential : "TokenCredential" ,
99114 subscription_id : str ,
100- base_url : str = "https://management.azure.com" ,
115+ base_url : Optional [str ] = None ,
116+ * ,
117+ cloud_setting : Optional ["AzureClouds" ] = None ,
101118 ** kwargs : Any
102119 ) -> None :
120+ _endpoint = "{endpoint}"
121+ _cloud = cloud_setting or settings .current .azure_cloud # type: ignore
122+ _endpoints = get_arm_endpoints (_cloud )
123+ if not base_url :
124+ base_url = _endpoints ["resource_manager" ]
125+ credential_scopes = kwargs .pop ("credential_scopes" , _endpoints ["credential_scopes" ])
103126 self ._config = ConsumptionManagementClientConfiguration (
104- credential = credential , subscription_id = subscription_id , ** kwargs
127+ credential = credential ,
128+ subscription_id = subscription_id ,
129+ base_url = cast (str , base_url ),
130+ cloud_setting = cloud_setting ,
131+ credential_scopes = credential_scopes ,
132+ ** kwargs
105133 )
106- self ._client = ARMPipelineClient (base_url = base_url , config = self ._config , ** kwargs )
107134
108- client_models = {k : v for k , v in _models .__dict__ .items () if isinstance (v , type )}
109- self ._serialize = Serializer (client_models )
110- self ._deserialize = Deserializer (client_models )
135+ _policies = kwargs .pop ("policies" , None )
136+ if _policies is None :
137+ _policies = [
138+ policies .RequestIdPolicy (** kwargs ),
139+ self ._config .headers_policy ,
140+ self ._config .user_agent_policy ,
141+ self ._config .proxy_policy ,
142+ policies .ContentDecodePolicy (** kwargs ),
143+ ARMAutoResourceProviderRegistrationPolicy (),
144+ self ._config .redirect_policy ,
145+ self ._config .retry_policy ,
146+ self ._config .authentication_policy ,
147+ self ._config .custom_hook_policy ,
148+ self ._config .logging_policy ,
149+ policies .DistributedTracingPolicy (** kwargs ),
150+ policies .SensitiveHeaderCleanupPolicy (** kwargs ) if self ._config .redirect_policy else None ,
151+ self ._config .http_logging_policy ,
152+ ]
153+ self ._client : ARMPipelineClient = ARMPipelineClient (base_url = cast (str , _endpoint ), policies = _policies , ** kwargs )
154+
155+ self ._serialize = Serializer ()
156+ self ._deserialize = Deserializer ()
111157 self ._serialize .client_side_validation = False
158+ self .operations = Operations (self ._client , self ._config , self ._serialize , self ._deserialize )
159+ self .price_sheet = PriceSheetOperations (self ._client , self ._config , self ._serialize , self ._deserialize )
160+ self .budgets = BudgetsOperations (self ._client , self ._config , self ._serialize , self ._deserialize )
161+ self .credits = CreditsOperations (self ._client , self ._config , self ._serialize , self ._deserialize )
112162 self .usage_details = UsageDetailsOperations (self ._client , self ._config , self ._serialize , self ._deserialize )
113163 self .marketplaces = MarketplacesOperations (self ._client , self ._config , self ._serialize , self ._deserialize )
114- self .budgets = BudgetsOperations (self ._client , self ._config , self ._serialize , self ._deserialize )
115164 self .tags = TagsOperations (self ._client , self ._config , self ._serialize , self ._deserialize )
116165 self .charges = ChargesOperations (self ._client , self ._config , self ._serialize , self ._deserialize )
117166 self .balances = BalancesOperations (self ._client , self ._config , self ._serialize , self ._deserialize )
@@ -130,20 +179,17 @@ def __init__(
130179 self .reservation_transactions = ReservationTransactionsOperations (
131180 self ._client , self ._config , self ._serialize , self ._deserialize
132181 )
133- self .price_sheet = PriceSheetOperations (self ._client , self ._config , self ._serialize , self ._deserialize )
134- self .operations = Operations (self ._client , self ._config , self ._serialize , self ._deserialize )
135182 self .aggregated_cost = AggregatedCostOperations (self ._client , self ._config , self ._serialize , self ._deserialize )
136183 self .events = EventsOperations (self ._client , self ._config , self ._serialize , self ._deserialize )
137184 self .lots = LotsOperations (self ._client , self ._config , self ._serialize , self ._deserialize )
138- self .credits = CreditsOperations (self ._client , self ._config , self ._serialize , self ._deserialize )
139185
140- def _send_request (self , request : HttpRequest , ** kwargs : Any ) -> HttpResponse :
186+ def send_request (self , request : HttpRequest , * , stream : bool = False , ** kwargs : Any ) -> HttpResponse :
141187 """Runs the network request through the client's chained policies.
142188
143189 >>> from azure.core.rest import HttpRequest
144190 >>> request = HttpRequest("GET", "https://www.example.org/")
145191 <HttpRequest [GET], url: 'https://www.example.org/'>
146- >>> response = client._send_request (request)
192+ >>> response = client.send_request (request)
147193 <HttpResponse: 200 OK>
148194
149195 For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request
@@ -156,15 +202,19 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse:
156202 """
157203
158204 request_copy = deepcopy (request )
159- request_copy .url = self ._client .format_url (request_copy .url )
160- return self ._client .send_request (request_copy , ** kwargs )
205+ path_format_arguments = {
206+ "endpoint" : self ._serialize .url ("self._config.base_url" , self ._config .base_url , "str" , skip_quote = True ),
207+ }
208+
209+ request_copy .url = self ._client .format_url (request_copy .url , ** path_format_arguments )
210+ return self ._client .send_request (request_copy , stream = stream , ** kwargs ) # type: ignore
161211
162212 def close (self ) -> None :
163213 self ._client .close ()
164214
165- def __enter__ (self ) -> "ConsumptionManagementClient" :
215+ def __enter__ (self ) -> Self :
166216 self ._client .__enter__ ()
167217 return self
168218
169- def __exit__ (self , * exc_details ) -> None :
219+ def __exit__ (self , * exc_details : Any ) -> None :
170220 self ._client .__exit__ (* exc_details )
0 commit comments