Skip to content

Commit faf0259

Browse files
author
SDKAuto
committed
CodeGen from PR 33626 in Azure/azure-rest-api-specs
Merge 5aecafed12c38ab12e3439d86807805f7ee59dee into ebabd96a91be0af107cc66f3149b0b41d7d44a8f
1 parent 803cfcf commit faf0259

File tree

191 files changed

+5983
-3298
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

191 files changed

+5983
-3298
lines changed

sdk/consumption/azure-mgmt-consumption/CHANGELOG.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,56 @@
11
# Release History
22

3+
## 11.0.0 (2025-05-05)
4+
5+
### Features Added
6+
7+
- Model `Balance` added property `overage_refund`
8+
- Model `CreditSummary` added property `is_estimated_balance`
9+
- Model `CreditSummary` added property `e_tag_properties_e_tag`
10+
- Model `EventSummary` added property `charges_in_lot_currency`
11+
- Model `EventSummary` added property `closed_balance_in_lot_currency`
12+
- Model `EventSummary` added property `billing_account_id`
13+
- Model `EventSummary` added property `billing_account_display_name`
14+
- Model `EventSummary` added property `is_estimated_balance`
15+
- Model `LegacyChargeSummary` added property `azure_marketplace_charges`
16+
- Model `LegacyReservationRecommendation` added property `last_usage_date`
17+
- Model `LegacyReservationRecommendation` added property `total_hours`
18+
- Model `LegacyReservationRecommendationProperties` added property `last_usage_date`
19+
- Model `LegacyReservationRecommendationProperties` added property `total_hours`
20+
- Model `LegacySharedScopeReservationRecommendationProperties` added property `last_usage_date`
21+
- Model `LegacySharedScopeReservationRecommendationProperties` added property `total_hours`
22+
- Model `LegacySingleScopeReservationRecommendationProperties` added property `last_usage_date`
23+
- Model `LegacySingleScopeReservationRecommendationProperties` added property `total_hours`
24+
- Model `LotSummary` added property `is_estimated_balance`
25+
- Model `LotSummary` added property `organization_type`
26+
- Model `LotSummary` added property `used_amount`
27+
- Model `ModernChargeSummary` added property `subscription_id`
28+
- Model `ModernReservationRecommendation` added property `resource_type`
29+
- Model `ModernReservationRecommendation` added property `last_usage_date`
30+
- Model `ModernReservationRecommendation` added property `total_hours`
31+
- Model `PriceSheetProperties` added property `savings_plan`
32+
- Enum `Term` added member `P1_M`
33+
- Added model `ErrorAdditionalInfo`
34+
- Added model `ErrorDetail`
35+
- Added model `ErrorResponseAutoGenerated`
36+
- Added model `ModernReservationRecommendationProperties`
37+
- Added model `ModernSharedScopeReservationRecommendationProperties`
38+
- Added model `ModernSingleScopeReservationRecommendationProperties`
39+
- Added model `OperationStatus`
40+
- Added enum `OperationStatusType`
41+
- Added enum `OrganizationType`
42+
- Added model `SavingsPlan`
43+
- Model `PriceSheetOperations` added method `begin_download_by_billing_account_period`
44+
- Method `BudgetsOperations.create_or_update` has a new overload `def create_or_update(self: None, scope: str, budget_name: str, parameters: Budget, content_type: str)`
45+
- Method `BudgetsOperations.create_or_update` has a new overload `def create_or_update(self: None, scope: str, budget_name: str, parameters: IO[bytes], content_type: str)`
46+
47+
### Breaking Changes
48+
49+
- Deleted or renamed enum value `BudgetOperatorType.IN_ENUM`
50+
- Model `CreditSummary` deleted or renamed its instance variable `etag`
51+
- Model `CreditSummary` deleted or renamed its instance variable `tags`
52+
- Model `LegacyChargeSummary` deleted or renamed its instance variable `marketplace_charges`
53+
354
## 11.0.0b1 (2022-12-07)
455

556
### Features Added
Lines changed: 44 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,61 @@
11
# Microsoft Azure SDK for Python
22

33
This is the Microsoft Azure Consumption Client Library.
4-
This package has been tested with Python 3.7+.
4+
This package has been tested with Python 3.9+.
55
For a more complete view of Azure libraries, see the [azure sdk python release](https://aka.ms/azsdk/python/all).
66

77
## _Disclaimer_
88

99
_Azure SDK Python packages support for Python 2.7 has ended 01 January 2022. For more information and questions, please refer to https://github.com/Azure/azure-sdk-for-python/issues/20691_
1010

11-
# Usage
11+
## Getting started
1212

13+
### Prerequisites
1314

14-
To learn how to use this package, see the [quickstart guide](https://aka.ms/azsdk/python/mgmt)
15-
16-
For docs and references, see [Python SDK References](https://docs.microsoft.com/python/api/overview/azure/consumption)
17-
Code samples for this package can be found at [Consumption](https://docs.microsoft.com/samples/browse/?languages=python&term=Getting%20started%20-%20Managing&terms=Getting%20started%20-%20Managing) on docs.microsoft.com.
18-
Additional code samples for different Azure services are available at [Samples Repo](https://github.com/Azure-Samples/azure-samples-python-management/tree/main/samples/consumption)
15+
- Python 3.9+ is required to use this package.
16+
- [Azure subscription](https://azure.microsoft.com/free/)
1917

18+
### Install the package
2019

21-
# Provide Feedback
20+
```bash
21+
pip install azure-mgmt-consumption
22+
pip install azure-identity
23+
```
2224

23-
If you encounter any bugs or have suggestions, please file an issue in the
24-
[Issues](https://github.com/Azure/azure-sdk-for-python/issues)
25-
section of the project.
25+
### Authentication
26+
27+
By default, [Azure Active Directory](https://aka.ms/awps/aad) token authentication depends on correct configuration of the following environment variables.
28+
29+
- `AZURE_CLIENT_ID` for Azure client ID.
30+
- `AZURE_TENANT_ID` for Azure tenant ID.
31+
- `AZURE_CLIENT_SECRET` for Azure client secret.
32+
33+
In addition, Azure subscription ID can be configured via environment variable `AZURE_SUBSCRIPTION_ID`.
34+
35+
With above configuration, client can be authenticated by following code:
36+
37+
```python
38+
from azure.identity import DefaultAzureCredential
39+
from azure.mgmt.consumption import ConsumptionManagementClient
40+
import os
2641

42+
sub_id = os.getenv("AZURE_SUBSCRIPTION_ID")
43+
client = ConsumptionManagementClient(credential=DefaultAzureCredential(), subscription_id=sub_id)
44+
```
2745

46+
## Examples
2847

48+
Code samples for this package can be found at:
49+
- [Search Consumption](https://docs.microsoft.com/samples/browse/?languages=python&term=Getting%20started%20-%20Managing&terms=Getting%20started%20-%20Managing) on docs.microsoft.com
50+
- [Azure Python Mgmt SDK Samples Repo](https://aka.ms/azsdk/python/mgmt/samples)
51+
52+
53+
## Troubleshooting
54+
55+
## Next steps
56+
57+
## Provide Feedback
58+
59+
If you encounter any bugs or have suggestions, please file an issue in the
60+
[Issues](https://github.com/Azure/azure-sdk-for-python/issues)
61+
section of the project.
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
2-
"commit": "1be09531e4c6edeafde41d6562371566d39669e8",
2+
"commit": "55d10e88f37024edfb692533c1770b6b9a97aaeb",
33
"repository_url": "https://github.com/Azure/azure-rest-api-specs",
4-
"autorest": "3.9.2",
4+
"autorest": "3.10.2",
55
"use": [
6-
"@autorest/python@6.2.7",
7-
"@autorest/modelerfour@4.24.3"
6+
"@autorest/python@6.34.1",
7+
"@autorest/modelerfour@4.27.0"
88
],
9-
"autorest_command": "autorest specification/consumption/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.2.7 --use=@autorest/modelerfour@4.24.3 --version=3.9.2 --version-tolerant=False",
9+
"autorest_command": "autorest specification/consumption/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.34.1 --use=@autorest/modelerfour@4.27.0 --version=3.10.2 --version-tolerant=False",
1010
"readme": "specification/consumption/resource-manager/readme.md"
1111
}

sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/__init__.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,28 @@
55
# Code generated by Microsoft (R) AutoRest Code Generator.
66
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
77
# --------------------------------------------------------------------------
8+
# pylint: disable=wrong-import-position
89

9-
from ._consumption_management_client import ConsumptionManagementClient
10+
from typing import TYPE_CHECKING
11+
12+
if TYPE_CHECKING:
13+
from ._patch import * # pylint: disable=unused-wildcard-import
14+
15+
from ._consumption_management_client import ConsumptionManagementClient # type: ignore
1016
from ._version import VERSION
1117

1218
__version__ = VERSION
1319

1420
try:
1521
from ._patch import __all__ as _patch_all
16-
from ._patch import * # pylint: disable=unused-wildcard-import
22+
from ._patch import *
1723
except ImportError:
1824
_patch_all = []
1925
from ._patch import patch_sdk as _patch_sdk
2026

2127
__all__ = [
2228
"ConsumptionManagementClient",
2329
]
24-
__all__.extend([p for p in _patch_all if p not in __all__])
30+
__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore
2531

2632
_patch_sdk()

sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/_configuration.py

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,18 @@
66
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
77
# --------------------------------------------------------------------------
88

9-
import sys
109
from typing import Any, TYPE_CHECKING
1110

12-
from azure.core.configuration import Configuration
1311
from azure.core.pipeline import policies
1412
from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy
1513

1614
from ._version import VERSION
1715

18-
if sys.version_info >= (3, 8):
19-
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
20-
else:
21-
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
22-
2316
if TYPE_CHECKING:
24-
# pylint: disable=unused-import,ungrouped-imports
2517
from azure.core.credentials import TokenCredential
2618

2719

28-
class ConsumptionManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes
20+
class ConsumptionManagementClientConfiguration: # pylint: disable=too-many-instance-attributes
2921
"""Configuration for ConsumptionManagementClient.
3022
3123
Note that all parameters used to create this instance are saved as instance
@@ -35,14 +27,13 @@ class ConsumptionManagementClientConfiguration(Configuration): # pylint: disabl
3527
:type credential: ~azure.core.credentials.TokenCredential
3628
:param subscription_id: Azure Subscription ID. Required.
3729
:type subscription_id: str
38-
:keyword api_version: Api Version. Default value is "2021-10-01". Note that overriding this
30+
:keyword api_version: Api Version. Default value is "2025-04-01". Note that overriding this
3931
default value may result in unsupported behavior.
4032
:paramtype api_version: str
4133
"""
4234

4335
def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None:
44-
super(ConsumptionManagementClientConfiguration, self).__init__(**kwargs)
45-
api_version: Literal["2021-10-01"] = kwargs.pop("api_version", "2021-10-01")
36+
api_version: str = kwargs.pop("api_version", "2025-04-01")
4637

4738
if credential is None:
4839
raise ValueError("Parameter 'credential' must not be None.")
@@ -54,6 +45,7 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs
5445
self.api_version = api_version
5546
self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"])
5647
kwargs.setdefault("sdk_moniker", "mgmt-consumption/{}".format(VERSION))
48+
self.polling_interval = kwargs.get("polling_interval", 30)
5749
self._configure(**kwargs)
5850

5951
def _configure(self, **kwargs: Any) -> None:
@@ -62,9 +54,9 @@ def _configure(self, **kwargs: Any) -> None:
6254
self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs)
6355
self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs)
6456
self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs)
65-
self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs)
6657
self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs)
6758
self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs)
59+
self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs)
6860
self.authentication_policy = kwargs.get("authentication_policy")
6961
if self.credential and not self.authentication_policy:
7062
self.authentication_policy = ARMChallengeAuthenticationPolicy(

sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/_consumption_management_client.py

Lines changed: 46 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,19 @@
77
# --------------------------------------------------------------------------
88

99
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
1112

13+
from azure.core.pipeline import policies
1214
from azure.core.rest import HttpRequest, HttpResponse
15+
from azure.core.settings import settings
1316
from azure.mgmt.core import ARMPipelineClient
17+
from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy
18+
from azure.mgmt.core.tools import get_arm_endpoints
1419

1520
from . import models as _models
1621
from ._configuration import ConsumptionManagementClientConfiguration
17-
from ._serialization import Deserializer, Serializer
22+
from ._utils.serialization import Deserializer, Serializer
1823
from .operations import (
1924
AggregatedCostOperations,
2025
BalancesOperations,
@@ -36,14 +41,15 @@
3641
)
3742

3843
if TYPE_CHECKING:
39-
# pylint: disable=unused-import,ungrouped-imports
4044
from azure.core.credentials import TokenCredential
4145

4246

43-
class ConsumptionManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes
47+
class ConsumptionManagementClient: # pylint: disable=too-many-instance-attributes
4448
"""Consumption management client provides access to consumption resources for Azure Enterprise
4549
Subscriptions.
4650
51+
:ivar price_sheet: PriceSheetOperations operations
52+
:vartype price_sheet: azure.mgmt.consumption.operations.PriceSheetOperations
4753
:ivar usage_details: UsageDetailsOperations operations
4854
:vartype usage_details: azure.mgmt.consumption.operations.UsageDetailsOperations
4955
:ivar marketplaces: MarketplacesOperations operations
@@ -70,8 +76,6 @@ class ConsumptionManagementClient: # pylint: disable=client-accepts-api-version
7076
:ivar reservation_transactions: ReservationTransactionsOperations operations
7177
:vartype reservation_transactions:
7278
azure.mgmt.consumption.operations.ReservationTransactionsOperations
73-
:ivar price_sheet: PriceSheetOperations operations
74-
:vartype price_sheet: azure.mgmt.consumption.operations.PriceSheetOperations
7579
:ivar operations: Operations operations
7680
:vartype operations: azure.mgmt.consumption.operations.Operations
7781
:ivar aggregated_cost: AggregatedCostOperations operations
@@ -86,29 +90,52 @@ class ConsumptionManagementClient: # pylint: disable=client-accepts-api-version
8690
:type credential: ~azure.core.credentials.TokenCredential
8791
:param subscription_id: Azure Subscription ID. Required.
8892
:type subscription_id: str
89-
:param base_url: Service URL. Default value is "https://management.azure.com".
93+
:param base_url: Service URL. Default value is None.
9094
:type base_url: str
91-
:keyword api_version: Api Version. Default value is "2021-10-01". Note that overriding this
95+
:keyword api_version: Api Version. Default value is "2025-04-01". Note that overriding this
9296
default value may result in unsupported behavior.
9397
:paramtype api_version: str
98+
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
99+
Retry-After header is present.
94100
"""
95101

96102
def __init__(
97-
self,
98-
credential: "TokenCredential",
99-
subscription_id: str,
100-
base_url: str = "https://management.azure.com",
101-
**kwargs: Any
103+
self, credential: "TokenCredential", subscription_id: str, base_url: Optional[str] = None, **kwargs: Any
102104
) -> None:
105+
_cloud = kwargs.pop("cloud_setting", None) or settings.current.azure_cloud # type: ignore
106+
_endpoints = get_arm_endpoints(_cloud)
107+
if not base_url:
108+
base_url = _endpoints["resource_manager"]
109+
credential_scopes = kwargs.pop("credential_scopes", _endpoints["credential_scopes"])
103110
self._config = ConsumptionManagementClientConfiguration(
104-
credential=credential, subscription_id=subscription_id, **kwargs
111+
credential=credential, subscription_id=subscription_id, credential_scopes=credential_scopes, **kwargs
105112
)
106-
self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs)
113+
114+
_policies = kwargs.pop("policies", None)
115+
if _policies is None:
116+
_policies = [
117+
policies.RequestIdPolicy(**kwargs),
118+
self._config.headers_policy,
119+
self._config.user_agent_policy,
120+
self._config.proxy_policy,
121+
policies.ContentDecodePolicy(**kwargs),
122+
ARMAutoResourceProviderRegistrationPolicy(),
123+
self._config.redirect_policy,
124+
self._config.retry_policy,
125+
self._config.authentication_policy,
126+
self._config.custom_hook_policy,
127+
self._config.logging_policy,
128+
policies.DistributedTracingPolicy(**kwargs),
129+
policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None,
130+
self._config.http_logging_policy,
131+
]
132+
self._client: ARMPipelineClient = ARMPipelineClient(base_url=cast(str, base_url), policies=_policies, **kwargs)
107133

108134
client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)}
109135
self._serialize = Serializer(client_models)
110136
self._deserialize = Deserializer(client_models)
111137
self._serialize.client_side_validation = False
138+
self.price_sheet = PriceSheetOperations(self._client, self._config, self._serialize, self._deserialize)
112139
self.usage_details = UsageDetailsOperations(self._client, self._config, self._serialize, self._deserialize)
113140
self.marketplaces = MarketplacesOperations(self._client, self._config, self._serialize, self._deserialize)
114141
self.budgets = BudgetsOperations(self._client, self._config, self._serialize, self._deserialize)
@@ -130,14 +157,13 @@ def __init__(
130157
self.reservation_transactions = ReservationTransactionsOperations(
131158
self._client, self._config, self._serialize, self._deserialize
132159
)
133-
self.price_sheet = PriceSheetOperations(self._client, self._config, self._serialize, self._deserialize)
134160
self.operations = Operations(self._client, self._config, self._serialize, self._deserialize)
135161
self.aggregated_cost = AggregatedCostOperations(self._client, self._config, self._serialize, self._deserialize)
136162
self.events = EventsOperations(self._client, self._config, self._serialize, self._deserialize)
137163
self.lots = LotsOperations(self._client, self._config, self._serialize, self._deserialize)
138164
self.credits = CreditsOperations(self._client, self._config, self._serialize, self._deserialize)
139165

140-
def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse:
166+
def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse:
141167
"""Runs the network request through the client's chained policies.
142168
143169
>>> from azure.core.rest import HttpRequest
@@ -157,14 +183,14 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse:
157183

158184
request_copy = deepcopy(request)
159185
request_copy.url = self._client.format_url(request_copy.url)
160-
return self._client.send_request(request_copy, **kwargs)
186+
return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore
161187

162188
def close(self) -> None:
163189
self._client.close()
164190

165-
def __enter__(self) -> "ConsumptionManagementClient":
191+
def __enter__(self) -> Self:
166192
self._client.__enter__()
167193
return self
168194

169-
def __exit__(self, *exc_details) -> None:
195+
def __exit__(self, *exc_details: Any) -> None:
170196
self._client.__exit__(*exc_details)

sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/_patch.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#
2626
# --------------------------------------------------------------------------
2727

28+
2829
# This file is used for handwritten extensions to the generated code. Example:
2930
# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md
3031
def patch_sdk():

0 commit comments

Comments
 (0)