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,624 @@
|
|
|
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.pagination import AsyncPager, SyncPager
|
|
10
|
+
from ..core.pydantic_utilities import parse_obj_as
|
|
11
|
+
from ..core.request_options import RequestOptions
|
|
12
|
+
from ..errors.forbidden_error import ForbiddenError
|
|
13
|
+
from ..errors.unauthorized_error import UnauthorizedError
|
|
14
|
+
from ..errors.unprocessable_entity_error import UnprocessableEntityError
|
|
15
|
+
from ..types.authentication_error import AuthenticationError
|
|
16
|
+
from ..types.authorization_error import AuthorizationError
|
|
17
|
+
from ..types.http_validation_error import HttpValidationError
|
|
18
|
+
from ..types.saved_breakdown_response import SavedBreakdownResponse
|
|
19
|
+
from ..types.saved_item import SavedItem
|
|
20
|
+
from ..types.saved_summary_response import SavedSummaryResponse
|
|
21
|
+
|
|
22
|
+
# this is used as the default value for optional parameters
|
|
23
|
+
OMIT = typing.cast(typing.Any, ...)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class RawSavingsClient:
|
|
27
|
+
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
|
28
|
+
self._client_wrapper = client_wrapper
|
|
29
|
+
|
|
30
|
+
def get_summary(
|
|
31
|
+
self, *, request_options: typing.Optional[RequestOptions] = None
|
|
32
|
+
) -> HttpResponse[SavedSummaryResponse]:
|
|
33
|
+
"""
|
|
34
|
+
Returns enhanced BigNumbers data for the Savings Audit page
|
|
35
|
+
|
|
36
|
+
Parameters
|
|
37
|
+
----------
|
|
38
|
+
request_options : typing.Optional[RequestOptions]
|
|
39
|
+
Request-specific configuration.
|
|
40
|
+
|
|
41
|
+
Returns
|
|
42
|
+
-------
|
|
43
|
+
HttpResponse[SavedSummaryResponse]
|
|
44
|
+
Successful Response
|
|
45
|
+
"""
|
|
46
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
47
|
+
"api/v1/savings/summary",
|
|
48
|
+
method="GET",
|
|
49
|
+
request_options=request_options,
|
|
50
|
+
)
|
|
51
|
+
try:
|
|
52
|
+
if 200 <= _response.status_code < 300:
|
|
53
|
+
_data = typing.cast(
|
|
54
|
+
SavedSummaryResponse,
|
|
55
|
+
parse_obj_as(
|
|
56
|
+
type_=SavedSummaryResponse, # type: ignore
|
|
57
|
+
object_=_response.json(),
|
|
58
|
+
),
|
|
59
|
+
)
|
|
60
|
+
return HttpResponse(response=_response, data=_data)
|
|
61
|
+
if _response.status_code == 401:
|
|
62
|
+
raise UnauthorizedError(
|
|
63
|
+
headers=dict(_response.headers),
|
|
64
|
+
body=typing.cast(
|
|
65
|
+
AuthenticationError,
|
|
66
|
+
parse_obj_as(
|
|
67
|
+
type_=AuthenticationError, # type: ignore
|
|
68
|
+
object_=_response.json(),
|
|
69
|
+
),
|
|
70
|
+
),
|
|
71
|
+
)
|
|
72
|
+
if _response.status_code == 403:
|
|
73
|
+
raise ForbiddenError(
|
|
74
|
+
headers=dict(_response.headers),
|
|
75
|
+
body=typing.cast(
|
|
76
|
+
AuthorizationError,
|
|
77
|
+
parse_obj_as(
|
|
78
|
+
type_=AuthorizationError, # type: ignore
|
|
79
|
+
object_=_response.json(),
|
|
80
|
+
),
|
|
81
|
+
),
|
|
82
|
+
)
|
|
83
|
+
_response_json = _response.json()
|
|
84
|
+
except JSONDecodeError:
|
|
85
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
86
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
87
|
+
|
|
88
|
+
def list_breakdown(
|
|
89
|
+
self,
|
|
90
|
+
*,
|
|
91
|
+
page: typing.Optional[int] = None,
|
|
92
|
+
page_size: typing.Optional[int] = None,
|
|
93
|
+
sort_by: typing.Optional[str] = None,
|
|
94
|
+
sort_order: typing.Optional[str] = None,
|
|
95
|
+
start: typing.Optional[str] = None,
|
|
96
|
+
end: typing.Optional[str] = None,
|
|
97
|
+
preset: typing.Optional[str] = None,
|
|
98
|
+
provider: typing.Optional[str] = None,
|
|
99
|
+
service: typing.Optional[typing.Sequence[str]] = None,
|
|
100
|
+
environment: typing.Optional[typing.Sequence[str]] = None,
|
|
101
|
+
account_id: typing.Optional[typing.Sequence[str]] = None,
|
|
102
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
103
|
+
) -> SyncPager[SavedItem, SavedBreakdownResponse]:
|
|
104
|
+
"""
|
|
105
|
+
Returns paginated list of all implemented savings with filtering
|
|
106
|
+
|
|
107
|
+
Parameters
|
|
108
|
+
----------
|
|
109
|
+
page : typing.Optional[int]
|
|
110
|
+
Page number (1-indexed)
|
|
111
|
+
|
|
112
|
+
page_size : typing.Optional[int]
|
|
113
|
+
Items per page (max 100)
|
|
114
|
+
|
|
115
|
+
sort_by : typing.Optional[str]
|
|
116
|
+
Field to sort by (period, account_id, environment, service, usage_type, usage_quantity, usage_unit, pre_optimization_cost, post_optimization_cost, monthly_savings, roi, approved_by)
|
|
117
|
+
|
|
118
|
+
sort_order : typing.Optional[str]
|
|
119
|
+
Sort order (asc or desc)
|
|
120
|
+
|
|
121
|
+
start : typing.Optional[str]
|
|
122
|
+
Start date filter (YYYY-MM-DD or YYYY-MM format)
|
|
123
|
+
|
|
124
|
+
end : typing.Optional[str]
|
|
125
|
+
End date filter (YYYY-MM-DD or YYYY-MM format)
|
|
126
|
+
|
|
127
|
+
preset : typing.Optional[str]
|
|
128
|
+
Date preset: '30D', '6M', or '12M' (takes precedence over start/end)
|
|
129
|
+
|
|
130
|
+
provider : typing.Optional[str]
|
|
131
|
+
Filter by provider ID (aws, gcp, azure, k8s)
|
|
132
|
+
|
|
133
|
+
service : typing.Optional[typing.Sequence[str]]
|
|
134
|
+
Filter by service(s) - can be repeated for multiple values
|
|
135
|
+
|
|
136
|
+
environment : typing.Optional[typing.Sequence[str]]
|
|
137
|
+
Filter by environment(s) - can be repeated for multiple values
|
|
138
|
+
|
|
139
|
+
account_id : typing.Optional[typing.Sequence[str]]
|
|
140
|
+
Filter by account ID(s) - can be repeated for multiple values
|
|
141
|
+
|
|
142
|
+
request_options : typing.Optional[RequestOptions]
|
|
143
|
+
Request-specific configuration.
|
|
144
|
+
|
|
145
|
+
Returns
|
|
146
|
+
-------
|
|
147
|
+
SyncPager[SavedItem, SavedBreakdownResponse]
|
|
148
|
+
Successful Response
|
|
149
|
+
"""
|
|
150
|
+
page = page if page is not None else 1
|
|
151
|
+
|
|
152
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
153
|
+
"api/v1/savings/breakdown",
|
|
154
|
+
method="GET",
|
|
155
|
+
params={
|
|
156
|
+
"page": page,
|
|
157
|
+
"page_size": page_size,
|
|
158
|
+
"sort_by": sort_by,
|
|
159
|
+
"sort_order": sort_order,
|
|
160
|
+
"start": start,
|
|
161
|
+
"end": end,
|
|
162
|
+
"preset": preset,
|
|
163
|
+
"provider": provider,
|
|
164
|
+
"service": service,
|
|
165
|
+
"environment": environment,
|
|
166
|
+
"account_id": account_id,
|
|
167
|
+
},
|
|
168
|
+
request_options=request_options,
|
|
169
|
+
)
|
|
170
|
+
try:
|
|
171
|
+
if 200 <= _response.status_code < 300:
|
|
172
|
+
_parsed_response = typing.cast(
|
|
173
|
+
SavedBreakdownResponse,
|
|
174
|
+
parse_obj_as(
|
|
175
|
+
type_=SavedBreakdownResponse, # type: ignore
|
|
176
|
+
object_=_response.json(),
|
|
177
|
+
),
|
|
178
|
+
)
|
|
179
|
+
_items = _parsed_response.data.items if _parsed_response.data is not None else []
|
|
180
|
+
|
|
181
|
+
_has_next = True
|
|
182
|
+
_get_next = lambda: self.list_breakdown(
|
|
183
|
+
page=page + 1,
|
|
184
|
+
page_size=page_size,
|
|
185
|
+
sort_by=sort_by,
|
|
186
|
+
sort_order=sort_order,
|
|
187
|
+
start=start,
|
|
188
|
+
end=end,
|
|
189
|
+
preset=preset,
|
|
190
|
+
provider=provider,
|
|
191
|
+
service=service,
|
|
192
|
+
environment=environment,
|
|
193
|
+
account_id=account_id,
|
|
194
|
+
request_options=request_options,
|
|
195
|
+
)
|
|
196
|
+
return SyncPager(has_next=_has_next, items=_items, get_next=_get_next, response=_parsed_response)
|
|
197
|
+
if _response.status_code == 401:
|
|
198
|
+
raise UnauthorizedError(
|
|
199
|
+
headers=dict(_response.headers),
|
|
200
|
+
body=typing.cast(
|
|
201
|
+
AuthenticationError,
|
|
202
|
+
parse_obj_as(
|
|
203
|
+
type_=AuthenticationError, # type: ignore
|
|
204
|
+
object_=_response.json(),
|
|
205
|
+
),
|
|
206
|
+
),
|
|
207
|
+
)
|
|
208
|
+
if _response.status_code == 403:
|
|
209
|
+
raise ForbiddenError(
|
|
210
|
+
headers=dict(_response.headers),
|
|
211
|
+
body=typing.cast(
|
|
212
|
+
AuthorizationError,
|
|
213
|
+
parse_obj_as(
|
|
214
|
+
type_=AuthorizationError, # type: ignore
|
|
215
|
+
object_=_response.json(),
|
|
216
|
+
),
|
|
217
|
+
),
|
|
218
|
+
)
|
|
219
|
+
if _response.status_code == 422:
|
|
220
|
+
raise UnprocessableEntityError(
|
|
221
|
+
headers=dict(_response.headers),
|
|
222
|
+
body=typing.cast(
|
|
223
|
+
HttpValidationError,
|
|
224
|
+
parse_obj_as(
|
|
225
|
+
type_=HttpValidationError, # type: ignore
|
|
226
|
+
object_=_response.json(),
|
|
227
|
+
),
|
|
228
|
+
),
|
|
229
|
+
)
|
|
230
|
+
_response_json = _response.json()
|
|
231
|
+
except JSONDecodeError:
|
|
232
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
233
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
234
|
+
|
|
235
|
+
def create_execution_request(
|
|
236
|
+
self,
|
|
237
|
+
*,
|
|
238
|
+
recommendation_id: str,
|
|
239
|
+
implementation_method: str,
|
|
240
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
241
|
+
) -> HttpResponse[typing.Any]:
|
|
242
|
+
"""
|
|
243
|
+
Triggers execution of a savings recommendation by updating its status to processing
|
|
244
|
+
|
|
245
|
+
Parameters
|
|
246
|
+
----------
|
|
247
|
+
recommendation_id : str
|
|
248
|
+
Recommendation ID to execute
|
|
249
|
+
|
|
250
|
+
implementation_method : str
|
|
251
|
+
Implementation method: 'one-click', 'iac', or 'one-click-plus-iac'
|
|
252
|
+
|
|
253
|
+
request_options : typing.Optional[RequestOptions]
|
|
254
|
+
Request-specific configuration.
|
|
255
|
+
|
|
256
|
+
Returns
|
|
257
|
+
-------
|
|
258
|
+
HttpResponse[typing.Any]
|
|
259
|
+
Successful Response
|
|
260
|
+
"""
|
|
261
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
262
|
+
"api/v1/savings/execution-requests",
|
|
263
|
+
method="POST",
|
|
264
|
+
json={
|
|
265
|
+
"recommendation_id": recommendation_id,
|
|
266
|
+
"implementation_method": implementation_method,
|
|
267
|
+
},
|
|
268
|
+
headers={
|
|
269
|
+
"content-type": "application/json",
|
|
270
|
+
},
|
|
271
|
+
request_options=request_options,
|
|
272
|
+
omit=OMIT,
|
|
273
|
+
)
|
|
274
|
+
try:
|
|
275
|
+
if _response is None or not _response.text.strip():
|
|
276
|
+
return HttpResponse(response=_response, data=None)
|
|
277
|
+
if 200 <= _response.status_code < 300:
|
|
278
|
+
_data = typing.cast(
|
|
279
|
+
typing.Any,
|
|
280
|
+
parse_obj_as(
|
|
281
|
+
type_=typing.Any, # type: ignore
|
|
282
|
+
object_=_response.json(),
|
|
283
|
+
),
|
|
284
|
+
)
|
|
285
|
+
return HttpResponse(response=_response, data=_data)
|
|
286
|
+
if _response.status_code == 401:
|
|
287
|
+
raise UnauthorizedError(
|
|
288
|
+
headers=dict(_response.headers),
|
|
289
|
+
body=typing.cast(
|
|
290
|
+
AuthenticationError,
|
|
291
|
+
parse_obj_as(
|
|
292
|
+
type_=AuthenticationError, # type: ignore
|
|
293
|
+
object_=_response.json(),
|
|
294
|
+
),
|
|
295
|
+
),
|
|
296
|
+
)
|
|
297
|
+
if _response.status_code == 403:
|
|
298
|
+
raise ForbiddenError(
|
|
299
|
+
headers=dict(_response.headers),
|
|
300
|
+
body=typing.cast(
|
|
301
|
+
AuthorizationError,
|
|
302
|
+
parse_obj_as(
|
|
303
|
+
type_=AuthorizationError, # type: ignore
|
|
304
|
+
object_=_response.json(),
|
|
305
|
+
),
|
|
306
|
+
),
|
|
307
|
+
)
|
|
308
|
+
if _response.status_code == 422:
|
|
309
|
+
raise UnprocessableEntityError(
|
|
310
|
+
headers=dict(_response.headers),
|
|
311
|
+
body=typing.cast(
|
|
312
|
+
HttpValidationError,
|
|
313
|
+
parse_obj_as(
|
|
314
|
+
type_=HttpValidationError, # type: ignore
|
|
315
|
+
object_=_response.json(),
|
|
316
|
+
),
|
|
317
|
+
),
|
|
318
|
+
)
|
|
319
|
+
_response_json = _response.json()
|
|
320
|
+
except JSONDecodeError:
|
|
321
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
322
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
323
|
+
|
|
324
|
+
|
|
325
|
+
class AsyncRawSavingsClient:
|
|
326
|
+
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
|
327
|
+
self._client_wrapper = client_wrapper
|
|
328
|
+
|
|
329
|
+
async def get_summary(
|
|
330
|
+
self, *, request_options: typing.Optional[RequestOptions] = None
|
|
331
|
+
) -> AsyncHttpResponse[SavedSummaryResponse]:
|
|
332
|
+
"""
|
|
333
|
+
Returns enhanced BigNumbers data for the Savings Audit page
|
|
334
|
+
|
|
335
|
+
Parameters
|
|
336
|
+
----------
|
|
337
|
+
request_options : typing.Optional[RequestOptions]
|
|
338
|
+
Request-specific configuration.
|
|
339
|
+
|
|
340
|
+
Returns
|
|
341
|
+
-------
|
|
342
|
+
AsyncHttpResponse[SavedSummaryResponse]
|
|
343
|
+
Successful Response
|
|
344
|
+
"""
|
|
345
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
346
|
+
"api/v1/savings/summary",
|
|
347
|
+
method="GET",
|
|
348
|
+
request_options=request_options,
|
|
349
|
+
)
|
|
350
|
+
try:
|
|
351
|
+
if 200 <= _response.status_code < 300:
|
|
352
|
+
_data = typing.cast(
|
|
353
|
+
SavedSummaryResponse,
|
|
354
|
+
parse_obj_as(
|
|
355
|
+
type_=SavedSummaryResponse, # type: ignore
|
|
356
|
+
object_=_response.json(),
|
|
357
|
+
),
|
|
358
|
+
)
|
|
359
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
360
|
+
if _response.status_code == 401:
|
|
361
|
+
raise UnauthorizedError(
|
|
362
|
+
headers=dict(_response.headers),
|
|
363
|
+
body=typing.cast(
|
|
364
|
+
AuthenticationError,
|
|
365
|
+
parse_obj_as(
|
|
366
|
+
type_=AuthenticationError, # type: ignore
|
|
367
|
+
object_=_response.json(),
|
|
368
|
+
),
|
|
369
|
+
),
|
|
370
|
+
)
|
|
371
|
+
if _response.status_code == 403:
|
|
372
|
+
raise ForbiddenError(
|
|
373
|
+
headers=dict(_response.headers),
|
|
374
|
+
body=typing.cast(
|
|
375
|
+
AuthorizationError,
|
|
376
|
+
parse_obj_as(
|
|
377
|
+
type_=AuthorizationError, # type: ignore
|
|
378
|
+
object_=_response.json(),
|
|
379
|
+
),
|
|
380
|
+
),
|
|
381
|
+
)
|
|
382
|
+
_response_json = _response.json()
|
|
383
|
+
except JSONDecodeError:
|
|
384
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
385
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
386
|
+
|
|
387
|
+
async def list_breakdown(
|
|
388
|
+
self,
|
|
389
|
+
*,
|
|
390
|
+
page: typing.Optional[int] = None,
|
|
391
|
+
page_size: typing.Optional[int] = None,
|
|
392
|
+
sort_by: typing.Optional[str] = None,
|
|
393
|
+
sort_order: typing.Optional[str] = None,
|
|
394
|
+
start: typing.Optional[str] = None,
|
|
395
|
+
end: typing.Optional[str] = None,
|
|
396
|
+
preset: typing.Optional[str] = None,
|
|
397
|
+
provider: typing.Optional[str] = None,
|
|
398
|
+
service: typing.Optional[typing.Sequence[str]] = None,
|
|
399
|
+
environment: typing.Optional[typing.Sequence[str]] = None,
|
|
400
|
+
account_id: typing.Optional[typing.Sequence[str]] = None,
|
|
401
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
402
|
+
) -> AsyncPager[SavedItem, SavedBreakdownResponse]:
|
|
403
|
+
"""
|
|
404
|
+
Returns paginated list of all implemented savings with filtering
|
|
405
|
+
|
|
406
|
+
Parameters
|
|
407
|
+
----------
|
|
408
|
+
page : typing.Optional[int]
|
|
409
|
+
Page number (1-indexed)
|
|
410
|
+
|
|
411
|
+
page_size : typing.Optional[int]
|
|
412
|
+
Items per page (max 100)
|
|
413
|
+
|
|
414
|
+
sort_by : typing.Optional[str]
|
|
415
|
+
Field to sort by (period, account_id, environment, service, usage_type, usage_quantity, usage_unit, pre_optimization_cost, post_optimization_cost, monthly_savings, roi, approved_by)
|
|
416
|
+
|
|
417
|
+
sort_order : typing.Optional[str]
|
|
418
|
+
Sort order (asc or desc)
|
|
419
|
+
|
|
420
|
+
start : typing.Optional[str]
|
|
421
|
+
Start date filter (YYYY-MM-DD or YYYY-MM format)
|
|
422
|
+
|
|
423
|
+
end : typing.Optional[str]
|
|
424
|
+
End date filter (YYYY-MM-DD or YYYY-MM format)
|
|
425
|
+
|
|
426
|
+
preset : typing.Optional[str]
|
|
427
|
+
Date preset: '30D', '6M', or '12M' (takes precedence over start/end)
|
|
428
|
+
|
|
429
|
+
provider : typing.Optional[str]
|
|
430
|
+
Filter by provider ID (aws, gcp, azure, k8s)
|
|
431
|
+
|
|
432
|
+
service : typing.Optional[typing.Sequence[str]]
|
|
433
|
+
Filter by service(s) - can be repeated for multiple values
|
|
434
|
+
|
|
435
|
+
environment : typing.Optional[typing.Sequence[str]]
|
|
436
|
+
Filter by environment(s) - can be repeated for multiple values
|
|
437
|
+
|
|
438
|
+
account_id : typing.Optional[typing.Sequence[str]]
|
|
439
|
+
Filter by account ID(s) - can be repeated for multiple values
|
|
440
|
+
|
|
441
|
+
request_options : typing.Optional[RequestOptions]
|
|
442
|
+
Request-specific configuration.
|
|
443
|
+
|
|
444
|
+
Returns
|
|
445
|
+
-------
|
|
446
|
+
AsyncPager[SavedItem, SavedBreakdownResponse]
|
|
447
|
+
Successful Response
|
|
448
|
+
"""
|
|
449
|
+
page = page if page is not None else 1
|
|
450
|
+
|
|
451
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
452
|
+
"api/v1/savings/breakdown",
|
|
453
|
+
method="GET",
|
|
454
|
+
params={
|
|
455
|
+
"page": page,
|
|
456
|
+
"page_size": page_size,
|
|
457
|
+
"sort_by": sort_by,
|
|
458
|
+
"sort_order": sort_order,
|
|
459
|
+
"start": start,
|
|
460
|
+
"end": end,
|
|
461
|
+
"preset": preset,
|
|
462
|
+
"provider": provider,
|
|
463
|
+
"service": service,
|
|
464
|
+
"environment": environment,
|
|
465
|
+
"account_id": account_id,
|
|
466
|
+
},
|
|
467
|
+
request_options=request_options,
|
|
468
|
+
)
|
|
469
|
+
try:
|
|
470
|
+
if 200 <= _response.status_code < 300:
|
|
471
|
+
_parsed_response = typing.cast(
|
|
472
|
+
SavedBreakdownResponse,
|
|
473
|
+
parse_obj_as(
|
|
474
|
+
type_=SavedBreakdownResponse, # type: ignore
|
|
475
|
+
object_=_response.json(),
|
|
476
|
+
),
|
|
477
|
+
)
|
|
478
|
+
_items = _parsed_response.data.items if _parsed_response.data is not None else []
|
|
479
|
+
|
|
480
|
+
_has_next = True
|
|
481
|
+
|
|
482
|
+
async def _get_next():
|
|
483
|
+
return await self.list_breakdown(
|
|
484
|
+
page=page + 1,
|
|
485
|
+
page_size=page_size,
|
|
486
|
+
sort_by=sort_by,
|
|
487
|
+
sort_order=sort_order,
|
|
488
|
+
start=start,
|
|
489
|
+
end=end,
|
|
490
|
+
preset=preset,
|
|
491
|
+
provider=provider,
|
|
492
|
+
service=service,
|
|
493
|
+
environment=environment,
|
|
494
|
+
account_id=account_id,
|
|
495
|
+
request_options=request_options,
|
|
496
|
+
)
|
|
497
|
+
|
|
498
|
+
return AsyncPager(has_next=_has_next, items=_items, get_next=_get_next, response=_parsed_response)
|
|
499
|
+
if _response.status_code == 401:
|
|
500
|
+
raise UnauthorizedError(
|
|
501
|
+
headers=dict(_response.headers),
|
|
502
|
+
body=typing.cast(
|
|
503
|
+
AuthenticationError,
|
|
504
|
+
parse_obj_as(
|
|
505
|
+
type_=AuthenticationError, # type: ignore
|
|
506
|
+
object_=_response.json(),
|
|
507
|
+
),
|
|
508
|
+
),
|
|
509
|
+
)
|
|
510
|
+
if _response.status_code == 403:
|
|
511
|
+
raise ForbiddenError(
|
|
512
|
+
headers=dict(_response.headers),
|
|
513
|
+
body=typing.cast(
|
|
514
|
+
AuthorizationError,
|
|
515
|
+
parse_obj_as(
|
|
516
|
+
type_=AuthorizationError, # type: ignore
|
|
517
|
+
object_=_response.json(),
|
|
518
|
+
),
|
|
519
|
+
),
|
|
520
|
+
)
|
|
521
|
+
if _response.status_code == 422:
|
|
522
|
+
raise UnprocessableEntityError(
|
|
523
|
+
headers=dict(_response.headers),
|
|
524
|
+
body=typing.cast(
|
|
525
|
+
HttpValidationError,
|
|
526
|
+
parse_obj_as(
|
|
527
|
+
type_=HttpValidationError, # type: ignore
|
|
528
|
+
object_=_response.json(),
|
|
529
|
+
),
|
|
530
|
+
),
|
|
531
|
+
)
|
|
532
|
+
_response_json = _response.json()
|
|
533
|
+
except JSONDecodeError:
|
|
534
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
535
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
536
|
+
|
|
537
|
+
async def create_execution_request(
|
|
538
|
+
self,
|
|
539
|
+
*,
|
|
540
|
+
recommendation_id: str,
|
|
541
|
+
implementation_method: str,
|
|
542
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
543
|
+
) -> AsyncHttpResponse[typing.Any]:
|
|
544
|
+
"""
|
|
545
|
+
Triggers execution of a savings recommendation by updating its status to processing
|
|
546
|
+
|
|
547
|
+
Parameters
|
|
548
|
+
----------
|
|
549
|
+
recommendation_id : str
|
|
550
|
+
Recommendation ID to execute
|
|
551
|
+
|
|
552
|
+
implementation_method : str
|
|
553
|
+
Implementation method: 'one-click', 'iac', or 'one-click-plus-iac'
|
|
554
|
+
|
|
555
|
+
request_options : typing.Optional[RequestOptions]
|
|
556
|
+
Request-specific configuration.
|
|
557
|
+
|
|
558
|
+
Returns
|
|
559
|
+
-------
|
|
560
|
+
AsyncHttpResponse[typing.Any]
|
|
561
|
+
Successful Response
|
|
562
|
+
"""
|
|
563
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
564
|
+
"api/v1/savings/execution-requests",
|
|
565
|
+
method="POST",
|
|
566
|
+
json={
|
|
567
|
+
"recommendation_id": recommendation_id,
|
|
568
|
+
"implementation_method": implementation_method,
|
|
569
|
+
},
|
|
570
|
+
headers={
|
|
571
|
+
"content-type": "application/json",
|
|
572
|
+
},
|
|
573
|
+
request_options=request_options,
|
|
574
|
+
omit=OMIT,
|
|
575
|
+
)
|
|
576
|
+
try:
|
|
577
|
+
if _response is None or not _response.text.strip():
|
|
578
|
+
return AsyncHttpResponse(response=_response, data=None)
|
|
579
|
+
if 200 <= _response.status_code < 300:
|
|
580
|
+
_data = typing.cast(
|
|
581
|
+
typing.Any,
|
|
582
|
+
parse_obj_as(
|
|
583
|
+
type_=typing.Any, # type: ignore
|
|
584
|
+
object_=_response.json(),
|
|
585
|
+
),
|
|
586
|
+
)
|
|
587
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
588
|
+
if _response.status_code == 401:
|
|
589
|
+
raise UnauthorizedError(
|
|
590
|
+
headers=dict(_response.headers),
|
|
591
|
+
body=typing.cast(
|
|
592
|
+
AuthenticationError,
|
|
593
|
+
parse_obj_as(
|
|
594
|
+
type_=AuthenticationError, # type: ignore
|
|
595
|
+
object_=_response.json(),
|
|
596
|
+
),
|
|
597
|
+
),
|
|
598
|
+
)
|
|
599
|
+
if _response.status_code == 403:
|
|
600
|
+
raise ForbiddenError(
|
|
601
|
+
headers=dict(_response.headers),
|
|
602
|
+
body=typing.cast(
|
|
603
|
+
AuthorizationError,
|
|
604
|
+
parse_obj_as(
|
|
605
|
+
type_=AuthorizationError, # type: ignore
|
|
606
|
+
object_=_response.json(),
|
|
607
|
+
),
|
|
608
|
+
),
|
|
609
|
+
)
|
|
610
|
+
if _response.status_code == 422:
|
|
611
|
+
raise UnprocessableEntityError(
|
|
612
|
+
headers=dict(_response.headers),
|
|
613
|
+
body=typing.cast(
|
|
614
|
+
HttpValidationError,
|
|
615
|
+
parse_obj_as(
|
|
616
|
+
type_=HttpValidationError, # type: ignore
|
|
617
|
+
object_=_response.json(),
|
|
618
|
+
),
|
|
619
|
+
),
|
|
620
|
+
)
|
|
621
|
+
_response_json = _response.json()
|
|
622
|
+
except JSONDecodeError:
|
|
623
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
624
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
# isort: skip_file
|
|
4
|
+
|
|
5
|
+
import typing
|
|
6
|
+
from importlib import import_module
|
|
7
|
+
|
|
8
|
+
if typing.TYPE_CHECKING:
|
|
9
|
+
from .types import ListBreakdownSpendingResponse
|
|
10
|
+
_dynamic_imports: typing.Dict[str, str] = {"ListBreakdownSpendingResponse": ".types"}
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def __getattr__(attr_name: str) -> typing.Any:
|
|
14
|
+
module_name = _dynamic_imports.get(attr_name)
|
|
15
|
+
if module_name is None:
|
|
16
|
+
raise AttributeError(f"No {attr_name} found in _dynamic_imports for module name -> {__name__}")
|
|
17
|
+
try:
|
|
18
|
+
module = import_module(module_name, __package__)
|
|
19
|
+
if module_name == f".{attr_name}":
|
|
20
|
+
return module
|
|
21
|
+
else:
|
|
22
|
+
return getattr(module, attr_name)
|
|
23
|
+
except ImportError as e:
|
|
24
|
+
raise ImportError(f"Failed to import {attr_name} from {module_name}: {e}") from e
|
|
25
|
+
except AttributeError as e:
|
|
26
|
+
raise AttributeError(f"Failed to get {attr_name} from {module_name}: {e}") from e
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def __dir__():
|
|
30
|
+
lazy_attrs = list(_dynamic_imports.keys())
|
|
31
|
+
return sorted(lazy_attrs)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
__all__ = ["ListBreakdownSpendingResponse"]
|