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.
Files changed (208) hide show
  1. levelfour/__init__.py +495 -0
  2. levelfour/api_keys/__init__.py +34 -0
  3. levelfour/api_keys/client.py +337 -0
  4. levelfour/api_keys/raw_client.py +621 -0
  5. levelfour/api_keys/types/__init__.py +34 -0
  6. levelfour/api_keys/types/create_api_key_request_scope.py +5 -0
  7. levelfour/async_levelfour_client.py +39 -0
  8. levelfour/base_client.py +346 -0
  9. levelfour/client.py +54 -0
  10. levelfour/core/__init__.py +127 -0
  11. levelfour/core/api_error.py +23 -0
  12. levelfour/core/client_wrapper.py +105 -0
  13. levelfour/core/datetime_utils.py +70 -0
  14. levelfour/core/file.py +67 -0
  15. levelfour/core/force_multipart.py +18 -0
  16. levelfour/core/http_client.py +776 -0
  17. levelfour/core/http_response.py +59 -0
  18. levelfour/core/http_sse/__init__.py +42 -0
  19. levelfour/core/http_sse/_api.py +112 -0
  20. levelfour/core/http_sse/_decoders.py +61 -0
  21. levelfour/core/http_sse/_exceptions.py +7 -0
  22. levelfour/core/http_sse/_models.py +17 -0
  23. levelfour/core/jsonable_encoder.py +108 -0
  24. levelfour/core/logging.py +107 -0
  25. levelfour/core/pagination.py +82 -0
  26. levelfour/core/pydantic_utilities.py +577 -0
  27. levelfour/core/query_encoder.py +58 -0
  28. levelfour/core/remove_none_from_dict.py +11 -0
  29. levelfour/core/request_options.py +35 -0
  30. levelfour/core/serialization.py +276 -0
  31. levelfour/errors/__init__.py +40 -0
  32. levelfour/errors/forbidden_error.py +11 -0
  33. levelfour/errors/unauthorized_error.py +11 -0
  34. levelfour/errors/unprocessable_entity_error.py +11 -0
  35. levelfour/evaluation/__init__.py +4 -0
  36. levelfour/evaluation/client.py +102 -0
  37. levelfour/evaluation/raw_client.py +141 -0
  38. levelfour/exceptions.py +63 -0
  39. levelfour/health/__init__.py +4 -0
  40. levelfour/health/client.py +163 -0
  41. levelfour/health/raw_client.py +164 -0
  42. levelfour/integrations/__init__.py +0 -0
  43. levelfour/integrations/django.py +26 -0
  44. levelfour/integrations/fastapi.py +39 -0
  45. levelfour/integrations/telemetry.py +66 -0
  46. levelfour/levelfour_client.py +47 -0
  47. levelfour/pagination.py +84 -0
  48. levelfour/pr_analysis/__init__.py +4 -0
  49. levelfour/pr_analysis/client.py +408 -0
  50. levelfour/pr_analysis/raw_client.py +620 -0
  51. levelfour/pr_analysis_actions/__init__.py +4 -0
  52. levelfour/pr_analysis_actions/client.py +588 -0
  53. levelfour/pr_analysis_actions/raw_client.py +939 -0
  54. levelfour/pr_analysis_installations/__init__.py +4 -0
  55. levelfour/pr_analysis_installations/client.py +470 -0
  56. levelfour/pr_analysis_installations/raw_client.py +868 -0
  57. levelfour/providers/__init__.py +34 -0
  58. levelfour/providers/client.py +1504 -0
  59. levelfour/providers/raw_client.py +2398 -0
  60. levelfour/providers/types/__init__.py +36 -0
  61. levelfour/providers/types/list_spending_breakdown_providers_response.py +11 -0
  62. levelfour/py.typed +0 -0
  63. levelfour/recommendations/__init__.py +4 -0
  64. levelfour/recommendations/client.py +1018 -0
  65. levelfour/recommendations/raw_client.py +1810 -0
  66. levelfour/savings/__init__.py +4 -0
  67. levelfour/savings/client.py +401 -0
  68. levelfour/savings/raw_client.py +624 -0
  69. levelfour/spending/__init__.py +34 -0
  70. levelfour/spending/client.py +437 -0
  71. levelfour/spending/raw_client.py +684 -0
  72. levelfour/spending/types/__init__.py +34 -0
  73. levelfour/spending/types/list_breakdown_spending_response.py +12 -0
  74. levelfour/types/__init__.py +413 -0
  75. levelfour/types/accept_terms_data.py +25 -0
  76. levelfour/types/accept_terms_response.py +27 -0
  77. levelfour/types/action_request.py +42 -0
  78. levelfour/types/api_key_created_data.py +28 -0
  79. levelfour/types/api_key_data.py +27 -0
  80. levelfour/types/authentication_error.py +5 -0
  81. levelfour/types/authorization_error.py +5 -0
  82. levelfour/types/bad_request_error.py +5 -0
  83. levelfour/types/comparison_item.py +32 -0
  84. levelfour/types/complete_wizard_data.py +27 -0
  85. levelfour/types/complete_wizard_response.py +27 -0
  86. levelfour/types/conflict_error.py +5 -0
  87. levelfour/types/cost_breakdown_data.py +35 -0
  88. levelfour/types/cost_breakdown_item.py +71 -0
  89. levelfour/types/cost_breakdown_raw_data.py +37 -0
  90. levelfour/types/cost_breakdown_raw_response.py +27 -0
  91. levelfour/types/cost_breakdown_response.py +27 -0
  92. levelfour/types/costs_breakdown_chart_data.py +48 -0
  93. levelfour/types/costs_breakdown_chart_response.py +27 -0
  94. levelfour/types/costs_breakdown_data_point.py +46 -0
  95. levelfour/types/costs_breakdown_grouped_chart_data.py +52 -0
  96. levelfour/types/costs_breakdown_grouped_chart_response.py +27 -0
  97. levelfour/types/costs_breakdown_grouped_data_point.py +36 -0
  98. levelfour/types/costs_breakdown_totals.py +41 -0
  99. levelfour/types/create_api_key_response.py +23 -0
  100. levelfour/types/daily_spending_breakdown_data.py +42 -0
  101. levelfour/types/daily_spending_breakdown_response.py +27 -0
  102. levelfour/types/daily_spending_data_point.py +31 -0
  103. levelfour/types/dashboard_summary_data.py +72 -0
  104. levelfour/types/dashboard_summary_response.py +27 -0
  105. levelfour/types/delete_endpoint_data.py +20 -0
  106. levelfour/types/delete_endpoint_response.py +23 -0
  107. levelfour/types/endpoint_data.py +23 -0
  108. levelfour/types/error_response.py +23 -0
  109. levelfour/types/error_response_error.py +21 -0
  110. levelfour/types/evaluation_status_data.py +71 -0
  111. levelfour/types/evaluation_status_response.py +27 -0
  112. levelfour/types/execution_log_command.py +21 -0
  113. levelfour/types/execution_log_entry.py +23 -0
  114. levelfour/types/execution_step_schema.py +23 -0
  115. levelfour/types/http_validation_error.py +20 -0
  116. levelfour/types/implementation_method_data.py +25 -0
  117. levelfour/types/implementation_method_response.py +27 -0
  118. levelfour/types/implementation_step.py +27 -0
  119. levelfour/types/internal_server_error.py +5 -0
  120. levelfour/types/list_api_keys_data.py +21 -0
  121. levelfour/types/list_api_keys_response.py +23 -0
  122. levelfour/types/list_endpoints_response.py +23 -0
  123. levelfour/types/metric_data_point.py +27 -0
  124. levelfour/types/metric_series.py +40 -0
  125. levelfour/types/metric_series_entry.py +25 -0
  126. levelfour/types/monthly_spending_data.py +27 -0
  127. levelfour/types/monthly_spending_data_point.py +31 -0
  128. levelfour/types/monthly_spending_response.py +27 -0
  129. levelfour/types/not_found_error.py +5 -0
  130. levelfour/types/pagination_meta.py +51 -0
  131. levelfour/types/processing_recommendation_item.py +61 -0
  132. levelfour/types/processing_recommendations_data.py +28 -0
  133. levelfour/types/processing_recommendations_response.py +27 -0
  134. levelfour/types/provider.py +46 -0
  135. levelfour/types/provider_breakdown_data.py +31 -0
  136. levelfour/types/provider_breakdown_item.py +77 -0
  137. levelfour/types/provider_breakdown_response.py +27 -0
  138. levelfour/types/provider_filter_options_data.py +51 -0
  139. levelfour/types/provider_filter_options_response.py +27 -0
  140. levelfour/types/provider_potential_savings_summary_data.py +46 -0
  141. levelfour/types/provider_potential_savings_summary_response.py +27 -0
  142. levelfour/types/provider_recommendations_summary_data.py +37 -0
  143. levelfour/types/provider_recommendations_summary_response.py +27 -0
  144. levelfour/types/provider_saved_summary_data.py +56 -0
  145. levelfour/types/provider_saved_summary_response.py +27 -0
  146. levelfour/types/provider_service_breakdown_data.py +65 -0
  147. levelfour/types/provider_service_breakdown_item.py +72 -0
  148. levelfour/types/provider_service_breakdown_raw_data.py +62 -0
  149. levelfour/types/provider_service_breakdown_raw_response.py +27 -0
  150. levelfour/types/provider_service_breakdown_response.py +27 -0
  151. levelfour/types/provider_service_costs_breakdown_data.py +62 -0
  152. levelfour/types/provider_service_costs_breakdown_response.py +27 -0
  153. levelfour/types/provider_service_costs_data_point.py +36 -0
  154. levelfour/types/provider_spending.py +61 -0
  155. levelfour/types/provider_spending_summary_data.py +67 -0
  156. levelfour/types/provider_spending_summary_response.py +27 -0
  157. levelfour/types/provider_timeline_data.py +57 -0
  158. levelfour/types/provider_timeline_response.py +27 -0
  159. levelfour/types/provider_top_service.py +36 -0
  160. levelfour/types/providers_summary_data.py +24 -0
  161. levelfour/types/providers_summary_response.py +27 -0
  162. levelfour/types/rate_limit_error.py +5 -0
  163. levelfour/types/recommendation_actions.py +60 -0
  164. levelfour/types/recommendation_detail.py +42 -0
  165. levelfour/types/recommendation_detail_response.py +27 -0
  166. levelfour/types/recommendation_filter_options_data.py +41 -0
  167. levelfour/types/recommendation_filter_options_response.py +27 -0
  168. levelfour/types/recommendation_item.py +36 -0
  169. levelfour/types/recommendation_wizard_data.py +173 -0
  170. levelfour/types/recommendation_wizard_data_metrics.py +7 -0
  171. levelfour/types/recommendation_wizard_response.py +27 -0
  172. levelfour/types/recommendations_breakdown_data.py +26 -0
  173. levelfour/types/recommendations_breakdown_response.py +27 -0
  174. levelfour/types/recommendations_overview_data.py +51 -0
  175. levelfour/types/recommendations_overview_response.py +27 -0
  176. levelfour/types/register_endpoint_response.py +23 -0
  177. levelfour/types/resource_change.py +42 -0
  178. levelfour/types/resource_snapshot.py +21 -0
  179. levelfour/types/revoke_api_key_data.py +20 -0
  180. levelfour/types/revoke_api_key_response.py +23 -0
  181. levelfour/types/risk_assessment.py +29 -0
  182. levelfour/types/risk_factor.py +27 -0
  183. levelfour/types/saved_breakdown_data.py +31 -0
  184. levelfour/types/saved_breakdown_response.py +27 -0
  185. levelfour/types/saved_by_provider_breakdown_data.py +31 -0
  186. levelfour/types/saved_by_provider_breakdown_response.py +27 -0
  187. levelfour/types/saved_by_provider_item.py +76 -0
  188. levelfour/types/saved_item.py +35 -0
  189. levelfour/types/saved_provider_summary.py +36 -0
  190. levelfour/types/saved_summary_data.py +57 -0
  191. levelfour/types/saved_summary_response.py +27 -0
  192. levelfour/types/savings_decision_data.py +28 -0
  193. levelfour/types/savings_decision_response.py +27 -0
  194. levelfour/types/spending_by_date_item.py +36 -0
  195. levelfour/types/top_recommendation.py +56 -0
  196. levelfour/types/trigger_info.py +22 -0
  197. levelfour/types/update_tag_data.py +20 -0
  198. levelfour/types/update_tag_response.py +23 -0
  199. levelfour/types/validation_error.py +24 -0
  200. levelfour/types/validation_error_loc_item.py +5 -0
  201. levelfour/webhooks/__init__.py +4 -0
  202. levelfour/webhooks/client.py +273 -0
  203. levelfour/webhooks/raw_client.py +483 -0
  204. levelfour/webhooks/verifier.py +61 -0
  205. levelfour-0.1.0.dist-info/METADATA +12 -0
  206. levelfour-0.1.0.dist-info/RECORD +208 -0
  207. levelfour-0.1.0.dist-info/WHEEL +5 -0
  208. levelfour-0.1.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,346 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ from __future__ import annotations
4
+
5
+ import typing
6
+
7
+ import httpx
8
+ from .core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
9
+ from .core.logging import LogConfig, Logger
10
+
11
+ if typing.TYPE_CHECKING:
12
+ from .api_keys.client import ApiKeysClient, AsyncApiKeysClient
13
+ from .evaluation.client import AsyncEvaluationClient, EvaluationClient
14
+ from .health.client import AsyncHealthClient, HealthClient
15
+ from .pr_analysis.client import AsyncPrAnalysisClient, PrAnalysisClient
16
+ from .pr_analysis_actions.client import AsyncPrAnalysisActionsClient, PrAnalysisActionsClient
17
+ from .pr_analysis_installations.client import AsyncPrAnalysisInstallationsClient, PrAnalysisInstallationsClient
18
+ from .providers.client import AsyncProvidersClient, ProvidersClient
19
+ from .recommendations.client import AsyncRecommendationsClient, RecommendationsClient
20
+ from .savings.client import AsyncSavingsClient, SavingsClient
21
+ from .spending.client import AsyncSpendingClient, SpendingClient
22
+ from .webhooks.client import AsyncWebhooksClient, WebhooksClient
23
+
24
+
25
+ class BaseLevelFour:
26
+ """
27
+ Use this class to access the different functions within the SDK. You can instantiate any number of clients with different configuration that will propagate to these functions.
28
+
29
+ Parameters
30
+ ----------
31
+ base_url : str
32
+ The base url to use for requests from the client.
33
+
34
+ token : typing.Optional[typing.Union[str, typing.Callable[[], str]]]
35
+ headers : typing.Optional[typing.Dict[str, str]]
36
+ Additional headers to send with every request.
37
+
38
+ timeout : typing.Optional[float]
39
+ The timeout to be used, in seconds, for requests. By default the timeout is 60 seconds, unless a custom httpx client is used, in which case this default is not enforced.
40
+
41
+ follow_redirects : typing.Optional[bool]
42
+ Whether the default httpx client follows redirects or not, this is irrelevant if a custom httpx client is passed in.
43
+
44
+ httpx_client : typing.Optional[httpx.Client]
45
+ The httpx client to use for making requests, a preconfigured client is used by default, however this is useful should you want to pass in any custom httpx configuration.
46
+
47
+ logging : typing.Optional[typing.Union[LogConfig, Logger]]
48
+ Configure logging for the SDK. Accepts a LogConfig dict with 'level' (debug/info/warn/error), 'logger' (custom logger implementation), and 'silent' (boolean, defaults to True) fields. You can also pass a pre-configured Logger instance.
49
+
50
+ Examples
51
+ --------
52
+ from levelfour import BaseLevelFour
53
+
54
+ client = BaseLevelFour(
55
+ token="YOUR_TOKEN",
56
+ base_url="https://yourhost.com/path/to/api",
57
+ )
58
+ """
59
+
60
+ def __init__(
61
+ self,
62
+ *,
63
+ base_url: str,
64
+ token: typing.Optional[typing.Union[str, typing.Callable[[], str]]] = None,
65
+ headers: typing.Optional[typing.Dict[str, str]] = None,
66
+ timeout: typing.Optional[float] = None,
67
+ follow_redirects: typing.Optional[bool] = True,
68
+ httpx_client: typing.Optional[httpx.Client] = None,
69
+ logging: typing.Optional[typing.Union[LogConfig, Logger]] = None,
70
+ ):
71
+ _defaulted_timeout = (
72
+ timeout if timeout is not None else 60 if httpx_client is None else httpx_client.timeout.read
73
+ )
74
+ self._client_wrapper = SyncClientWrapper(
75
+ base_url=base_url,
76
+ token=token,
77
+ headers=headers,
78
+ httpx_client=httpx_client
79
+ if httpx_client is not None
80
+ else httpx.Client(timeout=_defaulted_timeout, follow_redirects=follow_redirects)
81
+ if follow_redirects is not None
82
+ else httpx.Client(timeout=_defaulted_timeout),
83
+ timeout=_defaulted_timeout,
84
+ logging=logging,
85
+ )
86
+ self._api_keys: typing.Optional[ApiKeysClient] = None
87
+ self._webhooks: typing.Optional[WebhooksClient] = None
88
+ self._recommendations: typing.Optional[RecommendationsClient] = None
89
+ self._savings: typing.Optional[SavingsClient] = None
90
+ self._spending: typing.Optional[SpendingClient] = None
91
+ self._providers: typing.Optional[ProvidersClient] = None
92
+ self._evaluation: typing.Optional[EvaluationClient] = None
93
+ self._pr_analysis: typing.Optional[PrAnalysisClient] = None
94
+ self._pr_analysis_installations: typing.Optional[PrAnalysisInstallationsClient] = None
95
+ self._pr_analysis_actions: typing.Optional[PrAnalysisActionsClient] = None
96
+ self._health: typing.Optional[HealthClient] = None
97
+
98
+ @property
99
+ def api_keys(self):
100
+ if self._api_keys is None:
101
+ from .api_keys.client import ApiKeysClient # noqa: E402
102
+
103
+ self._api_keys = ApiKeysClient(client_wrapper=self._client_wrapper)
104
+ return self._api_keys
105
+
106
+ @property
107
+ def webhooks(self):
108
+ if self._webhooks is None:
109
+ from .webhooks.client import WebhooksClient # noqa: E402
110
+
111
+ self._webhooks = WebhooksClient(client_wrapper=self._client_wrapper)
112
+ return self._webhooks
113
+
114
+ @property
115
+ def recommendations(self):
116
+ if self._recommendations is None:
117
+ from .recommendations.client import RecommendationsClient # noqa: E402
118
+
119
+ self._recommendations = RecommendationsClient(client_wrapper=self._client_wrapper)
120
+ return self._recommendations
121
+
122
+ @property
123
+ def savings(self):
124
+ if self._savings is None:
125
+ from .savings.client import SavingsClient # noqa: E402
126
+
127
+ self._savings = SavingsClient(client_wrapper=self._client_wrapper)
128
+ return self._savings
129
+
130
+ @property
131
+ def spending(self):
132
+ if self._spending is None:
133
+ from .spending.client import SpendingClient # noqa: E402
134
+
135
+ self._spending = SpendingClient(client_wrapper=self._client_wrapper)
136
+ return self._spending
137
+
138
+ @property
139
+ def providers(self):
140
+ if self._providers is None:
141
+ from .providers.client import ProvidersClient # noqa: E402
142
+
143
+ self._providers = ProvidersClient(client_wrapper=self._client_wrapper)
144
+ return self._providers
145
+
146
+ @property
147
+ def evaluation(self):
148
+ if self._evaluation is None:
149
+ from .evaluation.client import EvaluationClient # noqa: E402
150
+
151
+ self._evaluation = EvaluationClient(client_wrapper=self._client_wrapper)
152
+ return self._evaluation
153
+
154
+ @property
155
+ def pr_analysis(self):
156
+ if self._pr_analysis is None:
157
+ from .pr_analysis.client import PrAnalysisClient # noqa: E402
158
+
159
+ self._pr_analysis = PrAnalysisClient(client_wrapper=self._client_wrapper)
160
+ return self._pr_analysis
161
+
162
+ @property
163
+ def pr_analysis_installations(self):
164
+ if self._pr_analysis_installations is None:
165
+ from .pr_analysis_installations.client import PrAnalysisInstallationsClient # noqa: E402
166
+
167
+ self._pr_analysis_installations = PrAnalysisInstallationsClient(client_wrapper=self._client_wrapper)
168
+ return self._pr_analysis_installations
169
+
170
+ @property
171
+ def pr_analysis_actions(self):
172
+ if self._pr_analysis_actions is None:
173
+ from .pr_analysis_actions.client import PrAnalysisActionsClient # noqa: E402
174
+
175
+ self._pr_analysis_actions = PrAnalysisActionsClient(client_wrapper=self._client_wrapper)
176
+ return self._pr_analysis_actions
177
+
178
+ @property
179
+ def health(self):
180
+ if self._health is None:
181
+ from .health.client import HealthClient # noqa: E402
182
+
183
+ self._health = HealthClient(client_wrapper=self._client_wrapper)
184
+ return self._health
185
+
186
+
187
+ class AsyncBaseLevelFour:
188
+ """
189
+ Use this class to access the different functions within the SDK. You can instantiate any number of clients with different configuration that will propagate to these functions.
190
+
191
+ Parameters
192
+ ----------
193
+ base_url : str
194
+ The base url to use for requests from the client.
195
+
196
+ token : typing.Optional[typing.Union[str, typing.Callable[[], str]]]
197
+ headers : typing.Optional[typing.Dict[str, str]]
198
+ Additional headers to send with every request.
199
+
200
+ timeout : typing.Optional[float]
201
+ The timeout to be used, in seconds, for requests. By default the timeout is 60 seconds, unless a custom httpx client is used, in which case this default is not enforced.
202
+
203
+ follow_redirects : typing.Optional[bool]
204
+ Whether the default httpx client follows redirects or not, this is irrelevant if a custom httpx client is passed in.
205
+
206
+ httpx_client : typing.Optional[httpx.AsyncClient]
207
+ The httpx client to use for making requests, a preconfigured client is used by default, however this is useful should you want to pass in any custom httpx configuration.
208
+
209
+ logging : typing.Optional[typing.Union[LogConfig, Logger]]
210
+ Configure logging for the SDK. Accepts a LogConfig dict with 'level' (debug/info/warn/error), 'logger' (custom logger implementation), and 'silent' (boolean, defaults to True) fields. You can also pass a pre-configured Logger instance.
211
+
212
+ Examples
213
+ --------
214
+ from levelfour import AsyncBaseLevelFour
215
+
216
+ client = AsyncBaseLevelFour(
217
+ token="YOUR_TOKEN",
218
+ base_url="https://yourhost.com/path/to/api",
219
+ )
220
+ """
221
+
222
+ def __init__(
223
+ self,
224
+ *,
225
+ base_url: str,
226
+ token: typing.Optional[typing.Union[str, typing.Callable[[], str]]] = None,
227
+ headers: typing.Optional[typing.Dict[str, str]] = None,
228
+ timeout: typing.Optional[float] = None,
229
+ follow_redirects: typing.Optional[bool] = True,
230
+ httpx_client: typing.Optional[httpx.AsyncClient] = None,
231
+ logging: typing.Optional[typing.Union[LogConfig, Logger]] = None,
232
+ ):
233
+ _defaulted_timeout = (
234
+ timeout if timeout is not None else 60 if httpx_client is None else httpx_client.timeout.read
235
+ )
236
+ self._client_wrapper = AsyncClientWrapper(
237
+ base_url=base_url,
238
+ token=token,
239
+ headers=headers,
240
+ httpx_client=httpx_client
241
+ if httpx_client is not None
242
+ else httpx.AsyncClient(timeout=_defaulted_timeout, follow_redirects=follow_redirects)
243
+ if follow_redirects is not None
244
+ else httpx.AsyncClient(timeout=_defaulted_timeout),
245
+ timeout=_defaulted_timeout,
246
+ logging=logging,
247
+ )
248
+ self._api_keys: typing.Optional[AsyncApiKeysClient] = None
249
+ self._webhooks: typing.Optional[AsyncWebhooksClient] = None
250
+ self._recommendations: typing.Optional[AsyncRecommendationsClient] = None
251
+ self._savings: typing.Optional[AsyncSavingsClient] = None
252
+ self._spending: typing.Optional[AsyncSpendingClient] = None
253
+ self._providers: typing.Optional[AsyncProvidersClient] = None
254
+ self._evaluation: typing.Optional[AsyncEvaluationClient] = None
255
+ self._pr_analysis: typing.Optional[AsyncPrAnalysisClient] = None
256
+ self._pr_analysis_installations: typing.Optional[AsyncPrAnalysisInstallationsClient] = None
257
+ self._pr_analysis_actions: typing.Optional[AsyncPrAnalysisActionsClient] = None
258
+ self._health: typing.Optional[AsyncHealthClient] = None
259
+
260
+ @property
261
+ def api_keys(self):
262
+ if self._api_keys is None:
263
+ from .api_keys.client import AsyncApiKeysClient # noqa: E402
264
+
265
+ self._api_keys = AsyncApiKeysClient(client_wrapper=self._client_wrapper)
266
+ return self._api_keys
267
+
268
+ @property
269
+ def webhooks(self):
270
+ if self._webhooks is None:
271
+ from .webhooks.client import AsyncWebhooksClient # noqa: E402
272
+
273
+ self._webhooks = AsyncWebhooksClient(client_wrapper=self._client_wrapper)
274
+ return self._webhooks
275
+
276
+ @property
277
+ def recommendations(self):
278
+ if self._recommendations is None:
279
+ from .recommendations.client import AsyncRecommendationsClient # noqa: E402
280
+
281
+ self._recommendations = AsyncRecommendationsClient(client_wrapper=self._client_wrapper)
282
+ return self._recommendations
283
+
284
+ @property
285
+ def savings(self):
286
+ if self._savings is None:
287
+ from .savings.client import AsyncSavingsClient # noqa: E402
288
+
289
+ self._savings = AsyncSavingsClient(client_wrapper=self._client_wrapper)
290
+ return self._savings
291
+
292
+ @property
293
+ def spending(self):
294
+ if self._spending is None:
295
+ from .spending.client import AsyncSpendingClient # noqa: E402
296
+
297
+ self._spending = AsyncSpendingClient(client_wrapper=self._client_wrapper)
298
+ return self._spending
299
+
300
+ @property
301
+ def providers(self):
302
+ if self._providers is None:
303
+ from .providers.client import AsyncProvidersClient # noqa: E402
304
+
305
+ self._providers = AsyncProvidersClient(client_wrapper=self._client_wrapper)
306
+ return self._providers
307
+
308
+ @property
309
+ def evaluation(self):
310
+ if self._evaluation is None:
311
+ from .evaluation.client import AsyncEvaluationClient # noqa: E402
312
+
313
+ self._evaluation = AsyncEvaluationClient(client_wrapper=self._client_wrapper)
314
+ return self._evaluation
315
+
316
+ @property
317
+ def pr_analysis(self):
318
+ if self._pr_analysis is None:
319
+ from .pr_analysis.client import AsyncPrAnalysisClient # noqa: E402
320
+
321
+ self._pr_analysis = AsyncPrAnalysisClient(client_wrapper=self._client_wrapper)
322
+ return self._pr_analysis
323
+
324
+ @property
325
+ def pr_analysis_installations(self):
326
+ if self._pr_analysis_installations is None:
327
+ from .pr_analysis_installations.client import AsyncPrAnalysisInstallationsClient # noqa: E402
328
+
329
+ self._pr_analysis_installations = AsyncPrAnalysisInstallationsClient(client_wrapper=self._client_wrapper)
330
+ return self._pr_analysis_installations
331
+
332
+ @property
333
+ def pr_analysis_actions(self):
334
+ if self._pr_analysis_actions is None:
335
+ from .pr_analysis_actions.client import AsyncPrAnalysisActionsClient # noqa: E402
336
+
337
+ self._pr_analysis_actions = AsyncPrAnalysisActionsClient(client_wrapper=self._client_wrapper)
338
+ return self._pr_analysis_actions
339
+
340
+ @property
341
+ def health(self):
342
+ if self._health is None:
343
+ from .health.client import AsyncHealthClient # noqa: E402
344
+
345
+ self._health = AsyncHealthClient(client_wrapper=self._client_wrapper)
346
+ return self._health
levelfour/client.py ADDED
@@ -0,0 +1,54 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+
5
+ import httpx
6
+ from .base_client import AsyncBaseLevelFour as base_client_AsyncBaseLevelFour
7
+ from .base_client import BaseLevelFour as base_client_BaseLevelFour
8
+ from .core.logging import LogConfig, Logger
9
+
10
+
11
+ class BaseLevelFour(base_client_BaseLevelFour):
12
+ def __init__(
13
+ self,
14
+ *,
15
+ base_url: str,
16
+ token: typing.Optional[typing.Union[str, typing.Callable[[], str]]] = None,
17
+ headers: typing.Optional[typing.Dict[str, str]] = None,
18
+ timeout: typing.Optional[float] = None,
19
+ follow_redirects: typing.Optional[bool] = True,
20
+ httpx_client: typing.Optional[httpx.Client] = None,
21
+ logging: typing.Optional[typing.Union[LogConfig, Logger]] = None,
22
+ ):
23
+ super().__init__(
24
+ base_url=base_url,
25
+ token=token,
26
+ headers=headers,
27
+ timeout=timeout,
28
+ follow_redirects=follow_redirects,
29
+ httpx_client=httpx_client,
30
+ logging=logging,
31
+ )
32
+
33
+
34
+ class AsyncBaseLevelFour(base_client_AsyncBaseLevelFour):
35
+ def __init__(
36
+ self,
37
+ *,
38
+ base_url: str,
39
+ token: typing.Optional[typing.Union[str, typing.Callable[[], str]]] = None,
40
+ headers: typing.Optional[typing.Dict[str, str]] = None,
41
+ timeout: typing.Optional[float] = None,
42
+ follow_redirects: typing.Optional[bool] = True,
43
+ httpx_client: typing.Optional[httpx.AsyncClient] = None,
44
+ logging: typing.Optional[typing.Union[LogConfig, Logger]] = None,
45
+ ):
46
+ super().__init__(
47
+ base_url=base_url,
48
+ token=token,
49
+ headers=headers,
50
+ timeout=timeout,
51
+ follow_redirects=follow_redirects,
52
+ httpx_client=httpx_client,
53
+ logging=logging,
54
+ )
@@ -0,0 +1,127 @@
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 .api_error import ApiError
10
+ from .client_wrapper import AsyncClientWrapper, BaseClientWrapper, SyncClientWrapper
11
+ from .datetime_utils import Rfc2822DateTime, parse_rfc2822_datetime, serialize_datetime
12
+ from .file import File, convert_file_dict_to_httpx_tuples, with_content_type
13
+ from .http_client import AsyncHttpClient, HttpClient
14
+ from .http_response import AsyncHttpResponse, HttpResponse
15
+ from .jsonable_encoder import jsonable_encoder
16
+ from .logging import ConsoleLogger, ILogger, LogConfig, LogLevel, Logger, create_logger
17
+ from .pagination import AsyncPager, SyncPager
18
+ from .pydantic_utilities import (
19
+ IS_PYDANTIC_V2,
20
+ UniversalBaseModel,
21
+ UniversalRootModel,
22
+ parse_obj_as,
23
+ universal_field_validator,
24
+ universal_root_validator,
25
+ update_forward_refs,
26
+ )
27
+ from .query_encoder import encode_query
28
+ from .remove_none_from_dict import remove_none_from_dict
29
+ from .request_options import RequestOptions
30
+ from .serialization import FieldMetadata, convert_and_respect_annotation_metadata
31
+ _dynamic_imports: typing.Dict[str, str] = {
32
+ "ApiError": ".api_error",
33
+ "AsyncClientWrapper": ".client_wrapper",
34
+ "AsyncHttpClient": ".http_client",
35
+ "AsyncHttpResponse": ".http_response",
36
+ "AsyncPager": ".pagination",
37
+ "BaseClientWrapper": ".client_wrapper",
38
+ "ConsoleLogger": ".logging",
39
+ "FieldMetadata": ".serialization",
40
+ "File": ".file",
41
+ "HttpClient": ".http_client",
42
+ "HttpResponse": ".http_response",
43
+ "ILogger": ".logging",
44
+ "IS_PYDANTIC_V2": ".pydantic_utilities",
45
+ "LogConfig": ".logging",
46
+ "LogLevel": ".logging",
47
+ "Logger": ".logging",
48
+ "RequestOptions": ".request_options",
49
+ "Rfc2822DateTime": ".datetime_utils",
50
+ "SyncClientWrapper": ".client_wrapper",
51
+ "SyncPager": ".pagination",
52
+ "UniversalBaseModel": ".pydantic_utilities",
53
+ "UniversalRootModel": ".pydantic_utilities",
54
+ "convert_and_respect_annotation_metadata": ".serialization",
55
+ "convert_file_dict_to_httpx_tuples": ".file",
56
+ "create_logger": ".logging",
57
+ "encode_query": ".query_encoder",
58
+ "jsonable_encoder": ".jsonable_encoder",
59
+ "parse_obj_as": ".pydantic_utilities",
60
+ "parse_rfc2822_datetime": ".datetime_utils",
61
+ "remove_none_from_dict": ".remove_none_from_dict",
62
+ "serialize_datetime": ".datetime_utils",
63
+ "universal_field_validator": ".pydantic_utilities",
64
+ "universal_root_validator": ".pydantic_utilities",
65
+ "update_forward_refs": ".pydantic_utilities",
66
+ "with_content_type": ".file",
67
+ }
68
+
69
+
70
+ def __getattr__(attr_name: str) -> typing.Any:
71
+ module_name = _dynamic_imports.get(attr_name)
72
+ if module_name is None:
73
+ raise AttributeError(f"No {attr_name} found in _dynamic_imports for module name -> {__name__}")
74
+ try:
75
+ module = import_module(module_name, __package__)
76
+ if module_name == f".{attr_name}":
77
+ return module
78
+ else:
79
+ return getattr(module, attr_name)
80
+ except ImportError as e:
81
+ raise ImportError(f"Failed to import {attr_name} from {module_name}: {e}") from e
82
+ except AttributeError as e:
83
+ raise AttributeError(f"Failed to get {attr_name} from {module_name}: {e}") from e
84
+
85
+
86
+ def __dir__():
87
+ lazy_attrs = list(_dynamic_imports.keys())
88
+ return sorted(lazy_attrs)
89
+
90
+
91
+ __all__ = [
92
+ "ApiError",
93
+ "AsyncClientWrapper",
94
+ "AsyncHttpClient",
95
+ "AsyncHttpResponse",
96
+ "AsyncPager",
97
+ "BaseClientWrapper",
98
+ "ConsoleLogger",
99
+ "FieldMetadata",
100
+ "File",
101
+ "HttpClient",
102
+ "HttpResponse",
103
+ "ILogger",
104
+ "IS_PYDANTIC_V2",
105
+ "LogConfig",
106
+ "LogLevel",
107
+ "Logger",
108
+ "RequestOptions",
109
+ "Rfc2822DateTime",
110
+ "SyncClientWrapper",
111
+ "SyncPager",
112
+ "UniversalBaseModel",
113
+ "UniversalRootModel",
114
+ "convert_and_respect_annotation_metadata",
115
+ "convert_file_dict_to_httpx_tuples",
116
+ "create_logger",
117
+ "encode_query",
118
+ "jsonable_encoder",
119
+ "parse_obj_as",
120
+ "parse_rfc2822_datetime",
121
+ "remove_none_from_dict",
122
+ "serialize_datetime",
123
+ "universal_field_validator",
124
+ "universal_root_validator",
125
+ "update_forward_refs",
126
+ "with_content_type",
127
+ ]
@@ -0,0 +1,23 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ from typing import Any, Dict, Optional
4
+
5
+
6
+ class ApiError(Exception):
7
+ headers: Optional[Dict[str, str]]
8
+ status_code: Optional[int]
9
+ body: Any
10
+
11
+ def __init__(
12
+ self,
13
+ *,
14
+ headers: Optional[Dict[str, str]] = None,
15
+ status_code: Optional[int] = None,
16
+ body: Any = None,
17
+ ) -> None:
18
+ self.headers = headers
19
+ self.status_code = status_code
20
+ self.body = body
21
+
22
+ def __str__(self) -> str:
23
+ return f"headers: {self.headers}, status_code: {self.status_code}, body: {self.body}"
@@ -0,0 +1,105 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+
5
+ import httpx
6
+ from .http_client import AsyncHttpClient, HttpClient
7
+ from .logging import LogConfig, Logger
8
+
9
+
10
+ class BaseClientWrapper:
11
+ def __init__(
12
+ self,
13
+ *,
14
+ token: typing.Optional[typing.Union[str, typing.Callable[[], str]]] = None,
15
+ headers: typing.Optional[typing.Dict[str, str]] = None,
16
+ base_url: str,
17
+ timeout: typing.Optional[float] = None,
18
+ logging: typing.Optional[typing.Union[LogConfig, Logger]] = None,
19
+ ):
20
+ self._token = token
21
+ self._headers = headers
22
+ self._base_url = base_url
23
+ self._timeout = timeout
24
+ self._logging = logging
25
+
26
+ def get_headers(self) -> typing.Dict[str, str]:
27
+ import platform
28
+
29
+ headers: typing.Dict[str, str] = {
30
+ "X-Fern-Language": "Python",
31
+ "X-Fern-Runtime": f"python/{platform.python_version()}",
32
+ "X-Fern-Platform": f"{platform.system().lower()}/{platform.release()}",
33
+ **(self.get_custom_headers() or {}),
34
+ }
35
+ token = self._get_token()
36
+ if token is not None:
37
+ headers["Authorization"] = f"Bearer {token}"
38
+ return headers
39
+
40
+ def _get_token(self) -> typing.Optional[str]:
41
+ if isinstance(self._token, str) or self._token is None:
42
+ return self._token
43
+ else:
44
+ return self._token()
45
+
46
+ def get_custom_headers(self) -> typing.Optional[typing.Dict[str, str]]:
47
+ return self._headers
48
+
49
+ def get_base_url(self) -> str:
50
+ return self._base_url
51
+
52
+ def get_timeout(self) -> typing.Optional[float]:
53
+ return self._timeout
54
+
55
+
56
+ class SyncClientWrapper(BaseClientWrapper):
57
+ def __init__(
58
+ self,
59
+ *,
60
+ token: typing.Optional[typing.Union[str, typing.Callable[[], str]]] = None,
61
+ headers: typing.Optional[typing.Dict[str, str]] = None,
62
+ base_url: str,
63
+ timeout: typing.Optional[float] = None,
64
+ logging: typing.Optional[typing.Union[LogConfig, Logger]] = None,
65
+ httpx_client: httpx.Client,
66
+ ):
67
+ super().__init__(token=token, headers=headers, base_url=base_url, timeout=timeout, logging=logging)
68
+ self.httpx_client = HttpClient(
69
+ httpx_client=httpx_client,
70
+ base_headers=self.get_headers,
71
+ base_timeout=self.get_timeout,
72
+ base_url=self.get_base_url,
73
+ logging_config=self._logging,
74
+ )
75
+
76
+
77
+ class AsyncClientWrapper(BaseClientWrapper):
78
+ def __init__(
79
+ self,
80
+ *,
81
+ token: typing.Optional[typing.Union[str, typing.Callable[[], str]]] = None,
82
+ headers: typing.Optional[typing.Dict[str, str]] = None,
83
+ base_url: str,
84
+ timeout: typing.Optional[float] = None,
85
+ logging: typing.Optional[typing.Union[LogConfig, Logger]] = None,
86
+ async_token: typing.Optional[typing.Callable[[], typing.Awaitable[str]]] = None,
87
+ httpx_client: httpx.AsyncClient,
88
+ ):
89
+ super().__init__(token=token, headers=headers, base_url=base_url, timeout=timeout, logging=logging)
90
+ self._async_token = async_token
91
+ self.httpx_client = AsyncHttpClient(
92
+ httpx_client=httpx_client,
93
+ base_headers=self.get_headers,
94
+ base_timeout=self.get_timeout,
95
+ base_url=self.get_base_url,
96
+ async_base_headers=self.async_get_headers,
97
+ logging_config=self._logging,
98
+ )
99
+
100
+ async def async_get_headers(self) -> typing.Dict[str, str]:
101
+ headers = self.get_headers()
102
+ if self._async_token is not None:
103
+ token = await self._async_token()
104
+ headers["Authorization"] = f"Bearer {token}"
105
+ return headers