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 CostManagementClientConfiguration
18
+ from .operations import AlertsOperations , DimensionsOperations , ExportsOperations , ForecastOperations , GenerateDetailedCostReportOperationResultsOperations , GenerateDetailedCostReportOperationStatusOperations , GenerateDetailedCostReportOperations , Operations , QueryOperations , ViewsOperations
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 CostManagementClientConfiguration
22
- from .operations import SettingsOperations
23
- from .operations import ViewsOperations
24
- from .operations import AlertsOperations
25
- from .operations import ForecastOperations
26
- from .operations import DimensionsOperations
27
- from .operations import QueryOperations
28
- from .operations import GenerateReservationDetailsReportOperations
29
- from .operations import Operations
30
- from .operations import ExportsOperations
31
- from . import models
32
-
33
23
34
- class CostManagementClient ( object ) :
24
+ class CostManagementClient :
35
25
"""CostManagementClient.
36
26
37
- :ivar settings: SettingsOperations operations
38
- :vartype settings: azure.mgmt.costmanagement.operations.SettingsOperations
27
+ :ivar exports: ExportsOperations operations
28
+ :vartype exports: azure.mgmt.costmanagement.operations.ExportsOperations
29
+ :ivar generate_detailed_cost_report: GenerateDetailedCostReportOperations operations
30
+ :vartype generate_detailed_cost_report:
31
+ azure.mgmt.costmanagement.operations.GenerateDetailedCostReportOperations
32
+ :ivar generate_detailed_cost_report_operation_results:
33
+ GenerateDetailedCostReportOperationResultsOperations operations
34
+ :vartype generate_detailed_cost_report_operation_results:
35
+ azure.mgmt.costmanagement.operations.GenerateDetailedCostReportOperationResultsOperations
36
+ :ivar generate_detailed_cost_report_operation_status:
37
+ GenerateDetailedCostReportOperationStatusOperations operations
38
+ :vartype generate_detailed_cost_report_operation_status:
39
+ azure.mgmt.costmanagement.operations.GenerateDetailedCostReportOperationStatusOperations
39
40
:ivar views: ViewsOperations operations
40
41
:vartype views: azure.mgmt.costmanagement.operations.ViewsOperations
41
42
:ivar alerts: AlertsOperations operations
@@ -46,68 +47,66 @@ class CostManagementClient(object):
46
47
:vartype dimensions: azure.mgmt.costmanagement.operations.DimensionsOperations
47
48
:ivar query: QueryOperations operations
48
49
:vartype query: azure.mgmt.costmanagement.operations.QueryOperations
49
- :ivar generate_reservation_details_report: GenerateReservationDetailsReportOperations operations
50
- :vartype generate_reservation_details_report: azure.mgmt.costmanagement.operations.GenerateReservationDetailsReportOperations
51
50
:ivar operations: Operations operations
52
51
:vartype operations: azure.mgmt.costmanagement.operations.Operations
53
- :ivar exports: ExportsOperations operations
54
- :vartype exports: azure.mgmt.costmanagement.operations.ExportsOperations
55
52
:param credential: Credential needed for the client to connect to Azure.
56
53
:type credential: ~azure.core.credentials.TokenCredential
57
- :param str base_url: Service URL
58
- :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present.
54
+ :param base_url: Service URL. Default value is 'https://management.azure.com'.
55
+ :type base_url: str
56
+ :keyword int polling_interval: Default waiting time between two polls for LRO operations if no
57
+ Retry-After header is present.
59
58
"""
60
59
61
60
def __init__ (
62
61
self ,
63
- credential , # type: "TokenCredential"
64
- base_url = None , # type: Optional[str]
65
- ** kwargs # type: Any
66
- ):
67
- # type: (...) -> None
68
- if not base_url :
69
- base_url = 'https://management.azure.com'
70
- self ._config = CostManagementClientConfiguration (credential , ** kwargs )
62
+ credential : "TokenCredential" ,
63
+ base_url : str = "https://management.azure.com" ,
64
+ ** kwargs : Any
65
+ ) -> None :
66
+ self ._config = CostManagementClientConfiguration (credential = credential , ** kwargs )
71
67
self ._client = ARMPipelineClient (base_url = base_url , config = self ._config , ** kwargs )
72
68
73
69
client_models = {k : v for k , v in models .__dict__ .items () if isinstance (v , type )}
74
70
self ._serialize = Serializer (client_models )
75
- self ._serialize .client_side_validation = False
76
71
self ._deserialize = Deserializer (client_models )
77
-
78
- self .settings = SettingsOperations (
79
- self ._client , self ._config , self ._serialize , self ._deserialize )
80
- self .views = ViewsOperations (
81
- self ._client , self ._config , self ._serialize , self ._deserialize )
82
- self .alerts = AlertsOperations (
83
- self ._client , self ._config , self ._serialize , self ._deserialize )
84
- self .forecast = ForecastOperations (
85
- self ._client , self ._config , self ._serialize , self ._deserialize )
86
- self .dimensions = DimensionsOperations (
87
- self ._client , self ._config , self ._serialize , self ._deserialize )
88
- self .query = QueryOperations (
89
- self ._client , self ._config , self ._serialize , self ._deserialize )
90
- self .generate_reservation_details_report = GenerateReservationDetailsReportOperations (
91
- self ._client , self ._config , self ._serialize , self ._deserialize )
92
- self .operations = Operations (
93
- self ._client , self ._config , self ._serialize , self ._deserialize )
94
- self .exports = ExportsOperations (
95
- self ._client , self ._config , self ._serialize , self ._deserialize )
96
-
97
- def _send_request (self , http_request , ** kwargs ):
98
- # type: (HttpRequest, Any) -> HttpResponse
72
+ self ._serialize .client_side_validation = False
73
+ self .exports = ExportsOperations (self ._client , self ._config , self ._serialize , self ._deserialize )
74
+ self .generate_detailed_cost_report = GenerateDetailedCostReportOperations (self ._client , self ._config , self ._serialize , self ._deserialize )
75
+ self .generate_detailed_cost_report_operation_results = GenerateDetailedCostReportOperationResultsOperations (self ._client , self ._config , self ._serialize , self ._deserialize )
76
+ self .generate_detailed_cost_report_operation_status = GenerateDetailedCostReportOperationStatusOperations (self ._client , self ._config , self ._serialize , self ._deserialize )
77
+ self .views = ViewsOperations (self ._client , self ._config , self ._serialize , self ._deserialize )
78
+ self .alerts = AlertsOperations (self ._client , self ._config , self ._serialize , self ._deserialize )
79
+ self .forecast = ForecastOperations (self ._client , self ._config , self ._serialize , self ._deserialize )
80
+ self .dimensions = DimensionsOperations (self ._client , self ._config , self ._serialize , self ._deserialize )
81
+ self .query = QueryOperations (self ._client , self ._config , self ._serialize , self ._deserialize )
82
+ self .operations = Operations (self ._client , self ._config , self ._serialize , self ._deserialize )
83
+
84
+
85
+ def _send_request (
86
+ self ,
87
+ request , # type: HttpRequest
88
+ ** kwargs : Any
89
+ ) -> HttpResponse :
99
90
"""Runs the network request through the client's chained policies.
100
91
101
- :param http_request: The network request you want to make. Required.
102
- :type http_request: ~azure.core.pipeline.transport.HttpRequest
103
- :keyword bool stream: Whether the response payload will be streamed. Defaults to True.
92
+ >>> from azure.core.rest import HttpRequest
93
+ >>> request = HttpRequest("GET", "https://www.example.org/")
94
+ <HttpRequest [GET], url: 'https://www.example.org/'>
95
+ >>> response = client._send_request(request)
96
+ <HttpResponse: 200 OK>
97
+
98
+ For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart
99
+
100
+ :param request: The network request you want to make. Required.
101
+ :type request: ~azure.core.rest.HttpRequest
102
+ :keyword bool stream: Whether the response payload will be streamed. Defaults to False.
104
103
:return: The response of your network call. Does not do error handling on your response.
105
- :rtype: ~azure.core.pipeline.transport .HttpResponse
104
+ :rtype: ~azure.core.rest .HttpResponse
106
105
"""
107
- http_request . url = self . _client . format_url ( http_request . url )
108
- stream = kwargs . pop ( "stream" , True )
109
- pipeline_response = self ._client ._pipeline . run ( http_request , stream = stream , ** kwargs )
110
- return pipeline_response . http_response
106
+
107
+ request_copy = deepcopy ( request )
108
+ request_copy . url = self ._client .format_url ( request_copy . url )
109
+ return self . _client . send_request ( request_copy , ** kwargs )
111
110
112
111
def close (self ):
113
112
# type: () -> None
0 commit comments