agenta 0.48.9__py3-none-any.whl → 0.49.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.

Potentially problematic release.


This version of agenta might be problematic. Click here for more details.

Files changed (297) hide show
  1. agenta/__init__.py +3 -2
  2. agenta/client/Readme.md +258 -80
  3. agenta/client/__init__.py +205 -29
  4. agenta/client/backend/__init__.py +461 -0
  5. agenta/client/backend/access_control/__init__.py +2 -0
  6. agenta/client/backend/access_control/client.py +53 -73
  7. agenta/client/backend/access_control/raw_client.py +180 -0
  8. agenta/client/backend/admin/__init__.py +2 -0
  9. agenta/client/backend/admin/client.py +473 -268
  10. agenta/client/backend/admin/raw_client.py +1017 -0
  11. agenta/client/backend/api_keys/__init__.py +2 -0
  12. agenta/client/backend/api_keys/client.py +43 -276
  13. agenta/client/backend/api_keys/raw_client.py +364 -0
  14. agenta/client/backend/apps/__init__.py +2 -0
  15. agenta/client/backend/apps/client.py +132 -895
  16. agenta/client/backend/apps/raw_client.py +1516 -0
  17. agenta/client/backend/bases/__init__.py +2 -0
  18. agenta/client/backend/bases/client.py +33 -73
  19. agenta/client/backend/bases/raw_client.py +179 -0
  20. agenta/client/backend/billing/__init__.py +3 -0
  21. agenta/client/backend/billing/client.py +564 -0
  22. agenta/client/backend/billing/raw_client.py +805 -0
  23. agenta/client/backend/client.py +1268 -0
  24. agenta/client/backend/configs/__init__.py +2 -0
  25. agenta/client/backend/configs/client.py +49 -361
  26. agenta/client/backend/configs/raw_client.py +402 -0
  27. agenta/client/backend/containers/__init__.py +1 -3
  28. agenta/client/backend/containers/client.py +25 -548
  29. agenta/client/backend/containers/raw_client.py +112 -0
  30. agenta/client/backend/core/__init__.py +5 -0
  31. agenta/client/backend/core/api_error.py +12 -6
  32. agenta/client/backend/core/client_wrapper.py +4 -4
  33. agenta/client/backend/core/file.py +1 -3
  34. agenta/client/backend/core/force_multipart.py +16 -0
  35. agenta/client/backend/core/http_client.py +78 -34
  36. agenta/client/backend/core/http_response.py +55 -0
  37. agenta/client/backend/core/jsonable_encoder.py +0 -1
  38. agenta/client/backend/core/pydantic_utilities.py +88 -113
  39. agenta/client/backend/core/serialization.py +9 -3
  40. agenta/client/backend/environment.py +7 -0
  41. agenta/client/backend/environments/__init__.py +2 -0
  42. agenta/client/backend/environments/client.py +43 -79
  43. agenta/client/backend/environments/raw_client.py +193 -0
  44. agenta/client/backend/errors/__init__.py +2 -0
  45. agenta/client/backend/errors/unprocessable_entity_error.py +8 -2
  46. agenta/client/backend/evals/__init__.py +3 -0
  47. agenta/client/backend/evals/client.py +1042 -0
  48. agenta/client/backend/evals/raw_client.py +1549 -0
  49. agenta/client/backend/evaluations/__init__.py +2 -0
  50. agenta/client/backend/evaluations/client.py +106 -590
  51. agenta/client/backend/evaluations/raw_client.py +1344 -0
  52. agenta/client/backend/evaluators/__init__.py +2 -0
  53. agenta/client/backend/evaluators/client.py +99 -516
  54. agenta/client/backend/evaluators/raw_client.py +1182 -0
  55. agenta/client/backend/human_evaluations/__init__.py +2 -0
  56. agenta/client/backend/human_evaluations/client.py +120 -680
  57. agenta/client/backend/human_evaluations/raw_client.py +1577 -0
  58. agenta/client/backend/observability/__init__.py +14 -2
  59. agenta/client/backend/observability/client.py +185 -341
  60. agenta/client/backend/observability/raw_client.py +943 -0
  61. agenta/client/backend/observability/types/__init__.py +10 -2
  62. agenta/client/backend/observability/types/{format.py → fetch_trace_by_id_request_trace_id.py} +1 -1
  63. agenta/client/backend/observability/types/fetch_trace_by_id_response.py +15 -0
  64. agenta/client/backend/observability/types/query_analytics_response.py +2 -1
  65. agenta/client/backend/observability/types/query_traces_response.py +7 -3
  66. agenta/client/backend/organization/__init__.py +2 -0
  67. agenta/client/backend/organization/client.py +105 -361
  68. agenta/client/backend/organization/raw_client.py +774 -0
  69. agenta/client/backend/raw_client.py +1432 -0
  70. agenta/client/backend/scopes/__init__.py +2 -0
  71. agenta/client/backend/scopes/client.py +31 -45
  72. agenta/client/backend/scopes/raw_client.py +105 -0
  73. agenta/client/backend/testsets/__init__.py +14 -0
  74. agenta/client/backend/testsets/client.py +1098 -653
  75. agenta/client/backend/testsets/raw_client.py +2348 -0
  76. agenta/client/backend/testsets/types/__init__.py +17 -0
  77. agenta/client/backend/testsets/types/create_testset_from_file_request_file_type.py +7 -0
  78. agenta/client/backend/testsets/types/fetch_testset_to_file_request_file_type.py +7 -0
  79. agenta/client/backend/testsets/types/update_testset_from_file_request_file_type.py +7 -0
  80. agenta/client/backend/tracing/__init__.py +7 -0
  81. agenta/client/backend/tracing/client.py +782 -0
  82. agenta/client/backend/tracing/raw_client.py +1223 -0
  83. agenta/client/backend/tracing/types/__init__.py +8 -0
  84. agenta/client/backend/{types/variant_action_enum.py → tracing/types/fetch_trace_request_trace_id.py} +1 -1
  85. agenta/client/backend/tracing/types/remove_trace_request_trace_id.py +5 -0
  86. agenta/client/backend/types/__init__.py +153 -26
  87. agenta/client/backend/types/account_request.py +24 -0
  88. agenta/client/backend/types/account_response.py +5 -7
  89. agenta/client/backend/types/agenta_node_dto.py +13 -13
  90. agenta/client/backend/types/agenta_node_dto_nodes_value.py +1 -0
  91. agenta/client/backend/types/agenta_nodes_response.py +14 -8
  92. agenta/client/backend/types/agenta_root_dto.py +16 -8
  93. agenta/client/backend/types/agenta_roots_response.py +16 -8
  94. agenta/client/backend/types/agenta_tree_dto.py +16 -8
  95. agenta/client/backend/types/agenta_trees_response.py +16 -8
  96. agenta/client/backend/types/aggregated_result.py +5 -7
  97. agenta/client/backend/types/aggregated_result_evaluator_config.py +1 -0
  98. agenta/client/backend/types/analytics_response.py +4 -6
  99. agenta/client/backend/types/annotation.py +50 -0
  100. agenta/client/backend/types/annotation_create.py +39 -0
  101. agenta/client/backend/types/annotation_edit.py +31 -0
  102. agenta/client/backend/types/annotation_kind.py +5 -0
  103. agenta/client/backend/types/{uri.py → annotation_link.py} +6 -7
  104. agenta/client/backend/types/{provider_key_dto.py → annotation_link_response.py} +6 -7
  105. agenta/client/backend/types/annotation_query.py +40 -0
  106. agenta/client/backend/types/annotation_query_request.py +20 -0
  107. agenta/client/backend/types/annotation_reference.py +21 -0
  108. agenta/client/backend/types/annotation_references.py +22 -0
  109. agenta/client/backend/types/{docker_env_vars.py → annotation_response.py} +6 -7
  110. agenta/client/backend/types/annotation_source.py +5 -0
  111. agenta/client/backend/types/annotations_response.py +24 -0
  112. agenta/client/backend/types/app.py +3 -5
  113. agenta/client/backend/types/app_variant_response.py +3 -6
  114. agenta/client/backend/types/app_variant_revision.py +5 -6
  115. agenta/client/backend/types/artifact.py +44 -0
  116. agenta/client/backend/types/base_output.py +3 -5
  117. agenta/client/backend/types/body_fetch_workflow_revision.py +21 -0
  118. agenta/client/backend/types/body_import_testset.py +3 -5
  119. agenta/client/backend/types/bucket_dto.py +4 -6
  120. agenta/client/backend/types/collect_status_response.py +3 -5
  121. agenta/client/backend/types/config_db.py +3 -5
  122. agenta/client/backend/types/config_dto.py +5 -7
  123. agenta/client/backend/types/config_response_model.py +5 -7
  124. agenta/client/backend/types/correct_answer.py +3 -5
  125. agenta/client/backend/types/create_app_output.py +3 -5
  126. agenta/client/backend/types/custom_model_settings_dto.py +3 -5
  127. agenta/client/backend/types/custom_provider_dto.py +6 -9
  128. agenta/client/backend/types/custom_provider_kind.py +5 -5
  129. agenta/client/backend/types/custom_provider_settings_dto.py +3 -5
  130. agenta/client/backend/types/data.py +2 -1
  131. agenta/client/backend/types/delete_evaluation.py +3 -5
  132. agenta/client/backend/types/environment_output.py +3 -5
  133. agenta/client/backend/types/environment_output_extended.py +4 -6
  134. agenta/client/backend/types/environment_revision.py +5 -5
  135. agenta/client/backend/types/error.py +3 -5
  136. agenta/client/backend/types/evaluation.py +6 -8
  137. agenta/client/backend/types/evaluation_scenario.py +5 -7
  138. agenta/client/backend/types/evaluation_scenario_input.py +3 -5
  139. agenta/client/backend/types/evaluation_scenario_output.py +4 -6
  140. agenta/client/backend/types/evaluation_scenario_result.py +4 -6
  141. agenta/client/backend/types/evaluator.py +31 -12
  142. agenta/client/backend/types/evaluator_config.py +3 -5
  143. agenta/client/backend/types/evaluator_flags.py +21 -0
  144. agenta/client/backend/types/evaluator_mapping_output_interface.py +3 -5
  145. agenta/client/backend/types/evaluator_output_interface.py +3 -5
  146. agenta/client/backend/types/evaluator_query.py +32 -0
  147. agenta/client/backend/types/evaluator_query_request.py +30 -0
  148. agenta/client/backend/types/evaluator_request.py +20 -0
  149. agenta/client/backend/types/evaluator_response.py +21 -0
  150. agenta/client/backend/types/evaluators_response.py +21 -0
  151. agenta/client/backend/types/exception_dto.py +3 -5
  152. agenta/client/backend/types/{o_tel_spans_response.py → extended_o_tel_tracing_response.py} +5 -7
  153. agenta/client/backend/types/focus.py +5 -0
  154. agenta/client/backend/types/format.py +5 -0
  155. agenta/client/backend/types/full_json_input.py +34 -0
  156. agenta/client/backend/types/full_json_output.py +29 -0
  157. agenta/client/backend/types/get_config_response.py +3 -5
  158. agenta/client/backend/types/{header_dto.py → header.py} +4 -6
  159. agenta/client/backend/types/http_validation_error.py +4 -6
  160. agenta/client/backend/types/human_evaluation.py +3 -5
  161. agenta/client/backend/types/human_evaluation_scenario.py +4 -6
  162. agenta/client/backend/types/human_evaluation_scenario_input.py +3 -5
  163. agenta/client/backend/types/human_evaluation_scenario_output.py +3 -5
  164. agenta/client/backend/types/invite_request.py +4 -6
  165. agenta/client/backend/types/legacy_analytics_response.py +4 -6
  166. agenta/client/backend/types/legacy_data_point.py +3 -5
  167. agenta/client/backend/types/legacy_evaluator.py +26 -0
  168. agenta/client/backend/types/legacy_scope_request.py +4 -6
  169. agenta/client/backend/types/legacy_scopes_response.py +3 -5
  170. agenta/client/backend/types/legacy_subscription_request.py +19 -0
  171. agenta/client/backend/types/legacy_user_request.py +5 -7
  172. agenta/client/backend/types/legacy_user_response.py +3 -5
  173. agenta/client/backend/types/lifecycle_dto.py +3 -5
  174. agenta/client/backend/types/link_dto.py +4 -6
  175. agenta/client/backend/types/list_api_keys_response.py +3 -5
  176. agenta/client/backend/types/llm_run_rate_limit.py +3 -5
  177. agenta/client/backend/types/meta_request.py +30 -0
  178. agenta/client/backend/types/metrics_dto.py +3 -5
  179. agenta/client/backend/types/new_testset.py +3 -5
  180. agenta/client/backend/types/node_dto.py +4 -6
  181. agenta/client/backend/types/o_tel_context_dto.py +3 -5
  182. agenta/client/backend/types/o_tel_event.py +35 -0
  183. agenta/client/backend/types/o_tel_event_dto.py +3 -5
  184. agenta/client/backend/types/o_tel_extra_dto.py +4 -6
  185. agenta/client/backend/types/o_tel_flat_span.py +56 -0
  186. agenta/client/backend/types/o_tel_flat_span_input_end_time.py +6 -0
  187. agenta/client/backend/types/o_tel_flat_span_input_start_time.py +6 -0
  188. agenta/client/backend/types/o_tel_flat_span_output_end_time.py +6 -0
  189. agenta/client/backend/types/o_tel_flat_span_output_start_time.py +6 -0
  190. agenta/client/backend/types/o_tel_link.py +34 -0
  191. agenta/client/backend/types/o_tel_link_dto.py +4 -6
  192. agenta/client/backend/types/o_tel_links_response.py +22 -0
  193. agenta/client/backend/types/o_tel_span.py +58 -0
  194. agenta/client/backend/types/o_tel_span_dto.py +8 -10
  195. agenta/client/backend/types/o_tel_span_input_end_time.py +6 -0
  196. agenta/client/backend/types/o_tel_span_input_spans_value.py +7 -0
  197. agenta/client/backend/types/o_tel_span_input_start_time.py +6 -0
  198. agenta/client/backend/types/o_tel_span_output_end_time.py +6 -0
  199. agenta/client/backend/types/o_tel_span_output_spans_value.py +30 -0
  200. agenta/client/backend/types/o_tel_span_output_start_time.py +6 -0
  201. agenta/client/backend/types/o_tel_spans_tree.py +22 -0
  202. agenta/client/backend/types/o_tel_spans_tree_input_spans_value.py +7 -0
  203. agenta/client/backend/types/o_tel_spans_tree_output_spans_value.py +5 -0
  204. agenta/client/backend/types/o_tel_status_code.py +1 -1
  205. agenta/client/backend/types/o_tel_tracing_data_response.py +22 -0
  206. agenta/client/backend/types/o_tel_tracing_request.py +22 -0
  207. agenta/client/backend/types/o_tel_tracing_response.py +27 -0
  208. agenta/client/backend/types/organization.py +3 -5
  209. agenta/client/backend/types/organization_details.py +3 -5
  210. agenta/client/backend/types/organization_membership_request.py +5 -7
  211. agenta/client/backend/types/organization_output.py +3 -5
  212. agenta/client/backend/types/organization_request.py +3 -5
  213. agenta/client/backend/types/parent_dto.py +3 -5
  214. agenta/client/backend/types/permission.py +11 -0
  215. agenta/client/backend/types/plan.py +14 -0
  216. agenta/client/backend/types/project_membership_request.py +5 -7
  217. agenta/client/backend/types/project_request.py +4 -6
  218. agenta/client/backend/types/project_scope.py +5 -7
  219. agenta/client/backend/types/projects_response.py +3 -5
  220. agenta/client/backend/types/recursive_types.py +23 -0
  221. agenta/client/backend/types/reference.py +18 -5
  222. agenta/client/backend/types/reference_dto.py +4 -5
  223. agenta/client/backend/types/reference_request_model.py +4 -5
  224. agenta/client/backend/types/result.py +4 -6
  225. agenta/client/backend/types/root_dto.py +3 -5
  226. agenta/client/backend/types/scopes_response_model.py +4 -6
  227. agenta/client/backend/types/secret_dto.py +5 -7
  228. agenta/client/backend/types/secret_response_dto.py +11 -11
  229. agenta/client/backend/types/simple_evaluation_output.py +4 -6
  230. agenta/client/backend/types/span_dto.py +18 -14
  231. agenta/client/backend/types/span_dto_nodes_value.py +1 -1
  232. agenta/client/backend/types/standard_provider_dto.py +5 -7
  233. agenta/client/backend/types/standard_provider_settings_dto.py +3 -5
  234. agenta/client/backend/types/status_dto.py +4 -6
  235. agenta/client/backend/types/tags_request.py +30 -0
  236. agenta/client/backend/types/test_set_output_response.py +5 -7
  237. agenta/client/backend/types/test_set_simple_response.py +3 -5
  238. agenta/client/backend/types/testcase_response.py +33 -0
  239. agenta/client/backend/types/testset.py +46 -0
  240. agenta/client/backend/types/testset_request.py +20 -0
  241. agenta/client/backend/types/testset_response.py +21 -0
  242. agenta/client/backend/types/testsets_response.py +21 -0
  243. agenta/client/backend/types/time_dto.py +3 -5
  244. agenta/client/backend/types/timestamp.py +6 -0
  245. agenta/client/backend/types/tree_dto.py +4 -6
  246. agenta/client/backend/types/update_app_output.py +3 -5
  247. agenta/client/backend/types/user_request.py +3 -5
  248. agenta/client/backend/types/validation_error.py +4 -6
  249. agenta/client/backend/types/workflow_artifact.py +45 -0
  250. agenta/client/backend/types/workflow_data.py +20 -0
  251. agenta/client/backend/types/workflow_flags.py +21 -0
  252. agenta/client/backend/types/workflow_request.py +20 -0
  253. agenta/client/backend/types/workflow_response.py +21 -0
  254. agenta/client/backend/types/workflow_revision.py +57 -0
  255. agenta/client/backend/types/workflow_revision_request.py +20 -0
  256. agenta/client/backend/types/workflow_revision_response.py +21 -0
  257. agenta/client/backend/types/workflow_revisions_response.py +21 -0
  258. agenta/client/backend/types/workflow_variant.py +48 -0
  259. agenta/client/backend/types/workflow_variant_request.py +20 -0
  260. agenta/client/backend/types/workflow_variant_response.py +21 -0
  261. agenta/client/backend/types/workflow_variants_response.py +21 -0
  262. agenta/client/backend/types/workflows_response.py +21 -0
  263. agenta/client/backend/types/workspace.py +3 -5
  264. agenta/client/backend/types/workspace_member_response.py +4 -6
  265. agenta/client/backend/types/workspace_membership_request.py +5 -7
  266. agenta/client/backend/types/workspace_permission.py +5 -7
  267. agenta/client/backend/types/workspace_request.py +4 -6
  268. agenta/client/backend/types/workspace_response.py +4 -6
  269. agenta/client/backend/variants/__init__.py +2 -0
  270. agenta/client/backend/variants/client.py +306 -1651
  271. agenta/client/backend/variants/raw_client.py +2482 -0
  272. agenta/client/backend/variants/types/__init__.py +2 -0
  273. agenta/client/backend/variants/types/add_variant_from_base_and_config_response.py +1 -0
  274. agenta/client/backend/vault/__init__.py +2 -0
  275. agenta/client/backend/vault/client.py +69 -323
  276. agenta/client/backend/vault/raw_client.py +616 -0
  277. agenta/client/backend/workflows/__init__.py +3 -0
  278. agenta/client/backend/workflows/client.py +2398 -0
  279. agenta/client/backend/workflows/raw_client.py +3639 -0
  280. agenta/client/backend/workspace/__init__.py +2 -0
  281. agenta/client/backend/workspace/client.py +46 -147
  282. agenta/client/backend/workspace/raw_client.py +376 -0
  283. agenta/client/types.py +4 -0
  284. agenta/sdk/litellm/mocks/__init__.py +144 -0
  285. agenta/sdk/middleware/auth.py +26 -25
  286. agenta/sdk/types.py +28 -1
  287. {agenta-0.48.9.dist-info → agenta-0.49.0.dist-info}/METADATA +1 -1
  288. agenta-0.49.0.dist-info/RECORD +362 -0
  289. agenta/client/backend/containers/types/__init__.py +0 -5
  290. agenta/client/backend/containers/types/container_templates_response.py +0 -6
  291. agenta/client/backend/types/image.py +0 -25
  292. agenta/client/backend/types/provider_kind.py +0 -21
  293. agenta/client/backend/types/template.py +0 -23
  294. agenta/client/backend/types/template_image_info.py +0 -29
  295. agenta/client/backend/types/variant_action.py +0 -22
  296. agenta-0.48.9.dist-info/RECORD +0 -255
  297. {agenta-0.48.9.dist-info → agenta-0.49.0.dist-info}/WHEEL +0 -0
@@ -0,0 +1,805 @@
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.pydantic_utilities import parse_obj_as
10
+ from ..core.request_options import RequestOptions
11
+ from ..errors.unprocessable_entity_error import UnprocessableEntityError
12
+ from ..types.http_validation_error import HttpValidationError
13
+ from ..types.plan import Plan
14
+
15
+
16
+ class RawBillingClient:
17
+ def __init__(self, *, client_wrapper: SyncClientWrapper):
18
+ self._client_wrapper = client_wrapper
19
+
20
+ def handle_events(
21
+ self, *, request_options: typing.Optional[RequestOptions] = None
22
+ ) -> HttpResponse[typing.Optional[typing.Any]]:
23
+ """
24
+ Parameters
25
+ ----------
26
+ request_options : typing.Optional[RequestOptions]
27
+ Request-specific configuration.
28
+
29
+ Returns
30
+ -------
31
+ HttpResponse[typing.Optional[typing.Any]]
32
+ Successful Response
33
+ """
34
+ _response = self._client_wrapper.httpx_client.request(
35
+ "billing/stripe/events/",
36
+ method="POST",
37
+ request_options=request_options,
38
+ )
39
+ try:
40
+ if _response is None or not _response.text.strip():
41
+ return HttpResponse(response=_response, data=None)
42
+ if 200 <= _response.status_code < 300:
43
+ _data = typing.cast(
44
+ typing.Optional[typing.Any],
45
+ parse_obj_as(
46
+ type_=typing.Optional[typing.Any], # type: ignore
47
+ object_=_response.json(),
48
+ ),
49
+ )
50
+ return HttpResponse(response=_response, data=_data)
51
+ _response_json = _response.json()
52
+ except JSONDecodeError:
53
+ raise ApiError(
54
+ status_code=_response.status_code,
55
+ headers=dict(_response.headers),
56
+ body=_response.text,
57
+ )
58
+ raise ApiError(
59
+ status_code=_response.status_code,
60
+ headers=dict(_response.headers),
61
+ body=_response_json,
62
+ )
63
+
64
+ def create_portal(
65
+ self, *, request_options: typing.Optional[RequestOptions] = None
66
+ ) -> HttpResponse[typing.Optional[typing.Any]]:
67
+ """
68
+ Parameters
69
+ ----------
70
+ request_options : typing.Optional[RequestOptions]
71
+ Request-specific configuration.
72
+
73
+ Returns
74
+ -------
75
+ HttpResponse[typing.Optional[typing.Any]]
76
+ Successful Response
77
+ """
78
+ _response = self._client_wrapper.httpx_client.request(
79
+ "billing/stripe/portals/",
80
+ method="POST",
81
+ request_options=request_options,
82
+ )
83
+ try:
84
+ if _response is None or not _response.text.strip():
85
+ return HttpResponse(response=_response, data=None)
86
+ if 200 <= _response.status_code < 300:
87
+ _data = typing.cast(
88
+ typing.Optional[typing.Any],
89
+ parse_obj_as(
90
+ type_=typing.Optional[typing.Any], # type: ignore
91
+ object_=_response.json(),
92
+ ),
93
+ )
94
+ return HttpResponse(response=_response, data=_data)
95
+ _response_json = _response.json()
96
+ except JSONDecodeError:
97
+ raise ApiError(
98
+ status_code=_response.status_code,
99
+ headers=dict(_response.headers),
100
+ body=_response.text,
101
+ )
102
+ raise ApiError(
103
+ status_code=_response.status_code,
104
+ headers=dict(_response.headers),
105
+ body=_response_json,
106
+ )
107
+
108
+ def create_checkout(
109
+ self,
110
+ *,
111
+ plan: Plan,
112
+ success_url: str,
113
+ request_options: typing.Optional[RequestOptions] = None
114
+ ) -> HttpResponse[typing.Optional[typing.Any]]:
115
+ """
116
+ Parameters
117
+ ----------
118
+ plan : Plan
119
+
120
+ success_url : str
121
+
122
+ request_options : typing.Optional[RequestOptions]
123
+ Request-specific configuration.
124
+
125
+ Returns
126
+ -------
127
+ HttpResponse[typing.Optional[typing.Any]]
128
+ Successful Response
129
+ """
130
+ _response = self._client_wrapper.httpx_client.request(
131
+ "billing/stripe/checkouts/",
132
+ method="POST",
133
+ params={
134
+ "plan": plan,
135
+ "success_url": success_url,
136
+ },
137
+ request_options=request_options,
138
+ )
139
+ try:
140
+ if _response is None or not _response.text.strip():
141
+ return HttpResponse(response=_response, data=None)
142
+ if 200 <= _response.status_code < 300:
143
+ _data = typing.cast(
144
+ typing.Optional[typing.Any],
145
+ parse_obj_as(
146
+ type_=typing.Optional[typing.Any], # type: ignore
147
+ object_=_response.json(),
148
+ ),
149
+ )
150
+ return HttpResponse(response=_response, data=_data)
151
+ if _response.status_code == 422:
152
+ raise UnprocessableEntityError(
153
+ headers=dict(_response.headers),
154
+ body=typing.cast(
155
+ HttpValidationError,
156
+ parse_obj_as(
157
+ type_=HttpValidationError, # type: ignore
158
+ object_=_response.json(),
159
+ ),
160
+ ),
161
+ )
162
+ _response_json = _response.json()
163
+ except JSONDecodeError:
164
+ raise ApiError(
165
+ status_code=_response.status_code,
166
+ headers=dict(_response.headers),
167
+ body=_response.text,
168
+ )
169
+ raise ApiError(
170
+ status_code=_response.status_code,
171
+ headers=dict(_response.headers),
172
+ body=_response_json,
173
+ )
174
+
175
+ def fetch_plans(
176
+ self, *, request_options: typing.Optional[RequestOptions] = None
177
+ ) -> HttpResponse[typing.Optional[typing.Any]]:
178
+ """
179
+ Parameters
180
+ ----------
181
+ request_options : typing.Optional[RequestOptions]
182
+ Request-specific configuration.
183
+
184
+ Returns
185
+ -------
186
+ HttpResponse[typing.Optional[typing.Any]]
187
+ Successful Response
188
+ """
189
+ _response = self._client_wrapper.httpx_client.request(
190
+ "billing/plans",
191
+ method="GET",
192
+ request_options=request_options,
193
+ )
194
+ try:
195
+ if _response is None or not _response.text.strip():
196
+ return HttpResponse(response=_response, data=None)
197
+ if 200 <= _response.status_code < 300:
198
+ _data = typing.cast(
199
+ typing.Optional[typing.Any],
200
+ parse_obj_as(
201
+ type_=typing.Optional[typing.Any], # type: ignore
202
+ object_=_response.json(),
203
+ ),
204
+ )
205
+ return HttpResponse(response=_response, data=_data)
206
+ _response_json = _response.json()
207
+ except JSONDecodeError:
208
+ raise ApiError(
209
+ status_code=_response.status_code,
210
+ headers=dict(_response.headers),
211
+ body=_response.text,
212
+ )
213
+ raise ApiError(
214
+ status_code=_response.status_code,
215
+ headers=dict(_response.headers),
216
+ body=_response_json,
217
+ )
218
+
219
+ def switch_plans(
220
+ self, *, plan: Plan, request_options: typing.Optional[RequestOptions] = None
221
+ ) -> HttpResponse[typing.Optional[typing.Any]]:
222
+ """
223
+ Parameters
224
+ ----------
225
+ plan : Plan
226
+
227
+ request_options : typing.Optional[RequestOptions]
228
+ Request-specific configuration.
229
+
230
+ Returns
231
+ -------
232
+ HttpResponse[typing.Optional[typing.Any]]
233
+ Successful Response
234
+ """
235
+ _response = self._client_wrapper.httpx_client.request(
236
+ "billing/plans/switch",
237
+ method="POST",
238
+ params={
239
+ "plan": plan,
240
+ },
241
+ request_options=request_options,
242
+ )
243
+ try:
244
+ if _response is None or not _response.text.strip():
245
+ return HttpResponse(response=_response, data=None)
246
+ if 200 <= _response.status_code < 300:
247
+ _data = typing.cast(
248
+ typing.Optional[typing.Any],
249
+ parse_obj_as(
250
+ type_=typing.Optional[typing.Any], # type: ignore
251
+ object_=_response.json(),
252
+ ),
253
+ )
254
+ return HttpResponse(response=_response, data=_data)
255
+ if _response.status_code == 422:
256
+ raise UnprocessableEntityError(
257
+ headers=dict(_response.headers),
258
+ body=typing.cast(
259
+ HttpValidationError,
260
+ parse_obj_as(
261
+ type_=HttpValidationError, # type: ignore
262
+ object_=_response.json(),
263
+ ),
264
+ ),
265
+ )
266
+ _response_json = _response.json()
267
+ except JSONDecodeError:
268
+ raise ApiError(
269
+ status_code=_response.status_code,
270
+ headers=dict(_response.headers),
271
+ body=_response.text,
272
+ )
273
+ raise ApiError(
274
+ status_code=_response.status_code,
275
+ headers=dict(_response.headers),
276
+ body=_response_json,
277
+ )
278
+
279
+ def fetch_subscription(
280
+ self, *, request_options: typing.Optional[RequestOptions] = None
281
+ ) -> HttpResponse[typing.Optional[typing.Any]]:
282
+ """
283
+ Parameters
284
+ ----------
285
+ request_options : typing.Optional[RequestOptions]
286
+ Request-specific configuration.
287
+
288
+ Returns
289
+ -------
290
+ HttpResponse[typing.Optional[typing.Any]]
291
+ Successful Response
292
+ """
293
+ _response = self._client_wrapper.httpx_client.request(
294
+ "billing/subscription",
295
+ method="GET",
296
+ request_options=request_options,
297
+ )
298
+ try:
299
+ if _response is None or not _response.text.strip():
300
+ return HttpResponse(response=_response, data=None)
301
+ if 200 <= _response.status_code < 300:
302
+ _data = typing.cast(
303
+ typing.Optional[typing.Any],
304
+ parse_obj_as(
305
+ type_=typing.Optional[typing.Any], # type: ignore
306
+ object_=_response.json(),
307
+ ),
308
+ )
309
+ return HttpResponse(response=_response, data=_data)
310
+ _response_json = _response.json()
311
+ except JSONDecodeError:
312
+ raise ApiError(
313
+ status_code=_response.status_code,
314
+ headers=dict(_response.headers),
315
+ body=_response.text,
316
+ )
317
+ raise ApiError(
318
+ status_code=_response.status_code,
319
+ headers=dict(_response.headers),
320
+ body=_response_json,
321
+ )
322
+
323
+ def cancel_plan(
324
+ self, *, request_options: typing.Optional[RequestOptions] = None
325
+ ) -> HttpResponse[typing.Optional[typing.Any]]:
326
+ """
327
+ Parameters
328
+ ----------
329
+ request_options : typing.Optional[RequestOptions]
330
+ Request-specific configuration.
331
+
332
+ Returns
333
+ -------
334
+ HttpResponse[typing.Optional[typing.Any]]
335
+ Successful Response
336
+ """
337
+ _response = self._client_wrapper.httpx_client.request(
338
+ "billing/subscription/cancel",
339
+ method="POST",
340
+ request_options=request_options,
341
+ )
342
+ try:
343
+ if _response is None or not _response.text.strip():
344
+ return HttpResponse(response=_response, data=None)
345
+ if 200 <= _response.status_code < 300:
346
+ _data = typing.cast(
347
+ typing.Optional[typing.Any],
348
+ parse_obj_as(
349
+ type_=typing.Optional[typing.Any], # type: ignore
350
+ object_=_response.json(),
351
+ ),
352
+ )
353
+ return HttpResponse(response=_response, data=_data)
354
+ _response_json = _response.json()
355
+ except JSONDecodeError:
356
+ raise ApiError(
357
+ status_code=_response.status_code,
358
+ headers=dict(_response.headers),
359
+ body=_response.text,
360
+ )
361
+ raise ApiError(
362
+ status_code=_response.status_code,
363
+ headers=dict(_response.headers),
364
+ body=_response_json,
365
+ )
366
+
367
+ def fetch_usage(
368
+ self, *, request_options: typing.Optional[RequestOptions] = None
369
+ ) -> HttpResponse[typing.Optional[typing.Any]]:
370
+ """
371
+ Parameters
372
+ ----------
373
+ request_options : typing.Optional[RequestOptions]
374
+ Request-specific configuration.
375
+
376
+ Returns
377
+ -------
378
+ HttpResponse[typing.Optional[typing.Any]]
379
+ Successful Response
380
+ """
381
+ _response = self._client_wrapper.httpx_client.request(
382
+ "billing/usage",
383
+ method="GET",
384
+ request_options=request_options,
385
+ )
386
+ try:
387
+ if _response is None or not _response.text.strip():
388
+ return HttpResponse(response=_response, data=None)
389
+ if 200 <= _response.status_code < 300:
390
+ _data = typing.cast(
391
+ typing.Optional[typing.Any],
392
+ parse_obj_as(
393
+ type_=typing.Optional[typing.Any], # type: ignore
394
+ object_=_response.json(),
395
+ ),
396
+ )
397
+ return HttpResponse(response=_response, data=_data)
398
+ _response_json = _response.json()
399
+ except JSONDecodeError:
400
+ raise ApiError(
401
+ status_code=_response.status_code,
402
+ headers=dict(_response.headers),
403
+ body=_response.text,
404
+ )
405
+ raise ApiError(
406
+ status_code=_response.status_code,
407
+ headers=dict(_response.headers),
408
+ body=_response_json,
409
+ )
410
+
411
+
412
+ class AsyncRawBillingClient:
413
+ def __init__(self, *, client_wrapper: AsyncClientWrapper):
414
+ self._client_wrapper = client_wrapper
415
+
416
+ async def handle_events(
417
+ self, *, request_options: typing.Optional[RequestOptions] = None
418
+ ) -> AsyncHttpResponse[typing.Optional[typing.Any]]:
419
+ """
420
+ Parameters
421
+ ----------
422
+ request_options : typing.Optional[RequestOptions]
423
+ Request-specific configuration.
424
+
425
+ Returns
426
+ -------
427
+ AsyncHttpResponse[typing.Optional[typing.Any]]
428
+ Successful Response
429
+ """
430
+ _response = await self._client_wrapper.httpx_client.request(
431
+ "billing/stripe/events/",
432
+ method="POST",
433
+ request_options=request_options,
434
+ )
435
+ try:
436
+ if _response is None or not _response.text.strip():
437
+ return AsyncHttpResponse(response=_response, data=None)
438
+ if 200 <= _response.status_code < 300:
439
+ _data = typing.cast(
440
+ typing.Optional[typing.Any],
441
+ parse_obj_as(
442
+ type_=typing.Optional[typing.Any], # type: ignore
443
+ object_=_response.json(),
444
+ ),
445
+ )
446
+ return AsyncHttpResponse(response=_response, data=_data)
447
+ _response_json = _response.json()
448
+ except JSONDecodeError:
449
+ raise ApiError(
450
+ status_code=_response.status_code,
451
+ headers=dict(_response.headers),
452
+ body=_response.text,
453
+ )
454
+ raise ApiError(
455
+ status_code=_response.status_code,
456
+ headers=dict(_response.headers),
457
+ body=_response_json,
458
+ )
459
+
460
+ async def create_portal(
461
+ self, *, request_options: typing.Optional[RequestOptions] = None
462
+ ) -> AsyncHttpResponse[typing.Optional[typing.Any]]:
463
+ """
464
+ Parameters
465
+ ----------
466
+ request_options : typing.Optional[RequestOptions]
467
+ Request-specific configuration.
468
+
469
+ Returns
470
+ -------
471
+ AsyncHttpResponse[typing.Optional[typing.Any]]
472
+ Successful Response
473
+ """
474
+ _response = await self._client_wrapper.httpx_client.request(
475
+ "billing/stripe/portals/",
476
+ method="POST",
477
+ request_options=request_options,
478
+ )
479
+ try:
480
+ if _response is None or not _response.text.strip():
481
+ return AsyncHttpResponse(response=_response, data=None)
482
+ if 200 <= _response.status_code < 300:
483
+ _data = typing.cast(
484
+ typing.Optional[typing.Any],
485
+ parse_obj_as(
486
+ type_=typing.Optional[typing.Any], # type: ignore
487
+ object_=_response.json(),
488
+ ),
489
+ )
490
+ return AsyncHttpResponse(response=_response, data=_data)
491
+ _response_json = _response.json()
492
+ except JSONDecodeError:
493
+ raise ApiError(
494
+ status_code=_response.status_code,
495
+ headers=dict(_response.headers),
496
+ body=_response.text,
497
+ )
498
+ raise ApiError(
499
+ status_code=_response.status_code,
500
+ headers=dict(_response.headers),
501
+ body=_response_json,
502
+ )
503
+
504
+ async def create_checkout(
505
+ self,
506
+ *,
507
+ plan: Plan,
508
+ success_url: str,
509
+ request_options: typing.Optional[RequestOptions] = None
510
+ ) -> AsyncHttpResponse[typing.Optional[typing.Any]]:
511
+ """
512
+ Parameters
513
+ ----------
514
+ plan : Plan
515
+
516
+ success_url : str
517
+
518
+ request_options : typing.Optional[RequestOptions]
519
+ Request-specific configuration.
520
+
521
+ Returns
522
+ -------
523
+ AsyncHttpResponse[typing.Optional[typing.Any]]
524
+ Successful Response
525
+ """
526
+ _response = await self._client_wrapper.httpx_client.request(
527
+ "billing/stripe/checkouts/",
528
+ method="POST",
529
+ params={
530
+ "plan": plan,
531
+ "success_url": success_url,
532
+ },
533
+ request_options=request_options,
534
+ )
535
+ try:
536
+ if _response is None or not _response.text.strip():
537
+ return AsyncHttpResponse(response=_response, data=None)
538
+ if 200 <= _response.status_code < 300:
539
+ _data = typing.cast(
540
+ typing.Optional[typing.Any],
541
+ parse_obj_as(
542
+ type_=typing.Optional[typing.Any], # type: ignore
543
+ object_=_response.json(),
544
+ ),
545
+ )
546
+ return AsyncHttpResponse(response=_response, data=_data)
547
+ if _response.status_code == 422:
548
+ raise UnprocessableEntityError(
549
+ headers=dict(_response.headers),
550
+ body=typing.cast(
551
+ HttpValidationError,
552
+ parse_obj_as(
553
+ type_=HttpValidationError, # type: ignore
554
+ object_=_response.json(),
555
+ ),
556
+ ),
557
+ )
558
+ _response_json = _response.json()
559
+ except JSONDecodeError:
560
+ raise ApiError(
561
+ status_code=_response.status_code,
562
+ headers=dict(_response.headers),
563
+ body=_response.text,
564
+ )
565
+ raise ApiError(
566
+ status_code=_response.status_code,
567
+ headers=dict(_response.headers),
568
+ body=_response_json,
569
+ )
570
+
571
+ async def fetch_plans(
572
+ self, *, request_options: typing.Optional[RequestOptions] = None
573
+ ) -> AsyncHttpResponse[typing.Optional[typing.Any]]:
574
+ """
575
+ Parameters
576
+ ----------
577
+ request_options : typing.Optional[RequestOptions]
578
+ Request-specific configuration.
579
+
580
+ Returns
581
+ -------
582
+ AsyncHttpResponse[typing.Optional[typing.Any]]
583
+ Successful Response
584
+ """
585
+ _response = await self._client_wrapper.httpx_client.request(
586
+ "billing/plans",
587
+ method="GET",
588
+ request_options=request_options,
589
+ )
590
+ try:
591
+ if _response is None or not _response.text.strip():
592
+ return AsyncHttpResponse(response=_response, data=None)
593
+ if 200 <= _response.status_code < 300:
594
+ _data = typing.cast(
595
+ typing.Optional[typing.Any],
596
+ parse_obj_as(
597
+ type_=typing.Optional[typing.Any], # type: ignore
598
+ object_=_response.json(),
599
+ ),
600
+ )
601
+ return AsyncHttpResponse(response=_response, data=_data)
602
+ _response_json = _response.json()
603
+ except JSONDecodeError:
604
+ raise ApiError(
605
+ status_code=_response.status_code,
606
+ headers=dict(_response.headers),
607
+ body=_response.text,
608
+ )
609
+ raise ApiError(
610
+ status_code=_response.status_code,
611
+ headers=dict(_response.headers),
612
+ body=_response_json,
613
+ )
614
+
615
+ async def switch_plans(
616
+ self, *, plan: Plan, request_options: typing.Optional[RequestOptions] = None
617
+ ) -> AsyncHttpResponse[typing.Optional[typing.Any]]:
618
+ """
619
+ Parameters
620
+ ----------
621
+ plan : Plan
622
+
623
+ request_options : typing.Optional[RequestOptions]
624
+ Request-specific configuration.
625
+
626
+ Returns
627
+ -------
628
+ AsyncHttpResponse[typing.Optional[typing.Any]]
629
+ Successful Response
630
+ """
631
+ _response = await self._client_wrapper.httpx_client.request(
632
+ "billing/plans/switch",
633
+ method="POST",
634
+ params={
635
+ "plan": plan,
636
+ },
637
+ request_options=request_options,
638
+ )
639
+ try:
640
+ if _response is None or not _response.text.strip():
641
+ return AsyncHttpResponse(response=_response, data=None)
642
+ if 200 <= _response.status_code < 300:
643
+ _data = typing.cast(
644
+ typing.Optional[typing.Any],
645
+ parse_obj_as(
646
+ type_=typing.Optional[typing.Any], # type: ignore
647
+ object_=_response.json(),
648
+ ),
649
+ )
650
+ return AsyncHttpResponse(response=_response, data=_data)
651
+ if _response.status_code == 422:
652
+ raise UnprocessableEntityError(
653
+ headers=dict(_response.headers),
654
+ body=typing.cast(
655
+ HttpValidationError,
656
+ parse_obj_as(
657
+ type_=HttpValidationError, # type: ignore
658
+ object_=_response.json(),
659
+ ),
660
+ ),
661
+ )
662
+ _response_json = _response.json()
663
+ except JSONDecodeError:
664
+ raise ApiError(
665
+ status_code=_response.status_code,
666
+ headers=dict(_response.headers),
667
+ body=_response.text,
668
+ )
669
+ raise ApiError(
670
+ status_code=_response.status_code,
671
+ headers=dict(_response.headers),
672
+ body=_response_json,
673
+ )
674
+
675
+ async def fetch_subscription(
676
+ self, *, request_options: typing.Optional[RequestOptions] = None
677
+ ) -> AsyncHttpResponse[typing.Optional[typing.Any]]:
678
+ """
679
+ Parameters
680
+ ----------
681
+ request_options : typing.Optional[RequestOptions]
682
+ Request-specific configuration.
683
+
684
+ Returns
685
+ -------
686
+ AsyncHttpResponse[typing.Optional[typing.Any]]
687
+ Successful Response
688
+ """
689
+ _response = await self._client_wrapper.httpx_client.request(
690
+ "billing/subscription",
691
+ method="GET",
692
+ request_options=request_options,
693
+ )
694
+ try:
695
+ if _response is None or not _response.text.strip():
696
+ return AsyncHttpResponse(response=_response, data=None)
697
+ if 200 <= _response.status_code < 300:
698
+ _data = typing.cast(
699
+ typing.Optional[typing.Any],
700
+ parse_obj_as(
701
+ type_=typing.Optional[typing.Any], # type: ignore
702
+ object_=_response.json(),
703
+ ),
704
+ )
705
+ return AsyncHttpResponse(response=_response, data=_data)
706
+ _response_json = _response.json()
707
+ except JSONDecodeError:
708
+ raise ApiError(
709
+ status_code=_response.status_code,
710
+ headers=dict(_response.headers),
711
+ body=_response.text,
712
+ )
713
+ raise ApiError(
714
+ status_code=_response.status_code,
715
+ headers=dict(_response.headers),
716
+ body=_response_json,
717
+ )
718
+
719
+ async def cancel_plan(
720
+ self, *, request_options: typing.Optional[RequestOptions] = None
721
+ ) -> AsyncHttpResponse[typing.Optional[typing.Any]]:
722
+ """
723
+ Parameters
724
+ ----------
725
+ request_options : typing.Optional[RequestOptions]
726
+ Request-specific configuration.
727
+
728
+ Returns
729
+ -------
730
+ AsyncHttpResponse[typing.Optional[typing.Any]]
731
+ Successful Response
732
+ """
733
+ _response = await self._client_wrapper.httpx_client.request(
734
+ "billing/subscription/cancel",
735
+ method="POST",
736
+ request_options=request_options,
737
+ )
738
+ try:
739
+ if _response is None or not _response.text.strip():
740
+ return AsyncHttpResponse(response=_response, data=None)
741
+ if 200 <= _response.status_code < 300:
742
+ _data = typing.cast(
743
+ typing.Optional[typing.Any],
744
+ parse_obj_as(
745
+ type_=typing.Optional[typing.Any], # type: ignore
746
+ object_=_response.json(),
747
+ ),
748
+ )
749
+ return AsyncHttpResponse(response=_response, data=_data)
750
+ _response_json = _response.json()
751
+ except JSONDecodeError:
752
+ raise ApiError(
753
+ status_code=_response.status_code,
754
+ headers=dict(_response.headers),
755
+ body=_response.text,
756
+ )
757
+ raise ApiError(
758
+ status_code=_response.status_code,
759
+ headers=dict(_response.headers),
760
+ body=_response_json,
761
+ )
762
+
763
+ async def fetch_usage(
764
+ self, *, request_options: typing.Optional[RequestOptions] = None
765
+ ) -> AsyncHttpResponse[typing.Optional[typing.Any]]:
766
+ """
767
+ Parameters
768
+ ----------
769
+ request_options : typing.Optional[RequestOptions]
770
+ Request-specific configuration.
771
+
772
+ Returns
773
+ -------
774
+ AsyncHttpResponse[typing.Optional[typing.Any]]
775
+ Successful Response
776
+ """
777
+ _response = await self._client_wrapper.httpx_client.request(
778
+ "billing/usage",
779
+ method="GET",
780
+ request_options=request_options,
781
+ )
782
+ try:
783
+ if _response is None or not _response.text.strip():
784
+ return AsyncHttpResponse(response=_response, data=None)
785
+ if 200 <= _response.status_code < 300:
786
+ _data = typing.cast(
787
+ typing.Optional[typing.Any],
788
+ parse_obj_as(
789
+ type_=typing.Optional[typing.Any], # type: ignore
790
+ object_=_response.json(),
791
+ ),
792
+ )
793
+ return AsyncHttpResponse(response=_response, data=_data)
794
+ _response_json = _response.json()
795
+ except JSONDecodeError:
796
+ raise ApiError(
797
+ status_code=_response.status_code,
798
+ headers=dict(_response.headers),
799
+ body=_response.text,
800
+ )
801
+ raise ApiError(
802
+ status_code=_response.status_code,
803
+ headers=dict(_response.headers),
804
+ body=_response_json,
805
+ )