Skip to content

Commit a0669e6

Browse files
author
SDKAuto
committed
CodeGen from PR 17458 in Azure/azure-rest-api-specs
Merge cc012e96cc9bb035f7e595ed954f175bf6186c92 into a4def98
1 parent c2c5fa4 commit a0669e6

File tree

58 files changed

+7978
-9049
lines changed

Some content is hidden

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

58 files changed

+7978
-9049
lines changed
Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
{
2-
"autorest": "3.3.0",
3-
"use": "@autorest/[email protected]",
4-
"commit": "1e43e60cfb0bb2829ff8d57a9ba06a2410f0b3c0",
2+
"autorest": "3.7.2",
3+
"use": [
4+
"@autorest/[email protected]",
5+
"@autorest/[email protected]"
6+
],
7+
"commit": "a64ff1c7b9466f6efc1bd4868782569d7efcce89",
58
"repository_url": "https://github.com/Azure/azure-rest-api-specs",
6-
"autorest_command": "autorest specification/billing/resource-manager/readme.md --multiapi --python --python-mode=update --python-sdks-folder=/home/vsts/work/1/s/azure-sdk-for-python/sdk --track2 --use=@autorest/python@5.6.6 --version=3.3.0",
9+
"autorest_command": "autorest specification/billing/resource-manager/readme.md --multiapi --python --python-mode=update --python-sdks-folder=/home/vsts/work/1/s/azure-sdk-for-python/sdk --python3-only --track2 --use=@autorest/python@5.12.0 --use=@autorest/[email protected] --version=3.7.2",
710
"readme": "specification/billing/resource-manager/readme.md"
811
}

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212
__version__ = VERSION
1313
__all__ = ['BillingManagementClient']
1414

15-
try:
16-
from ._patch import patch_sdk # type: ignore
17-
patch_sdk()
18-
except ImportError:
19-
pass
15+
# `._patch.py` is used for handwritten extensions to the generated code
16+
# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md
17+
from ._patch import patch_sdk
18+
patch_sdk()

sdk/billing/azure-mgmt-billing/azure/mgmt/billing/_billing_management_client.py

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

9-
from typing import TYPE_CHECKING
9+
from copy import deepcopy
10+
from typing import Any, Optional, TYPE_CHECKING
1011

12+
from azure.core.rest import HttpRequest, HttpResponse
1113
from azure.mgmt.core import ARMPipelineClient
1214
from msrest import Deserializer, Serializer
1315

16+
from . import models
17+
from ._configuration import BillingManagementClientConfiguration
18+
from .operations import AddressOperations, AgreementsOperations, AvailableBalancesOperations, BillingAccountsOperations, BillingPeriodsOperations, BillingPermissionsOperations, BillingProfilesOperations, BillingPropertyOperations, BillingRoleAssignmentsOperations, BillingRoleDefinitionsOperations, BillingSubscriptionsOperations, CustomersOperations, EnrollmentAccountsOperations, InstructionsOperations, InvoiceSectionsOperations, InvoicesOperations, Operations, PoliciesOperations, ProductsOperations, ReservationsOperations, TransactionsOperations
19+
1420
if TYPE_CHECKING:
1521
# pylint: disable=unused-import,ungrouped-imports
16-
from typing import Any, Optional
17-
1822
from azure.core.credentials import TokenCredential
19-
from azure.core.pipeline.transport import HttpRequest, HttpResponse
20-
21-
from ._configuration import BillingManagementClientConfiguration
22-
from .operations import BillingAccountsOperations
23-
from .operations import AddressOperations
24-
from .operations import AvailableBalancesOperations
25-
from .operations import InstructionsOperations
26-
from .operations import BillingProfilesOperations
27-
from .operations import CustomersOperations
28-
from .operations import InvoiceSectionsOperations
29-
from .operations import BillingPermissionsOperations
30-
from .operations import BillingSubscriptionsOperations
31-
from .operations import ProductsOperations
32-
from .operations import InvoicesOperations
33-
from .operations import TransactionsOperations
34-
from .operations import PoliciesOperations
35-
from .operations import BillingPropertyOperations
36-
from .operations import Operations
37-
from .operations import BillingRoleDefinitionsOperations
38-
from .operations import BillingRoleAssignmentsOperations
39-
from .operations import AgreementsOperations
40-
from .operations import ReservationsOperations
41-
from .operations import EnrollmentAccountsOperations
42-
from .operations import BillingPeriodsOperations
43-
from . import models
44-
4523

46-
class BillingManagementClient(object):
24+
class BillingManagementClient:
4725
"""Billing client provides access to billing resources for Azure subscriptions.
4826
4927
:ivar billing_accounts: BillingAccountsOperations operations
@@ -77,9 +55,11 @@ class BillingManagementClient(object):
7755
:ivar operations: Operations operations
7856
:vartype operations: azure.mgmt.billing.operations.Operations
7957
:ivar billing_role_definitions: BillingRoleDefinitionsOperations operations
80-
:vartype billing_role_definitions: azure.mgmt.billing.operations.BillingRoleDefinitionsOperations
58+
:vartype billing_role_definitions:
59+
azure.mgmt.billing.operations.BillingRoleDefinitionsOperations
8160
:ivar billing_role_assignments: BillingRoleAssignmentsOperations operations
82-
:vartype billing_role_assignments: azure.mgmt.billing.operations.BillingRoleAssignmentsOperations
61+
:vartype billing_role_assignments:
62+
azure.mgmt.billing.operations.BillingRoleAssignmentsOperations
8363
:ivar agreements: AgreementsOperations operations
8464
:vartype agreements: azure.mgmt.billing.operations.AgreementsOperations
8565
:ivar reservations: ReservationsOperations operations
@@ -92,88 +72,74 @@ class BillingManagementClient(object):
9272
:type credential: ~azure.core.credentials.TokenCredential
9373
:param subscription_id: The ID that uniquely identifies an Azure subscription.
9474
:type subscription_id: str
95-
:param str base_url: Service URL
96-
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present.
75+
:param base_url: Service URL. Default value is 'https://management.azure.com'.
76+
:type base_url: str
77+
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
78+
Retry-After header is present.
9779
"""
9880

9981
def __init__(
10082
self,
101-
credential, # type: "TokenCredential"
102-
subscription_id, # type: str
103-
base_url=None, # type: Optional[str]
104-
**kwargs # type: Any
105-
):
106-
# type: (...) -> None
107-
if not base_url:
108-
base_url = 'https://management.azure.com'
109-
self._config = BillingManagementClientConfiguration(credential, subscription_id, **kwargs)
83+
credential: "TokenCredential",
84+
subscription_id: str,
85+
base_url: str = "https://management.azure.com",
86+
**kwargs: Any
87+
) -> None:
88+
self._config = BillingManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs)
11089
self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs)
11190

11291
client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
11392
self._serialize = Serializer(client_models)
114-
self._serialize.client_side_validation = False
11593
self._deserialize = Deserializer(client_models)
116-
117-
self.billing_accounts = BillingAccountsOperations(
118-
self._client, self._config, self._serialize, self._deserialize)
119-
self.address = AddressOperations(
120-
self._client, self._config, self._serialize, self._deserialize)
121-
self.available_balances = AvailableBalancesOperations(
122-
self._client, self._config, self._serialize, self._deserialize)
123-
self.instructions = InstructionsOperations(
124-
self._client, self._config, self._serialize, self._deserialize)
125-
self.billing_profiles = BillingProfilesOperations(
126-
self._client, self._config, self._serialize, self._deserialize)
127-
self.customers = CustomersOperations(
128-
self._client, self._config, self._serialize, self._deserialize)
129-
self.invoice_sections = InvoiceSectionsOperations(
130-
self._client, self._config, self._serialize, self._deserialize)
131-
self.billing_permissions = BillingPermissionsOperations(
132-
self._client, self._config, self._serialize, self._deserialize)
133-
self.billing_subscriptions = BillingSubscriptionsOperations(
134-
self._client, self._config, self._serialize, self._deserialize)
135-
self.products = ProductsOperations(
136-
self._client, self._config, self._serialize, self._deserialize)
137-
self.invoices = InvoicesOperations(
138-
self._client, self._config, self._serialize, self._deserialize)
139-
self.transactions = TransactionsOperations(
140-
self._client, self._config, self._serialize, self._deserialize)
141-
self.policies = PoliciesOperations(
142-
self._client, self._config, self._serialize, self._deserialize)
143-
self.billing_property = BillingPropertyOperations(
144-
self._client, self._config, self._serialize, self._deserialize)
145-
self.operations = Operations(
146-
self._client, self._config, self._serialize, self._deserialize)
147-
self.billing_role_definitions = BillingRoleDefinitionsOperations(
148-
self._client, self._config, self._serialize, self._deserialize)
149-
self.billing_role_assignments = BillingRoleAssignmentsOperations(
150-
self._client, self._config, self._serialize, self._deserialize)
151-
self.agreements = AgreementsOperations(
152-
self._client, self._config, self._serialize, self._deserialize)
153-
self.reservations = ReservationsOperations(
154-
self._client, self._config, self._serialize, self._deserialize)
155-
self.enrollment_accounts = EnrollmentAccountsOperations(
156-
self._client, self._config, self._serialize, self._deserialize)
157-
self.billing_periods = BillingPeriodsOperations(
158-
self._client, self._config, self._serialize, self._deserialize)
159-
160-
def _send_request(self, http_request, **kwargs):
161-
# type: (HttpRequest, Any) -> HttpResponse
94+
self._serialize.client_side_validation = False
95+
self.billing_accounts = BillingAccountsOperations(self._client, self._config, self._serialize, self._deserialize)
96+
self.address = AddressOperations(self._client, self._config, self._serialize, self._deserialize)
97+
self.available_balances = AvailableBalancesOperations(self._client, self._config, self._serialize, self._deserialize)
98+
self.instructions = InstructionsOperations(self._client, self._config, self._serialize, self._deserialize)
99+
self.billing_profiles = BillingProfilesOperations(self._client, self._config, self._serialize, self._deserialize)
100+
self.customers = CustomersOperations(self._client, self._config, self._serialize, self._deserialize)
101+
self.invoice_sections = InvoiceSectionsOperations(self._client, self._config, self._serialize, self._deserialize)
102+
self.billing_permissions = BillingPermissionsOperations(self._client, self._config, self._serialize, self._deserialize)
103+
self.billing_subscriptions = BillingSubscriptionsOperations(self._client, self._config, self._serialize, self._deserialize)
104+
self.products = ProductsOperations(self._client, self._config, self._serialize, self._deserialize)
105+
self.invoices = InvoicesOperations(self._client, self._config, self._serialize, self._deserialize)
106+
self.transactions = TransactionsOperations(self._client, self._config, self._serialize, self._deserialize)
107+
self.policies = PoliciesOperations(self._client, self._config, self._serialize, self._deserialize)
108+
self.billing_property = BillingPropertyOperations(self._client, self._config, self._serialize, self._deserialize)
109+
self.operations = Operations(self._client, self._config, self._serialize, self._deserialize)
110+
self.billing_role_definitions = BillingRoleDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize)
111+
self.billing_role_assignments = BillingRoleAssignmentsOperations(self._client, self._config, self._serialize, self._deserialize)
112+
self.agreements = AgreementsOperations(self._client, self._config, self._serialize, self._deserialize)
113+
self.reservations = ReservationsOperations(self._client, self._config, self._serialize, self._deserialize)
114+
self.enrollment_accounts = EnrollmentAccountsOperations(self._client, self._config, self._serialize, self._deserialize)
115+
self.billing_periods = BillingPeriodsOperations(self._client, self._config, self._serialize, self._deserialize)
116+
117+
118+
def _send_request(
119+
self,
120+
request, # type: HttpRequest
121+
**kwargs: Any
122+
) -> HttpResponse:
162123
"""Runs the network request through the client's chained policies.
163124
164-
:param http_request: The network request you want to make. Required.
165-
:type http_request: ~azure.core.pipeline.transport.HttpRequest
166-
:keyword bool stream: Whether the response payload will be streamed. Defaults to True.
125+
>>> from azure.core.rest import HttpRequest
126+
>>> request = HttpRequest("GET", "https://www.example.org/")
127+
<HttpRequest [GET], url: 'https://www.example.org/'>
128+
>>> response = client._send_request(request)
129+
<HttpResponse: 200 OK>
130+
131+
For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart
132+
133+
:param request: The network request you want to make. Required.
134+
:type request: ~azure.core.rest.HttpRequest
135+
:keyword bool stream: Whether the response payload will be streamed. Defaults to False.
167136
:return: The response of your network call. Does not do error handling on your response.
168-
:rtype: ~azure.core.pipeline.transport.HttpResponse
137+
:rtype: ~azure.core.rest.HttpResponse
169138
"""
170-
path_format_arguments = {
171-
'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'),
172-
}
173-
http_request.url = self._client.format_url(http_request.url, **path_format_arguments)
174-
stream = kwargs.pop("stream", True)
175-
pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs)
176-
return pipeline_response.http_response
139+
140+
request_copy = deepcopy(request)
141+
request_copy.url = self._client.format_url(request_copy.url)
142+
return self._client.send_request(request_copy, **kwargs)
177143

178144
def close(self):
179145
# type: () -> None

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

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

9-
from typing import TYPE_CHECKING
9+
from typing import Any, TYPE_CHECKING
1010

1111
from azure.core.configuration import Configuration
1212
from azure.core.pipeline import policies
13-
from azure.mgmt.core.policies import ARMHttpLoggingPolicy
13+
from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy
1414

1515
from ._version import VERSION
1616

1717
if TYPE_CHECKING:
1818
# pylint: disable=unused-import,ungrouped-imports
19-
from typing import Any
20-
2119
from azure.core.credentials import TokenCredential
2220

2321

@@ -35,16 +33,15 @@ class BillingManagementClientConfiguration(Configuration):
3533

3634
def __init__(
3735
self,
38-
credential, # type: "TokenCredential"
39-
subscription_id, # type: str
40-
**kwargs # type: Any
41-
):
42-
# type: (...) -> None
36+
credential: "TokenCredential",
37+
subscription_id: str,
38+
**kwargs: Any
39+
) -> None:
40+
super(BillingManagementClientConfiguration, self).__init__(**kwargs)
4341
if credential is None:
4442
raise ValueError("Parameter 'credential' must not be None.")
4543
if subscription_id is None:
4644
raise ValueError("Parameter 'subscription_id' must not be None.")
47-
super(BillingManagementClientConfiguration, self).__init__(**kwargs)
4845

4946
self.credential = credential
5047
self.subscription_id = subscription_id
@@ -67,4 +64,4 @@ def _configure(
6764
self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs)
6865
self.authentication_policy = kwargs.get('authentication_policy')
6966
if self.credential and not self.authentication_policy:
70-
self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs)
67+
self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)

0 commit comments

Comments
 (0)