6
6
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
7
7
# --------------------------------------------------------------------------
8
8
9
- from typing import TYPE_CHECKING
9
+ from copy import deepcopy
10
+ from typing import Any , Optional , TYPE_CHECKING
10
11
12
+ from azure .core .rest import HttpRequest , HttpResponse
11
13
from azure .mgmt .core import ARMPipelineClient
12
14
from msrest import Deserializer , Serializer
13
15
16
+ from . import models
17
+ from ._configuration import AzureReservationAPIConfiguration
18
+ from .operations import AzureReservationAPIOperationsMixin , CalculateExchangeOperations , ExchangeOperations , OperationOperations , QuotaOperations , QuotaRequestStatusOperations , ReservationOperations , ReservationOrderOperations
19
+
14
20
if TYPE_CHECKING :
15
21
# pylint: disable=unused-import,ungrouped-imports
16
- from typing import Any , Optional
17
-
18
22
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
-
32
23
33
24
class AzureReservationAPI (AzureReservationAPIOperationsMixin ):
34
25
"""This API describe Azure Reservation.
@@ -49,56 +40,59 @@ class AzureReservationAPI(AzureReservationAPIOperationsMixin):
49
40
:vartype quota_request_status: azure.mgmt.reservations.operations.QuotaRequestStatusOperations
50
41
:param credential: Credential needed for the client to connect to Azure.
51
42
: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.
54
47
"""
55
48
56
49
def __init__ (
57
50
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 )
66
56
self ._client = ARMPipelineClient (base_url = base_url , config = self ._config , ** kwargs )
67
57
68
58
client_models = {k : v for k , v in models .__dict__ .items () if isinstance (v , type )}
69
59
self ._serialize = Serializer (client_models )
70
- self ._serialize .client_side_validation = False
71
60
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 )
72
69
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 :
90
76
"""Runs the network request through the client's chained policies.
91
77
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.
95
89
: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
97
91
"""
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 )
102
96
103
97
def close (self ):
104
98
# type: () -> None
0 commit comments