Skip to content

Commit 3cb5160

Browse files
author
SDKAuto
committed
CodeGen from PR 18208 in Azure/azure-rest-api-specs
Merge 4772ab9f3e13afc920d577bea23077ec30e32528 into 2abe647120f14bb145968a5543ead8ed51394498
1 parent 14ff5a8 commit 3cb5160

32 files changed

+4834
-4748
lines changed
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
2-
"autorest": "3.4.2",
2+
"autorest": "3.7.2",
33
"use": [
4-
"@autorest/python@5.8.0",
5-
"@autorest/[email protected].1"
4+
"@autorest/python@5.12.0",
5+
"@autorest/[email protected].3"
66
],
7-
"commit": "aac59eea2fb1c142fd371c9c1886f33713e494a2",
7+
"commit": "d6191d641c750189751bde4466749fa589265abc",
88
"repository_url": "https://github.com/Azure/azure-rest-api-specs",
9-
"autorest_command": "autorest specification/reservations/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.8.0 --use=@autorest/[email protected].1 --version=3.4.2",
9+
"autorest_command": "autorest specification/reservations/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].3 --version=3.7.2",
1010
"readme": "specification/reservations/resource-manager/readme.md"
1111
}

sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/__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__ = ['AzureReservationAPI']
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/reservations/azure-mgmt-reservations/azure/mgmt/reservations/_azure_reservation_api.py

Lines changed: 46 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,20 @@
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 AzureReservationAPIConfiguration
18+
from .operations import AzureReservationAPIOperationsMixin, CalculateExchangeOperations, ExchangeOperations, OperationOperations, QuotaOperations, QuotaRequestStatusOperations, ReservationOperations, ReservationOrderOperations
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 AzureReservationAPIConfiguration
22-
from .operations import ReservationOperations
23-
from .operations import AzureReservationAPIOperationsMixin
24-
from .operations import ReservationOrderOperations
25-
from .operations import OperationOperations
26-
from .operations import CalculateExchangeOperations
27-
from .operations import ExchangeOperations
28-
from .operations import QuotaOperations
29-
from .operations import QuotaRequestStatusOperations
30-
from . import models
31-
3223

3324
class AzureReservationAPI(AzureReservationAPIOperationsMixin):
3425
"""This API describe Azure Reservation.
@@ -49,56 +40,59 @@ class AzureReservationAPI(AzureReservationAPIOperationsMixin):
4940
:vartype quota_request_status: azure.mgmt.reservations.operations.QuotaRequestStatusOperations
5041
:param credential: Credential needed for the client to connect to Azure.
5142
:type credential: ~azure.core.credentials.TokenCredential
52-
:param str base_url: Service URL
53-
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present.
43+
:param base_url: Service URL. Default value is 'https://management.azure.com'.
44+
:type base_url: str
45+
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
46+
Retry-After header is present.
5447
"""
5548

5649
def __init__(
5750
self,
58-
credential, # type: "TokenCredential"
59-
base_url=None, # type: Optional[str]
60-
**kwargs # type: Any
61-
):
62-
# type: (...) -> None
63-
if not base_url:
64-
base_url = 'https://management.azure.com'
65-
self._config = AzureReservationAPIConfiguration(credential, **kwargs)
51+
credential: "TokenCredential",
52+
base_url: str = "https://management.azure.com",
53+
**kwargs: Any
54+
) -> None:
55+
self._config = AzureReservationAPIConfiguration(credential=credential, **kwargs)
6656
self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs)
6757

6858
client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
6959
self._serialize = Serializer(client_models)
70-
self._serialize.client_side_validation = False
7160
self._deserialize = Deserializer(client_models)
61+
self._serialize.client_side_validation = False
62+
self.reservation = ReservationOperations(self._client, self._config, self._serialize, self._deserialize)
63+
self.reservation_order = ReservationOrderOperations(self._client, self._config, self._serialize, self._deserialize)
64+
self.operation = OperationOperations(self._client, self._config, self._serialize, self._deserialize)
65+
self.calculate_exchange = CalculateExchangeOperations(self._client, self._config, self._serialize, self._deserialize)
66+
self.exchange = ExchangeOperations(self._client, self._config, self._serialize, self._deserialize)
67+
self.quota = QuotaOperations(self._client, self._config, self._serialize, self._deserialize)
68+
self.quota_request_status = QuotaRequestStatusOperations(self._client, self._config, self._serialize, self._deserialize)
7269

73-
self.reservation = ReservationOperations(
74-
self._client, self._config, self._serialize, self._deserialize)
75-
self.reservation_order = ReservationOrderOperations(
76-
self._client, self._config, self._serialize, self._deserialize)
77-
self.operation = OperationOperations(
78-
self._client, self._config, self._serialize, self._deserialize)
79-
self.calculate_exchange = CalculateExchangeOperations(
80-
self._client, self._config, self._serialize, self._deserialize)
81-
self.exchange = ExchangeOperations(
82-
self._client, self._config, self._serialize, self._deserialize)
83-
self.quota = QuotaOperations(
84-
self._client, self._config, self._serialize, self._deserialize)
85-
self.quota_request_status = QuotaRequestStatusOperations(
86-
self._client, self._config, self._serialize, self._deserialize)
87-
88-
def _send_request(self, http_request, **kwargs):
89-
# type: (HttpRequest, Any) -> HttpResponse
70+
71+
def _send_request(
72+
self,
73+
request, # type: HttpRequest
74+
**kwargs: Any
75+
) -> HttpResponse:
9076
"""Runs the network request through the client's chained policies.
9177
92-
:param http_request: The network request you want to make. Required.
93-
:type http_request: ~azure.core.pipeline.transport.HttpRequest
94-
:keyword bool stream: Whether the response payload will be streamed. Defaults to True.
78+
>>> from azure.core.rest import HttpRequest
79+
>>> request = HttpRequest("GET", "https://www.example.org/")
80+
<HttpRequest [GET], url: 'https://www.example.org/'>
81+
>>> response = client._send_request(request)
82+
<HttpResponse: 200 OK>
83+
84+
For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart
85+
86+
:param request: The network request you want to make. Required.
87+
:type request: ~azure.core.rest.HttpRequest
88+
:keyword bool stream: Whether the response payload will be streamed. Defaults to False.
9589
:return: The response of your network call. Does not do error handling on your response.
96-
:rtype: ~azure.core.pipeline.transport.HttpResponse
90+
:rtype: ~azure.core.rest.HttpResponse
9791
"""
98-
http_request.url = self._client.format_url(http_request.url)
99-
stream = kwargs.pop("stream", True)
100-
pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs)
101-
return pipeline_response.http_response
92+
93+
request_copy = deepcopy(request)
94+
request_copy.url = self._client.format_url(request_copy.url)
95+
return self._client.send_request(request_copy, **kwargs)
10296

10397
def close(self):
10498
# type: () -> None

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

Lines changed: 7 additions & 10 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

@@ -33,13 +31,12 @@ class AzureReservationAPIConfiguration(Configuration):
3331

3432
def __init__(
3533
self,
36-
credential, # type: "TokenCredential"
37-
**kwargs # type: Any
38-
):
39-
# type: (...) -> None
34+
credential: "TokenCredential",
35+
**kwargs: Any
36+
) -> None:
37+
super(AzureReservationAPIConfiguration, self).__init__(**kwargs)
4038
if credential is None:
4139
raise ValueError("Parameter 'credential' must not be None.")
42-
super(AzureReservationAPIConfiguration, self).__init__(**kwargs)
4340

4441
self.credential = credential
4542
self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default'])
@@ -61,4 +58,4 @@ def _configure(
6158
self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs)
6259
self.authentication_policy = kwargs.get('authentication_policy')
6360
if self.credential and not self.authentication_policy:
64-
self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs)
61+
self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)

0 commit comments

Comments
 (0)