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,1017 @@
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 ..core.serialization import convert_and_respect_annotation_metadata
12
+ from ..errors.unprocessable_entity_error import UnprocessableEntityError
13
+ from ..types.account_request import AccountRequest
14
+ from ..types.account_response import AccountResponse
15
+ from ..types.http_validation_error import HttpValidationError
16
+ from ..types.organization_membership_request import OrganizationMembershipRequest
17
+ from ..types.organization_request import OrganizationRequest
18
+ from ..types.plan import Plan
19
+ from ..types.project_membership_request import ProjectMembershipRequest
20
+ from ..types.project_request import ProjectRequest
21
+ from ..types.scopes_response_model import ScopesResponseModel
22
+ from ..types.user_request import UserRequest
23
+ from ..types.workspace_membership_request import WorkspaceMembershipRequest
24
+ from ..types.workspace_request import WorkspaceRequest
25
+
26
+ # this is used as the default value for optional parameters
27
+ OMIT = typing.cast(typing.Any, ...)
28
+
29
+
30
+ class RawAdminClient:
31
+ def __init__(self, *, client_wrapper: SyncClientWrapper):
32
+ self._client_wrapper = client_wrapper
33
+
34
+ def create_accounts(
35
+ self,
36
+ *,
37
+ users: typing.Dict[str, UserRequest],
38
+ organizations: typing.Dict[str, OrganizationRequest],
39
+ workspaces: typing.Dict[str, WorkspaceRequest],
40
+ projects: typing.Dict[str, ProjectRequest],
41
+ organization_memberships: typing.Dict[str, OrganizationMembershipRequest],
42
+ workspace_memberships: typing.Dict[str, WorkspaceMembershipRequest],
43
+ project_memberships: typing.Dict[str, ProjectMembershipRequest],
44
+ request_options: typing.Optional[RequestOptions] = None,
45
+ ) -> HttpResponse[ScopesResponseModel]:
46
+ """
47
+ Parameters
48
+ ----------
49
+ users : typing.Dict[str, UserRequest]
50
+
51
+ organizations : typing.Dict[str, OrganizationRequest]
52
+
53
+ workspaces : typing.Dict[str, WorkspaceRequest]
54
+
55
+ projects : typing.Dict[str, ProjectRequest]
56
+
57
+ organization_memberships : typing.Dict[str, OrganizationMembershipRequest]
58
+
59
+ workspace_memberships : typing.Dict[str, WorkspaceMembershipRequest]
60
+
61
+ project_memberships : typing.Dict[str, ProjectMembershipRequest]
62
+
63
+ request_options : typing.Optional[RequestOptions]
64
+ Request-specific configuration.
65
+
66
+ Returns
67
+ -------
68
+ HttpResponse[ScopesResponseModel]
69
+ Successful Response
70
+ """
71
+ _response = self._client_wrapper.httpx_client.request(
72
+ "admin/accounts",
73
+ method="POST",
74
+ json={
75
+ "users": convert_and_respect_annotation_metadata(
76
+ object_=users,
77
+ annotation=typing.Dict[str, UserRequest],
78
+ direction="write",
79
+ ),
80
+ "organizations": convert_and_respect_annotation_metadata(
81
+ object_=organizations,
82
+ annotation=typing.Dict[str, OrganizationRequest],
83
+ direction="write",
84
+ ),
85
+ "workspaces": convert_and_respect_annotation_metadata(
86
+ object_=workspaces,
87
+ annotation=typing.Dict[str, WorkspaceRequest],
88
+ direction="write",
89
+ ),
90
+ "projects": convert_and_respect_annotation_metadata(
91
+ object_=projects,
92
+ annotation=typing.Dict[str, ProjectRequest],
93
+ direction="write",
94
+ ),
95
+ "organization_memberships": convert_and_respect_annotation_metadata(
96
+ object_=organization_memberships,
97
+ annotation=typing.Dict[str, OrganizationMembershipRequest],
98
+ direction="write",
99
+ ),
100
+ "workspace_memberships": convert_and_respect_annotation_metadata(
101
+ object_=workspace_memberships,
102
+ annotation=typing.Dict[str, WorkspaceMembershipRequest],
103
+ direction="write",
104
+ ),
105
+ "project_memberships": convert_and_respect_annotation_metadata(
106
+ object_=project_memberships,
107
+ annotation=typing.Dict[str, ProjectMembershipRequest],
108
+ direction="write",
109
+ ),
110
+ },
111
+ headers={
112
+ "content-type": "application/json",
113
+ },
114
+ request_options=request_options,
115
+ omit=OMIT,
116
+ )
117
+ try:
118
+ if 200 <= _response.status_code < 300:
119
+ _data = typing.cast(
120
+ ScopesResponseModel,
121
+ parse_obj_as(
122
+ type_=ScopesResponseModel, # type: ignore
123
+ object_=_response.json(),
124
+ ),
125
+ )
126
+ return HttpResponse(response=_response, data=_data)
127
+ if _response.status_code == 422:
128
+ raise UnprocessableEntityError(
129
+ headers=dict(_response.headers),
130
+ body=typing.cast(
131
+ HttpValidationError,
132
+ parse_obj_as(
133
+ type_=HttpValidationError, # type: ignore
134
+ object_=_response.json(),
135
+ ),
136
+ ),
137
+ )
138
+ _response_json = _response.json()
139
+ except JSONDecodeError:
140
+ raise ApiError(
141
+ status_code=_response.status_code,
142
+ headers=dict(_response.headers),
143
+ body=_response.text,
144
+ )
145
+ raise ApiError(
146
+ status_code=_response.status_code,
147
+ headers=dict(_response.headers),
148
+ body=_response_json,
149
+ )
150
+
151
+ def create_account(
152
+ self,
153
+ *,
154
+ request: typing.Optional[AccountRequest] = None,
155
+ request_options: typing.Optional[RequestOptions] = None,
156
+ ) -> HttpResponse[AccountResponse]:
157
+ """
158
+ Parameters
159
+ ----------
160
+ request : typing.Optional[AccountRequest]
161
+
162
+ request_options : typing.Optional[RequestOptions]
163
+ Request-specific configuration.
164
+
165
+ Returns
166
+ -------
167
+ HttpResponse[AccountResponse]
168
+ Successful Response
169
+ """
170
+ _response = self._client_wrapper.httpx_client.request(
171
+ "admin/account",
172
+ method="POST",
173
+ json=convert_and_respect_annotation_metadata(
174
+ object_=request, annotation=AccountRequest, direction="write"
175
+ ),
176
+ headers={
177
+ "content-type": "application/json",
178
+ },
179
+ request_options=request_options,
180
+ omit=OMIT,
181
+ )
182
+ try:
183
+ if 200 <= _response.status_code < 300:
184
+ _data = typing.cast(
185
+ AccountResponse,
186
+ parse_obj_as(
187
+ type_=AccountResponse, # type: ignore
188
+ object_=_response.json(),
189
+ ),
190
+ )
191
+ return HttpResponse(response=_response, data=_data)
192
+ if _response.status_code == 422:
193
+ raise UnprocessableEntityError(
194
+ headers=dict(_response.headers),
195
+ body=typing.cast(
196
+ HttpValidationError,
197
+ parse_obj_as(
198
+ type_=HttpValidationError, # type: ignore
199
+ object_=_response.json(),
200
+ ),
201
+ ),
202
+ )
203
+ _response_json = _response.json()
204
+ except JSONDecodeError:
205
+ raise ApiError(
206
+ status_code=_response.status_code,
207
+ headers=dict(_response.headers),
208
+ body=_response.text,
209
+ )
210
+ raise ApiError(
211
+ status_code=_response.status_code,
212
+ headers=dict(_response.headers),
213
+ body=_response_json,
214
+ )
215
+
216
+ def create_portal(
217
+ self,
218
+ *,
219
+ organization_id: str,
220
+ request_options: typing.Optional[RequestOptions] = None,
221
+ ) -> HttpResponse[typing.Optional[typing.Any]]:
222
+ """
223
+ Parameters
224
+ ----------
225
+ organization_id : str
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
+ "admin/billing/stripe/portals/",
237
+ method="POST",
238
+ params={
239
+ "organization_id": organization_id,
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 create_checkout(
280
+ self,
281
+ *,
282
+ organization_id: str,
283
+ plan: Plan,
284
+ success_url: str,
285
+ request_options: typing.Optional[RequestOptions] = None,
286
+ ) -> HttpResponse[typing.Optional[typing.Any]]:
287
+ """
288
+ Parameters
289
+ ----------
290
+ organization_id : str
291
+
292
+ plan : Plan
293
+
294
+ success_url : str
295
+
296
+ request_options : typing.Optional[RequestOptions]
297
+ Request-specific configuration.
298
+
299
+ Returns
300
+ -------
301
+ HttpResponse[typing.Optional[typing.Any]]
302
+ Successful Response
303
+ """
304
+ _response = self._client_wrapper.httpx_client.request(
305
+ "admin/billing/stripe/checkouts/",
306
+ method="POST",
307
+ params={
308
+ "organization_id": organization_id,
309
+ "plan": plan,
310
+ "success_url": success_url,
311
+ },
312
+ request_options=request_options,
313
+ )
314
+ try:
315
+ if _response is None or not _response.text.strip():
316
+ return HttpResponse(response=_response, data=None)
317
+ if 200 <= _response.status_code < 300:
318
+ _data = typing.cast(
319
+ typing.Optional[typing.Any],
320
+ parse_obj_as(
321
+ type_=typing.Optional[typing.Any], # type: ignore
322
+ object_=_response.json(),
323
+ ),
324
+ )
325
+ return HttpResponse(response=_response, data=_data)
326
+ if _response.status_code == 422:
327
+ raise UnprocessableEntityError(
328
+ headers=dict(_response.headers),
329
+ body=typing.cast(
330
+ HttpValidationError,
331
+ parse_obj_as(
332
+ type_=HttpValidationError, # type: ignore
333
+ object_=_response.json(),
334
+ ),
335
+ ),
336
+ )
337
+ _response_json = _response.json()
338
+ except JSONDecodeError:
339
+ raise ApiError(
340
+ status_code=_response.status_code,
341
+ headers=dict(_response.headers),
342
+ body=_response.text,
343
+ )
344
+ raise ApiError(
345
+ status_code=_response.status_code,
346
+ headers=dict(_response.headers),
347
+ body=_response_json,
348
+ )
349
+
350
+ def switch_plans(
351
+ self,
352
+ *,
353
+ organization_id: str,
354
+ plan: Plan,
355
+ request_options: typing.Optional[RequestOptions] = None,
356
+ ) -> HttpResponse[typing.Optional[typing.Any]]:
357
+ """
358
+ Parameters
359
+ ----------
360
+ organization_id : str
361
+
362
+ plan : Plan
363
+
364
+ request_options : typing.Optional[RequestOptions]
365
+ Request-specific configuration.
366
+
367
+ Returns
368
+ -------
369
+ HttpResponse[typing.Optional[typing.Any]]
370
+ Successful Response
371
+ """
372
+ _response = self._client_wrapper.httpx_client.request(
373
+ "admin/billing/plans/switch",
374
+ method="POST",
375
+ params={
376
+ "organization_id": organization_id,
377
+ "plan": plan,
378
+ },
379
+ request_options=request_options,
380
+ )
381
+ try:
382
+ if _response is None or not _response.text.strip():
383
+ return HttpResponse(response=_response, data=None)
384
+ if 200 <= _response.status_code < 300:
385
+ _data = typing.cast(
386
+ typing.Optional[typing.Any],
387
+ parse_obj_as(
388
+ type_=typing.Optional[typing.Any], # type: ignore
389
+ object_=_response.json(),
390
+ ),
391
+ )
392
+ return HttpResponse(response=_response, data=_data)
393
+ if _response.status_code == 422:
394
+ raise UnprocessableEntityError(
395
+ headers=dict(_response.headers),
396
+ body=typing.cast(
397
+ HttpValidationError,
398
+ parse_obj_as(
399
+ type_=HttpValidationError, # type: ignore
400
+ object_=_response.json(),
401
+ ),
402
+ ),
403
+ )
404
+ _response_json = _response.json()
405
+ except JSONDecodeError:
406
+ raise ApiError(
407
+ status_code=_response.status_code,
408
+ headers=dict(_response.headers),
409
+ body=_response.text,
410
+ )
411
+ raise ApiError(
412
+ status_code=_response.status_code,
413
+ headers=dict(_response.headers),
414
+ body=_response_json,
415
+ )
416
+
417
+ def cancel_subscription(
418
+ self,
419
+ *,
420
+ organization_id: str,
421
+ request_options: typing.Optional[RequestOptions] = None,
422
+ ) -> HttpResponse[typing.Optional[typing.Any]]:
423
+ """
424
+ Parameters
425
+ ----------
426
+ organization_id : str
427
+
428
+ request_options : typing.Optional[RequestOptions]
429
+ Request-specific configuration.
430
+
431
+ Returns
432
+ -------
433
+ HttpResponse[typing.Optional[typing.Any]]
434
+ Successful Response
435
+ """
436
+ _response = self._client_wrapper.httpx_client.request(
437
+ "admin/billing/subscription/cancel",
438
+ method="POST",
439
+ params={
440
+ "organization_id": organization_id,
441
+ },
442
+ request_options=request_options,
443
+ )
444
+ try:
445
+ if _response is None or not _response.text.strip():
446
+ return HttpResponse(response=_response, data=None)
447
+ if 200 <= _response.status_code < 300:
448
+ _data = typing.cast(
449
+ typing.Optional[typing.Any],
450
+ parse_obj_as(
451
+ type_=typing.Optional[typing.Any], # type: ignore
452
+ object_=_response.json(),
453
+ ),
454
+ )
455
+ return HttpResponse(response=_response, data=_data)
456
+ if _response.status_code == 422:
457
+ raise UnprocessableEntityError(
458
+ headers=dict(_response.headers),
459
+ body=typing.cast(
460
+ HttpValidationError,
461
+ parse_obj_as(
462
+ type_=HttpValidationError, # type: ignore
463
+ object_=_response.json(),
464
+ ),
465
+ ),
466
+ )
467
+ _response_json = _response.json()
468
+ except JSONDecodeError:
469
+ raise ApiError(
470
+ status_code=_response.status_code,
471
+ headers=dict(_response.headers),
472
+ body=_response.text,
473
+ )
474
+ raise ApiError(
475
+ status_code=_response.status_code,
476
+ headers=dict(_response.headers),
477
+ body=_response_json,
478
+ )
479
+
480
+ def report_usage(
481
+ self, *, request_options: typing.Optional[RequestOptions] = None
482
+ ) -> HttpResponse[typing.Optional[typing.Any]]:
483
+ """
484
+ Parameters
485
+ ----------
486
+ request_options : typing.Optional[RequestOptions]
487
+ Request-specific configuration.
488
+
489
+ Returns
490
+ -------
491
+ HttpResponse[typing.Optional[typing.Any]]
492
+ Successful Response
493
+ """
494
+ _response = self._client_wrapper.httpx_client.request(
495
+ "admin/billing/usage/report",
496
+ method="POST",
497
+ request_options=request_options,
498
+ )
499
+ try:
500
+ if _response is None or not _response.text.strip():
501
+ return HttpResponse(response=_response, data=None)
502
+ if 200 <= _response.status_code < 300:
503
+ _data = typing.cast(
504
+ typing.Optional[typing.Any],
505
+ parse_obj_as(
506
+ type_=typing.Optional[typing.Any], # type: ignore
507
+ object_=_response.json(),
508
+ ),
509
+ )
510
+ return HttpResponse(response=_response, data=_data)
511
+ _response_json = _response.json()
512
+ except JSONDecodeError:
513
+ raise ApiError(
514
+ status_code=_response.status_code,
515
+ headers=dict(_response.headers),
516
+ body=_response.text,
517
+ )
518
+ raise ApiError(
519
+ status_code=_response.status_code,
520
+ headers=dict(_response.headers),
521
+ body=_response_json,
522
+ )
523
+
524
+
525
+ class AsyncRawAdminClient:
526
+ def __init__(self, *, client_wrapper: AsyncClientWrapper):
527
+ self._client_wrapper = client_wrapper
528
+
529
+ async def create_accounts(
530
+ self,
531
+ *,
532
+ users: typing.Dict[str, UserRequest],
533
+ organizations: typing.Dict[str, OrganizationRequest],
534
+ workspaces: typing.Dict[str, WorkspaceRequest],
535
+ projects: typing.Dict[str, ProjectRequest],
536
+ organization_memberships: typing.Dict[str, OrganizationMembershipRequest],
537
+ workspace_memberships: typing.Dict[str, WorkspaceMembershipRequest],
538
+ project_memberships: typing.Dict[str, ProjectMembershipRequest],
539
+ request_options: typing.Optional[RequestOptions] = None,
540
+ ) -> AsyncHttpResponse[ScopesResponseModel]:
541
+ """
542
+ Parameters
543
+ ----------
544
+ users : typing.Dict[str, UserRequest]
545
+
546
+ organizations : typing.Dict[str, OrganizationRequest]
547
+
548
+ workspaces : typing.Dict[str, WorkspaceRequest]
549
+
550
+ projects : typing.Dict[str, ProjectRequest]
551
+
552
+ organization_memberships : typing.Dict[str, OrganizationMembershipRequest]
553
+
554
+ workspace_memberships : typing.Dict[str, WorkspaceMembershipRequest]
555
+
556
+ project_memberships : typing.Dict[str, ProjectMembershipRequest]
557
+
558
+ request_options : typing.Optional[RequestOptions]
559
+ Request-specific configuration.
560
+
561
+ Returns
562
+ -------
563
+ AsyncHttpResponse[ScopesResponseModel]
564
+ Successful Response
565
+ """
566
+ _response = await self._client_wrapper.httpx_client.request(
567
+ "admin/accounts",
568
+ method="POST",
569
+ json={
570
+ "users": convert_and_respect_annotation_metadata(
571
+ object_=users,
572
+ annotation=typing.Dict[str, UserRequest],
573
+ direction="write",
574
+ ),
575
+ "organizations": convert_and_respect_annotation_metadata(
576
+ object_=organizations,
577
+ annotation=typing.Dict[str, OrganizationRequest],
578
+ direction="write",
579
+ ),
580
+ "workspaces": convert_and_respect_annotation_metadata(
581
+ object_=workspaces,
582
+ annotation=typing.Dict[str, WorkspaceRequest],
583
+ direction="write",
584
+ ),
585
+ "projects": convert_and_respect_annotation_metadata(
586
+ object_=projects,
587
+ annotation=typing.Dict[str, ProjectRequest],
588
+ direction="write",
589
+ ),
590
+ "organization_memberships": convert_and_respect_annotation_metadata(
591
+ object_=organization_memberships,
592
+ annotation=typing.Dict[str, OrganizationMembershipRequest],
593
+ direction="write",
594
+ ),
595
+ "workspace_memberships": convert_and_respect_annotation_metadata(
596
+ object_=workspace_memberships,
597
+ annotation=typing.Dict[str, WorkspaceMembershipRequest],
598
+ direction="write",
599
+ ),
600
+ "project_memberships": convert_and_respect_annotation_metadata(
601
+ object_=project_memberships,
602
+ annotation=typing.Dict[str, ProjectMembershipRequest],
603
+ direction="write",
604
+ ),
605
+ },
606
+ headers={
607
+ "content-type": "application/json",
608
+ },
609
+ request_options=request_options,
610
+ omit=OMIT,
611
+ )
612
+ try:
613
+ if 200 <= _response.status_code < 300:
614
+ _data = typing.cast(
615
+ ScopesResponseModel,
616
+ parse_obj_as(
617
+ type_=ScopesResponseModel, # type: ignore
618
+ object_=_response.json(),
619
+ ),
620
+ )
621
+ return AsyncHttpResponse(response=_response, data=_data)
622
+ if _response.status_code == 422:
623
+ raise UnprocessableEntityError(
624
+ headers=dict(_response.headers),
625
+ body=typing.cast(
626
+ HttpValidationError,
627
+ parse_obj_as(
628
+ type_=HttpValidationError, # type: ignore
629
+ object_=_response.json(),
630
+ ),
631
+ ),
632
+ )
633
+ _response_json = _response.json()
634
+ except JSONDecodeError:
635
+ raise ApiError(
636
+ status_code=_response.status_code,
637
+ headers=dict(_response.headers),
638
+ body=_response.text,
639
+ )
640
+ raise ApiError(
641
+ status_code=_response.status_code,
642
+ headers=dict(_response.headers),
643
+ body=_response_json,
644
+ )
645
+
646
+ async def create_account(
647
+ self,
648
+ *,
649
+ request: typing.Optional[AccountRequest] = None,
650
+ request_options: typing.Optional[RequestOptions] = None,
651
+ ) -> AsyncHttpResponse[AccountResponse]:
652
+ """
653
+ Parameters
654
+ ----------
655
+ request : typing.Optional[AccountRequest]
656
+
657
+ request_options : typing.Optional[RequestOptions]
658
+ Request-specific configuration.
659
+
660
+ Returns
661
+ -------
662
+ AsyncHttpResponse[AccountResponse]
663
+ Successful Response
664
+ """
665
+ _response = await self._client_wrapper.httpx_client.request(
666
+ "admin/account",
667
+ method="POST",
668
+ json=convert_and_respect_annotation_metadata(
669
+ object_=request, annotation=AccountRequest, direction="write"
670
+ ),
671
+ headers={
672
+ "content-type": "application/json",
673
+ },
674
+ request_options=request_options,
675
+ omit=OMIT,
676
+ )
677
+ try:
678
+ if 200 <= _response.status_code < 300:
679
+ _data = typing.cast(
680
+ AccountResponse,
681
+ parse_obj_as(
682
+ type_=AccountResponse, # type: ignore
683
+ object_=_response.json(),
684
+ ),
685
+ )
686
+ return AsyncHttpResponse(response=_response, data=_data)
687
+ if _response.status_code == 422:
688
+ raise UnprocessableEntityError(
689
+ headers=dict(_response.headers),
690
+ body=typing.cast(
691
+ HttpValidationError,
692
+ parse_obj_as(
693
+ type_=HttpValidationError, # type: ignore
694
+ object_=_response.json(),
695
+ ),
696
+ ),
697
+ )
698
+ _response_json = _response.json()
699
+ except JSONDecodeError:
700
+ raise ApiError(
701
+ status_code=_response.status_code,
702
+ headers=dict(_response.headers),
703
+ body=_response.text,
704
+ )
705
+ raise ApiError(
706
+ status_code=_response.status_code,
707
+ headers=dict(_response.headers),
708
+ body=_response_json,
709
+ )
710
+
711
+ async def create_portal(
712
+ self,
713
+ *,
714
+ organization_id: str,
715
+ request_options: typing.Optional[RequestOptions] = None,
716
+ ) -> AsyncHttpResponse[typing.Optional[typing.Any]]:
717
+ """
718
+ Parameters
719
+ ----------
720
+ organization_id : str
721
+
722
+ request_options : typing.Optional[RequestOptions]
723
+ Request-specific configuration.
724
+
725
+ Returns
726
+ -------
727
+ AsyncHttpResponse[typing.Optional[typing.Any]]
728
+ Successful Response
729
+ """
730
+ _response = await self._client_wrapper.httpx_client.request(
731
+ "admin/billing/stripe/portals/",
732
+ method="POST",
733
+ params={
734
+ "organization_id": organization_id,
735
+ },
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
+ if _response.status_code == 422:
751
+ raise UnprocessableEntityError(
752
+ headers=dict(_response.headers),
753
+ body=typing.cast(
754
+ HttpValidationError,
755
+ parse_obj_as(
756
+ type_=HttpValidationError, # type: ignore
757
+ object_=_response.json(),
758
+ ),
759
+ ),
760
+ )
761
+ _response_json = _response.json()
762
+ except JSONDecodeError:
763
+ raise ApiError(
764
+ status_code=_response.status_code,
765
+ headers=dict(_response.headers),
766
+ body=_response.text,
767
+ )
768
+ raise ApiError(
769
+ status_code=_response.status_code,
770
+ headers=dict(_response.headers),
771
+ body=_response_json,
772
+ )
773
+
774
+ async def create_checkout(
775
+ self,
776
+ *,
777
+ organization_id: str,
778
+ plan: Plan,
779
+ success_url: str,
780
+ request_options: typing.Optional[RequestOptions] = None,
781
+ ) -> AsyncHttpResponse[typing.Optional[typing.Any]]:
782
+ """
783
+ Parameters
784
+ ----------
785
+ organization_id : str
786
+
787
+ plan : Plan
788
+
789
+ success_url : str
790
+
791
+ request_options : typing.Optional[RequestOptions]
792
+ Request-specific configuration.
793
+
794
+ Returns
795
+ -------
796
+ AsyncHttpResponse[typing.Optional[typing.Any]]
797
+ Successful Response
798
+ """
799
+ _response = await self._client_wrapper.httpx_client.request(
800
+ "admin/billing/stripe/checkouts/",
801
+ method="POST",
802
+ params={
803
+ "organization_id": organization_id,
804
+ "plan": plan,
805
+ "success_url": success_url,
806
+ },
807
+ request_options=request_options,
808
+ )
809
+ try:
810
+ if _response is None or not _response.text.strip():
811
+ return AsyncHttpResponse(response=_response, data=None)
812
+ if 200 <= _response.status_code < 300:
813
+ _data = typing.cast(
814
+ typing.Optional[typing.Any],
815
+ parse_obj_as(
816
+ type_=typing.Optional[typing.Any], # type: ignore
817
+ object_=_response.json(),
818
+ ),
819
+ )
820
+ return AsyncHttpResponse(response=_response, data=_data)
821
+ if _response.status_code == 422:
822
+ raise UnprocessableEntityError(
823
+ headers=dict(_response.headers),
824
+ body=typing.cast(
825
+ HttpValidationError,
826
+ parse_obj_as(
827
+ type_=HttpValidationError, # type: ignore
828
+ object_=_response.json(),
829
+ ),
830
+ ),
831
+ )
832
+ _response_json = _response.json()
833
+ except JSONDecodeError:
834
+ raise ApiError(
835
+ status_code=_response.status_code,
836
+ headers=dict(_response.headers),
837
+ body=_response.text,
838
+ )
839
+ raise ApiError(
840
+ status_code=_response.status_code,
841
+ headers=dict(_response.headers),
842
+ body=_response_json,
843
+ )
844
+
845
+ async def switch_plans(
846
+ self,
847
+ *,
848
+ organization_id: str,
849
+ plan: Plan,
850
+ request_options: typing.Optional[RequestOptions] = None,
851
+ ) -> AsyncHttpResponse[typing.Optional[typing.Any]]:
852
+ """
853
+ Parameters
854
+ ----------
855
+ organization_id : str
856
+
857
+ plan : Plan
858
+
859
+ request_options : typing.Optional[RequestOptions]
860
+ Request-specific configuration.
861
+
862
+ Returns
863
+ -------
864
+ AsyncHttpResponse[typing.Optional[typing.Any]]
865
+ Successful Response
866
+ """
867
+ _response = await self._client_wrapper.httpx_client.request(
868
+ "admin/billing/plans/switch",
869
+ method="POST",
870
+ params={
871
+ "organization_id": organization_id,
872
+ "plan": plan,
873
+ },
874
+ request_options=request_options,
875
+ )
876
+ try:
877
+ if _response is None or not _response.text.strip():
878
+ return AsyncHttpResponse(response=_response, data=None)
879
+ if 200 <= _response.status_code < 300:
880
+ _data = typing.cast(
881
+ typing.Optional[typing.Any],
882
+ parse_obj_as(
883
+ type_=typing.Optional[typing.Any], # type: ignore
884
+ object_=_response.json(),
885
+ ),
886
+ )
887
+ return AsyncHttpResponse(response=_response, data=_data)
888
+ if _response.status_code == 422:
889
+ raise UnprocessableEntityError(
890
+ headers=dict(_response.headers),
891
+ body=typing.cast(
892
+ HttpValidationError,
893
+ parse_obj_as(
894
+ type_=HttpValidationError, # type: ignore
895
+ object_=_response.json(),
896
+ ),
897
+ ),
898
+ )
899
+ _response_json = _response.json()
900
+ except JSONDecodeError:
901
+ raise ApiError(
902
+ status_code=_response.status_code,
903
+ headers=dict(_response.headers),
904
+ body=_response.text,
905
+ )
906
+ raise ApiError(
907
+ status_code=_response.status_code,
908
+ headers=dict(_response.headers),
909
+ body=_response_json,
910
+ )
911
+
912
+ async def cancel_subscription(
913
+ self,
914
+ *,
915
+ organization_id: str,
916
+ request_options: typing.Optional[RequestOptions] = None,
917
+ ) -> AsyncHttpResponse[typing.Optional[typing.Any]]:
918
+ """
919
+ Parameters
920
+ ----------
921
+ organization_id : str
922
+
923
+ request_options : typing.Optional[RequestOptions]
924
+ Request-specific configuration.
925
+
926
+ Returns
927
+ -------
928
+ AsyncHttpResponse[typing.Optional[typing.Any]]
929
+ Successful Response
930
+ """
931
+ _response = await self._client_wrapper.httpx_client.request(
932
+ "admin/billing/subscription/cancel",
933
+ method="POST",
934
+ params={
935
+ "organization_id": organization_id,
936
+ },
937
+ request_options=request_options,
938
+ )
939
+ try:
940
+ if _response is None or not _response.text.strip():
941
+ return AsyncHttpResponse(response=_response, data=None)
942
+ if 200 <= _response.status_code < 300:
943
+ _data = typing.cast(
944
+ typing.Optional[typing.Any],
945
+ parse_obj_as(
946
+ type_=typing.Optional[typing.Any], # type: ignore
947
+ object_=_response.json(),
948
+ ),
949
+ )
950
+ return AsyncHttpResponse(response=_response, data=_data)
951
+ if _response.status_code == 422:
952
+ raise UnprocessableEntityError(
953
+ headers=dict(_response.headers),
954
+ body=typing.cast(
955
+ HttpValidationError,
956
+ parse_obj_as(
957
+ type_=HttpValidationError, # type: ignore
958
+ object_=_response.json(),
959
+ ),
960
+ ),
961
+ )
962
+ _response_json = _response.json()
963
+ except JSONDecodeError:
964
+ raise ApiError(
965
+ status_code=_response.status_code,
966
+ headers=dict(_response.headers),
967
+ body=_response.text,
968
+ )
969
+ raise ApiError(
970
+ status_code=_response.status_code,
971
+ headers=dict(_response.headers),
972
+ body=_response_json,
973
+ )
974
+
975
+ async def report_usage(
976
+ self, *, request_options: typing.Optional[RequestOptions] = None
977
+ ) -> AsyncHttpResponse[typing.Optional[typing.Any]]:
978
+ """
979
+ Parameters
980
+ ----------
981
+ request_options : typing.Optional[RequestOptions]
982
+ Request-specific configuration.
983
+
984
+ Returns
985
+ -------
986
+ AsyncHttpResponse[typing.Optional[typing.Any]]
987
+ Successful Response
988
+ """
989
+ _response = await self._client_wrapper.httpx_client.request(
990
+ "admin/billing/usage/report",
991
+ method="POST",
992
+ request_options=request_options,
993
+ )
994
+ try:
995
+ if _response is None or not _response.text.strip():
996
+ return AsyncHttpResponse(response=_response, data=None)
997
+ if 200 <= _response.status_code < 300:
998
+ _data = typing.cast(
999
+ typing.Optional[typing.Any],
1000
+ parse_obj_as(
1001
+ type_=typing.Optional[typing.Any], # type: ignore
1002
+ object_=_response.json(),
1003
+ ),
1004
+ )
1005
+ return AsyncHttpResponse(response=_response, data=_data)
1006
+ _response_json = _response.json()
1007
+ except JSONDecodeError:
1008
+ raise ApiError(
1009
+ status_code=_response.status_code,
1010
+ headers=dict(_response.headers),
1011
+ body=_response.text,
1012
+ )
1013
+ raise ApiError(
1014
+ status_code=_response.status_code,
1015
+ headers=dict(_response.headers),
1016
+ body=_response_json,
1017
+ )