Skip to content

Commit 9e65d54

Browse files
author
SDKAuto
committed
CodeGen from PR 33456 in Azure/azure-rest-api-specs
Merge f7ecbda47cca50e78dfef5457ba1f293bc971f23 into 9b3e29902644a7bb9317d68f249c7cb8b11d82cf
1 parent 7656cf2 commit 9e65d54

File tree

79 files changed

+8256
-1600
lines changed

Some content is hidden

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

79 files changed

+8256
-1600
lines changed
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 Billingbenefits Management Client Library.
4-
This package has been tested with Python 3.7+.
4+
This package has been tested with Python 3.8+.
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/)
17-
Code samples for this package can be found at [Billingbenefits Management](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://aka.ms/azsdk/python/mgmt/samples)
15+
- Python 3.8+ 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-billingbenefits
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 configure of 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.billingbenefits import BillingBenefitsRP
40+
import os
2641

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

46+
## Examples
2847

48+
Code samples for this package can be found at:
49+
- [Search Billingbenefits Management](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": "9b3aa35e75751e751070a7af1f96518cb8820e44",
2+
"commit": "28ddbd460d515cf7d15c335edbbff89b1d8416e5",
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.27.4",
7+
"@autorest/modelerfour@4.27.0"
88
],
9-
"autorest_command": "autorest specification/billingbenefits/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/billingbenefits/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.27.4 --use=@autorest/modelerfour@4.27.0 --version=3.10.2 --version-tolerant=False",
1010
"readme": "specification/billingbenefits/resource-manager/readme.md"
1111
}

sdk/billingbenefits/azure-mgmt-billingbenefits/azure/mgmt/billingbenefits/__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 ._billing_benefits_rp import BillingBenefitsRP
10+
from typing import TYPE_CHECKING
11+
12+
if TYPE_CHECKING:
13+
from ._patch import * # pylint: disable=unused-wildcard-import
14+
15+
from ._billing_benefits_rp import BillingBenefitsRP # 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
"BillingBenefitsRP",
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/billingbenefits/azure-mgmt-billingbenefits/azure/mgmt/billingbenefits/_billing_benefits_rp.py

Lines changed: 43 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,20 @@
88

99
from copy import deepcopy
1010
from typing import Any, Optional, TYPE_CHECKING
11+
from typing_extensions import Self
1112

13+
from azure.core.pipeline import policies
1214
from azure.core.rest import HttpRequest, HttpResponse
1315
from azure.mgmt.core import ARMPipelineClient
16+
from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy
1417

1518
from . import models as _models
1619
from ._configuration import BillingBenefitsRPConfiguration
1720
from ._serialization import Deserializer, Serializer
1821
from .operations import (
1922
BillingBenefitsRPOperationsMixin,
23+
DiscountOperations,
24+
DiscountsOperations,
2025
Operations,
2126
ReservationOrderAliasOperations,
2227
SavingsPlanOperations,
@@ -25,11 +30,10 @@
2530
)
2631

2732
if TYPE_CHECKING:
28-
# pylint: disable=unused-import,ungrouped-imports
2933
from azure.core.credentials import TokenCredential
3034

3135

32-
class BillingBenefitsRP(BillingBenefitsRPOperationsMixin): # pylint: disable=client-accepts-api-version-keyword
36+
class BillingBenefitsRP(BillingBenefitsRPOperationsMixin): # pylint: disable=too-many-instance-attributes
3337
"""Azure Benefits RP let users create and manage benefits like savings plan.
3438
3539
:ivar operations: Operations operations
@@ -44,15 +48,21 @@ class BillingBenefitsRP(BillingBenefitsRPOperationsMixin): # pylint: disable=cl
4448
:ivar reservation_order_alias: ReservationOrderAliasOperations operations
4549
:vartype reservation_order_alias:
4650
azure.mgmt.billingbenefits.operations.ReservationOrderAliasOperations
51+
:ivar discounts: DiscountsOperations operations
52+
:vartype discounts: azure.mgmt.billingbenefits.operations.DiscountsOperations
53+
:ivar discount: DiscountOperations operations
54+
:vartype discount: azure.mgmt.billingbenefits.operations.DiscountOperations
4755
:param credential: Credential needed for the client to connect to Azure. Required.
4856
:type credential: ~azure.core.credentials.TokenCredential
57+
:param subscription_id: The ID of the target subscription. The value must be an UUID. Required.
58+
:type subscription_id: str
4959
:param expand: May be used to expand the detail information of some properties. Default value
5060
is None.
5161
:type expand: str
5262
:param base_url: Service URL. Default value is "https://management.azure.com".
5363
:type base_url: str
54-
:keyword api_version: Api Version. Default value is "2022-11-01". Note that overriding this
55-
default value may result in unsupported behavior.
64+
:keyword api_version: Api Version. Default value is "2024-11-01-preview". Note that overriding
65+
this default value may result in unsupported behavior.
5666
:paramtype api_version: str
5767
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
5868
Retry-After header is present.
@@ -61,12 +71,33 @@ class BillingBenefitsRP(BillingBenefitsRPOperationsMixin): # pylint: disable=cl
6171
def __init__(
6272
self,
6373
credential: "TokenCredential",
74+
subscription_id: str,
6475
expand: Optional[str] = None,
6576
base_url: str = "https://management.azure.com",
6677
**kwargs: Any
6778
) -> None:
68-
self._config = BillingBenefitsRPConfiguration(credential=credential, expand=expand, **kwargs)
69-
self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs)
79+
self._config = BillingBenefitsRPConfiguration(
80+
credential=credential, subscription_id=subscription_id, expand=expand, **kwargs
81+
)
82+
_policies = kwargs.pop("policies", None)
83+
if _policies is None:
84+
_policies = [
85+
policies.RequestIdPolicy(**kwargs),
86+
self._config.headers_policy,
87+
self._config.user_agent_policy,
88+
self._config.proxy_policy,
89+
policies.ContentDecodePolicy(**kwargs),
90+
ARMAutoResourceProviderRegistrationPolicy(),
91+
self._config.redirect_policy,
92+
self._config.retry_policy,
93+
self._config.authentication_policy,
94+
self._config.custom_hook_policy,
95+
self._config.logging_policy,
96+
policies.DistributedTracingPolicy(**kwargs),
97+
policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None,
98+
self._config.http_logging_policy,
99+
]
100+
self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **kwargs)
70101

71102
client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)}
72103
self._serialize = Serializer(client_models)
@@ -83,8 +114,10 @@ def __init__(
83114
self.reservation_order_alias = ReservationOrderAliasOperations(
84115
self._client, self._config, self._serialize, self._deserialize
85116
)
117+
self.discounts = DiscountsOperations(self._client, self._config, self._serialize, self._deserialize)
118+
self.discount = DiscountOperations(self._client, self._config, self._serialize, self._deserialize)
86119

87-
def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse:
120+
def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse:
88121
"""Runs the network request through the client's chained policies.
89122
90123
>>> from azure.core.rest import HttpRequest
@@ -104,14 +137,14 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse:
104137

105138
request_copy = deepcopy(request)
106139
request_copy.url = self._client.format_url(request_copy.url)
107-
return self._client.send_request(request_copy, **kwargs)
140+
return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore
108141

109142
def close(self) -> None:
110143
self._client.close()
111144

112-
def __enter__(self) -> "BillingBenefitsRP":
145+
def __enter__(self) -> Self:
113146
self._client.__enter__()
114147
return self
115148

116-
def __exit__(self, *exc_details) -> None:
149+
def __exit__(self, *exc_details: Any) -> None:
117150
self._client.__exit__(*exc_details)

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

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,53 +6,52 @@
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, Optional, 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 BillingBenefitsRPConfiguration(Configuration): # pylint: disable=too-many-instance-attributes
20+
class BillingBenefitsRPConfiguration: # pylint: disable=too-many-instance-attributes
2921
"""Configuration for BillingBenefitsRP.
3022
3123
Note that all parameters used to create this instance are saved as instance
3224
attributes.
3325
3426
:param credential: Credential needed for the client to connect to Azure. Required.
3527
:type credential: ~azure.core.credentials.TokenCredential
28+
:param subscription_id: The ID of the target subscription. The value must be an UUID. Required.
29+
:type subscription_id: str
3630
:param expand: May be used to expand the detail information of some properties. Default value
3731
is None.
3832
:type expand: str
39-
:keyword api_version: Api Version. Default value is "2022-11-01". Note that overriding this
40-
default value may result in unsupported behavior.
33+
:keyword api_version: Api Version. Default value is "2024-11-01-preview". Note that overriding
34+
this default value may result in unsupported behavior.
4135
:paramtype api_version: str
4236
"""
4337

44-
def __init__(self, credential: "TokenCredential", expand: Optional[str] = None, **kwargs: Any) -> None:
45-
super(BillingBenefitsRPConfiguration, self).__init__(**kwargs)
46-
api_version: Literal["2022-11-01"] = kwargs.pop("api_version", "2022-11-01")
38+
def __init__(
39+
self, credential: "TokenCredential", subscription_id: str, expand: Optional[str] = None, **kwargs: Any
40+
) -> None:
41+
api_version: str = kwargs.pop("api_version", "2024-11-01-preview")
4742

4843
if credential is None:
4944
raise ValueError("Parameter 'credential' must not be None.")
45+
if subscription_id is None:
46+
raise ValueError("Parameter 'subscription_id' must not be None.")
5047

5148
self.credential = credential
49+
self.subscription_id = subscription_id
5250
self.expand = expand
5351
self.api_version = api_version
5452
self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"])
5553
kwargs.setdefault("sdk_moniker", "mgmt-billingbenefits/{}".format(VERSION))
54+
self.polling_interval = kwargs.get("polling_interval", 30)
5655
self._configure(**kwargs)
5756

5857
def _configure(self, **kwargs: Any) -> None:
@@ -61,9 +60,9 @@ def _configure(self, **kwargs: Any) -> None:
6160
self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs)
6261
self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs)
6362
self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs)
64-
self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs)
6563
self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs)
6664
self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs)
65+
self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs)
6766
self.authentication_policy = kwargs.get("authentication_policy")
6867
if self.credential and not self.authentication_policy:
6968
self.authentication_policy = ARMChallengeAuthenticationPolicy(

0 commit comments

Comments
 (0)