levelfour 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- levelfour/__init__.py +495 -0
- levelfour/api_keys/__init__.py +34 -0
- levelfour/api_keys/client.py +337 -0
- levelfour/api_keys/raw_client.py +621 -0
- levelfour/api_keys/types/__init__.py +34 -0
- levelfour/api_keys/types/create_api_key_request_scope.py +5 -0
- levelfour/async_levelfour_client.py +39 -0
- levelfour/base_client.py +346 -0
- levelfour/client.py +54 -0
- levelfour/core/__init__.py +127 -0
- levelfour/core/api_error.py +23 -0
- levelfour/core/client_wrapper.py +105 -0
- levelfour/core/datetime_utils.py +70 -0
- levelfour/core/file.py +67 -0
- levelfour/core/force_multipart.py +18 -0
- levelfour/core/http_client.py +776 -0
- levelfour/core/http_response.py +59 -0
- levelfour/core/http_sse/__init__.py +42 -0
- levelfour/core/http_sse/_api.py +112 -0
- levelfour/core/http_sse/_decoders.py +61 -0
- levelfour/core/http_sse/_exceptions.py +7 -0
- levelfour/core/http_sse/_models.py +17 -0
- levelfour/core/jsonable_encoder.py +108 -0
- levelfour/core/logging.py +107 -0
- levelfour/core/pagination.py +82 -0
- levelfour/core/pydantic_utilities.py +577 -0
- levelfour/core/query_encoder.py +58 -0
- levelfour/core/remove_none_from_dict.py +11 -0
- levelfour/core/request_options.py +35 -0
- levelfour/core/serialization.py +276 -0
- levelfour/errors/__init__.py +40 -0
- levelfour/errors/forbidden_error.py +11 -0
- levelfour/errors/unauthorized_error.py +11 -0
- levelfour/errors/unprocessable_entity_error.py +11 -0
- levelfour/evaluation/__init__.py +4 -0
- levelfour/evaluation/client.py +102 -0
- levelfour/evaluation/raw_client.py +141 -0
- levelfour/exceptions.py +63 -0
- levelfour/health/__init__.py +4 -0
- levelfour/health/client.py +163 -0
- levelfour/health/raw_client.py +164 -0
- levelfour/integrations/__init__.py +0 -0
- levelfour/integrations/django.py +26 -0
- levelfour/integrations/fastapi.py +39 -0
- levelfour/integrations/telemetry.py +66 -0
- levelfour/levelfour_client.py +47 -0
- levelfour/pagination.py +84 -0
- levelfour/pr_analysis/__init__.py +4 -0
- levelfour/pr_analysis/client.py +408 -0
- levelfour/pr_analysis/raw_client.py +620 -0
- levelfour/pr_analysis_actions/__init__.py +4 -0
- levelfour/pr_analysis_actions/client.py +588 -0
- levelfour/pr_analysis_actions/raw_client.py +939 -0
- levelfour/pr_analysis_installations/__init__.py +4 -0
- levelfour/pr_analysis_installations/client.py +470 -0
- levelfour/pr_analysis_installations/raw_client.py +868 -0
- levelfour/providers/__init__.py +34 -0
- levelfour/providers/client.py +1504 -0
- levelfour/providers/raw_client.py +2398 -0
- levelfour/providers/types/__init__.py +36 -0
- levelfour/providers/types/list_spending_breakdown_providers_response.py +11 -0
- levelfour/py.typed +0 -0
- levelfour/recommendations/__init__.py +4 -0
- levelfour/recommendations/client.py +1018 -0
- levelfour/recommendations/raw_client.py +1810 -0
- levelfour/savings/__init__.py +4 -0
- levelfour/savings/client.py +401 -0
- levelfour/savings/raw_client.py +624 -0
- levelfour/spending/__init__.py +34 -0
- levelfour/spending/client.py +437 -0
- levelfour/spending/raw_client.py +684 -0
- levelfour/spending/types/__init__.py +34 -0
- levelfour/spending/types/list_breakdown_spending_response.py +12 -0
- levelfour/types/__init__.py +413 -0
- levelfour/types/accept_terms_data.py +25 -0
- levelfour/types/accept_terms_response.py +27 -0
- levelfour/types/action_request.py +42 -0
- levelfour/types/api_key_created_data.py +28 -0
- levelfour/types/api_key_data.py +27 -0
- levelfour/types/authentication_error.py +5 -0
- levelfour/types/authorization_error.py +5 -0
- levelfour/types/bad_request_error.py +5 -0
- levelfour/types/comparison_item.py +32 -0
- levelfour/types/complete_wizard_data.py +27 -0
- levelfour/types/complete_wizard_response.py +27 -0
- levelfour/types/conflict_error.py +5 -0
- levelfour/types/cost_breakdown_data.py +35 -0
- levelfour/types/cost_breakdown_item.py +71 -0
- levelfour/types/cost_breakdown_raw_data.py +37 -0
- levelfour/types/cost_breakdown_raw_response.py +27 -0
- levelfour/types/cost_breakdown_response.py +27 -0
- levelfour/types/costs_breakdown_chart_data.py +48 -0
- levelfour/types/costs_breakdown_chart_response.py +27 -0
- levelfour/types/costs_breakdown_data_point.py +46 -0
- levelfour/types/costs_breakdown_grouped_chart_data.py +52 -0
- levelfour/types/costs_breakdown_grouped_chart_response.py +27 -0
- levelfour/types/costs_breakdown_grouped_data_point.py +36 -0
- levelfour/types/costs_breakdown_totals.py +41 -0
- levelfour/types/create_api_key_response.py +23 -0
- levelfour/types/daily_spending_breakdown_data.py +42 -0
- levelfour/types/daily_spending_breakdown_response.py +27 -0
- levelfour/types/daily_spending_data_point.py +31 -0
- levelfour/types/dashboard_summary_data.py +72 -0
- levelfour/types/dashboard_summary_response.py +27 -0
- levelfour/types/delete_endpoint_data.py +20 -0
- levelfour/types/delete_endpoint_response.py +23 -0
- levelfour/types/endpoint_data.py +23 -0
- levelfour/types/error_response.py +23 -0
- levelfour/types/error_response_error.py +21 -0
- levelfour/types/evaluation_status_data.py +71 -0
- levelfour/types/evaluation_status_response.py +27 -0
- levelfour/types/execution_log_command.py +21 -0
- levelfour/types/execution_log_entry.py +23 -0
- levelfour/types/execution_step_schema.py +23 -0
- levelfour/types/http_validation_error.py +20 -0
- levelfour/types/implementation_method_data.py +25 -0
- levelfour/types/implementation_method_response.py +27 -0
- levelfour/types/implementation_step.py +27 -0
- levelfour/types/internal_server_error.py +5 -0
- levelfour/types/list_api_keys_data.py +21 -0
- levelfour/types/list_api_keys_response.py +23 -0
- levelfour/types/list_endpoints_response.py +23 -0
- levelfour/types/metric_data_point.py +27 -0
- levelfour/types/metric_series.py +40 -0
- levelfour/types/metric_series_entry.py +25 -0
- levelfour/types/monthly_spending_data.py +27 -0
- levelfour/types/monthly_spending_data_point.py +31 -0
- levelfour/types/monthly_spending_response.py +27 -0
- levelfour/types/not_found_error.py +5 -0
- levelfour/types/pagination_meta.py +51 -0
- levelfour/types/processing_recommendation_item.py +61 -0
- levelfour/types/processing_recommendations_data.py +28 -0
- levelfour/types/processing_recommendations_response.py +27 -0
- levelfour/types/provider.py +46 -0
- levelfour/types/provider_breakdown_data.py +31 -0
- levelfour/types/provider_breakdown_item.py +77 -0
- levelfour/types/provider_breakdown_response.py +27 -0
- levelfour/types/provider_filter_options_data.py +51 -0
- levelfour/types/provider_filter_options_response.py +27 -0
- levelfour/types/provider_potential_savings_summary_data.py +46 -0
- levelfour/types/provider_potential_savings_summary_response.py +27 -0
- levelfour/types/provider_recommendations_summary_data.py +37 -0
- levelfour/types/provider_recommendations_summary_response.py +27 -0
- levelfour/types/provider_saved_summary_data.py +56 -0
- levelfour/types/provider_saved_summary_response.py +27 -0
- levelfour/types/provider_service_breakdown_data.py +65 -0
- levelfour/types/provider_service_breakdown_item.py +72 -0
- levelfour/types/provider_service_breakdown_raw_data.py +62 -0
- levelfour/types/provider_service_breakdown_raw_response.py +27 -0
- levelfour/types/provider_service_breakdown_response.py +27 -0
- levelfour/types/provider_service_costs_breakdown_data.py +62 -0
- levelfour/types/provider_service_costs_breakdown_response.py +27 -0
- levelfour/types/provider_service_costs_data_point.py +36 -0
- levelfour/types/provider_spending.py +61 -0
- levelfour/types/provider_spending_summary_data.py +67 -0
- levelfour/types/provider_spending_summary_response.py +27 -0
- levelfour/types/provider_timeline_data.py +57 -0
- levelfour/types/provider_timeline_response.py +27 -0
- levelfour/types/provider_top_service.py +36 -0
- levelfour/types/providers_summary_data.py +24 -0
- levelfour/types/providers_summary_response.py +27 -0
- levelfour/types/rate_limit_error.py +5 -0
- levelfour/types/recommendation_actions.py +60 -0
- levelfour/types/recommendation_detail.py +42 -0
- levelfour/types/recommendation_detail_response.py +27 -0
- levelfour/types/recommendation_filter_options_data.py +41 -0
- levelfour/types/recommendation_filter_options_response.py +27 -0
- levelfour/types/recommendation_item.py +36 -0
- levelfour/types/recommendation_wizard_data.py +173 -0
- levelfour/types/recommendation_wizard_data_metrics.py +7 -0
- levelfour/types/recommendation_wizard_response.py +27 -0
- levelfour/types/recommendations_breakdown_data.py +26 -0
- levelfour/types/recommendations_breakdown_response.py +27 -0
- levelfour/types/recommendations_overview_data.py +51 -0
- levelfour/types/recommendations_overview_response.py +27 -0
- levelfour/types/register_endpoint_response.py +23 -0
- levelfour/types/resource_change.py +42 -0
- levelfour/types/resource_snapshot.py +21 -0
- levelfour/types/revoke_api_key_data.py +20 -0
- levelfour/types/revoke_api_key_response.py +23 -0
- levelfour/types/risk_assessment.py +29 -0
- levelfour/types/risk_factor.py +27 -0
- levelfour/types/saved_breakdown_data.py +31 -0
- levelfour/types/saved_breakdown_response.py +27 -0
- levelfour/types/saved_by_provider_breakdown_data.py +31 -0
- levelfour/types/saved_by_provider_breakdown_response.py +27 -0
- levelfour/types/saved_by_provider_item.py +76 -0
- levelfour/types/saved_item.py +35 -0
- levelfour/types/saved_provider_summary.py +36 -0
- levelfour/types/saved_summary_data.py +57 -0
- levelfour/types/saved_summary_response.py +27 -0
- levelfour/types/savings_decision_data.py +28 -0
- levelfour/types/savings_decision_response.py +27 -0
- levelfour/types/spending_by_date_item.py +36 -0
- levelfour/types/top_recommendation.py +56 -0
- levelfour/types/trigger_info.py +22 -0
- levelfour/types/update_tag_data.py +20 -0
- levelfour/types/update_tag_response.py +23 -0
- levelfour/types/validation_error.py +24 -0
- levelfour/types/validation_error_loc_item.py +5 -0
- levelfour/webhooks/__init__.py +4 -0
- levelfour/webhooks/client.py +273 -0
- levelfour/webhooks/raw_client.py +483 -0
- levelfour/webhooks/verifier.py +61 -0
- levelfour-0.1.0.dist-info/METADATA +12 -0
- levelfour-0.1.0.dist-info/RECORD +208 -0
- levelfour-0.1.0.dist-info/WHEEL +5 -0
- levelfour-0.1.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,2398 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
import typing
|
|
4
|
+
from json.decoder import JSONDecodeError
|
|
5
|
+
|
|
6
|
+
from ..core.api_error import ApiError
|
|
7
|
+
from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
|
|
8
|
+
from ..core.http_response import AsyncHttpResponse, HttpResponse
|
|
9
|
+
from ..core.jsonable_encoder import jsonable_encoder
|
|
10
|
+
from ..core.pagination import AsyncPager, SyncPager
|
|
11
|
+
from ..core.pydantic_utilities import parse_obj_as
|
|
12
|
+
from ..core.request_options import RequestOptions
|
|
13
|
+
from ..errors.forbidden_error import ForbiddenError
|
|
14
|
+
from ..errors.unauthorized_error import UnauthorizedError
|
|
15
|
+
from ..errors.unprocessable_entity_error import UnprocessableEntityError
|
|
16
|
+
from ..types.authentication_error import AuthenticationError
|
|
17
|
+
from ..types.authorization_error import AuthorizationError
|
|
18
|
+
from ..types.http_validation_error import HttpValidationError
|
|
19
|
+
from ..types.provider_breakdown_item import ProviderBreakdownItem
|
|
20
|
+
from ..types.provider_breakdown_response import ProviderBreakdownResponse
|
|
21
|
+
from ..types.provider_filter_options_response import ProviderFilterOptionsResponse
|
|
22
|
+
from ..types.provider_potential_savings_summary_response import ProviderPotentialSavingsSummaryResponse
|
|
23
|
+
from ..types.provider_recommendations_summary_response import ProviderRecommendationsSummaryResponse
|
|
24
|
+
from ..types.provider_saved_summary_response import ProviderSavedSummaryResponse
|
|
25
|
+
from ..types.provider_spending_summary_response import ProviderSpendingSummaryResponse
|
|
26
|
+
from ..types.provider_timeline_response import ProviderTimelineResponse
|
|
27
|
+
from ..types.recommendation_filter_options_response import RecommendationFilterOptionsResponse
|
|
28
|
+
from ..types.recommendations_overview_response import RecommendationsOverviewResponse
|
|
29
|
+
from ..types.saved_by_provider_breakdown_response import SavedByProviderBreakdownResponse
|
|
30
|
+
from ..types.saved_by_provider_item import SavedByProviderItem
|
|
31
|
+
from .types.list_spending_breakdown_providers_response import ListSpendingBreakdownProvidersResponse
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
class RawProvidersClient:
|
|
35
|
+
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
|
36
|
+
self._client_wrapper = client_wrapper
|
|
37
|
+
|
|
38
|
+
def get_recommendations_summary(
|
|
39
|
+
self, provider_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
40
|
+
) -> HttpResponse[ProviderRecommendationsSummaryResponse]:
|
|
41
|
+
"""
|
|
42
|
+
Returns top 7 recommendations for a specific cloud provider
|
|
43
|
+
|
|
44
|
+
Parameters
|
|
45
|
+
----------
|
|
46
|
+
provider_id : str
|
|
47
|
+
|
|
48
|
+
request_options : typing.Optional[RequestOptions]
|
|
49
|
+
Request-specific configuration.
|
|
50
|
+
|
|
51
|
+
Returns
|
|
52
|
+
-------
|
|
53
|
+
HttpResponse[ProviderRecommendationsSummaryResponse]
|
|
54
|
+
Successful Response
|
|
55
|
+
"""
|
|
56
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
57
|
+
f"api/v1/providers/{jsonable_encoder(provider_id)}/recommendations/summary",
|
|
58
|
+
method="GET",
|
|
59
|
+
request_options=request_options,
|
|
60
|
+
)
|
|
61
|
+
try:
|
|
62
|
+
if 200 <= _response.status_code < 300:
|
|
63
|
+
_data = typing.cast(
|
|
64
|
+
ProviderRecommendationsSummaryResponse,
|
|
65
|
+
parse_obj_as(
|
|
66
|
+
type_=ProviderRecommendationsSummaryResponse, # type: ignore
|
|
67
|
+
object_=_response.json(),
|
|
68
|
+
),
|
|
69
|
+
)
|
|
70
|
+
return HttpResponse(response=_response, data=_data)
|
|
71
|
+
if _response.status_code == 401:
|
|
72
|
+
raise UnauthorizedError(
|
|
73
|
+
headers=dict(_response.headers),
|
|
74
|
+
body=typing.cast(
|
|
75
|
+
AuthenticationError,
|
|
76
|
+
parse_obj_as(
|
|
77
|
+
type_=AuthenticationError, # type: ignore
|
|
78
|
+
object_=_response.json(),
|
|
79
|
+
),
|
|
80
|
+
),
|
|
81
|
+
)
|
|
82
|
+
if _response.status_code == 403:
|
|
83
|
+
raise ForbiddenError(
|
|
84
|
+
headers=dict(_response.headers),
|
|
85
|
+
body=typing.cast(
|
|
86
|
+
AuthorizationError,
|
|
87
|
+
parse_obj_as(
|
|
88
|
+
type_=AuthorizationError, # type: ignore
|
|
89
|
+
object_=_response.json(),
|
|
90
|
+
),
|
|
91
|
+
),
|
|
92
|
+
)
|
|
93
|
+
if _response.status_code == 422:
|
|
94
|
+
raise UnprocessableEntityError(
|
|
95
|
+
headers=dict(_response.headers),
|
|
96
|
+
body=typing.cast(
|
|
97
|
+
HttpValidationError,
|
|
98
|
+
parse_obj_as(
|
|
99
|
+
type_=HttpValidationError, # type: ignore
|
|
100
|
+
object_=_response.json(),
|
|
101
|
+
),
|
|
102
|
+
),
|
|
103
|
+
)
|
|
104
|
+
_response_json = _response.json()
|
|
105
|
+
except JSONDecodeError:
|
|
106
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
107
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
108
|
+
|
|
109
|
+
def list_recommendations(
|
|
110
|
+
self,
|
|
111
|
+
provider_id: str,
|
|
112
|
+
*,
|
|
113
|
+
start: typing.Optional[str] = None,
|
|
114
|
+
end: typing.Optional[str] = None,
|
|
115
|
+
page: typing.Optional[int] = None,
|
|
116
|
+
page_size: typing.Optional[int] = None,
|
|
117
|
+
sort_by: typing.Optional[str] = None,
|
|
118
|
+
sort_order: typing.Optional[str] = None,
|
|
119
|
+
service: typing.Optional[typing.Sequence[str]] = None,
|
|
120
|
+
environment: typing.Optional[typing.Sequence[str]] = None,
|
|
121
|
+
account: typing.Optional[typing.Sequence[str]] = None,
|
|
122
|
+
tag: typing.Optional[typing.Sequence[str]] = None,
|
|
123
|
+
display_status: typing.Optional[typing.Sequence[str]] = None,
|
|
124
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
125
|
+
) -> SyncPager[ProviderBreakdownItem, ProviderBreakdownResponse]:
|
|
126
|
+
"""
|
|
127
|
+
Returns paginated breakdown of recommendations for a specific provider
|
|
128
|
+
|
|
129
|
+
Parameters
|
|
130
|
+
----------
|
|
131
|
+
provider_id : str
|
|
132
|
+
|
|
133
|
+
start : typing.Optional[str]
|
|
134
|
+
Start date filter (ISO 8601 format: YYYY-MM-DD)
|
|
135
|
+
|
|
136
|
+
end : typing.Optional[str]
|
|
137
|
+
End date filter (ISO 8601 format: YYYY-MM-DD)
|
|
138
|
+
|
|
139
|
+
page : typing.Optional[int]
|
|
140
|
+
Page number (1-indexed)
|
|
141
|
+
|
|
142
|
+
page_size : typing.Optional[int]
|
|
143
|
+
Items per page (max 100)
|
|
144
|
+
|
|
145
|
+
sort_by : typing.Optional[str]
|
|
146
|
+
Field to sort by (recommendation_id, service, environment, account, tag, monthly_savings, savings_percentage, status)
|
|
147
|
+
|
|
148
|
+
sort_order : typing.Optional[str]
|
|
149
|
+
Sort order (asc or desc)
|
|
150
|
+
|
|
151
|
+
service : typing.Optional[typing.Sequence[str]]
|
|
152
|
+
Filter by service(s) - can be repeated for multiple values
|
|
153
|
+
|
|
154
|
+
environment : typing.Optional[typing.Sequence[str]]
|
|
155
|
+
Filter by environment(s) - can be repeated for multiple values
|
|
156
|
+
|
|
157
|
+
account : typing.Optional[typing.Sequence[str]]
|
|
158
|
+
Filter by account(s) - can be repeated for multiple values
|
|
159
|
+
|
|
160
|
+
tag : typing.Optional[typing.Sequence[str]]
|
|
161
|
+
Filter by tag(s) - can be repeated for multiple values
|
|
162
|
+
|
|
163
|
+
display_status : typing.Optional[typing.Sequence[str]]
|
|
164
|
+
Filter by display status(es): available, pending, processing, optimized, rejected, unavailable
|
|
165
|
+
|
|
166
|
+
request_options : typing.Optional[RequestOptions]
|
|
167
|
+
Request-specific configuration.
|
|
168
|
+
|
|
169
|
+
Returns
|
|
170
|
+
-------
|
|
171
|
+
SyncPager[ProviderBreakdownItem, ProviderBreakdownResponse]
|
|
172
|
+
Successful Response
|
|
173
|
+
"""
|
|
174
|
+
page = page if page is not None else 1
|
|
175
|
+
|
|
176
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
177
|
+
f"api/v1/providers/{jsonable_encoder(provider_id)}/recommendations",
|
|
178
|
+
method="GET",
|
|
179
|
+
params={
|
|
180
|
+
"start": start,
|
|
181
|
+
"end": end,
|
|
182
|
+
"page": page,
|
|
183
|
+
"page_size": page_size,
|
|
184
|
+
"sort_by": sort_by,
|
|
185
|
+
"sort_order": sort_order,
|
|
186
|
+
"service": service,
|
|
187
|
+
"environment": environment,
|
|
188
|
+
"account": account,
|
|
189
|
+
"tag": tag,
|
|
190
|
+
"display_status": display_status,
|
|
191
|
+
},
|
|
192
|
+
request_options=request_options,
|
|
193
|
+
)
|
|
194
|
+
try:
|
|
195
|
+
if 200 <= _response.status_code < 300:
|
|
196
|
+
_parsed_response = typing.cast(
|
|
197
|
+
ProviderBreakdownResponse,
|
|
198
|
+
parse_obj_as(
|
|
199
|
+
type_=ProviderBreakdownResponse, # type: ignore
|
|
200
|
+
object_=_response.json(),
|
|
201
|
+
),
|
|
202
|
+
)
|
|
203
|
+
_items = _parsed_response.data.items if _parsed_response.data is not None else []
|
|
204
|
+
|
|
205
|
+
_has_next = True
|
|
206
|
+
_get_next = lambda: self.list_recommendations(
|
|
207
|
+
provider_id,
|
|
208
|
+
start=start,
|
|
209
|
+
end=end,
|
|
210
|
+
page=page + 1,
|
|
211
|
+
page_size=page_size,
|
|
212
|
+
sort_by=sort_by,
|
|
213
|
+
sort_order=sort_order,
|
|
214
|
+
service=service,
|
|
215
|
+
environment=environment,
|
|
216
|
+
account=account,
|
|
217
|
+
tag=tag,
|
|
218
|
+
display_status=display_status,
|
|
219
|
+
request_options=request_options,
|
|
220
|
+
)
|
|
221
|
+
return SyncPager(has_next=_has_next, items=_items, get_next=_get_next, response=_parsed_response)
|
|
222
|
+
if _response.status_code == 401:
|
|
223
|
+
raise UnauthorizedError(
|
|
224
|
+
headers=dict(_response.headers),
|
|
225
|
+
body=typing.cast(
|
|
226
|
+
AuthenticationError,
|
|
227
|
+
parse_obj_as(
|
|
228
|
+
type_=AuthenticationError, # type: ignore
|
|
229
|
+
object_=_response.json(),
|
|
230
|
+
),
|
|
231
|
+
),
|
|
232
|
+
)
|
|
233
|
+
if _response.status_code == 403:
|
|
234
|
+
raise ForbiddenError(
|
|
235
|
+
headers=dict(_response.headers),
|
|
236
|
+
body=typing.cast(
|
|
237
|
+
AuthorizationError,
|
|
238
|
+
parse_obj_as(
|
|
239
|
+
type_=AuthorizationError, # type: ignore
|
|
240
|
+
object_=_response.json(),
|
|
241
|
+
),
|
|
242
|
+
),
|
|
243
|
+
)
|
|
244
|
+
if _response.status_code == 422:
|
|
245
|
+
raise UnprocessableEntityError(
|
|
246
|
+
headers=dict(_response.headers),
|
|
247
|
+
body=typing.cast(
|
|
248
|
+
HttpValidationError,
|
|
249
|
+
parse_obj_as(
|
|
250
|
+
type_=HttpValidationError, # type: ignore
|
|
251
|
+
object_=_response.json(),
|
|
252
|
+
),
|
|
253
|
+
),
|
|
254
|
+
)
|
|
255
|
+
_response_json = _response.json()
|
|
256
|
+
except JSONDecodeError:
|
|
257
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
258
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
259
|
+
|
|
260
|
+
def get_recommendations_overview(
|
|
261
|
+
self, provider_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
262
|
+
) -> HttpResponse[RecommendationsOverviewResponse]:
|
|
263
|
+
"""
|
|
264
|
+
Returns overview metrics (total spend, available/pending savings, saved ITD) for a provider
|
|
265
|
+
|
|
266
|
+
Parameters
|
|
267
|
+
----------
|
|
268
|
+
provider_id : str
|
|
269
|
+
|
|
270
|
+
request_options : typing.Optional[RequestOptions]
|
|
271
|
+
Request-specific configuration.
|
|
272
|
+
|
|
273
|
+
Returns
|
|
274
|
+
-------
|
|
275
|
+
HttpResponse[RecommendationsOverviewResponse]
|
|
276
|
+
Successful Response
|
|
277
|
+
"""
|
|
278
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
279
|
+
f"api/v1/providers/{jsonable_encoder(provider_id)}/recommendations/overview",
|
|
280
|
+
method="GET",
|
|
281
|
+
request_options=request_options,
|
|
282
|
+
)
|
|
283
|
+
try:
|
|
284
|
+
if 200 <= _response.status_code < 300:
|
|
285
|
+
_data = typing.cast(
|
|
286
|
+
RecommendationsOverviewResponse,
|
|
287
|
+
parse_obj_as(
|
|
288
|
+
type_=RecommendationsOverviewResponse, # type: ignore
|
|
289
|
+
object_=_response.json(),
|
|
290
|
+
),
|
|
291
|
+
)
|
|
292
|
+
return HttpResponse(response=_response, data=_data)
|
|
293
|
+
if _response.status_code == 401:
|
|
294
|
+
raise UnauthorizedError(
|
|
295
|
+
headers=dict(_response.headers),
|
|
296
|
+
body=typing.cast(
|
|
297
|
+
AuthenticationError,
|
|
298
|
+
parse_obj_as(
|
|
299
|
+
type_=AuthenticationError, # type: ignore
|
|
300
|
+
object_=_response.json(),
|
|
301
|
+
),
|
|
302
|
+
),
|
|
303
|
+
)
|
|
304
|
+
if _response.status_code == 403:
|
|
305
|
+
raise ForbiddenError(
|
|
306
|
+
headers=dict(_response.headers),
|
|
307
|
+
body=typing.cast(
|
|
308
|
+
AuthorizationError,
|
|
309
|
+
parse_obj_as(
|
|
310
|
+
type_=AuthorizationError, # type: ignore
|
|
311
|
+
object_=_response.json(),
|
|
312
|
+
),
|
|
313
|
+
),
|
|
314
|
+
)
|
|
315
|
+
if _response.status_code == 422:
|
|
316
|
+
raise UnprocessableEntityError(
|
|
317
|
+
headers=dict(_response.headers),
|
|
318
|
+
body=typing.cast(
|
|
319
|
+
HttpValidationError,
|
|
320
|
+
parse_obj_as(
|
|
321
|
+
type_=HttpValidationError, # type: ignore
|
|
322
|
+
object_=_response.json(),
|
|
323
|
+
),
|
|
324
|
+
),
|
|
325
|
+
)
|
|
326
|
+
_response_json = _response.json()
|
|
327
|
+
except JSONDecodeError:
|
|
328
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
329
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
330
|
+
|
|
331
|
+
def get_recommendation_filters(
|
|
332
|
+
self, provider_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
333
|
+
) -> HttpResponse[RecommendationFilterOptionsResponse]:
|
|
334
|
+
"""
|
|
335
|
+
Returns distinct environments, accounts, and tags for recommendation filtering
|
|
336
|
+
|
|
337
|
+
Parameters
|
|
338
|
+
----------
|
|
339
|
+
provider_id : str
|
|
340
|
+
|
|
341
|
+
request_options : typing.Optional[RequestOptions]
|
|
342
|
+
Request-specific configuration.
|
|
343
|
+
|
|
344
|
+
Returns
|
|
345
|
+
-------
|
|
346
|
+
HttpResponse[RecommendationFilterOptionsResponse]
|
|
347
|
+
Successful Response
|
|
348
|
+
"""
|
|
349
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
350
|
+
f"api/v1/providers/{jsonable_encoder(provider_id)}/recommendations/filter-options",
|
|
351
|
+
method="GET",
|
|
352
|
+
request_options=request_options,
|
|
353
|
+
)
|
|
354
|
+
try:
|
|
355
|
+
if 200 <= _response.status_code < 300:
|
|
356
|
+
_data = typing.cast(
|
|
357
|
+
RecommendationFilterOptionsResponse,
|
|
358
|
+
parse_obj_as(
|
|
359
|
+
type_=RecommendationFilterOptionsResponse, # type: ignore
|
|
360
|
+
object_=_response.json(),
|
|
361
|
+
),
|
|
362
|
+
)
|
|
363
|
+
return HttpResponse(response=_response, data=_data)
|
|
364
|
+
if _response.status_code == 401:
|
|
365
|
+
raise UnauthorizedError(
|
|
366
|
+
headers=dict(_response.headers),
|
|
367
|
+
body=typing.cast(
|
|
368
|
+
AuthenticationError,
|
|
369
|
+
parse_obj_as(
|
|
370
|
+
type_=AuthenticationError, # type: ignore
|
|
371
|
+
object_=_response.json(),
|
|
372
|
+
),
|
|
373
|
+
),
|
|
374
|
+
)
|
|
375
|
+
if _response.status_code == 403:
|
|
376
|
+
raise ForbiddenError(
|
|
377
|
+
headers=dict(_response.headers),
|
|
378
|
+
body=typing.cast(
|
|
379
|
+
AuthorizationError,
|
|
380
|
+
parse_obj_as(
|
|
381
|
+
type_=AuthorizationError, # type: ignore
|
|
382
|
+
object_=_response.json(),
|
|
383
|
+
),
|
|
384
|
+
),
|
|
385
|
+
)
|
|
386
|
+
if _response.status_code == 422:
|
|
387
|
+
raise UnprocessableEntityError(
|
|
388
|
+
headers=dict(_response.headers),
|
|
389
|
+
body=typing.cast(
|
|
390
|
+
HttpValidationError,
|
|
391
|
+
parse_obj_as(
|
|
392
|
+
type_=HttpValidationError, # type: ignore
|
|
393
|
+
object_=_response.json(),
|
|
394
|
+
),
|
|
395
|
+
),
|
|
396
|
+
)
|
|
397
|
+
_response_json = _response.json()
|
|
398
|
+
except JSONDecodeError:
|
|
399
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
400
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
401
|
+
|
|
402
|
+
def list_savings_breakdown(
|
|
403
|
+
self,
|
|
404
|
+
provider_id: str,
|
|
405
|
+
*,
|
|
406
|
+
start: typing.Optional[str] = None,
|
|
407
|
+
end: typing.Optional[str] = None,
|
|
408
|
+
page: typing.Optional[int] = None,
|
|
409
|
+
page_size: typing.Optional[int] = None,
|
|
410
|
+
sort_by: typing.Optional[str] = None,
|
|
411
|
+
sort_order: typing.Optional[str] = None,
|
|
412
|
+
preset: typing.Optional[str] = None,
|
|
413
|
+
service: typing.Optional[typing.Sequence[str]] = None,
|
|
414
|
+
environment: typing.Optional[typing.Sequence[str]] = None,
|
|
415
|
+
account_id: typing.Optional[typing.Sequence[str]] = None,
|
|
416
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
417
|
+
) -> SyncPager[SavedByProviderItem, SavedByProviderBreakdownResponse]:
|
|
418
|
+
"""
|
|
419
|
+
Returns paginated breakdown of saved recommendations for a specific provider with filtering and sorting
|
|
420
|
+
|
|
421
|
+
Parameters
|
|
422
|
+
----------
|
|
423
|
+
provider_id : str
|
|
424
|
+
|
|
425
|
+
start : typing.Optional[str]
|
|
426
|
+
Start date filter (ISO 8601 format: YYYY-MM-DD or YYYY-MM)
|
|
427
|
+
|
|
428
|
+
end : typing.Optional[str]
|
|
429
|
+
End date filter (ISO 8601 format: YYYY-MM-DD or YYYY-MM)
|
|
430
|
+
|
|
431
|
+
page : typing.Optional[int]
|
|
432
|
+
Page number (1-indexed)
|
|
433
|
+
|
|
434
|
+
page_size : typing.Optional[int]
|
|
435
|
+
Items per page (max 100)
|
|
436
|
+
|
|
437
|
+
sort_by : typing.Optional[str]
|
|
438
|
+
Field to sort by (period, account_id, environment, service, usage_type, usage_quantity, usage_unit, pre_optimization_cost, monthly_savings, approved_by)
|
|
439
|
+
|
|
440
|
+
sort_order : typing.Optional[str]
|
|
441
|
+
Sort order (asc or desc)
|
|
442
|
+
|
|
443
|
+
preset : typing.Optional[str]
|
|
444
|
+
Date preset: '30D', '6M', or '12M' (takes precedence over start/end)
|
|
445
|
+
|
|
446
|
+
service : typing.Optional[typing.Sequence[str]]
|
|
447
|
+
Filter by service(s) - can be repeated for multiple values
|
|
448
|
+
|
|
449
|
+
environment : typing.Optional[typing.Sequence[str]]
|
|
450
|
+
Filter by environment(s) - can be repeated for multiple values
|
|
451
|
+
|
|
452
|
+
account_id : typing.Optional[typing.Sequence[str]]
|
|
453
|
+
Filter by account ID(s) - can be repeated for multiple values
|
|
454
|
+
|
|
455
|
+
request_options : typing.Optional[RequestOptions]
|
|
456
|
+
Request-specific configuration.
|
|
457
|
+
|
|
458
|
+
Returns
|
|
459
|
+
-------
|
|
460
|
+
SyncPager[SavedByProviderItem, SavedByProviderBreakdownResponse]
|
|
461
|
+
Successful Response
|
|
462
|
+
"""
|
|
463
|
+
page = page if page is not None else 1
|
|
464
|
+
|
|
465
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
466
|
+
f"api/v1/providers/{jsonable_encoder(provider_id)}/savings/breakdown",
|
|
467
|
+
method="GET",
|
|
468
|
+
params={
|
|
469
|
+
"start": start,
|
|
470
|
+
"end": end,
|
|
471
|
+
"page": page,
|
|
472
|
+
"page_size": page_size,
|
|
473
|
+
"sort_by": sort_by,
|
|
474
|
+
"sort_order": sort_order,
|
|
475
|
+
"preset": preset,
|
|
476
|
+
"service": service,
|
|
477
|
+
"environment": environment,
|
|
478
|
+
"account_id": account_id,
|
|
479
|
+
},
|
|
480
|
+
request_options=request_options,
|
|
481
|
+
)
|
|
482
|
+
try:
|
|
483
|
+
if 200 <= _response.status_code < 300:
|
|
484
|
+
_parsed_response = typing.cast(
|
|
485
|
+
SavedByProviderBreakdownResponse,
|
|
486
|
+
parse_obj_as(
|
|
487
|
+
type_=SavedByProviderBreakdownResponse, # type: ignore
|
|
488
|
+
object_=_response.json(),
|
|
489
|
+
),
|
|
490
|
+
)
|
|
491
|
+
_items = _parsed_response.data.items if _parsed_response.data is not None else []
|
|
492
|
+
|
|
493
|
+
_has_next = True
|
|
494
|
+
_get_next = lambda: self.list_savings_breakdown(
|
|
495
|
+
provider_id,
|
|
496
|
+
start=start,
|
|
497
|
+
end=end,
|
|
498
|
+
page=page + 1,
|
|
499
|
+
page_size=page_size,
|
|
500
|
+
sort_by=sort_by,
|
|
501
|
+
sort_order=sort_order,
|
|
502
|
+
preset=preset,
|
|
503
|
+
service=service,
|
|
504
|
+
environment=environment,
|
|
505
|
+
account_id=account_id,
|
|
506
|
+
request_options=request_options,
|
|
507
|
+
)
|
|
508
|
+
return SyncPager(has_next=_has_next, items=_items, get_next=_get_next, response=_parsed_response)
|
|
509
|
+
if _response.status_code == 401:
|
|
510
|
+
raise UnauthorizedError(
|
|
511
|
+
headers=dict(_response.headers),
|
|
512
|
+
body=typing.cast(
|
|
513
|
+
AuthenticationError,
|
|
514
|
+
parse_obj_as(
|
|
515
|
+
type_=AuthenticationError, # type: ignore
|
|
516
|
+
object_=_response.json(),
|
|
517
|
+
),
|
|
518
|
+
),
|
|
519
|
+
)
|
|
520
|
+
if _response.status_code == 403:
|
|
521
|
+
raise ForbiddenError(
|
|
522
|
+
headers=dict(_response.headers),
|
|
523
|
+
body=typing.cast(
|
|
524
|
+
AuthorizationError,
|
|
525
|
+
parse_obj_as(
|
|
526
|
+
type_=AuthorizationError, # type: ignore
|
|
527
|
+
object_=_response.json(),
|
|
528
|
+
),
|
|
529
|
+
),
|
|
530
|
+
)
|
|
531
|
+
if _response.status_code == 422:
|
|
532
|
+
raise UnprocessableEntityError(
|
|
533
|
+
headers=dict(_response.headers),
|
|
534
|
+
body=typing.cast(
|
|
535
|
+
HttpValidationError,
|
|
536
|
+
parse_obj_as(
|
|
537
|
+
type_=HttpValidationError, # type: ignore
|
|
538
|
+
object_=_response.json(),
|
|
539
|
+
),
|
|
540
|
+
),
|
|
541
|
+
)
|
|
542
|
+
_response_json = _response.json()
|
|
543
|
+
except JSONDecodeError:
|
|
544
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
545
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
546
|
+
|
|
547
|
+
def get_savings_summary(
|
|
548
|
+
self, provider_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
549
|
+
) -> HttpResponse[ProviderSavedSummaryResponse]:
|
|
550
|
+
"""
|
|
551
|
+
Returns saved summary totals for a specific provider (for BigNumbers)
|
|
552
|
+
|
|
553
|
+
Parameters
|
|
554
|
+
----------
|
|
555
|
+
provider_id : str
|
|
556
|
+
|
|
557
|
+
request_options : typing.Optional[RequestOptions]
|
|
558
|
+
Request-specific configuration.
|
|
559
|
+
|
|
560
|
+
Returns
|
|
561
|
+
-------
|
|
562
|
+
HttpResponse[ProviderSavedSummaryResponse]
|
|
563
|
+
Successful Response
|
|
564
|
+
"""
|
|
565
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
566
|
+
f"api/v1/providers/{jsonable_encoder(provider_id)}/savings/summary",
|
|
567
|
+
method="GET",
|
|
568
|
+
request_options=request_options,
|
|
569
|
+
)
|
|
570
|
+
try:
|
|
571
|
+
if 200 <= _response.status_code < 300:
|
|
572
|
+
_data = typing.cast(
|
|
573
|
+
ProviderSavedSummaryResponse,
|
|
574
|
+
parse_obj_as(
|
|
575
|
+
type_=ProviderSavedSummaryResponse, # type: ignore
|
|
576
|
+
object_=_response.json(),
|
|
577
|
+
),
|
|
578
|
+
)
|
|
579
|
+
return HttpResponse(response=_response, data=_data)
|
|
580
|
+
if _response.status_code == 401:
|
|
581
|
+
raise UnauthorizedError(
|
|
582
|
+
headers=dict(_response.headers),
|
|
583
|
+
body=typing.cast(
|
|
584
|
+
AuthenticationError,
|
|
585
|
+
parse_obj_as(
|
|
586
|
+
type_=AuthenticationError, # type: ignore
|
|
587
|
+
object_=_response.json(),
|
|
588
|
+
),
|
|
589
|
+
),
|
|
590
|
+
)
|
|
591
|
+
if _response.status_code == 403:
|
|
592
|
+
raise ForbiddenError(
|
|
593
|
+
headers=dict(_response.headers),
|
|
594
|
+
body=typing.cast(
|
|
595
|
+
AuthorizationError,
|
|
596
|
+
parse_obj_as(
|
|
597
|
+
type_=AuthorizationError, # type: ignore
|
|
598
|
+
object_=_response.json(),
|
|
599
|
+
),
|
|
600
|
+
),
|
|
601
|
+
)
|
|
602
|
+
if _response.status_code == 422:
|
|
603
|
+
raise UnprocessableEntityError(
|
|
604
|
+
headers=dict(_response.headers),
|
|
605
|
+
body=typing.cast(
|
|
606
|
+
HttpValidationError,
|
|
607
|
+
parse_obj_as(
|
|
608
|
+
type_=HttpValidationError, # type: ignore
|
|
609
|
+
object_=_response.json(),
|
|
610
|
+
),
|
|
611
|
+
),
|
|
612
|
+
)
|
|
613
|
+
_response_json = _response.json()
|
|
614
|
+
except JSONDecodeError:
|
|
615
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
616
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
617
|
+
|
|
618
|
+
def get_spending_summary(
|
|
619
|
+
self, provider_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
620
|
+
) -> HttpResponse[ProviderSpendingSummaryResponse]:
|
|
621
|
+
"""
|
|
622
|
+
Returns spending summary for a specific cloud provider
|
|
623
|
+
|
|
624
|
+
Parameters
|
|
625
|
+
----------
|
|
626
|
+
provider_id : str
|
|
627
|
+
|
|
628
|
+
request_options : typing.Optional[RequestOptions]
|
|
629
|
+
Request-specific configuration.
|
|
630
|
+
|
|
631
|
+
Returns
|
|
632
|
+
-------
|
|
633
|
+
HttpResponse[ProviderSpendingSummaryResponse]
|
|
634
|
+
Successful Response
|
|
635
|
+
"""
|
|
636
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
637
|
+
f"api/v1/providers/{jsonable_encoder(provider_id)}/spending/summary",
|
|
638
|
+
method="GET",
|
|
639
|
+
request_options=request_options,
|
|
640
|
+
)
|
|
641
|
+
try:
|
|
642
|
+
if 200 <= _response.status_code < 300:
|
|
643
|
+
_data = typing.cast(
|
|
644
|
+
ProviderSpendingSummaryResponse,
|
|
645
|
+
parse_obj_as(
|
|
646
|
+
type_=ProviderSpendingSummaryResponse, # type: ignore
|
|
647
|
+
object_=_response.json(),
|
|
648
|
+
),
|
|
649
|
+
)
|
|
650
|
+
return HttpResponse(response=_response, data=_data)
|
|
651
|
+
if _response.status_code == 401:
|
|
652
|
+
raise UnauthorizedError(
|
|
653
|
+
headers=dict(_response.headers),
|
|
654
|
+
body=typing.cast(
|
|
655
|
+
AuthenticationError,
|
|
656
|
+
parse_obj_as(
|
|
657
|
+
type_=AuthenticationError, # type: ignore
|
|
658
|
+
object_=_response.json(),
|
|
659
|
+
),
|
|
660
|
+
),
|
|
661
|
+
)
|
|
662
|
+
if _response.status_code == 403:
|
|
663
|
+
raise ForbiddenError(
|
|
664
|
+
headers=dict(_response.headers),
|
|
665
|
+
body=typing.cast(
|
|
666
|
+
AuthorizationError,
|
|
667
|
+
parse_obj_as(
|
|
668
|
+
type_=AuthorizationError, # type: ignore
|
|
669
|
+
object_=_response.json(),
|
|
670
|
+
),
|
|
671
|
+
),
|
|
672
|
+
)
|
|
673
|
+
if _response.status_code == 422:
|
|
674
|
+
raise UnprocessableEntityError(
|
|
675
|
+
headers=dict(_response.headers),
|
|
676
|
+
body=typing.cast(
|
|
677
|
+
HttpValidationError,
|
|
678
|
+
parse_obj_as(
|
|
679
|
+
type_=HttpValidationError, # type: ignore
|
|
680
|
+
object_=_response.json(),
|
|
681
|
+
),
|
|
682
|
+
),
|
|
683
|
+
)
|
|
684
|
+
_response_json = _response.json()
|
|
685
|
+
except JSONDecodeError:
|
|
686
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
687
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
688
|
+
|
|
689
|
+
def get_spending_filters(
|
|
690
|
+
self,
|
|
691
|
+
provider_id: str,
|
|
692
|
+
*,
|
|
693
|
+
start: typing.Optional[str] = None,
|
|
694
|
+
end: typing.Optional[str] = None,
|
|
695
|
+
tag_key: typing.Optional[typing.Sequence[str]] = None,
|
|
696
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
697
|
+
) -> HttpResponse[ProviderFilterOptionsResponse]:
|
|
698
|
+
"""
|
|
699
|
+
Returns distinct services, regions, and accounts for the date range
|
|
700
|
+
|
|
701
|
+
Parameters
|
|
702
|
+
----------
|
|
703
|
+
provider_id : str
|
|
704
|
+
|
|
705
|
+
start : typing.Optional[str]
|
|
706
|
+
Start date in ISO 8601 format
|
|
707
|
+
|
|
708
|
+
end : typing.Optional[str]
|
|
709
|
+
End date in ISO 8601 format
|
|
710
|
+
|
|
711
|
+
tag_key : typing.Optional[typing.Sequence[str]]
|
|
712
|
+
Filter tag_values by these tag keys
|
|
713
|
+
|
|
714
|
+
request_options : typing.Optional[RequestOptions]
|
|
715
|
+
Request-specific configuration.
|
|
716
|
+
|
|
717
|
+
Returns
|
|
718
|
+
-------
|
|
719
|
+
HttpResponse[ProviderFilterOptionsResponse]
|
|
720
|
+
Successful Response
|
|
721
|
+
"""
|
|
722
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
723
|
+
f"api/v1/providers/{jsonable_encoder(provider_id)}/spending/filter-options",
|
|
724
|
+
method="GET",
|
|
725
|
+
params={
|
|
726
|
+
"start": start,
|
|
727
|
+
"end": end,
|
|
728
|
+
"tag_key": tag_key,
|
|
729
|
+
},
|
|
730
|
+
request_options=request_options,
|
|
731
|
+
)
|
|
732
|
+
try:
|
|
733
|
+
if 200 <= _response.status_code < 300:
|
|
734
|
+
_data = typing.cast(
|
|
735
|
+
ProviderFilterOptionsResponse,
|
|
736
|
+
parse_obj_as(
|
|
737
|
+
type_=ProviderFilterOptionsResponse, # type: ignore
|
|
738
|
+
object_=_response.json(),
|
|
739
|
+
),
|
|
740
|
+
)
|
|
741
|
+
return HttpResponse(response=_response, data=_data)
|
|
742
|
+
if _response.status_code == 401:
|
|
743
|
+
raise UnauthorizedError(
|
|
744
|
+
headers=dict(_response.headers),
|
|
745
|
+
body=typing.cast(
|
|
746
|
+
AuthenticationError,
|
|
747
|
+
parse_obj_as(
|
|
748
|
+
type_=AuthenticationError, # type: ignore
|
|
749
|
+
object_=_response.json(),
|
|
750
|
+
),
|
|
751
|
+
),
|
|
752
|
+
)
|
|
753
|
+
if _response.status_code == 403:
|
|
754
|
+
raise ForbiddenError(
|
|
755
|
+
headers=dict(_response.headers),
|
|
756
|
+
body=typing.cast(
|
|
757
|
+
AuthorizationError,
|
|
758
|
+
parse_obj_as(
|
|
759
|
+
type_=AuthorizationError, # type: ignore
|
|
760
|
+
object_=_response.json(),
|
|
761
|
+
),
|
|
762
|
+
),
|
|
763
|
+
)
|
|
764
|
+
if _response.status_code == 422:
|
|
765
|
+
raise UnprocessableEntityError(
|
|
766
|
+
headers=dict(_response.headers),
|
|
767
|
+
body=typing.cast(
|
|
768
|
+
HttpValidationError,
|
|
769
|
+
parse_obj_as(
|
|
770
|
+
type_=HttpValidationError, # type: ignore
|
|
771
|
+
object_=_response.json(),
|
|
772
|
+
),
|
|
773
|
+
),
|
|
774
|
+
)
|
|
775
|
+
_response_json = _response.json()
|
|
776
|
+
except JSONDecodeError:
|
|
777
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
778
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
779
|
+
|
|
780
|
+
def list_spending_breakdown(
|
|
781
|
+
self,
|
|
782
|
+
provider_id: str,
|
|
783
|
+
*,
|
|
784
|
+
format: typing.Optional[str] = None,
|
|
785
|
+
start: typing.Optional[str] = None,
|
|
786
|
+
end: typing.Optional[str] = None,
|
|
787
|
+
granularity: typing.Optional[str] = None,
|
|
788
|
+
page: typing.Optional[int] = None,
|
|
789
|
+
page_size: typing.Optional[int] = None,
|
|
790
|
+
sort_by: typing.Optional[str] = None,
|
|
791
|
+
sort_order: typing.Optional[str] = None,
|
|
792
|
+
sort_by_date: typing.Optional[str] = None,
|
|
793
|
+
preset: typing.Optional[str] = None,
|
|
794
|
+
service: typing.Optional[typing.Sequence[str]] = None,
|
|
795
|
+
environment: typing.Optional[typing.Sequence[str]] = None,
|
|
796
|
+
account_id: typing.Optional[typing.Sequence[str]] = None,
|
|
797
|
+
region: typing.Optional[typing.Sequence[str]] = None,
|
|
798
|
+
tag_key: typing.Optional[typing.Sequence[str]] = None,
|
|
799
|
+
tag_value: typing.Optional[typing.Sequence[str]] = None,
|
|
800
|
+
group_by: typing.Optional[typing.Sequence[str]] = None,
|
|
801
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
802
|
+
) -> HttpResponse[ListSpendingBreakdownProvidersResponse]:
|
|
803
|
+
"""
|
|
804
|
+
Returns service breakdown in different formats: table (paginated), chart (aggregated), csv (export), raw (all records)
|
|
805
|
+
|
|
806
|
+
Parameters
|
|
807
|
+
----------
|
|
808
|
+
provider_id : str
|
|
809
|
+
|
|
810
|
+
format : typing.Optional[str]
|
|
811
|
+
Response format: table (paginated UI), chart (aggregated stacked bar), csv (export), raw (all records)
|
|
812
|
+
|
|
813
|
+
start : typing.Optional[str]
|
|
814
|
+
Start date in ISO 8601 format (e.g., 2026-02-01T00:00:00.000Z). Defaults to first of current month
|
|
815
|
+
|
|
816
|
+
end : typing.Optional[str]
|
|
817
|
+
End date in ISO 8601 format (e.g., 2026-02-01T00:00:00.000Z). Defaults to today
|
|
818
|
+
|
|
819
|
+
granularity : typing.Optional[str]
|
|
820
|
+
Granularity: 'daily' or 'monthly' (used for chart format)
|
|
821
|
+
|
|
822
|
+
page : typing.Optional[int]
|
|
823
|
+
Page number (1-indexed, table format only)
|
|
824
|
+
|
|
825
|
+
page_size : typing.Optional[int]
|
|
826
|
+
Items per page (max 100, table format only)
|
|
827
|
+
|
|
828
|
+
sort_by : typing.Optional[str]
|
|
829
|
+
Field to sort by (service, environment, region, account_id, cost, previous_cost, change_percentage)
|
|
830
|
+
|
|
831
|
+
sort_order : typing.Optional[str]
|
|
832
|
+
Sort order (asc or desc)
|
|
833
|
+
|
|
834
|
+
sort_by_date : typing.Optional[str]
|
|
835
|
+
Sort by a specific date's cost (YYYY-MM-DD for daily, YYYY-MM for monthly). Overrides sort_by.
|
|
836
|
+
|
|
837
|
+
preset : typing.Optional[str]
|
|
838
|
+
Date preset: '30D', '6M', or '12M' (takes precedence over start/end)
|
|
839
|
+
|
|
840
|
+
service : typing.Optional[typing.Sequence[str]]
|
|
841
|
+
Filter by service(s) - can be repeated for multiple values
|
|
842
|
+
|
|
843
|
+
environment : typing.Optional[typing.Sequence[str]]
|
|
844
|
+
Filter by environment(s) - can be repeated for multiple values
|
|
845
|
+
|
|
846
|
+
account_id : typing.Optional[typing.Sequence[str]]
|
|
847
|
+
Filter by account ID(s) - can be repeated for multiple values
|
|
848
|
+
|
|
849
|
+
region : typing.Optional[typing.Sequence[str]]
|
|
850
|
+
Filter by region(s) - can be repeated for multiple values
|
|
851
|
+
|
|
852
|
+
tag_key : typing.Optional[typing.Sequence[str]]
|
|
853
|
+
Filter by tag key(s) - required when group_by=tag
|
|
854
|
+
|
|
855
|
+
tag_value : typing.Optional[typing.Sequence[str]]
|
|
856
|
+
Filter by tag value(s) - can be repeated for multiple values
|
|
857
|
+
|
|
858
|
+
group_by : typing.Optional[typing.Sequence[str]]
|
|
859
|
+
Group by field(s). Valid: service, account_id, region, tag
|
|
860
|
+
|
|
861
|
+
request_options : typing.Optional[RequestOptions]
|
|
862
|
+
Request-specific configuration.
|
|
863
|
+
|
|
864
|
+
Returns
|
|
865
|
+
-------
|
|
866
|
+
HttpResponse[ListSpendingBreakdownProvidersResponse]
|
|
867
|
+
Successful Response
|
|
868
|
+
"""
|
|
869
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
870
|
+
f"api/v1/providers/{jsonable_encoder(provider_id)}/spending/breakdown",
|
|
871
|
+
method="GET",
|
|
872
|
+
params={
|
|
873
|
+
"format": format,
|
|
874
|
+
"start": start,
|
|
875
|
+
"end": end,
|
|
876
|
+
"granularity": granularity,
|
|
877
|
+
"page": page,
|
|
878
|
+
"page_size": page_size,
|
|
879
|
+
"sort_by": sort_by,
|
|
880
|
+
"sort_order": sort_order,
|
|
881
|
+
"sort_by_date": sort_by_date,
|
|
882
|
+
"preset": preset,
|
|
883
|
+
"service": service,
|
|
884
|
+
"environment": environment,
|
|
885
|
+
"account_id": account_id,
|
|
886
|
+
"region": region,
|
|
887
|
+
"tag_key": tag_key,
|
|
888
|
+
"tag_value": tag_value,
|
|
889
|
+
"group_by": group_by,
|
|
890
|
+
},
|
|
891
|
+
request_options=request_options,
|
|
892
|
+
)
|
|
893
|
+
try:
|
|
894
|
+
if 200 <= _response.status_code < 300:
|
|
895
|
+
_data = typing.cast(
|
|
896
|
+
ListSpendingBreakdownProvidersResponse,
|
|
897
|
+
parse_obj_as(
|
|
898
|
+
type_=ListSpendingBreakdownProvidersResponse, # type: ignore
|
|
899
|
+
object_=_response.json(),
|
|
900
|
+
),
|
|
901
|
+
)
|
|
902
|
+
return HttpResponse(response=_response, data=_data)
|
|
903
|
+
if _response.status_code == 401:
|
|
904
|
+
raise UnauthorizedError(
|
|
905
|
+
headers=dict(_response.headers),
|
|
906
|
+
body=typing.cast(
|
|
907
|
+
AuthenticationError,
|
|
908
|
+
parse_obj_as(
|
|
909
|
+
type_=AuthenticationError, # type: ignore
|
|
910
|
+
object_=_response.json(),
|
|
911
|
+
),
|
|
912
|
+
),
|
|
913
|
+
)
|
|
914
|
+
if _response.status_code == 403:
|
|
915
|
+
raise ForbiddenError(
|
|
916
|
+
headers=dict(_response.headers),
|
|
917
|
+
body=typing.cast(
|
|
918
|
+
AuthorizationError,
|
|
919
|
+
parse_obj_as(
|
|
920
|
+
type_=AuthorizationError, # type: ignore
|
|
921
|
+
object_=_response.json(),
|
|
922
|
+
),
|
|
923
|
+
),
|
|
924
|
+
)
|
|
925
|
+
if _response.status_code == 422:
|
|
926
|
+
raise UnprocessableEntityError(
|
|
927
|
+
headers=dict(_response.headers),
|
|
928
|
+
body=typing.cast(
|
|
929
|
+
HttpValidationError,
|
|
930
|
+
parse_obj_as(
|
|
931
|
+
type_=HttpValidationError, # type: ignore
|
|
932
|
+
object_=_response.json(),
|
|
933
|
+
),
|
|
934
|
+
),
|
|
935
|
+
)
|
|
936
|
+
_response_json = _response.json()
|
|
937
|
+
except JSONDecodeError:
|
|
938
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
939
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
940
|
+
|
|
941
|
+
def get_spending_timeline(
|
|
942
|
+
self,
|
|
943
|
+
provider_id: str,
|
|
944
|
+
*,
|
|
945
|
+
start: typing.Optional[str] = None,
|
|
946
|
+
end: typing.Optional[str] = None,
|
|
947
|
+
granularity: typing.Optional[str] = None,
|
|
948
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
949
|
+
) -> HttpResponse[ProviderTimelineResponse]:
|
|
950
|
+
"""
|
|
951
|
+
Returns spending timeline for a specific provider
|
|
952
|
+
|
|
953
|
+
Parameters
|
|
954
|
+
----------
|
|
955
|
+
provider_id : str
|
|
956
|
+
|
|
957
|
+
start : typing.Optional[str]
|
|
958
|
+
Start date in ISO 8601 format
|
|
959
|
+
|
|
960
|
+
end : typing.Optional[str]
|
|
961
|
+
End date in ISO 8601 format
|
|
962
|
+
|
|
963
|
+
granularity : typing.Optional[str]
|
|
964
|
+
Granularity: 'daily' or 'monthly'
|
|
965
|
+
|
|
966
|
+
request_options : typing.Optional[RequestOptions]
|
|
967
|
+
Request-specific configuration.
|
|
968
|
+
|
|
969
|
+
Returns
|
|
970
|
+
-------
|
|
971
|
+
HttpResponse[ProviderTimelineResponse]
|
|
972
|
+
Successful Response
|
|
973
|
+
"""
|
|
974
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
975
|
+
f"api/v1/providers/{jsonable_encoder(provider_id)}/spending/timeline",
|
|
976
|
+
method="GET",
|
|
977
|
+
params={
|
|
978
|
+
"start": start,
|
|
979
|
+
"end": end,
|
|
980
|
+
"granularity": granularity,
|
|
981
|
+
},
|
|
982
|
+
request_options=request_options,
|
|
983
|
+
)
|
|
984
|
+
try:
|
|
985
|
+
if 200 <= _response.status_code < 300:
|
|
986
|
+
_data = typing.cast(
|
|
987
|
+
ProviderTimelineResponse,
|
|
988
|
+
parse_obj_as(
|
|
989
|
+
type_=ProviderTimelineResponse, # type: ignore
|
|
990
|
+
object_=_response.json(),
|
|
991
|
+
),
|
|
992
|
+
)
|
|
993
|
+
return HttpResponse(response=_response, data=_data)
|
|
994
|
+
if _response.status_code == 401:
|
|
995
|
+
raise UnauthorizedError(
|
|
996
|
+
headers=dict(_response.headers),
|
|
997
|
+
body=typing.cast(
|
|
998
|
+
AuthenticationError,
|
|
999
|
+
parse_obj_as(
|
|
1000
|
+
type_=AuthenticationError, # type: ignore
|
|
1001
|
+
object_=_response.json(),
|
|
1002
|
+
),
|
|
1003
|
+
),
|
|
1004
|
+
)
|
|
1005
|
+
if _response.status_code == 403:
|
|
1006
|
+
raise ForbiddenError(
|
|
1007
|
+
headers=dict(_response.headers),
|
|
1008
|
+
body=typing.cast(
|
|
1009
|
+
AuthorizationError,
|
|
1010
|
+
parse_obj_as(
|
|
1011
|
+
type_=AuthorizationError, # type: ignore
|
|
1012
|
+
object_=_response.json(),
|
|
1013
|
+
),
|
|
1014
|
+
),
|
|
1015
|
+
)
|
|
1016
|
+
if _response.status_code == 422:
|
|
1017
|
+
raise UnprocessableEntityError(
|
|
1018
|
+
headers=dict(_response.headers),
|
|
1019
|
+
body=typing.cast(
|
|
1020
|
+
HttpValidationError,
|
|
1021
|
+
parse_obj_as(
|
|
1022
|
+
type_=HttpValidationError, # type: ignore
|
|
1023
|
+
object_=_response.json(),
|
|
1024
|
+
),
|
|
1025
|
+
),
|
|
1026
|
+
)
|
|
1027
|
+
_response_json = _response.json()
|
|
1028
|
+
except JSONDecodeError:
|
|
1029
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
1030
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
1031
|
+
|
|
1032
|
+
def get_potential_savings_summary(
|
|
1033
|
+
self, provider_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
1034
|
+
) -> HttpResponse[ProviderPotentialSavingsSummaryResponse]:
|
|
1035
|
+
"""
|
|
1036
|
+
Returns potential savings summary for a specific provider
|
|
1037
|
+
|
|
1038
|
+
Parameters
|
|
1039
|
+
----------
|
|
1040
|
+
provider_id : str
|
|
1041
|
+
|
|
1042
|
+
request_options : typing.Optional[RequestOptions]
|
|
1043
|
+
Request-specific configuration.
|
|
1044
|
+
|
|
1045
|
+
Returns
|
|
1046
|
+
-------
|
|
1047
|
+
HttpResponse[ProviderPotentialSavingsSummaryResponse]
|
|
1048
|
+
Successful Response
|
|
1049
|
+
"""
|
|
1050
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
1051
|
+
f"api/v1/providers/{jsonable_encoder(provider_id)}/potential-savings/summary",
|
|
1052
|
+
method="GET",
|
|
1053
|
+
request_options=request_options,
|
|
1054
|
+
)
|
|
1055
|
+
try:
|
|
1056
|
+
if 200 <= _response.status_code < 300:
|
|
1057
|
+
_data = typing.cast(
|
|
1058
|
+
ProviderPotentialSavingsSummaryResponse,
|
|
1059
|
+
parse_obj_as(
|
|
1060
|
+
type_=ProviderPotentialSavingsSummaryResponse, # type: ignore
|
|
1061
|
+
object_=_response.json(),
|
|
1062
|
+
),
|
|
1063
|
+
)
|
|
1064
|
+
return HttpResponse(response=_response, data=_data)
|
|
1065
|
+
if _response.status_code == 401:
|
|
1066
|
+
raise UnauthorizedError(
|
|
1067
|
+
headers=dict(_response.headers),
|
|
1068
|
+
body=typing.cast(
|
|
1069
|
+
AuthenticationError,
|
|
1070
|
+
parse_obj_as(
|
|
1071
|
+
type_=AuthenticationError, # type: ignore
|
|
1072
|
+
object_=_response.json(),
|
|
1073
|
+
),
|
|
1074
|
+
),
|
|
1075
|
+
)
|
|
1076
|
+
if _response.status_code == 403:
|
|
1077
|
+
raise ForbiddenError(
|
|
1078
|
+
headers=dict(_response.headers),
|
|
1079
|
+
body=typing.cast(
|
|
1080
|
+
AuthorizationError,
|
|
1081
|
+
parse_obj_as(
|
|
1082
|
+
type_=AuthorizationError, # type: ignore
|
|
1083
|
+
object_=_response.json(),
|
|
1084
|
+
),
|
|
1085
|
+
),
|
|
1086
|
+
)
|
|
1087
|
+
if _response.status_code == 422:
|
|
1088
|
+
raise UnprocessableEntityError(
|
|
1089
|
+
headers=dict(_response.headers),
|
|
1090
|
+
body=typing.cast(
|
|
1091
|
+
HttpValidationError,
|
|
1092
|
+
parse_obj_as(
|
|
1093
|
+
type_=HttpValidationError, # type: ignore
|
|
1094
|
+
object_=_response.json(),
|
|
1095
|
+
),
|
|
1096
|
+
),
|
|
1097
|
+
)
|
|
1098
|
+
_response_json = _response.json()
|
|
1099
|
+
except JSONDecodeError:
|
|
1100
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
1101
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
1102
|
+
|
|
1103
|
+
def list_potential_savings(
|
|
1104
|
+
self,
|
|
1105
|
+
provider_id: str,
|
|
1106
|
+
*,
|
|
1107
|
+
page: typing.Optional[int] = None,
|
|
1108
|
+
page_size: typing.Optional[int] = None,
|
|
1109
|
+
sort_by: typing.Optional[str] = None,
|
|
1110
|
+
sort_order: typing.Optional[str] = None,
|
|
1111
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
1112
|
+
) -> SyncPager[ProviderBreakdownItem, ProviderBreakdownResponse]:
|
|
1113
|
+
"""
|
|
1114
|
+
Returns paginated potential savings breakdown for a specific provider
|
|
1115
|
+
|
|
1116
|
+
Parameters
|
|
1117
|
+
----------
|
|
1118
|
+
provider_id : str
|
|
1119
|
+
|
|
1120
|
+
page : typing.Optional[int]
|
|
1121
|
+
Page number (1-indexed)
|
|
1122
|
+
|
|
1123
|
+
page_size : typing.Optional[int]
|
|
1124
|
+
Items per page
|
|
1125
|
+
|
|
1126
|
+
sort_by : typing.Optional[str]
|
|
1127
|
+
Field to sort by
|
|
1128
|
+
|
|
1129
|
+
sort_order : typing.Optional[str]
|
|
1130
|
+
Sort order
|
|
1131
|
+
|
|
1132
|
+
request_options : typing.Optional[RequestOptions]
|
|
1133
|
+
Request-specific configuration.
|
|
1134
|
+
|
|
1135
|
+
Returns
|
|
1136
|
+
-------
|
|
1137
|
+
SyncPager[ProviderBreakdownItem, ProviderBreakdownResponse]
|
|
1138
|
+
Successful Response
|
|
1139
|
+
"""
|
|
1140
|
+
page = page if page is not None else 1
|
|
1141
|
+
|
|
1142
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
1143
|
+
f"api/v1/providers/{jsonable_encoder(provider_id)}/potential-savings/breakdown",
|
|
1144
|
+
method="GET",
|
|
1145
|
+
params={
|
|
1146
|
+
"page": page,
|
|
1147
|
+
"page_size": page_size,
|
|
1148
|
+
"sort_by": sort_by,
|
|
1149
|
+
"sort_order": sort_order,
|
|
1150
|
+
},
|
|
1151
|
+
request_options=request_options,
|
|
1152
|
+
)
|
|
1153
|
+
try:
|
|
1154
|
+
if 200 <= _response.status_code < 300:
|
|
1155
|
+
_parsed_response = typing.cast(
|
|
1156
|
+
ProviderBreakdownResponse,
|
|
1157
|
+
parse_obj_as(
|
|
1158
|
+
type_=ProviderBreakdownResponse, # type: ignore
|
|
1159
|
+
object_=_response.json(),
|
|
1160
|
+
),
|
|
1161
|
+
)
|
|
1162
|
+
_items = _parsed_response.data.items if _parsed_response.data is not None else []
|
|
1163
|
+
|
|
1164
|
+
_has_next = True
|
|
1165
|
+
_get_next = lambda: self.list_potential_savings(
|
|
1166
|
+
provider_id,
|
|
1167
|
+
page=page + 1,
|
|
1168
|
+
page_size=page_size,
|
|
1169
|
+
sort_by=sort_by,
|
|
1170
|
+
sort_order=sort_order,
|
|
1171
|
+
request_options=request_options,
|
|
1172
|
+
)
|
|
1173
|
+
return SyncPager(has_next=_has_next, items=_items, get_next=_get_next, response=_parsed_response)
|
|
1174
|
+
if _response.status_code == 401:
|
|
1175
|
+
raise UnauthorizedError(
|
|
1176
|
+
headers=dict(_response.headers),
|
|
1177
|
+
body=typing.cast(
|
|
1178
|
+
AuthenticationError,
|
|
1179
|
+
parse_obj_as(
|
|
1180
|
+
type_=AuthenticationError, # type: ignore
|
|
1181
|
+
object_=_response.json(),
|
|
1182
|
+
),
|
|
1183
|
+
),
|
|
1184
|
+
)
|
|
1185
|
+
if _response.status_code == 403:
|
|
1186
|
+
raise ForbiddenError(
|
|
1187
|
+
headers=dict(_response.headers),
|
|
1188
|
+
body=typing.cast(
|
|
1189
|
+
AuthorizationError,
|
|
1190
|
+
parse_obj_as(
|
|
1191
|
+
type_=AuthorizationError, # type: ignore
|
|
1192
|
+
object_=_response.json(),
|
|
1193
|
+
),
|
|
1194
|
+
),
|
|
1195
|
+
)
|
|
1196
|
+
if _response.status_code == 422:
|
|
1197
|
+
raise UnprocessableEntityError(
|
|
1198
|
+
headers=dict(_response.headers),
|
|
1199
|
+
body=typing.cast(
|
|
1200
|
+
HttpValidationError,
|
|
1201
|
+
parse_obj_as(
|
|
1202
|
+
type_=HttpValidationError, # type: ignore
|
|
1203
|
+
object_=_response.json(),
|
|
1204
|
+
),
|
|
1205
|
+
),
|
|
1206
|
+
)
|
|
1207
|
+
_response_json = _response.json()
|
|
1208
|
+
except JSONDecodeError:
|
|
1209
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
1210
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
1211
|
+
|
|
1212
|
+
|
|
1213
|
+
class AsyncRawProvidersClient:
|
|
1214
|
+
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
|
1215
|
+
self._client_wrapper = client_wrapper
|
|
1216
|
+
|
|
1217
|
+
async def get_recommendations_summary(
|
|
1218
|
+
self, provider_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
1219
|
+
) -> AsyncHttpResponse[ProviderRecommendationsSummaryResponse]:
|
|
1220
|
+
"""
|
|
1221
|
+
Returns top 7 recommendations for a specific cloud provider
|
|
1222
|
+
|
|
1223
|
+
Parameters
|
|
1224
|
+
----------
|
|
1225
|
+
provider_id : str
|
|
1226
|
+
|
|
1227
|
+
request_options : typing.Optional[RequestOptions]
|
|
1228
|
+
Request-specific configuration.
|
|
1229
|
+
|
|
1230
|
+
Returns
|
|
1231
|
+
-------
|
|
1232
|
+
AsyncHttpResponse[ProviderRecommendationsSummaryResponse]
|
|
1233
|
+
Successful Response
|
|
1234
|
+
"""
|
|
1235
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
1236
|
+
f"api/v1/providers/{jsonable_encoder(provider_id)}/recommendations/summary",
|
|
1237
|
+
method="GET",
|
|
1238
|
+
request_options=request_options,
|
|
1239
|
+
)
|
|
1240
|
+
try:
|
|
1241
|
+
if 200 <= _response.status_code < 300:
|
|
1242
|
+
_data = typing.cast(
|
|
1243
|
+
ProviderRecommendationsSummaryResponse,
|
|
1244
|
+
parse_obj_as(
|
|
1245
|
+
type_=ProviderRecommendationsSummaryResponse, # type: ignore
|
|
1246
|
+
object_=_response.json(),
|
|
1247
|
+
),
|
|
1248
|
+
)
|
|
1249
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
1250
|
+
if _response.status_code == 401:
|
|
1251
|
+
raise UnauthorizedError(
|
|
1252
|
+
headers=dict(_response.headers),
|
|
1253
|
+
body=typing.cast(
|
|
1254
|
+
AuthenticationError,
|
|
1255
|
+
parse_obj_as(
|
|
1256
|
+
type_=AuthenticationError, # type: ignore
|
|
1257
|
+
object_=_response.json(),
|
|
1258
|
+
),
|
|
1259
|
+
),
|
|
1260
|
+
)
|
|
1261
|
+
if _response.status_code == 403:
|
|
1262
|
+
raise ForbiddenError(
|
|
1263
|
+
headers=dict(_response.headers),
|
|
1264
|
+
body=typing.cast(
|
|
1265
|
+
AuthorizationError,
|
|
1266
|
+
parse_obj_as(
|
|
1267
|
+
type_=AuthorizationError, # type: ignore
|
|
1268
|
+
object_=_response.json(),
|
|
1269
|
+
),
|
|
1270
|
+
),
|
|
1271
|
+
)
|
|
1272
|
+
if _response.status_code == 422:
|
|
1273
|
+
raise UnprocessableEntityError(
|
|
1274
|
+
headers=dict(_response.headers),
|
|
1275
|
+
body=typing.cast(
|
|
1276
|
+
HttpValidationError,
|
|
1277
|
+
parse_obj_as(
|
|
1278
|
+
type_=HttpValidationError, # type: ignore
|
|
1279
|
+
object_=_response.json(),
|
|
1280
|
+
),
|
|
1281
|
+
),
|
|
1282
|
+
)
|
|
1283
|
+
_response_json = _response.json()
|
|
1284
|
+
except JSONDecodeError:
|
|
1285
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
1286
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
1287
|
+
|
|
1288
|
+
async def list_recommendations(
|
|
1289
|
+
self,
|
|
1290
|
+
provider_id: str,
|
|
1291
|
+
*,
|
|
1292
|
+
start: typing.Optional[str] = None,
|
|
1293
|
+
end: typing.Optional[str] = None,
|
|
1294
|
+
page: typing.Optional[int] = None,
|
|
1295
|
+
page_size: typing.Optional[int] = None,
|
|
1296
|
+
sort_by: typing.Optional[str] = None,
|
|
1297
|
+
sort_order: typing.Optional[str] = None,
|
|
1298
|
+
service: typing.Optional[typing.Sequence[str]] = None,
|
|
1299
|
+
environment: typing.Optional[typing.Sequence[str]] = None,
|
|
1300
|
+
account: typing.Optional[typing.Sequence[str]] = None,
|
|
1301
|
+
tag: typing.Optional[typing.Sequence[str]] = None,
|
|
1302
|
+
display_status: typing.Optional[typing.Sequence[str]] = None,
|
|
1303
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
1304
|
+
) -> AsyncPager[ProviderBreakdownItem, ProviderBreakdownResponse]:
|
|
1305
|
+
"""
|
|
1306
|
+
Returns paginated breakdown of recommendations for a specific provider
|
|
1307
|
+
|
|
1308
|
+
Parameters
|
|
1309
|
+
----------
|
|
1310
|
+
provider_id : str
|
|
1311
|
+
|
|
1312
|
+
start : typing.Optional[str]
|
|
1313
|
+
Start date filter (ISO 8601 format: YYYY-MM-DD)
|
|
1314
|
+
|
|
1315
|
+
end : typing.Optional[str]
|
|
1316
|
+
End date filter (ISO 8601 format: YYYY-MM-DD)
|
|
1317
|
+
|
|
1318
|
+
page : typing.Optional[int]
|
|
1319
|
+
Page number (1-indexed)
|
|
1320
|
+
|
|
1321
|
+
page_size : typing.Optional[int]
|
|
1322
|
+
Items per page (max 100)
|
|
1323
|
+
|
|
1324
|
+
sort_by : typing.Optional[str]
|
|
1325
|
+
Field to sort by (recommendation_id, service, environment, account, tag, monthly_savings, savings_percentage, status)
|
|
1326
|
+
|
|
1327
|
+
sort_order : typing.Optional[str]
|
|
1328
|
+
Sort order (asc or desc)
|
|
1329
|
+
|
|
1330
|
+
service : typing.Optional[typing.Sequence[str]]
|
|
1331
|
+
Filter by service(s) - can be repeated for multiple values
|
|
1332
|
+
|
|
1333
|
+
environment : typing.Optional[typing.Sequence[str]]
|
|
1334
|
+
Filter by environment(s) - can be repeated for multiple values
|
|
1335
|
+
|
|
1336
|
+
account : typing.Optional[typing.Sequence[str]]
|
|
1337
|
+
Filter by account(s) - can be repeated for multiple values
|
|
1338
|
+
|
|
1339
|
+
tag : typing.Optional[typing.Sequence[str]]
|
|
1340
|
+
Filter by tag(s) - can be repeated for multiple values
|
|
1341
|
+
|
|
1342
|
+
display_status : typing.Optional[typing.Sequence[str]]
|
|
1343
|
+
Filter by display status(es): available, pending, processing, optimized, rejected, unavailable
|
|
1344
|
+
|
|
1345
|
+
request_options : typing.Optional[RequestOptions]
|
|
1346
|
+
Request-specific configuration.
|
|
1347
|
+
|
|
1348
|
+
Returns
|
|
1349
|
+
-------
|
|
1350
|
+
AsyncPager[ProviderBreakdownItem, ProviderBreakdownResponse]
|
|
1351
|
+
Successful Response
|
|
1352
|
+
"""
|
|
1353
|
+
page = page if page is not None else 1
|
|
1354
|
+
|
|
1355
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
1356
|
+
f"api/v1/providers/{jsonable_encoder(provider_id)}/recommendations",
|
|
1357
|
+
method="GET",
|
|
1358
|
+
params={
|
|
1359
|
+
"start": start,
|
|
1360
|
+
"end": end,
|
|
1361
|
+
"page": page,
|
|
1362
|
+
"page_size": page_size,
|
|
1363
|
+
"sort_by": sort_by,
|
|
1364
|
+
"sort_order": sort_order,
|
|
1365
|
+
"service": service,
|
|
1366
|
+
"environment": environment,
|
|
1367
|
+
"account": account,
|
|
1368
|
+
"tag": tag,
|
|
1369
|
+
"display_status": display_status,
|
|
1370
|
+
},
|
|
1371
|
+
request_options=request_options,
|
|
1372
|
+
)
|
|
1373
|
+
try:
|
|
1374
|
+
if 200 <= _response.status_code < 300:
|
|
1375
|
+
_parsed_response = typing.cast(
|
|
1376
|
+
ProviderBreakdownResponse,
|
|
1377
|
+
parse_obj_as(
|
|
1378
|
+
type_=ProviderBreakdownResponse, # type: ignore
|
|
1379
|
+
object_=_response.json(),
|
|
1380
|
+
),
|
|
1381
|
+
)
|
|
1382
|
+
_items = _parsed_response.data.items if _parsed_response.data is not None else []
|
|
1383
|
+
|
|
1384
|
+
_has_next = True
|
|
1385
|
+
|
|
1386
|
+
async def _get_next():
|
|
1387
|
+
return await self.list_recommendations(
|
|
1388
|
+
provider_id,
|
|
1389
|
+
start=start,
|
|
1390
|
+
end=end,
|
|
1391
|
+
page=page + 1,
|
|
1392
|
+
page_size=page_size,
|
|
1393
|
+
sort_by=sort_by,
|
|
1394
|
+
sort_order=sort_order,
|
|
1395
|
+
service=service,
|
|
1396
|
+
environment=environment,
|
|
1397
|
+
account=account,
|
|
1398
|
+
tag=tag,
|
|
1399
|
+
display_status=display_status,
|
|
1400
|
+
request_options=request_options,
|
|
1401
|
+
)
|
|
1402
|
+
|
|
1403
|
+
return AsyncPager(has_next=_has_next, items=_items, get_next=_get_next, response=_parsed_response)
|
|
1404
|
+
if _response.status_code == 401:
|
|
1405
|
+
raise UnauthorizedError(
|
|
1406
|
+
headers=dict(_response.headers),
|
|
1407
|
+
body=typing.cast(
|
|
1408
|
+
AuthenticationError,
|
|
1409
|
+
parse_obj_as(
|
|
1410
|
+
type_=AuthenticationError, # type: ignore
|
|
1411
|
+
object_=_response.json(),
|
|
1412
|
+
),
|
|
1413
|
+
),
|
|
1414
|
+
)
|
|
1415
|
+
if _response.status_code == 403:
|
|
1416
|
+
raise ForbiddenError(
|
|
1417
|
+
headers=dict(_response.headers),
|
|
1418
|
+
body=typing.cast(
|
|
1419
|
+
AuthorizationError,
|
|
1420
|
+
parse_obj_as(
|
|
1421
|
+
type_=AuthorizationError, # type: ignore
|
|
1422
|
+
object_=_response.json(),
|
|
1423
|
+
),
|
|
1424
|
+
),
|
|
1425
|
+
)
|
|
1426
|
+
if _response.status_code == 422:
|
|
1427
|
+
raise UnprocessableEntityError(
|
|
1428
|
+
headers=dict(_response.headers),
|
|
1429
|
+
body=typing.cast(
|
|
1430
|
+
HttpValidationError,
|
|
1431
|
+
parse_obj_as(
|
|
1432
|
+
type_=HttpValidationError, # type: ignore
|
|
1433
|
+
object_=_response.json(),
|
|
1434
|
+
),
|
|
1435
|
+
),
|
|
1436
|
+
)
|
|
1437
|
+
_response_json = _response.json()
|
|
1438
|
+
except JSONDecodeError:
|
|
1439
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
1440
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
1441
|
+
|
|
1442
|
+
async def get_recommendations_overview(
|
|
1443
|
+
self, provider_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
1444
|
+
) -> AsyncHttpResponse[RecommendationsOverviewResponse]:
|
|
1445
|
+
"""
|
|
1446
|
+
Returns overview metrics (total spend, available/pending savings, saved ITD) for a provider
|
|
1447
|
+
|
|
1448
|
+
Parameters
|
|
1449
|
+
----------
|
|
1450
|
+
provider_id : str
|
|
1451
|
+
|
|
1452
|
+
request_options : typing.Optional[RequestOptions]
|
|
1453
|
+
Request-specific configuration.
|
|
1454
|
+
|
|
1455
|
+
Returns
|
|
1456
|
+
-------
|
|
1457
|
+
AsyncHttpResponse[RecommendationsOverviewResponse]
|
|
1458
|
+
Successful Response
|
|
1459
|
+
"""
|
|
1460
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
1461
|
+
f"api/v1/providers/{jsonable_encoder(provider_id)}/recommendations/overview",
|
|
1462
|
+
method="GET",
|
|
1463
|
+
request_options=request_options,
|
|
1464
|
+
)
|
|
1465
|
+
try:
|
|
1466
|
+
if 200 <= _response.status_code < 300:
|
|
1467
|
+
_data = typing.cast(
|
|
1468
|
+
RecommendationsOverviewResponse,
|
|
1469
|
+
parse_obj_as(
|
|
1470
|
+
type_=RecommendationsOverviewResponse, # type: ignore
|
|
1471
|
+
object_=_response.json(),
|
|
1472
|
+
),
|
|
1473
|
+
)
|
|
1474
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
1475
|
+
if _response.status_code == 401:
|
|
1476
|
+
raise UnauthorizedError(
|
|
1477
|
+
headers=dict(_response.headers),
|
|
1478
|
+
body=typing.cast(
|
|
1479
|
+
AuthenticationError,
|
|
1480
|
+
parse_obj_as(
|
|
1481
|
+
type_=AuthenticationError, # type: ignore
|
|
1482
|
+
object_=_response.json(),
|
|
1483
|
+
),
|
|
1484
|
+
),
|
|
1485
|
+
)
|
|
1486
|
+
if _response.status_code == 403:
|
|
1487
|
+
raise ForbiddenError(
|
|
1488
|
+
headers=dict(_response.headers),
|
|
1489
|
+
body=typing.cast(
|
|
1490
|
+
AuthorizationError,
|
|
1491
|
+
parse_obj_as(
|
|
1492
|
+
type_=AuthorizationError, # type: ignore
|
|
1493
|
+
object_=_response.json(),
|
|
1494
|
+
),
|
|
1495
|
+
),
|
|
1496
|
+
)
|
|
1497
|
+
if _response.status_code == 422:
|
|
1498
|
+
raise UnprocessableEntityError(
|
|
1499
|
+
headers=dict(_response.headers),
|
|
1500
|
+
body=typing.cast(
|
|
1501
|
+
HttpValidationError,
|
|
1502
|
+
parse_obj_as(
|
|
1503
|
+
type_=HttpValidationError, # type: ignore
|
|
1504
|
+
object_=_response.json(),
|
|
1505
|
+
),
|
|
1506
|
+
),
|
|
1507
|
+
)
|
|
1508
|
+
_response_json = _response.json()
|
|
1509
|
+
except JSONDecodeError:
|
|
1510
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
1511
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
1512
|
+
|
|
1513
|
+
async def get_recommendation_filters(
|
|
1514
|
+
self, provider_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
1515
|
+
) -> AsyncHttpResponse[RecommendationFilterOptionsResponse]:
|
|
1516
|
+
"""
|
|
1517
|
+
Returns distinct environments, accounts, and tags for recommendation filtering
|
|
1518
|
+
|
|
1519
|
+
Parameters
|
|
1520
|
+
----------
|
|
1521
|
+
provider_id : str
|
|
1522
|
+
|
|
1523
|
+
request_options : typing.Optional[RequestOptions]
|
|
1524
|
+
Request-specific configuration.
|
|
1525
|
+
|
|
1526
|
+
Returns
|
|
1527
|
+
-------
|
|
1528
|
+
AsyncHttpResponse[RecommendationFilterOptionsResponse]
|
|
1529
|
+
Successful Response
|
|
1530
|
+
"""
|
|
1531
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
1532
|
+
f"api/v1/providers/{jsonable_encoder(provider_id)}/recommendations/filter-options",
|
|
1533
|
+
method="GET",
|
|
1534
|
+
request_options=request_options,
|
|
1535
|
+
)
|
|
1536
|
+
try:
|
|
1537
|
+
if 200 <= _response.status_code < 300:
|
|
1538
|
+
_data = typing.cast(
|
|
1539
|
+
RecommendationFilterOptionsResponse,
|
|
1540
|
+
parse_obj_as(
|
|
1541
|
+
type_=RecommendationFilterOptionsResponse, # type: ignore
|
|
1542
|
+
object_=_response.json(),
|
|
1543
|
+
),
|
|
1544
|
+
)
|
|
1545
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
1546
|
+
if _response.status_code == 401:
|
|
1547
|
+
raise UnauthorizedError(
|
|
1548
|
+
headers=dict(_response.headers),
|
|
1549
|
+
body=typing.cast(
|
|
1550
|
+
AuthenticationError,
|
|
1551
|
+
parse_obj_as(
|
|
1552
|
+
type_=AuthenticationError, # type: ignore
|
|
1553
|
+
object_=_response.json(),
|
|
1554
|
+
),
|
|
1555
|
+
),
|
|
1556
|
+
)
|
|
1557
|
+
if _response.status_code == 403:
|
|
1558
|
+
raise ForbiddenError(
|
|
1559
|
+
headers=dict(_response.headers),
|
|
1560
|
+
body=typing.cast(
|
|
1561
|
+
AuthorizationError,
|
|
1562
|
+
parse_obj_as(
|
|
1563
|
+
type_=AuthorizationError, # type: ignore
|
|
1564
|
+
object_=_response.json(),
|
|
1565
|
+
),
|
|
1566
|
+
),
|
|
1567
|
+
)
|
|
1568
|
+
if _response.status_code == 422:
|
|
1569
|
+
raise UnprocessableEntityError(
|
|
1570
|
+
headers=dict(_response.headers),
|
|
1571
|
+
body=typing.cast(
|
|
1572
|
+
HttpValidationError,
|
|
1573
|
+
parse_obj_as(
|
|
1574
|
+
type_=HttpValidationError, # type: ignore
|
|
1575
|
+
object_=_response.json(),
|
|
1576
|
+
),
|
|
1577
|
+
),
|
|
1578
|
+
)
|
|
1579
|
+
_response_json = _response.json()
|
|
1580
|
+
except JSONDecodeError:
|
|
1581
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
1582
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
1583
|
+
|
|
1584
|
+
async def list_savings_breakdown(
|
|
1585
|
+
self,
|
|
1586
|
+
provider_id: str,
|
|
1587
|
+
*,
|
|
1588
|
+
start: typing.Optional[str] = None,
|
|
1589
|
+
end: typing.Optional[str] = None,
|
|
1590
|
+
page: typing.Optional[int] = None,
|
|
1591
|
+
page_size: typing.Optional[int] = None,
|
|
1592
|
+
sort_by: typing.Optional[str] = None,
|
|
1593
|
+
sort_order: typing.Optional[str] = None,
|
|
1594
|
+
preset: typing.Optional[str] = None,
|
|
1595
|
+
service: typing.Optional[typing.Sequence[str]] = None,
|
|
1596
|
+
environment: typing.Optional[typing.Sequence[str]] = None,
|
|
1597
|
+
account_id: typing.Optional[typing.Sequence[str]] = None,
|
|
1598
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
1599
|
+
) -> AsyncPager[SavedByProviderItem, SavedByProviderBreakdownResponse]:
|
|
1600
|
+
"""
|
|
1601
|
+
Returns paginated breakdown of saved recommendations for a specific provider with filtering and sorting
|
|
1602
|
+
|
|
1603
|
+
Parameters
|
|
1604
|
+
----------
|
|
1605
|
+
provider_id : str
|
|
1606
|
+
|
|
1607
|
+
start : typing.Optional[str]
|
|
1608
|
+
Start date filter (ISO 8601 format: YYYY-MM-DD or YYYY-MM)
|
|
1609
|
+
|
|
1610
|
+
end : typing.Optional[str]
|
|
1611
|
+
End date filter (ISO 8601 format: YYYY-MM-DD or YYYY-MM)
|
|
1612
|
+
|
|
1613
|
+
page : typing.Optional[int]
|
|
1614
|
+
Page number (1-indexed)
|
|
1615
|
+
|
|
1616
|
+
page_size : typing.Optional[int]
|
|
1617
|
+
Items per page (max 100)
|
|
1618
|
+
|
|
1619
|
+
sort_by : typing.Optional[str]
|
|
1620
|
+
Field to sort by (period, account_id, environment, service, usage_type, usage_quantity, usage_unit, pre_optimization_cost, monthly_savings, approved_by)
|
|
1621
|
+
|
|
1622
|
+
sort_order : typing.Optional[str]
|
|
1623
|
+
Sort order (asc or desc)
|
|
1624
|
+
|
|
1625
|
+
preset : typing.Optional[str]
|
|
1626
|
+
Date preset: '30D', '6M', or '12M' (takes precedence over start/end)
|
|
1627
|
+
|
|
1628
|
+
service : typing.Optional[typing.Sequence[str]]
|
|
1629
|
+
Filter by service(s) - can be repeated for multiple values
|
|
1630
|
+
|
|
1631
|
+
environment : typing.Optional[typing.Sequence[str]]
|
|
1632
|
+
Filter by environment(s) - can be repeated for multiple values
|
|
1633
|
+
|
|
1634
|
+
account_id : typing.Optional[typing.Sequence[str]]
|
|
1635
|
+
Filter by account ID(s) - can be repeated for multiple values
|
|
1636
|
+
|
|
1637
|
+
request_options : typing.Optional[RequestOptions]
|
|
1638
|
+
Request-specific configuration.
|
|
1639
|
+
|
|
1640
|
+
Returns
|
|
1641
|
+
-------
|
|
1642
|
+
AsyncPager[SavedByProviderItem, SavedByProviderBreakdownResponse]
|
|
1643
|
+
Successful Response
|
|
1644
|
+
"""
|
|
1645
|
+
page = page if page is not None else 1
|
|
1646
|
+
|
|
1647
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
1648
|
+
f"api/v1/providers/{jsonable_encoder(provider_id)}/savings/breakdown",
|
|
1649
|
+
method="GET",
|
|
1650
|
+
params={
|
|
1651
|
+
"start": start,
|
|
1652
|
+
"end": end,
|
|
1653
|
+
"page": page,
|
|
1654
|
+
"page_size": page_size,
|
|
1655
|
+
"sort_by": sort_by,
|
|
1656
|
+
"sort_order": sort_order,
|
|
1657
|
+
"preset": preset,
|
|
1658
|
+
"service": service,
|
|
1659
|
+
"environment": environment,
|
|
1660
|
+
"account_id": account_id,
|
|
1661
|
+
},
|
|
1662
|
+
request_options=request_options,
|
|
1663
|
+
)
|
|
1664
|
+
try:
|
|
1665
|
+
if 200 <= _response.status_code < 300:
|
|
1666
|
+
_parsed_response = typing.cast(
|
|
1667
|
+
SavedByProviderBreakdownResponse,
|
|
1668
|
+
parse_obj_as(
|
|
1669
|
+
type_=SavedByProviderBreakdownResponse, # type: ignore
|
|
1670
|
+
object_=_response.json(),
|
|
1671
|
+
),
|
|
1672
|
+
)
|
|
1673
|
+
_items = _parsed_response.data.items if _parsed_response.data is not None else []
|
|
1674
|
+
|
|
1675
|
+
_has_next = True
|
|
1676
|
+
|
|
1677
|
+
async def _get_next():
|
|
1678
|
+
return await self.list_savings_breakdown(
|
|
1679
|
+
provider_id,
|
|
1680
|
+
start=start,
|
|
1681
|
+
end=end,
|
|
1682
|
+
page=page + 1,
|
|
1683
|
+
page_size=page_size,
|
|
1684
|
+
sort_by=sort_by,
|
|
1685
|
+
sort_order=sort_order,
|
|
1686
|
+
preset=preset,
|
|
1687
|
+
service=service,
|
|
1688
|
+
environment=environment,
|
|
1689
|
+
account_id=account_id,
|
|
1690
|
+
request_options=request_options,
|
|
1691
|
+
)
|
|
1692
|
+
|
|
1693
|
+
return AsyncPager(has_next=_has_next, items=_items, get_next=_get_next, response=_parsed_response)
|
|
1694
|
+
if _response.status_code == 401:
|
|
1695
|
+
raise UnauthorizedError(
|
|
1696
|
+
headers=dict(_response.headers),
|
|
1697
|
+
body=typing.cast(
|
|
1698
|
+
AuthenticationError,
|
|
1699
|
+
parse_obj_as(
|
|
1700
|
+
type_=AuthenticationError, # type: ignore
|
|
1701
|
+
object_=_response.json(),
|
|
1702
|
+
),
|
|
1703
|
+
),
|
|
1704
|
+
)
|
|
1705
|
+
if _response.status_code == 403:
|
|
1706
|
+
raise ForbiddenError(
|
|
1707
|
+
headers=dict(_response.headers),
|
|
1708
|
+
body=typing.cast(
|
|
1709
|
+
AuthorizationError,
|
|
1710
|
+
parse_obj_as(
|
|
1711
|
+
type_=AuthorizationError, # type: ignore
|
|
1712
|
+
object_=_response.json(),
|
|
1713
|
+
),
|
|
1714
|
+
),
|
|
1715
|
+
)
|
|
1716
|
+
if _response.status_code == 422:
|
|
1717
|
+
raise UnprocessableEntityError(
|
|
1718
|
+
headers=dict(_response.headers),
|
|
1719
|
+
body=typing.cast(
|
|
1720
|
+
HttpValidationError,
|
|
1721
|
+
parse_obj_as(
|
|
1722
|
+
type_=HttpValidationError, # type: ignore
|
|
1723
|
+
object_=_response.json(),
|
|
1724
|
+
),
|
|
1725
|
+
),
|
|
1726
|
+
)
|
|
1727
|
+
_response_json = _response.json()
|
|
1728
|
+
except JSONDecodeError:
|
|
1729
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
1730
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
1731
|
+
|
|
1732
|
+
async def get_savings_summary(
|
|
1733
|
+
self, provider_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
1734
|
+
) -> AsyncHttpResponse[ProviderSavedSummaryResponse]:
|
|
1735
|
+
"""
|
|
1736
|
+
Returns saved summary totals for a specific provider (for BigNumbers)
|
|
1737
|
+
|
|
1738
|
+
Parameters
|
|
1739
|
+
----------
|
|
1740
|
+
provider_id : str
|
|
1741
|
+
|
|
1742
|
+
request_options : typing.Optional[RequestOptions]
|
|
1743
|
+
Request-specific configuration.
|
|
1744
|
+
|
|
1745
|
+
Returns
|
|
1746
|
+
-------
|
|
1747
|
+
AsyncHttpResponse[ProviderSavedSummaryResponse]
|
|
1748
|
+
Successful Response
|
|
1749
|
+
"""
|
|
1750
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
1751
|
+
f"api/v1/providers/{jsonable_encoder(provider_id)}/savings/summary",
|
|
1752
|
+
method="GET",
|
|
1753
|
+
request_options=request_options,
|
|
1754
|
+
)
|
|
1755
|
+
try:
|
|
1756
|
+
if 200 <= _response.status_code < 300:
|
|
1757
|
+
_data = typing.cast(
|
|
1758
|
+
ProviderSavedSummaryResponse,
|
|
1759
|
+
parse_obj_as(
|
|
1760
|
+
type_=ProviderSavedSummaryResponse, # type: ignore
|
|
1761
|
+
object_=_response.json(),
|
|
1762
|
+
),
|
|
1763
|
+
)
|
|
1764
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
1765
|
+
if _response.status_code == 401:
|
|
1766
|
+
raise UnauthorizedError(
|
|
1767
|
+
headers=dict(_response.headers),
|
|
1768
|
+
body=typing.cast(
|
|
1769
|
+
AuthenticationError,
|
|
1770
|
+
parse_obj_as(
|
|
1771
|
+
type_=AuthenticationError, # type: ignore
|
|
1772
|
+
object_=_response.json(),
|
|
1773
|
+
),
|
|
1774
|
+
),
|
|
1775
|
+
)
|
|
1776
|
+
if _response.status_code == 403:
|
|
1777
|
+
raise ForbiddenError(
|
|
1778
|
+
headers=dict(_response.headers),
|
|
1779
|
+
body=typing.cast(
|
|
1780
|
+
AuthorizationError,
|
|
1781
|
+
parse_obj_as(
|
|
1782
|
+
type_=AuthorizationError, # type: ignore
|
|
1783
|
+
object_=_response.json(),
|
|
1784
|
+
),
|
|
1785
|
+
),
|
|
1786
|
+
)
|
|
1787
|
+
if _response.status_code == 422:
|
|
1788
|
+
raise UnprocessableEntityError(
|
|
1789
|
+
headers=dict(_response.headers),
|
|
1790
|
+
body=typing.cast(
|
|
1791
|
+
HttpValidationError,
|
|
1792
|
+
parse_obj_as(
|
|
1793
|
+
type_=HttpValidationError, # type: ignore
|
|
1794
|
+
object_=_response.json(),
|
|
1795
|
+
),
|
|
1796
|
+
),
|
|
1797
|
+
)
|
|
1798
|
+
_response_json = _response.json()
|
|
1799
|
+
except JSONDecodeError:
|
|
1800
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
1801
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
1802
|
+
|
|
1803
|
+
async def get_spending_summary(
|
|
1804
|
+
self, provider_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
1805
|
+
) -> AsyncHttpResponse[ProviderSpendingSummaryResponse]:
|
|
1806
|
+
"""
|
|
1807
|
+
Returns spending summary for a specific cloud provider
|
|
1808
|
+
|
|
1809
|
+
Parameters
|
|
1810
|
+
----------
|
|
1811
|
+
provider_id : str
|
|
1812
|
+
|
|
1813
|
+
request_options : typing.Optional[RequestOptions]
|
|
1814
|
+
Request-specific configuration.
|
|
1815
|
+
|
|
1816
|
+
Returns
|
|
1817
|
+
-------
|
|
1818
|
+
AsyncHttpResponse[ProviderSpendingSummaryResponse]
|
|
1819
|
+
Successful Response
|
|
1820
|
+
"""
|
|
1821
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
1822
|
+
f"api/v1/providers/{jsonable_encoder(provider_id)}/spending/summary",
|
|
1823
|
+
method="GET",
|
|
1824
|
+
request_options=request_options,
|
|
1825
|
+
)
|
|
1826
|
+
try:
|
|
1827
|
+
if 200 <= _response.status_code < 300:
|
|
1828
|
+
_data = typing.cast(
|
|
1829
|
+
ProviderSpendingSummaryResponse,
|
|
1830
|
+
parse_obj_as(
|
|
1831
|
+
type_=ProviderSpendingSummaryResponse, # type: ignore
|
|
1832
|
+
object_=_response.json(),
|
|
1833
|
+
),
|
|
1834
|
+
)
|
|
1835
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
1836
|
+
if _response.status_code == 401:
|
|
1837
|
+
raise UnauthorizedError(
|
|
1838
|
+
headers=dict(_response.headers),
|
|
1839
|
+
body=typing.cast(
|
|
1840
|
+
AuthenticationError,
|
|
1841
|
+
parse_obj_as(
|
|
1842
|
+
type_=AuthenticationError, # type: ignore
|
|
1843
|
+
object_=_response.json(),
|
|
1844
|
+
),
|
|
1845
|
+
),
|
|
1846
|
+
)
|
|
1847
|
+
if _response.status_code == 403:
|
|
1848
|
+
raise ForbiddenError(
|
|
1849
|
+
headers=dict(_response.headers),
|
|
1850
|
+
body=typing.cast(
|
|
1851
|
+
AuthorizationError,
|
|
1852
|
+
parse_obj_as(
|
|
1853
|
+
type_=AuthorizationError, # type: ignore
|
|
1854
|
+
object_=_response.json(),
|
|
1855
|
+
),
|
|
1856
|
+
),
|
|
1857
|
+
)
|
|
1858
|
+
if _response.status_code == 422:
|
|
1859
|
+
raise UnprocessableEntityError(
|
|
1860
|
+
headers=dict(_response.headers),
|
|
1861
|
+
body=typing.cast(
|
|
1862
|
+
HttpValidationError,
|
|
1863
|
+
parse_obj_as(
|
|
1864
|
+
type_=HttpValidationError, # type: ignore
|
|
1865
|
+
object_=_response.json(),
|
|
1866
|
+
),
|
|
1867
|
+
),
|
|
1868
|
+
)
|
|
1869
|
+
_response_json = _response.json()
|
|
1870
|
+
except JSONDecodeError:
|
|
1871
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
1872
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
1873
|
+
|
|
1874
|
+
async def get_spending_filters(
|
|
1875
|
+
self,
|
|
1876
|
+
provider_id: str,
|
|
1877
|
+
*,
|
|
1878
|
+
start: typing.Optional[str] = None,
|
|
1879
|
+
end: typing.Optional[str] = None,
|
|
1880
|
+
tag_key: typing.Optional[typing.Sequence[str]] = None,
|
|
1881
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
1882
|
+
) -> AsyncHttpResponse[ProviderFilterOptionsResponse]:
|
|
1883
|
+
"""
|
|
1884
|
+
Returns distinct services, regions, and accounts for the date range
|
|
1885
|
+
|
|
1886
|
+
Parameters
|
|
1887
|
+
----------
|
|
1888
|
+
provider_id : str
|
|
1889
|
+
|
|
1890
|
+
start : typing.Optional[str]
|
|
1891
|
+
Start date in ISO 8601 format
|
|
1892
|
+
|
|
1893
|
+
end : typing.Optional[str]
|
|
1894
|
+
End date in ISO 8601 format
|
|
1895
|
+
|
|
1896
|
+
tag_key : typing.Optional[typing.Sequence[str]]
|
|
1897
|
+
Filter tag_values by these tag keys
|
|
1898
|
+
|
|
1899
|
+
request_options : typing.Optional[RequestOptions]
|
|
1900
|
+
Request-specific configuration.
|
|
1901
|
+
|
|
1902
|
+
Returns
|
|
1903
|
+
-------
|
|
1904
|
+
AsyncHttpResponse[ProviderFilterOptionsResponse]
|
|
1905
|
+
Successful Response
|
|
1906
|
+
"""
|
|
1907
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
1908
|
+
f"api/v1/providers/{jsonable_encoder(provider_id)}/spending/filter-options",
|
|
1909
|
+
method="GET",
|
|
1910
|
+
params={
|
|
1911
|
+
"start": start,
|
|
1912
|
+
"end": end,
|
|
1913
|
+
"tag_key": tag_key,
|
|
1914
|
+
},
|
|
1915
|
+
request_options=request_options,
|
|
1916
|
+
)
|
|
1917
|
+
try:
|
|
1918
|
+
if 200 <= _response.status_code < 300:
|
|
1919
|
+
_data = typing.cast(
|
|
1920
|
+
ProviderFilterOptionsResponse,
|
|
1921
|
+
parse_obj_as(
|
|
1922
|
+
type_=ProviderFilterOptionsResponse, # type: ignore
|
|
1923
|
+
object_=_response.json(),
|
|
1924
|
+
),
|
|
1925
|
+
)
|
|
1926
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
1927
|
+
if _response.status_code == 401:
|
|
1928
|
+
raise UnauthorizedError(
|
|
1929
|
+
headers=dict(_response.headers),
|
|
1930
|
+
body=typing.cast(
|
|
1931
|
+
AuthenticationError,
|
|
1932
|
+
parse_obj_as(
|
|
1933
|
+
type_=AuthenticationError, # type: ignore
|
|
1934
|
+
object_=_response.json(),
|
|
1935
|
+
),
|
|
1936
|
+
),
|
|
1937
|
+
)
|
|
1938
|
+
if _response.status_code == 403:
|
|
1939
|
+
raise ForbiddenError(
|
|
1940
|
+
headers=dict(_response.headers),
|
|
1941
|
+
body=typing.cast(
|
|
1942
|
+
AuthorizationError,
|
|
1943
|
+
parse_obj_as(
|
|
1944
|
+
type_=AuthorizationError, # type: ignore
|
|
1945
|
+
object_=_response.json(),
|
|
1946
|
+
),
|
|
1947
|
+
),
|
|
1948
|
+
)
|
|
1949
|
+
if _response.status_code == 422:
|
|
1950
|
+
raise UnprocessableEntityError(
|
|
1951
|
+
headers=dict(_response.headers),
|
|
1952
|
+
body=typing.cast(
|
|
1953
|
+
HttpValidationError,
|
|
1954
|
+
parse_obj_as(
|
|
1955
|
+
type_=HttpValidationError, # type: ignore
|
|
1956
|
+
object_=_response.json(),
|
|
1957
|
+
),
|
|
1958
|
+
),
|
|
1959
|
+
)
|
|
1960
|
+
_response_json = _response.json()
|
|
1961
|
+
except JSONDecodeError:
|
|
1962
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
1963
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
1964
|
+
|
|
1965
|
+
async def list_spending_breakdown(
|
|
1966
|
+
self,
|
|
1967
|
+
provider_id: str,
|
|
1968
|
+
*,
|
|
1969
|
+
format: typing.Optional[str] = None,
|
|
1970
|
+
start: typing.Optional[str] = None,
|
|
1971
|
+
end: typing.Optional[str] = None,
|
|
1972
|
+
granularity: typing.Optional[str] = None,
|
|
1973
|
+
page: typing.Optional[int] = None,
|
|
1974
|
+
page_size: typing.Optional[int] = None,
|
|
1975
|
+
sort_by: typing.Optional[str] = None,
|
|
1976
|
+
sort_order: typing.Optional[str] = None,
|
|
1977
|
+
sort_by_date: typing.Optional[str] = None,
|
|
1978
|
+
preset: typing.Optional[str] = None,
|
|
1979
|
+
service: typing.Optional[typing.Sequence[str]] = None,
|
|
1980
|
+
environment: typing.Optional[typing.Sequence[str]] = None,
|
|
1981
|
+
account_id: typing.Optional[typing.Sequence[str]] = None,
|
|
1982
|
+
region: typing.Optional[typing.Sequence[str]] = None,
|
|
1983
|
+
tag_key: typing.Optional[typing.Sequence[str]] = None,
|
|
1984
|
+
tag_value: typing.Optional[typing.Sequence[str]] = None,
|
|
1985
|
+
group_by: typing.Optional[typing.Sequence[str]] = None,
|
|
1986
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
1987
|
+
) -> AsyncHttpResponse[ListSpendingBreakdownProvidersResponse]:
|
|
1988
|
+
"""
|
|
1989
|
+
Returns service breakdown in different formats: table (paginated), chart (aggregated), csv (export), raw (all records)
|
|
1990
|
+
|
|
1991
|
+
Parameters
|
|
1992
|
+
----------
|
|
1993
|
+
provider_id : str
|
|
1994
|
+
|
|
1995
|
+
format : typing.Optional[str]
|
|
1996
|
+
Response format: table (paginated UI), chart (aggregated stacked bar), csv (export), raw (all records)
|
|
1997
|
+
|
|
1998
|
+
start : typing.Optional[str]
|
|
1999
|
+
Start date in ISO 8601 format (e.g., 2026-02-01T00:00:00.000Z). Defaults to first of current month
|
|
2000
|
+
|
|
2001
|
+
end : typing.Optional[str]
|
|
2002
|
+
End date in ISO 8601 format (e.g., 2026-02-01T00:00:00.000Z). Defaults to today
|
|
2003
|
+
|
|
2004
|
+
granularity : typing.Optional[str]
|
|
2005
|
+
Granularity: 'daily' or 'monthly' (used for chart format)
|
|
2006
|
+
|
|
2007
|
+
page : typing.Optional[int]
|
|
2008
|
+
Page number (1-indexed, table format only)
|
|
2009
|
+
|
|
2010
|
+
page_size : typing.Optional[int]
|
|
2011
|
+
Items per page (max 100, table format only)
|
|
2012
|
+
|
|
2013
|
+
sort_by : typing.Optional[str]
|
|
2014
|
+
Field to sort by (service, environment, region, account_id, cost, previous_cost, change_percentage)
|
|
2015
|
+
|
|
2016
|
+
sort_order : typing.Optional[str]
|
|
2017
|
+
Sort order (asc or desc)
|
|
2018
|
+
|
|
2019
|
+
sort_by_date : typing.Optional[str]
|
|
2020
|
+
Sort by a specific date's cost (YYYY-MM-DD for daily, YYYY-MM for monthly). Overrides sort_by.
|
|
2021
|
+
|
|
2022
|
+
preset : typing.Optional[str]
|
|
2023
|
+
Date preset: '30D', '6M', or '12M' (takes precedence over start/end)
|
|
2024
|
+
|
|
2025
|
+
service : typing.Optional[typing.Sequence[str]]
|
|
2026
|
+
Filter by service(s) - can be repeated for multiple values
|
|
2027
|
+
|
|
2028
|
+
environment : typing.Optional[typing.Sequence[str]]
|
|
2029
|
+
Filter by environment(s) - can be repeated for multiple values
|
|
2030
|
+
|
|
2031
|
+
account_id : typing.Optional[typing.Sequence[str]]
|
|
2032
|
+
Filter by account ID(s) - can be repeated for multiple values
|
|
2033
|
+
|
|
2034
|
+
region : typing.Optional[typing.Sequence[str]]
|
|
2035
|
+
Filter by region(s) - can be repeated for multiple values
|
|
2036
|
+
|
|
2037
|
+
tag_key : typing.Optional[typing.Sequence[str]]
|
|
2038
|
+
Filter by tag key(s) - required when group_by=tag
|
|
2039
|
+
|
|
2040
|
+
tag_value : typing.Optional[typing.Sequence[str]]
|
|
2041
|
+
Filter by tag value(s) - can be repeated for multiple values
|
|
2042
|
+
|
|
2043
|
+
group_by : typing.Optional[typing.Sequence[str]]
|
|
2044
|
+
Group by field(s). Valid: service, account_id, region, tag
|
|
2045
|
+
|
|
2046
|
+
request_options : typing.Optional[RequestOptions]
|
|
2047
|
+
Request-specific configuration.
|
|
2048
|
+
|
|
2049
|
+
Returns
|
|
2050
|
+
-------
|
|
2051
|
+
AsyncHttpResponse[ListSpendingBreakdownProvidersResponse]
|
|
2052
|
+
Successful Response
|
|
2053
|
+
"""
|
|
2054
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
2055
|
+
f"api/v1/providers/{jsonable_encoder(provider_id)}/spending/breakdown",
|
|
2056
|
+
method="GET",
|
|
2057
|
+
params={
|
|
2058
|
+
"format": format,
|
|
2059
|
+
"start": start,
|
|
2060
|
+
"end": end,
|
|
2061
|
+
"granularity": granularity,
|
|
2062
|
+
"page": page,
|
|
2063
|
+
"page_size": page_size,
|
|
2064
|
+
"sort_by": sort_by,
|
|
2065
|
+
"sort_order": sort_order,
|
|
2066
|
+
"sort_by_date": sort_by_date,
|
|
2067
|
+
"preset": preset,
|
|
2068
|
+
"service": service,
|
|
2069
|
+
"environment": environment,
|
|
2070
|
+
"account_id": account_id,
|
|
2071
|
+
"region": region,
|
|
2072
|
+
"tag_key": tag_key,
|
|
2073
|
+
"tag_value": tag_value,
|
|
2074
|
+
"group_by": group_by,
|
|
2075
|
+
},
|
|
2076
|
+
request_options=request_options,
|
|
2077
|
+
)
|
|
2078
|
+
try:
|
|
2079
|
+
if 200 <= _response.status_code < 300:
|
|
2080
|
+
_data = typing.cast(
|
|
2081
|
+
ListSpendingBreakdownProvidersResponse,
|
|
2082
|
+
parse_obj_as(
|
|
2083
|
+
type_=ListSpendingBreakdownProvidersResponse, # type: ignore
|
|
2084
|
+
object_=_response.json(),
|
|
2085
|
+
),
|
|
2086
|
+
)
|
|
2087
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
2088
|
+
if _response.status_code == 401:
|
|
2089
|
+
raise UnauthorizedError(
|
|
2090
|
+
headers=dict(_response.headers),
|
|
2091
|
+
body=typing.cast(
|
|
2092
|
+
AuthenticationError,
|
|
2093
|
+
parse_obj_as(
|
|
2094
|
+
type_=AuthenticationError, # type: ignore
|
|
2095
|
+
object_=_response.json(),
|
|
2096
|
+
),
|
|
2097
|
+
),
|
|
2098
|
+
)
|
|
2099
|
+
if _response.status_code == 403:
|
|
2100
|
+
raise ForbiddenError(
|
|
2101
|
+
headers=dict(_response.headers),
|
|
2102
|
+
body=typing.cast(
|
|
2103
|
+
AuthorizationError,
|
|
2104
|
+
parse_obj_as(
|
|
2105
|
+
type_=AuthorizationError, # type: ignore
|
|
2106
|
+
object_=_response.json(),
|
|
2107
|
+
),
|
|
2108
|
+
),
|
|
2109
|
+
)
|
|
2110
|
+
if _response.status_code == 422:
|
|
2111
|
+
raise UnprocessableEntityError(
|
|
2112
|
+
headers=dict(_response.headers),
|
|
2113
|
+
body=typing.cast(
|
|
2114
|
+
HttpValidationError,
|
|
2115
|
+
parse_obj_as(
|
|
2116
|
+
type_=HttpValidationError, # type: ignore
|
|
2117
|
+
object_=_response.json(),
|
|
2118
|
+
),
|
|
2119
|
+
),
|
|
2120
|
+
)
|
|
2121
|
+
_response_json = _response.json()
|
|
2122
|
+
except JSONDecodeError:
|
|
2123
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
2124
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
2125
|
+
|
|
2126
|
+
async def get_spending_timeline(
|
|
2127
|
+
self,
|
|
2128
|
+
provider_id: str,
|
|
2129
|
+
*,
|
|
2130
|
+
start: typing.Optional[str] = None,
|
|
2131
|
+
end: typing.Optional[str] = None,
|
|
2132
|
+
granularity: typing.Optional[str] = None,
|
|
2133
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
2134
|
+
) -> AsyncHttpResponse[ProviderTimelineResponse]:
|
|
2135
|
+
"""
|
|
2136
|
+
Returns spending timeline for a specific provider
|
|
2137
|
+
|
|
2138
|
+
Parameters
|
|
2139
|
+
----------
|
|
2140
|
+
provider_id : str
|
|
2141
|
+
|
|
2142
|
+
start : typing.Optional[str]
|
|
2143
|
+
Start date in ISO 8601 format
|
|
2144
|
+
|
|
2145
|
+
end : typing.Optional[str]
|
|
2146
|
+
End date in ISO 8601 format
|
|
2147
|
+
|
|
2148
|
+
granularity : typing.Optional[str]
|
|
2149
|
+
Granularity: 'daily' or 'monthly'
|
|
2150
|
+
|
|
2151
|
+
request_options : typing.Optional[RequestOptions]
|
|
2152
|
+
Request-specific configuration.
|
|
2153
|
+
|
|
2154
|
+
Returns
|
|
2155
|
+
-------
|
|
2156
|
+
AsyncHttpResponse[ProviderTimelineResponse]
|
|
2157
|
+
Successful Response
|
|
2158
|
+
"""
|
|
2159
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
2160
|
+
f"api/v1/providers/{jsonable_encoder(provider_id)}/spending/timeline",
|
|
2161
|
+
method="GET",
|
|
2162
|
+
params={
|
|
2163
|
+
"start": start,
|
|
2164
|
+
"end": end,
|
|
2165
|
+
"granularity": granularity,
|
|
2166
|
+
},
|
|
2167
|
+
request_options=request_options,
|
|
2168
|
+
)
|
|
2169
|
+
try:
|
|
2170
|
+
if 200 <= _response.status_code < 300:
|
|
2171
|
+
_data = typing.cast(
|
|
2172
|
+
ProviderTimelineResponse,
|
|
2173
|
+
parse_obj_as(
|
|
2174
|
+
type_=ProviderTimelineResponse, # type: ignore
|
|
2175
|
+
object_=_response.json(),
|
|
2176
|
+
),
|
|
2177
|
+
)
|
|
2178
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
2179
|
+
if _response.status_code == 401:
|
|
2180
|
+
raise UnauthorizedError(
|
|
2181
|
+
headers=dict(_response.headers),
|
|
2182
|
+
body=typing.cast(
|
|
2183
|
+
AuthenticationError,
|
|
2184
|
+
parse_obj_as(
|
|
2185
|
+
type_=AuthenticationError, # type: ignore
|
|
2186
|
+
object_=_response.json(),
|
|
2187
|
+
),
|
|
2188
|
+
),
|
|
2189
|
+
)
|
|
2190
|
+
if _response.status_code == 403:
|
|
2191
|
+
raise ForbiddenError(
|
|
2192
|
+
headers=dict(_response.headers),
|
|
2193
|
+
body=typing.cast(
|
|
2194
|
+
AuthorizationError,
|
|
2195
|
+
parse_obj_as(
|
|
2196
|
+
type_=AuthorizationError, # type: ignore
|
|
2197
|
+
object_=_response.json(),
|
|
2198
|
+
),
|
|
2199
|
+
),
|
|
2200
|
+
)
|
|
2201
|
+
if _response.status_code == 422:
|
|
2202
|
+
raise UnprocessableEntityError(
|
|
2203
|
+
headers=dict(_response.headers),
|
|
2204
|
+
body=typing.cast(
|
|
2205
|
+
HttpValidationError,
|
|
2206
|
+
parse_obj_as(
|
|
2207
|
+
type_=HttpValidationError, # type: ignore
|
|
2208
|
+
object_=_response.json(),
|
|
2209
|
+
),
|
|
2210
|
+
),
|
|
2211
|
+
)
|
|
2212
|
+
_response_json = _response.json()
|
|
2213
|
+
except JSONDecodeError:
|
|
2214
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
2215
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
2216
|
+
|
|
2217
|
+
async def get_potential_savings_summary(
|
|
2218
|
+
self, provider_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
2219
|
+
) -> AsyncHttpResponse[ProviderPotentialSavingsSummaryResponse]:
|
|
2220
|
+
"""
|
|
2221
|
+
Returns potential savings summary for a specific provider
|
|
2222
|
+
|
|
2223
|
+
Parameters
|
|
2224
|
+
----------
|
|
2225
|
+
provider_id : str
|
|
2226
|
+
|
|
2227
|
+
request_options : typing.Optional[RequestOptions]
|
|
2228
|
+
Request-specific configuration.
|
|
2229
|
+
|
|
2230
|
+
Returns
|
|
2231
|
+
-------
|
|
2232
|
+
AsyncHttpResponse[ProviderPotentialSavingsSummaryResponse]
|
|
2233
|
+
Successful Response
|
|
2234
|
+
"""
|
|
2235
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
2236
|
+
f"api/v1/providers/{jsonable_encoder(provider_id)}/potential-savings/summary",
|
|
2237
|
+
method="GET",
|
|
2238
|
+
request_options=request_options,
|
|
2239
|
+
)
|
|
2240
|
+
try:
|
|
2241
|
+
if 200 <= _response.status_code < 300:
|
|
2242
|
+
_data = typing.cast(
|
|
2243
|
+
ProviderPotentialSavingsSummaryResponse,
|
|
2244
|
+
parse_obj_as(
|
|
2245
|
+
type_=ProviderPotentialSavingsSummaryResponse, # type: ignore
|
|
2246
|
+
object_=_response.json(),
|
|
2247
|
+
),
|
|
2248
|
+
)
|
|
2249
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
2250
|
+
if _response.status_code == 401:
|
|
2251
|
+
raise UnauthorizedError(
|
|
2252
|
+
headers=dict(_response.headers),
|
|
2253
|
+
body=typing.cast(
|
|
2254
|
+
AuthenticationError,
|
|
2255
|
+
parse_obj_as(
|
|
2256
|
+
type_=AuthenticationError, # type: ignore
|
|
2257
|
+
object_=_response.json(),
|
|
2258
|
+
),
|
|
2259
|
+
),
|
|
2260
|
+
)
|
|
2261
|
+
if _response.status_code == 403:
|
|
2262
|
+
raise ForbiddenError(
|
|
2263
|
+
headers=dict(_response.headers),
|
|
2264
|
+
body=typing.cast(
|
|
2265
|
+
AuthorizationError,
|
|
2266
|
+
parse_obj_as(
|
|
2267
|
+
type_=AuthorizationError, # type: ignore
|
|
2268
|
+
object_=_response.json(),
|
|
2269
|
+
),
|
|
2270
|
+
),
|
|
2271
|
+
)
|
|
2272
|
+
if _response.status_code == 422:
|
|
2273
|
+
raise UnprocessableEntityError(
|
|
2274
|
+
headers=dict(_response.headers),
|
|
2275
|
+
body=typing.cast(
|
|
2276
|
+
HttpValidationError,
|
|
2277
|
+
parse_obj_as(
|
|
2278
|
+
type_=HttpValidationError, # type: ignore
|
|
2279
|
+
object_=_response.json(),
|
|
2280
|
+
),
|
|
2281
|
+
),
|
|
2282
|
+
)
|
|
2283
|
+
_response_json = _response.json()
|
|
2284
|
+
except JSONDecodeError:
|
|
2285
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
2286
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
2287
|
+
|
|
2288
|
+
async def list_potential_savings(
|
|
2289
|
+
self,
|
|
2290
|
+
provider_id: str,
|
|
2291
|
+
*,
|
|
2292
|
+
page: typing.Optional[int] = None,
|
|
2293
|
+
page_size: typing.Optional[int] = None,
|
|
2294
|
+
sort_by: typing.Optional[str] = None,
|
|
2295
|
+
sort_order: typing.Optional[str] = None,
|
|
2296
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
2297
|
+
) -> AsyncPager[ProviderBreakdownItem, ProviderBreakdownResponse]:
|
|
2298
|
+
"""
|
|
2299
|
+
Returns paginated potential savings breakdown for a specific provider
|
|
2300
|
+
|
|
2301
|
+
Parameters
|
|
2302
|
+
----------
|
|
2303
|
+
provider_id : str
|
|
2304
|
+
|
|
2305
|
+
page : typing.Optional[int]
|
|
2306
|
+
Page number (1-indexed)
|
|
2307
|
+
|
|
2308
|
+
page_size : typing.Optional[int]
|
|
2309
|
+
Items per page
|
|
2310
|
+
|
|
2311
|
+
sort_by : typing.Optional[str]
|
|
2312
|
+
Field to sort by
|
|
2313
|
+
|
|
2314
|
+
sort_order : typing.Optional[str]
|
|
2315
|
+
Sort order
|
|
2316
|
+
|
|
2317
|
+
request_options : typing.Optional[RequestOptions]
|
|
2318
|
+
Request-specific configuration.
|
|
2319
|
+
|
|
2320
|
+
Returns
|
|
2321
|
+
-------
|
|
2322
|
+
AsyncPager[ProviderBreakdownItem, ProviderBreakdownResponse]
|
|
2323
|
+
Successful Response
|
|
2324
|
+
"""
|
|
2325
|
+
page = page if page is not None else 1
|
|
2326
|
+
|
|
2327
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
2328
|
+
f"api/v1/providers/{jsonable_encoder(provider_id)}/potential-savings/breakdown",
|
|
2329
|
+
method="GET",
|
|
2330
|
+
params={
|
|
2331
|
+
"page": page,
|
|
2332
|
+
"page_size": page_size,
|
|
2333
|
+
"sort_by": sort_by,
|
|
2334
|
+
"sort_order": sort_order,
|
|
2335
|
+
},
|
|
2336
|
+
request_options=request_options,
|
|
2337
|
+
)
|
|
2338
|
+
try:
|
|
2339
|
+
if 200 <= _response.status_code < 300:
|
|
2340
|
+
_parsed_response = typing.cast(
|
|
2341
|
+
ProviderBreakdownResponse,
|
|
2342
|
+
parse_obj_as(
|
|
2343
|
+
type_=ProviderBreakdownResponse, # type: ignore
|
|
2344
|
+
object_=_response.json(),
|
|
2345
|
+
),
|
|
2346
|
+
)
|
|
2347
|
+
_items = _parsed_response.data.items if _parsed_response.data is not None else []
|
|
2348
|
+
|
|
2349
|
+
_has_next = True
|
|
2350
|
+
|
|
2351
|
+
async def _get_next():
|
|
2352
|
+
return await self.list_potential_savings(
|
|
2353
|
+
provider_id,
|
|
2354
|
+
page=page + 1,
|
|
2355
|
+
page_size=page_size,
|
|
2356
|
+
sort_by=sort_by,
|
|
2357
|
+
sort_order=sort_order,
|
|
2358
|
+
request_options=request_options,
|
|
2359
|
+
)
|
|
2360
|
+
|
|
2361
|
+
return AsyncPager(has_next=_has_next, items=_items, get_next=_get_next, response=_parsed_response)
|
|
2362
|
+
if _response.status_code == 401:
|
|
2363
|
+
raise UnauthorizedError(
|
|
2364
|
+
headers=dict(_response.headers),
|
|
2365
|
+
body=typing.cast(
|
|
2366
|
+
AuthenticationError,
|
|
2367
|
+
parse_obj_as(
|
|
2368
|
+
type_=AuthenticationError, # type: ignore
|
|
2369
|
+
object_=_response.json(),
|
|
2370
|
+
),
|
|
2371
|
+
),
|
|
2372
|
+
)
|
|
2373
|
+
if _response.status_code == 403:
|
|
2374
|
+
raise ForbiddenError(
|
|
2375
|
+
headers=dict(_response.headers),
|
|
2376
|
+
body=typing.cast(
|
|
2377
|
+
AuthorizationError,
|
|
2378
|
+
parse_obj_as(
|
|
2379
|
+
type_=AuthorizationError, # type: ignore
|
|
2380
|
+
object_=_response.json(),
|
|
2381
|
+
),
|
|
2382
|
+
),
|
|
2383
|
+
)
|
|
2384
|
+
if _response.status_code == 422:
|
|
2385
|
+
raise UnprocessableEntityError(
|
|
2386
|
+
headers=dict(_response.headers),
|
|
2387
|
+
body=typing.cast(
|
|
2388
|
+
HttpValidationError,
|
|
2389
|
+
parse_obj_as(
|
|
2390
|
+
type_=HttpValidationError, # type: ignore
|
|
2391
|
+
object_=_response.json(),
|
|
2392
|
+
),
|
|
2393
|
+
),
|
|
2394
|
+
)
|
|
2395
|
+
_response_json = _response.json()
|
|
2396
|
+
except JSONDecodeError:
|
|
2397
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
2398
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|