mirascope 1.0.5__py3-none-any.whl → 2.1.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (632) hide show
  1. mirascope/__init__.py +6 -6
  2. mirascope/_stubs.py +384 -0
  3. mirascope/_utils.py +34 -0
  4. mirascope/api/__init__.py +14 -0
  5. mirascope/api/_generated/README.md +207 -0
  6. mirascope/api/_generated/__init__.py +444 -0
  7. mirascope/api/_generated/annotations/__init__.py +33 -0
  8. mirascope/api/_generated/annotations/client.py +506 -0
  9. mirascope/api/_generated/annotations/raw_client.py +1414 -0
  10. mirascope/api/_generated/annotations/types/__init__.py +31 -0
  11. mirascope/api/_generated/annotations/types/annotations_create_request_label.py +5 -0
  12. mirascope/api/_generated/annotations/types/annotations_create_response.py +48 -0
  13. mirascope/api/_generated/annotations/types/annotations_create_response_label.py +5 -0
  14. mirascope/api/_generated/annotations/types/annotations_get_response.py +48 -0
  15. mirascope/api/_generated/annotations/types/annotations_get_response_label.py +5 -0
  16. mirascope/api/_generated/annotations/types/annotations_list_request_label.py +5 -0
  17. mirascope/api/_generated/annotations/types/annotations_list_response.py +21 -0
  18. mirascope/api/_generated/annotations/types/annotations_list_response_annotations_item.py +50 -0
  19. mirascope/api/_generated/annotations/types/annotations_list_response_annotations_item_label.py +5 -0
  20. mirascope/api/_generated/annotations/types/annotations_update_request_label.py +5 -0
  21. mirascope/api/_generated/annotations/types/annotations_update_response.py +48 -0
  22. mirascope/api/_generated/annotations/types/annotations_update_response_label.py +5 -0
  23. mirascope/api/_generated/api_keys/__init__.py +17 -0
  24. mirascope/api/_generated/api_keys/client.py +530 -0
  25. mirascope/api/_generated/api_keys/raw_client.py +1236 -0
  26. mirascope/api/_generated/api_keys/types/__init__.py +15 -0
  27. mirascope/api/_generated/api_keys/types/api_keys_create_response.py +28 -0
  28. mirascope/api/_generated/api_keys/types/api_keys_get_response.py +27 -0
  29. mirascope/api/_generated/api_keys/types/api_keys_list_all_for_org_response_item.py +40 -0
  30. mirascope/api/_generated/api_keys/types/api_keys_list_response_item.py +27 -0
  31. mirascope/api/_generated/client.py +211 -0
  32. mirascope/api/_generated/core/__init__.py +52 -0
  33. mirascope/api/_generated/core/api_error.py +23 -0
  34. mirascope/api/_generated/core/client_wrapper.py +46 -0
  35. mirascope/api/_generated/core/datetime_utils.py +28 -0
  36. mirascope/api/_generated/core/file.py +67 -0
  37. mirascope/api/_generated/core/force_multipart.py +16 -0
  38. mirascope/api/_generated/core/http_client.py +543 -0
  39. mirascope/api/_generated/core/http_response.py +55 -0
  40. mirascope/api/_generated/core/jsonable_encoder.py +100 -0
  41. mirascope/api/_generated/core/pydantic_utilities.py +255 -0
  42. mirascope/api/_generated/core/query_encoder.py +58 -0
  43. mirascope/api/_generated/core/remove_none_from_dict.py +11 -0
  44. mirascope/api/_generated/core/request_options.py +35 -0
  45. mirascope/api/_generated/core/serialization.py +276 -0
  46. mirascope/api/_generated/docs/__init__.py +4 -0
  47. mirascope/api/_generated/docs/client.py +91 -0
  48. mirascope/api/_generated/docs/raw_client.py +178 -0
  49. mirascope/api/_generated/environment.py +9 -0
  50. mirascope/api/_generated/environments/__init__.py +23 -0
  51. mirascope/api/_generated/environments/client.py +649 -0
  52. mirascope/api/_generated/environments/raw_client.py +1567 -0
  53. mirascope/api/_generated/environments/types/__init__.py +25 -0
  54. mirascope/api/_generated/environments/types/environments_create_response.py +24 -0
  55. mirascope/api/_generated/environments/types/environments_get_analytics_response.py +60 -0
  56. mirascope/api/_generated/environments/types/environments_get_analytics_response_top_functions_item.py +24 -0
  57. mirascope/api/_generated/environments/types/environments_get_analytics_response_top_models_item.py +22 -0
  58. mirascope/api/_generated/environments/types/environments_get_response.py +24 -0
  59. mirascope/api/_generated/environments/types/environments_list_response_item.py +24 -0
  60. mirascope/api/_generated/environments/types/environments_update_response.py +24 -0
  61. mirascope/api/_generated/errors/__init__.py +25 -0
  62. mirascope/api/_generated/errors/bad_request_error.py +14 -0
  63. mirascope/api/_generated/errors/conflict_error.py +14 -0
  64. mirascope/api/_generated/errors/forbidden_error.py +11 -0
  65. mirascope/api/_generated/errors/internal_server_error.py +10 -0
  66. mirascope/api/_generated/errors/not_found_error.py +11 -0
  67. mirascope/api/_generated/errors/payment_required_error.py +15 -0
  68. mirascope/api/_generated/errors/service_unavailable_error.py +14 -0
  69. mirascope/api/_generated/errors/too_many_requests_error.py +15 -0
  70. mirascope/api/_generated/errors/unauthorized_error.py +11 -0
  71. mirascope/api/_generated/functions/__init__.py +39 -0
  72. mirascope/api/_generated/functions/client.py +647 -0
  73. mirascope/api/_generated/functions/raw_client.py +1890 -0
  74. mirascope/api/_generated/functions/types/__init__.py +53 -0
  75. mirascope/api/_generated/functions/types/functions_create_request_dependencies_value.py +20 -0
  76. mirascope/api/_generated/functions/types/functions_create_response.py +37 -0
  77. mirascope/api/_generated/functions/types/functions_create_response_dependencies_value.py +20 -0
  78. mirascope/api/_generated/functions/types/functions_find_by_hash_response.py +39 -0
  79. mirascope/api/_generated/functions/types/functions_find_by_hash_response_dependencies_value.py +20 -0
  80. mirascope/api/_generated/functions/types/functions_get_by_env_response.py +53 -0
  81. mirascope/api/_generated/functions/types/functions_get_by_env_response_dependencies_value.py +22 -0
  82. mirascope/api/_generated/functions/types/functions_get_response.py +37 -0
  83. mirascope/api/_generated/functions/types/functions_get_response_dependencies_value.py +20 -0
  84. mirascope/api/_generated/functions/types/functions_list_by_env_response.py +25 -0
  85. mirascope/api/_generated/functions/types/functions_list_by_env_response_functions_item.py +56 -0
  86. mirascope/api/_generated/functions/types/functions_list_by_env_response_functions_item_dependencies_value.py +22 -0
  87. mirascope/api/_generated/functions/types/functions_list_response.py +21 -0
  88. mirascope/api/_generated/functions/types/functions_list_response_functions_item.py +41 -0
  89. mirascope/api/_generated/functions/types/functions_list_response_functions_item_dependencies_value.py +20 -0
  90. mirascope/api/_generated/health/__init__.py +7 -0
  91. mirascope/api/_generated/health/client.py +92 -0
  92. mirascope/api/_generated/health/raw_client.py +175 -0
  93. mirascope/api/_generated/health/types/__init__.py +8 -0
  94. mirascope/api/_generated/health/types/health_check_response.py +22 -0
  95. mirascope/api/_generated/health/types/health_check_response_status.py +5 -0
  96. mirascope/api/_generated/organization_invitations/__init__.py +33 -0
  97. mirascope/api/_generated/organization_invitations/client.py +546 -0
  98. mirascope/api/_generated/organization_invitations/raw_client.py +1519 -0
  99. mirascope/api/_generated/organization_invitations/types/__init__.py +53 -0
  100. mirascope/api/_generated/organization_invitations/types/organization_invitations_accept_response.py +34 -0
  101. mirascope/api/_generated/organization_invitations/types/organization_invitations_accept_response_role.py +7 -0
  102. mirascope/api/_generated/organization_invitations/types/organization_invitations_create_request_role.py +7 -0
  103. mirascope/api/_generated/organization_invitations/types/organization_invitations_create_response.py +48 -0
  104. mirascope/api/_generated/organization_invitations/types/organization_invitations_create_response_role.py +7 -0
  105. mirascope/api/_generated/organization_invitations/types/organization_invitations_create_response_status.py +7 -0
  106. mirascope/api/_generated/organization_invitations/types/organization_invitations_get_response.py +48 -0
  107. mirascope/api/_generated/organization_invitations/types/organization_invitations_get_response_role.py +7 -0
  108. mirascope/api/_generated/organization_invitations/types/organization_invitations_get_response_status.py +7 -0
  109. mirascope/api/_generated/organization_invitations/types/organization_invitations_list_response_item.py +48 -0
  110. mirascope/api/_generated/organization_invitations/types/organization_invitations_list_response_item_role.py +7 -0
  111. mirascope/api/_generated/organization_invitations/types/organization_invitations_list_response_item_status.py +7 -0
  112. mirascope/api/_generated/organization_memberships/__init__.py +19 -0
  113. mirascope/api/_generated/organization_memberships/client.py +302 -0
  114. mirascope/api/_generated/organization_memberships/raw_client.py +736 -0
  115. mirascope/api/_generated/organization_memberships/types/__init__.py +27 -0
  116. mirascope/api/_generated/organization_memberships/types/organization_memberships_list_response_item.py +33 -0
  117. mirascope/api/_generated/organization_memberships/types/organization_memberships_list_response_item_role.py +7 -0
  118. mirascope/api/_generated/organization_memberships/types/organization_memberships_update_request_role.py +7 -0
  119. mirascope/api/_generated/organization_memberships/types/organization_memberships_update_response.py +31 -0
  120. mirascope/api/_generated/organization_memberships/types/organization_memberships_update_response_role.py +7 -0
  121. mirascope/api/_generated/organizations/__init__.py +51 -0
  122. mirascope/api/_generated/organizations/client.py +869 -0
  123. mirascope/api/_generated/organizations/raw_client.py +2593 -0
  124. mirascope/api/_generated/organizations/types/__init__.py +71 -0
  125. mirascope/api/_generated/organizations/types/organizations_create_payment_intent_response.py +24 -0
  126. mirascope/api/_generated/organizations/types/organizations_create_response.py +26 -0
  127. mirascope/api/_generated/organizations/types/organizations_create_response_role.py +5 -0
  128. mirascope/api/_generated/organizations/types/organizations_get_response.py +26 -0
  129. mirascope/api/_generated/organizations/types/organizations_get_response_role.py +5 -0
  130. mirascope/api/_generated/organizations/types/organizations_list_response_item.py +26 -0
  131. mirascope/api/_generated/organizations/types/organizations_list_response_item_role.py +5 -0
  132. mirascope/api/_generated/organizations/types/organizations_preview_subscription_change_request_target_plan.py +7 -0
  133. mirascope/api/_generated/organizations/types/organizations_preview_subscription_change_response.py +47 -0
  134. mirascope/api/_generated/organizations/types/organizations_preview_subscription_change_response_validation_errors_item.py +33 -0
  135. mirascope/api/_generated/organizations/types/organizations_preview_subscription_change_response_validation_errors_item_resource.py +7 -0
  136. mirascope/api/_generated/organizations/types/organizations_router_balance_response.py +24 -0
  137. mirascope/api/_generated/organizations/types/organizations_subscription_response.py +53 -0
  138. mirascope/api/_generated/organizations/types/organizations_subscription_response_current_plan.py +7 -0
  139. mirascope/api/_generated/organizations/types/organizations_subscription_response_payment_method.py +26 -0
  140. mirascope/api/_generated/organizations/types/organizations_subscription_response_scheduled_change.py +34 -0
  141. mirascope/api/_generated/organizations/types/organizations_subscription_response_scheduled_change_target_plan.py +7 -0
  142. mirascope/api/_generated/organizations/types/organizations_update_response.py +26 -0
  143. mirascope/api/_generated/organizations/types/organizations_update_response_role.py +5 -0
  144. mirascope/api/_generated/organizations/types/organizations_update_subscription_request_target_plan.py +7 -0
  145. mirascope/api/_generated/organizations/types/organizations_update_subscription_response.py +35 -0
  146. mirascope/api/_generated/project_memberships/__init__.py +29 -0
  147. mirascope/api/_generated/project_memberships/client.py +528 -0
  148. mirascope/api/_generated/project_memberships/raw_client.py +1278 -0
  149. mirascope/api/_generated/project_memberships/types/__init__.py +33 -0
  150. mirascope/api/_generated/project_memberships/types/project_memberships_create_request_role.py +7 -0
  151. mirascope/api/_generated/project_memberships/types/project_memberships_create_response.py +35 -0
  152. mirascope/api/_generated/project_memberships/types/project_memberships_create_response_role.py +7 -0
  153. mirascope/api/_generated/project_memberships/types/project_memberships_get_response.py +33 -0
  154. mirascope/api/_generated/project_memberships/types/project_memberships_get_response_role.py +7 -0
  155. mirascope/api/_generated/project_memberships/types/project_memberships_list_response_item.py +33 -0
  156. mirascope/api/_generated/project_memberships/types/project_memberships_list_response_item_role.py +7 -0
  157. mirascope/api/_generated/project_memberships/types/project_memberships_update_request_role.py +7 -0
  158. mirascope/api/_generated/project_memberships/types/project_memberships_update_response.py +35 -0
  159. mirascope/api/_generated/project_memberships/types/project_memberships_update_response_role.py +7 -0
  160. mirascope/api/_generated/projects/__init__.py +7 -0
  161. mirascope/api/_generated/projects/client.py +428 -0
  162. mirascope/api/_generated/projects/raw_client.py +1302 -0
  163. mirascope/api/_generated/projects/types/__init__.py +10 -0
  164. mirascope/api/_generated/projects/types/projects_create_response.py +25 -0
  165. mirascope/api/_generated/projects/types/projects_get_response.py +25 -0
  166. mirascope/api/_generated/projects/types/projects_list_response_item.py +25 -0
  167. mirascope/api/_generated/projects/types/projects_update_response.py +25 -0
  168. mirascope/api/_generated/reference.md +4987 -0
  169. mirascope/api/_generated/tags/__init__.py +19 -0
  170. mirascope/api/_generated/tags/client.py +504 -0
  171. mirascope/api/_generated/tags/raw_client.py +1288 -0
  172. mirascope/api/_generated/tags/types/__init__.py +17 -0
  173. mirascope/api/_generated/tags/types/tags_create_response.py +41 -0
  174. mirascope/api/_generated/tags/types/tags_get_response.py +41 -0
  175. mirascope/api/_generated/tags/types/tags_list_response.py +23 -0
  176. mirascope/api/_generated/tags/types/tags_list_response_tags_item.py +41 -0
  177. mirascope/api/_generated/tags/types/tags_update_response.py +41 -0
  178. mirascope/api/_generated/token_cost/__init__.py +7 -0
  179. mirascope/api/_generated/token_cost/client.py +160 -0
  180. mirascope/api/_generated/token_cost/raw_client.py +264 -0
  181. mirascope/api/_generated/token_cost/types/__init__.py +8 -0
  182. mirascope/api/_generated/token_cost/types/token_cost_calculate_request_usage.py +54 -0
  183. mirascope/api/_generated/token_cost/types/token_cost_calculate_response.py +52 -0
  184. mirascope/api/_generated/traces/__init__.py +97 -0
  185. mirascope/api/_generated/traces/client.py +1103 -0
  186. mirascope/api/_generated/traces/raw_client.py +2322 -0
  187. mirascope/api/_generated/traces/types/__init__.py +155 -0
  188. mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item.py +29 -0
  189. mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_resource.py +27 -0
  190. mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_resource_attributes_item.py +23 -0
  191. mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_resource_attributes_item_value.py +38 -0
  192. mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_resource_attributes_item_value_array_value.py +19 -0
  193. mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_resource_attributes_item_value_kvlist_value.py +22 -0
  194. mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_resource_attributes_item_value_kvlist_value_values_item.py +20 -0
  195. mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item.py +29 -0
  196. mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item_scope.py +31 -0
  197. mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item_scope_attributes_item.py +23 -0
  198. mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item_scope_attributes_item_value.py +38 -0
  199. mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item_scope_attributes_item_value_array_value.py +19 -0
  200. mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item_scope_attributes_item_value_kvlist_value.py +22 -0
  201. mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item_scope_attributes_item_value_kvlist_value_values_item.py +22 -0
  202. mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item_spans_item.py +48 -0
  203. mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item_spans_item_attributes_item.py +23 -0
  204. mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item_spans_item_attributes_item_value.py +38 -0
  205. mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item_spans_item_attributes_item_value_array_value.py +19 -0
  206. mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item_spans_item_attributes_item_value_kvlist_value.py +24 -0
  207. mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item_spans_item_attributes_item_value_kvlist_value_values_item.py +22 -0
  208. mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item_spans_item_status.py +20 -0
  209. mirascope/api/_generated/traces/types/traces_create_response.py +24 -0
  210. mirascope/api/_generated/traces/types/traces_create_response_partial_success.py +22 -0
  211. mirascope/api/_generated/traces/types/traces_get_analytics_summary_response.py +60 -0
  212. mirascope/api/_generated/traces/types/traces_get_analytics_summary_response_top_functions_item.py +24 -0
  213. mirascope/api/_generated/traces/types/traces_get_analytics_summary_response_top_models_item.py +22 -0
  214. mirascope/api/_generated/traces/types/traces_get_trace_detail_by_env_response.py +33 -0
  215. mirascope/api/_generated/traces/types/traces_get_trace_detail_by_env_response_spans_item.py +88 -0
  216. mirascope/api/_generated/traces/types/traces_get_trace_detail_response.py +33 -0
  217. mirascope/api/_generated/traces/types/traces_get_trace_detail_response_spans_item.py +88 -0
  218. mirascope/api/_generated/traces/types/traces_list_by_function_hash_response.py +25 -0
  219. mirascope/api/_generated/traces/types/traces_list_by_function_hash_response_traces_item.py +44 -0
  220. mirascope/api/_generated/traces/types/traces_search_by_env_request_attribute_filters_item.py +26 -0
  221. mirascope/api/_generated/traces/types/traces_search_by_env_request_attribute_filters_item_operator.py +7 -0
  222. mirascope/api/_generated/traces/types/traces_search_by_env_request_sort_by.py +7 -0
  223. mirascope/api/_generated/traces/types/traces_search_by_env_request_sort_order.py +7 -0
  224. mirascope/api/_generated/traces/types/traces_search_by_env_response.py +26 -0
  225. mirascope/api/_generated/traces/types/traces_search_by_env_response_spans_item.py +50 -0
  226. mirascope/api/_generated/traces/types/traces_search_request_attribute_filters_item.py +26 -0
  227. mirascope/api/_generated/traces/types/traces_search_request_attribute_filters_item_operator.py +7 -0
  228. mirascope/api/_generated/traces/types/traces_search_request_sort_by.py +7 -0
  229. mirascope/api/_generated/traces/types/traces_search_request_sort_order.py +5 -0
  230. mirascope/api/_generated/traces/types/traces_search_response.py +26 -0
  231. mirascope/api/_generated/traces/types/traces_search_response_spans_item.py +50 -0
  232. mirascope/api/_generated/types/__init__.py +85 -0
  233. mirascope/api/_generated/types/already_exists_error.py +22 -0
  234. mirascope/api/_generated/types/already_exists_error_tag.py +5 -0
  235. mirascope/api/_generated/types/bad_request_error_body.py +50 -0
  236. mirascope/api/_generated/types/click_house_error.py +22 -0
  237. mirascope/api/_generated/types/database_error.py +22 -0
  238. mirascope/api/_generated/types/database_error_tag.py +5 -0
  239. mirascope/api/_generated/types/date.py +3 -0
  240. mirascope/api/_generated/types/http_api_decode_error.py +27 -0
  241. mirascope/api/_generated/types/http_api_decode_error_tag.py +5 -0
  242. mirascope/api/_generated/types/immutable_resource_error.py +22 -0
  243. mirascope/api/_generated/types/internal_server_error_body.py +49 -0
  244. mirascope/api/_generated/types/issue.py +38 -0
  245. mirascope/api/_generated/types/issue_tag.py +10 -0
  246. mirascope/api/_generated/types/not_found_error_body.py +22 -0
  247. mirascope/api/_generated/types/not_found_error_tag.py +5 -0
  248. mirascope/api/_generated/types/number_from_string.py +3 -0
  249. mirascope/api/_generated/types/permission_denied_error.py +22 -0
  250. mirascope/api/_generated/types/permission_denied_error_tag.py +5 -0
  251. mirascope/api/_generated/types/plan_limit_exceeded_error.py +32 -0
  252. mirascope/api/_generated/types/plan_limit_exceeded_error_tag.py +7 -0
  253. mirascope/api/_generated/types/pricing_unavailable_error.py +23 -0
  254. mirascope/api/_generated/types/property_key.py +7 -0
  255. mirascope/api/_generated/types/property_key_key.py +25 -0
  256. mirascope/api/_generated/types/property_key_key_tag.py +5 -0
  257. mirascope/api/_generated/types/rate_limit_error.py +31 -0
  258. mirascope/api/_generated/types/rate_limit_error_tag.py +5 -0
  259. mirascope/api/_generated/types/service_unavailable_error_body.py +24 -0
  260. mirascope/api/_generated/types/service_unavailable_error_tag.py +7 -0
  261. mirascope/api/_generated/types/stripe_error.py +20 -0
  262. mirascope/api/_generated/types/subscription_past_due_error.py +31 -0
  263. mirascope/api/_generated/types/subscription_past_due_error_tag.py +7 -0
  264. mirascope/api/_generated/types/unauthorized_error_body.py +21 -0
  265. mirascope/api/_generated/types/unauthorized_error_tag.py +5 -0
  266. mirascope/api/client.py +255 -0
  267. mirascope/api/settings.py +99 -0
  268. mirascope/llm/__init__.py +316 -0
  269. mirascope/llm/calls/__init__.py +17 -0
  270. mirascope/llm/calls/calls.py +348 -0
  271. mirascope/llm/calls/decorator.py +268 -0
  272. mirascope/llm/content/__init__.py +71 -0
  273. mirascope/llm/content/audio.py +173 -0
  274. mirascope/llm/content/document.py +94 -0
  275. mirascope/llm/content/image.py +206 -0
  276. mirascope/llm/content/text.py +47 -0
  277. mirascope/llm/content/thought.py +58 -0
  278. mirascope/llm/content/tool_call.py +69 -0
  279. mirascope/llm/content/tool_output.py +43 -0
  280. mirascope/llm/context/__init__.py +6 -0
  281. mirascope/llm/context/_utils.py +41 -0
  282. mirascope/llm/context/context.py +24 -0
  283. mirascope/llm/exceptions.py +360 -0
  284. mirascope/llm/formatting/__init__.py +39 -0
  285. mirascope/llm/formatting/format.py +291 -0
  286. mirascope/llm/formatting/from_call_args.py +30 -0
  287. mirascope/llm/formatting/output_parser.py +178 -0
  288. mirascope/llm/formatting/partial.py +131 -0
  289. mirascope/llm/formatting/primitives.py +192 -0
  290. mirascope/llm/formatting/types.py +83 -0
  291. mirascope/llm/mcp/__init__.py +5 -0
  292. mirascope/llm/mcp/mcp_client.py +130 -0
  293. mirascope/llm/messages/__init__.py +35 -0
  294. mirascope/llm/messages/_utils.py +34 -0
  295. mirascope/llm/messages/message.py +190 -0
  296. mirascope/llm/models/__init__.py +21 -0
  297. mirascope/llm/models/models.py +1339 -0
  298. mirascope/llm/models/params.py +72 -0
  299. mirascope/llm/models/thinking_config.py +61 -0
  300. mirascope/llm/prompts/__init__.py +34 -0
  301. mirascope/llm/prompts/_utils.py +31 -0
  302. mirascope/llm/prompts/decorator.py +215 -0
  303. mirascope/llm/prompts/prompts.py +484 -0
  304. mirascope/llm/prompts/protocols.py +65 -0
  305. mirascope/llm/providers/__init__.py +65 -0
  306. mirascope/llm/providers/anthropic/__init__.py +11 -0
  307. mirascope/llm/providers/anthropic/_utils/__init__.py +27 -0
  308. mirascope/llm/providers/anthropic/_utils/beta_decode.py +297 -0
  309. mirascope/llm/providers/anthropic/_utils/beta_encode.py +272 -0
  310. mirascope/llm/providers/anthropic/_utils/decode.py +326 -0
  311. mirascope/llm/providers/anthropic/_utils/encode.py +431 -0
  312. mirascope/llm/providers/anthropic/_utils/errors.py +46 -0
  313. mirascope/llm/providers/anthropic/beta_provider.py +338 -0
  314. mirascope/llm/providers/anthropic/model_id.py +23 -0
  315. mirascope/llm/providers/anthropic/model_info.py +87 -0
  316. mirascope/llm/providers/anthropic/provider.py +440 -0
  317. mirascope/llm/providers/base/__init__.py +14 -0
  318. mirascope/llm/providers/base/_utils.py +248 -0
  319. mirascope/llm/providers/base/base_provider.py +1463 -0
  320. mirascope/llm/providers/base/kwargs.py +12 -0
  321. mirascope/llm/providers/google/__init__.py +6 -0
  322. mirascope/llm/providers/google/_utils/__init__.py +17 -0
  323. mirascope/llm/providers/google/_utils/decode.py +357 -0
  324. mirascope/llm/providers/google/_utils/encode.py +418 -0
  325. mirascope/llm/providers/google/_utils/errors.py +50 -0
  326. mirascope/llm/providers/google/message.py +7 -0
  327. mirascope/llm/providers/google/model_id.py +22 -0
  328. mirascope/llm/providers/google/model_info.py +63 -0
  329. mirascope/llm/providers/google/provider.py +456 -0
  330. mirascope/llm/providers/mirascope/__init__.py +5 -0
  331. mirascope/llm/providers/mirascope/_utils.py +73 -0
  332. mirascope/llm/providers/mirascope/provider.py +313 -0
  333. mirascope/llm/providers/mlx/__init__.py +9 -0
  334. mirascope/llm/providers/mlx/_utils.py +141 -0
  335. mirascope/llm/providers/mlx/encoding/__init__.py +8 -0
  336. mirascope/llm/providers/mlx/encoding/base.py +69 -0
  337. mirascope/llm/providers/mlx/encoding/transformers.py +146 -0
  338. mirascope/llm/providers/mlx/mlx.py +242 -0
  339. mirascope/llm/providers/mlx/model_id.py +17 -0
  340. mirascope/llm/providers/mlx/provider.py +416 -0
  341. mirascope/llm/providers/model_id.py +16 -0
  342. mirascope/llm/providers/ollama/__init__.py +7 -0
  343. mirascope/llm/providers/ollama/provider.py +71 -0
  344. mirascope/llm/providers/openai/__init__.py +15 -0
  345. mirascope/llm/providers/openai/_utils/__init__.py +5 -0
  346. mirascope/llm/providers/openai/_utils/errors.py +46 -0
  347. mirascope/llm/providers/openai/completions/__init__.py +7 -0
  348. mirascope/llm/providers/openai/completions/_utils/__init__.py +18 -0
  349. mirascope/llm/providers/openai/completions/_utils/decode.py +252 -0
  350. mirascope/llm/providers/openai/completions/_utils/encode.py +390 -0
  351. mirascope/llm/providers/openai/completions/_utils/feature_info.py +50 -0
  352. mirascope/llm/providers/openai/completions/base_provider.py +522 -0
  353. mirascope/llm/providers/openai/completions/provider.py +28 -0
  354. mirascope/llm/providers/openai/model_id.py +31 -0
  355. mirascope/llm/providers/openai/model_info.py +303 -0
  356. mirascope/llm/providers/openai/provider.py +405 -0
  357. mirascope/llm/providers/openai/responses/__init__.py +5 -0
  358. mirascope/llm/providers/openai/responses/_utils/__init__.py +15 -0
  359. mirascope/llm/providers/openai/responses/_utils/decode.py +289 -0
  360. mirascope/llm/providers/openai/responses/_utils/encode.py +399 -0
  361. mirascope/llm/providers/openai/responses/provider.py +472 -0
  362. mirascope/llm/providers/openrouter/__init__.py +5 -0
  363. mirascope/llm/providers/openrouter/provider.py +67 -0
  364. mirascope/llm/providers/provider_id.py +26 -0
  365. mirascope/llm/providers/provider_registry.py +305 -0
  366. mirascope/llm/providers/together/__init__.py +7 -0
  367. mirascope/llm/providers/together/provider.py +40 -0
  368. mirascope/llm/responses/__init__.py +66 -0
  369. mirascope/llm/responses/_utils.py +146 -0
  370. mirascope/llm/responses/base_response.py +103 -0
  371. mirascope/llm/responses/base_stream_response.py +824 -0
  372. mirascope/llm/responses/finish_reason.py +28 -0
  373. mirascope/llm/responses/response.py +362 -0
  374. mirascope/llm/responses/root_response.py +248 -0
  375. mirascope/llm/responses/stream_response.py +577 -0
  376. mirascope/llm/responses/streams.py +363 -0
  377. mirascope/llm/responses/usage.py +139 -0
  378. mirascope/llm/tools/__init__.py +71 -0
  379. mirascope/llm/tools/_utils.py +34 -0
  380. mirascope/llm/tools/decorator.py +184 -0
  381. mirascope/llm/tools/protocols.py +96 -0
  382. mirascope/llm/tools/provider_tools.py +18 -0
  383. mirascope/llm/tools/tool_schema.py +321 -0
  384. mirascope/llm/tools/toolkit.py +178 -0
  385. mirascope/llm/tools/tools.py +263 -0
  386. mirascope/llm/tools/types.py +112 -0
  387. mirascope/llm/tools/web_search_tool.py +32 -0
  388. mirascope/llm/types/__init__.py +22 -0
  389. mirascope/llm/types/dataclass.py +9 -0
  390. mirascope/llm/types/jsonable.py +44 -0
  391. mirascope/llm/types/type_vars.py +19 -0
  392. mirascope/ops/__init__.py +129 -0
  393. mirascope/ops/_internal/__init__.py +5 -0
  394. mirascope/ops/_internal/closure.py +1172 -0
  395. mirascope/ops/_internal/configuration.py +177 -0
  396. mirascope/ops/_internal/context.py +76 -0
  397. mirascope/ops/_internal/exporters/__init__.py +26 -0
  398. mirascope/ops/_internal/exporters/exporters.py +362 -0
  399. mirascope/ops/_internal/exporters/processors.py +104 -0
  400. mirascope/ops/_internal/exporters/types.py +165 -0
  401. mirascope/ops/_internal/exporters/utils.py +66 -0
  402. mirascope/ops/_internal/instrumentation/__init__.py +28 -0
  403. mirascope/ops/_internal/instrumentation/llm/__init__.py +8 -0
  404. mirascope/ops/_internal/instrumentation/llm/common.py +500 -0
  405. mirascope/ops/_internal/instrumentation/llm/cost.py +190 -0
  406. mirascope/ops/_internal/instrumentation/llm/encode.py +238 -0
  407. mirascope/ops/_internal/instrumentation/llm/gen_ai_types/__init__.py +38 -0
  408. mirascope/ops/_internal/instrumentation/llm/gen_ai_types/gen_ai_input_messages.py +31 -0
  409. mirascope/ops/_internal/instrumentation/llm/gen_ai_types/gen_ai_output_messages.py +38 -0
  410. mirascope/ops/_internal/instrumentation/llm/gen_ai_types/gen_ai_system_instructions.py +18 -0
  411. mirascope/ops/_internal/instrumentation/llm/gen_ai_types/shared.py +100 -0
  412. mirascope/ops/_internal/instrumentation/llm/llm.py +161 -0
  413. mirascope/ops/_internal/instrumentation/llm/model.py +1777 -0
  414. mirascope/ops/_internal/instrumentation/llm/response.py +521 -0
  415. mirascope/ops/_internal/instrumentation/llm/serialize.py +324 -0
  416. mirascope/ops/_internal/instrumentation/providers/__init__.py +29 -0
  417. mirascope/ops/_internal/instrumentation/providers/anthropic.py +78 -0
  418. mirascope/ops/_internal/instrumentation/providers/base.py +179 -0
  419. mirascope/ops/_internal/instrumentation/providers/google_genai.py +85 -0
  420. mirascope/ops/_internal/instrumentation/providers/openai.py +82 -0
  421. mirascope/ops/_internal/propagation.py +198 -0
  422. mirascope/ops/_internal/protocols.py +133 -0
  423. mirascope/ops/_internal/session.py +139 -0
  424. mirascope/ops/_internal/spans.py +232 -0
  425. mirascope/ops/_internal/traced_calls.py +389 -0
  426. mirascope/ops/_internal/traced_functions.py +528 -0
  427. mirascope/ops/_internal/tracing.py +353 -0
  428. mirascope/ops/_internal/types.py +13 -0
  429. mirascope/ops/_internal/utils.py +131 -0
  430. mirascope/ops/_internal/versioned_calls.py +512 -0
  431. mirascope/ops/_internal/versioned_functions.py +357 -0
  432. mirascope/ops/_internal/versioning.py +303 -0
  433. mirascope/ops/exceptions.py +21 -0
  434. mirascope-2.1.1.dist-info/METADATA +231 -0
  435. mirascope-2.1.1.dist-info/RECORD +437 -0
  436. {mirascope-1.0.5.dist-info → mirascope-2.1.1.dist-info}/WHEEL +1 -1
  437. {mirascope-1.0.5.dist-info → mirascope-2.1.1.dist-info}/licenses/LICENSE +1 -1
  438. mirascope/beta/__init__.py +0 -0
  439. mirascope/beta/openai/__init__.py +0 -5
  440. mirascope/beta/openai/parse.py +0 -129
  441. mirascope/beta/rag/__init__.py +0 -24
  442. mirascope/beta/rag/base/__init__.py +0 -22
  443. mirascope/beta/rag/base/chunkers/__init__.py +0 -2
  444. mirascope/beta/rag/base/chunkers/base_chunker.py +0 -37
  445. mirascope/beta/rag/base/chunkers/text_chunker.py +0 -33
  446. mirascope/beta/rag/base/config.py +0 -8
  447. mirascope/beta/rag/base/document.py +0 -11
  448. mirascope/beta/rag/base/embedders.py +0 -35
  449. mirascope/beta/rag/base/embedding_params.py +0 -18
  450. mirascope/beta/rag/base/embedding_response.py +0 -30
  451. mirascope/beta/rag/base/query_results.py +0 -7
  452. mirascope/beta/rag/base/vectorstore_params.py +0 -18
  453. mirascope/beta/rag/base/vectorstores.py +0 -37
  454. mirascope/beta/rag/chroma/__init__.py +0 -11
  455. mirascope/beta/rag/chroma/types.py +0 -57
  456. mirascope/beta/rag/chroma/vectorstores.py +0 -97
  457. mirascope/beta/rag/cohere/__init__.py +0 -11
  458. mirascope/beta/rag/cohere/embedders.py +0 -87
  459. mirascope/beta/rag/cohere/embedding_params.py +0 -29
  460. mirascope/beta/rag/cohere/embedding_response.py +0 -29
  461. mirascope/beta/rag/cohere/py.typed +0 -0
  462. mirascope/beta/rag/openai/__init__.py +0 -11
  463. mirascope/beta/rag/openai/embedders.py +0 -144
  464. mirascope/beta/rag/openai/embedding_params.py +0 -18
  465. mirascope/beta/rag/openai/embedding_response.py +0 -14
  466. mirascope/beta/rag/openai/py.typed +0 -0
  467. mirascope/beta/rag/pinecone/__init__.py +0 -19
  468. mirascope/beta/rag/pinecone/types.py +0 -143
  469. mirascope/beta/rag/pinecone/vectorstores.py +0 -148
  470. mirascope/beta/rag/weaviate/__init__.py +0 -6
  471. mirascope/beta/rag/weaviate/types.py +0 -92
  472. mirascope/beta/rag/weaviate/vectorstores.py +0 -103
  473. mirascope/core/__init__.py +0 -55
  474. mirascope/core/anthropic/__init__.py +0 -21
  475. mirascope/core/anthropic/_call.py +0 -71
  476. mirascope/core/anthropic/_utils/__init__.py +0 -16
  477. mirascope/core/anthropic/_utils/_calculate_cost.py +0 -63
  478. mirascope/core/anthropic/_utils/_convert_message_params.py +0 -54
  479. mirascope/core/anthropic/_utils/_get_json_output.py +0 -34
  480. mirascope/core/anthropic/_utils/_handle_stream.py +0 -89
  481. mirascope/core/anthropic/_utils/_setup_call.py +0 -76
  482. mirascope/core/anthropic/call_params.py +0 -36
  483. mirascope/core/anthropic/call_response.py +0 -158
  484. mirascope/core/anthropic/call_response_chunk.py +0 -104
  485. mirascope/core/anthropic/dynamic_config.py +0 -26
  486. mirascope/core/anthropic/py.typed +0 -0
  487. mirascope/core/anthropic/stream.py +0 -140
  488. mirascope/core/anthropic/tool.py +0 -77
  489. mirascope/core/base/__init__.py +0 -40
  490. mirascope/core/base/_call_factory.py +0 -323
  491. mirascope/core/base/_create.py +0 -167
  492. mirascope/core/base/_extract.py +0 -139
  493. mirascope/core/base/_partial.py +0 -63
  494. mirascope/core/base/_utils/__init__.py +0 -64
  495. mirascope/core/base/_utils/_base_type.py +0 -17
  496. mirascope/core/base/_utils/_convert_base_model_to_base_tool.py +0 -45
  497. mirascope/core/base/_utils/_convert_base_type_to_base_tool.py +0 -24
  498. mirascope/core/base/_utils/_convert_function_to_base_tool.py +0 -126
  499. mirascope/core/base/_utils/_default_tool_docstring.py +0 -6
  500. mirascope/core/base/_utils/_extract_tool_return.py +0 -36
  501. mirascope/core/base/_utils/_format_template.py +0 -29
  502. mirascope/core/base/_utils/_get_audio_type.py +0 -18
  503. mirascope/core/base/_utils/_get_fn_args.py +0 -14
  504. mirascope/core/base/_utils/_get_image_type.py +0 -26
  505. mirascope/core/base/_utils/_get_metadata.py +0 -17
  506. mirascope/core/base/_utils/_get_possible_user_message_param.py +0 -21
  507. mirascope/core/base/_utils/_get_prompt_template.py +0 -25
  508. mirascope/core/base/_utils/_get_template_values.py +0 -52
  509. mirascope/core/base/_utils/_get_template_variables.py +0 -38
  510. mirascope/core/base/_utils/_json_mode_content.py +0 -15
  511. mirascope/core/base/_utils/_parse_content_template.py +0 -157
  512. mirascope/core/base/_utils/_parse_prompt_messages.py +0 -51
  513. mirascope/core/base/_utils/_protocols.py +0 -215
  514. mirascope/core/base/_utils/_setup_call.py +0 -64
  515. mirascope/core/base/_utils/_setup_extract_tool.py +0 -24
  516. mirascope/core/base/call_params.py +0 -6
  517. mirascope/core/base/call_response.py +0 -189
  518. mirascope/core/base/call_response_chunk.py +0 -91
  519. mirascope/core/base/dynamic_config.py +0 -55
  520. mirascope/core/base/message_param.py +0 -61
  521. mirascope/core/base/metadata.py +0 -13
  522. mirascope/core/base/prompt.py +0 -415
  523. mirascope/core/base/stream.py +0 -365
  524. mirascope/core/base/structured_stream.py +0 -251
  525. mirascope/core/base/tool.py +0 -126
  526. mirascope/core/base/toolkit.py +0 -146
  527. mirascope/core/cohere/__init__.py +0 -21
  528. mirascope/core/cohere/_call.py +0 -71
  529. mirascope/core/cohere/_utils/__init__.py +0 -16
  530. mirascope/core/cohere/_utils/_calculate_cost.py +0 -39
  531. mirascope/core/cohere/_utils/_convert_message_params.py +0 -31
  532. mirascope/core/cohere/_utils/_get_json_output.py +0 -31
  533. mirascope/core/cohere/_utils/_handle_stream.py +0 -33
  534. mirascope/core/cohere/_utils/_setup_call.py +0 -89
  535. mirascope/core/cohere/call_params.py +0 -57
  536. mirascope/core/cohere/call_response.py +0 -167
  537. mirascope/core/cohere/call_response_chunk.py +0 -101
  538. mirascope/core/cohere/dynamic_config.py +0 -24
  539. mirascope/core/cohere/py.typed +0 -0
  540. mirascope/core/cohere/stream.py +0 -113
  541. mirascope/core/cohere/tool.py +0 -92
  542. mirascope/core/gemini/__init__.py +0 -21
  543. mirascope/core/gemini/_call.py +0 -71
  544. mirascope/core/gemini/_utils/__init__.py +0 -16
  545. mirascope/core/gemini/_utils/_calculate_cost.py +0 -8
  546. mirascope/core/gemini/_utils/_convert_message_params.py +0 -74
  547. mirascope/core/gemini/_utils/_get_json_output.py +0 -33
  548. mirascope/core/gemini/_utils/_handle_stream.py +0 -33
  549. mirascope/core/gemini/_utils/_setup_call.py +0 -68
  550. mirascope/core/gemini/call_params.py +0 -28
  551. mirascope/core/gemini/call_response.py +0 -173
  552. mirascope/core/gemini/call_response_chunk.py +0 -85
  553. mirascope/core/gemini/dynamic_config.py +0 -26
  554. mirascope/core/gemini/stream.py +0 -121
  555. mirascope/core/gemini/tool.py +0 -104
  556. mirascope/core/groq/__init__.py +0 -21
  557. mirascope/core/groq/_call.py +0 -71
  558. mirascope/core/groq/_utils/__init__.py +0 -16
  559. mirascope/core/groq/_utils/_calculate_cost.py +0 -68
  560. mirascope/core/groq/_utils/_convert_message_params.py +0 -23
  561. mirascope/core/groq/_utils/_get_json_output.py +0 -27
  562. mirascope/core/groq/_utils/_handle_stream.py +0 -121
  563. mirascope/core/groq/_utils/_setup_call.py +0 -67
  564. mirascope/core/groq/call_params.py +0 -51
  565. mirascope/core/groq/call_response.py +0 -160
  566. mirascope/core/groq/call_response_chunk.py +0 -89
  567. mirascope/core/groq/dynamic_config.py +0 -26
  568. mirascope/core/groq/py.typed +0 -0
  569. mirascope/core/groq/stream.py +0 -136
  570. mirascope/core/groq/tool.py +0 -79
  571. mirascope/core/litellm/__init__.py +0 -6
  572. mirascope/core/litellm/_call.py +0 -73
  573. mirascope/core/litellm/_utils/__init__.py +0 -5
  574. mirascope/core/litellm/_utils/_setup_call.py +0 -46
  575. mirascope/core/litellm/py.typed +0 -0
  576. mirascope/core/mistral/__init__.py +0 -21
  577. mirascope/core/mistral/_call.py +0 -69
  578. mirascope/core/mistral/_utils/__init__.py +0 -16
  579. mirascope/core/mistral/_utils/_calculate_cost.py +0 -47
  580. mirascope/core/mistral/_utils/_convert_message_params.py +0 -23
  581. mirascope/core/mistral/_utils/_get_json_output.py +0 -28
  582. mirascope/core/mistral/_utils/_handle_stream.py +0 -121
  583. mirascope/core/mistral/_utils/_setup_call.py +0 -86
  584. mirascope/core/mistral/call_params.py +0 -36
  585. mirascope/core/mistral/call_response.py +0 -156
  586. mirascope/core/mistral/call_response_chunk.py +0 -84
  587. mirascope/core/mistral/dynamic_config.py +0 -24
  588. mirascope/core/mistral/py.typed +0 -0
  589. mirascope/core/mistral/stream.py +0 -117
  590. mirascope/core/mistral/tool.py +0 -77
  591. mirascope/core/openai/__init__.py +0 -21
  592. mirascope/core/openai/_call.py +0 -71
  593. mirascope/core/openai/_utils/__init__.py +0 -16
  594. mirascope/core/openai/_utils/_calculate_cost.py +0 -110
  595. mirascope/core/openai/_utils/_convert_message_params.py +0 -53
  596. mirascope/core/openai/_utils/_get_json_output.py +0 -27
  597. mirascope/core/openai/_utils/_handle_stream.py +0 -125
  598. mirascope/core/openai/_utils/_setup_call.py +0 -62
  599. mirascope/core/openai/call_params.py +0 -54
  600. mirascope/core/openai/call_response.py +0 -162
  601. mirascope/core/openai/call_response_chunk.py +0 -90
  602. mirascope/core/openai/dynamic_config.py +0 -26
  603. mirascope/core/openai/py.typed +0 -0
  604. mirascope/core/openai/stream.py +0 -148
  605. mirascope/core/openai/tool.py +0 -79
  606. mirascope/core/py.typed +0 -0
  607. mirascope/integrations/__init__.py +0 -20
  608. mirascope/integrations/_middleware_factory.py +0 -277
  609. mirascope/integrations/langfuse/__init__.py +0 -3
  610. mirascope/integrations/langfuse/_utils.py +0 -114
  611. mirascope/integrations/langfuse/_with_langfuse.py +0 -71
  612. mirascope/integrations/logfire/__init__.py +0 -3
  613. mirascope/integrations/logfire/_utils.py +0 -188
  614. mirascope/integrations/logfire/_with_logfire.py +0 -60
  615. mirascope/integrations/otel/__init__.py +0 -5
  616. mirascope/integrations/otel/_utils.py +0 -268
  617. mirascope/integrations/otel/_with_hyperdx.py +0 -61
  618. mirascope/integrations/otel/_with_otel.py +0 -60
  619. mirascope/integrations/tenacity.py +0 -50
  620. mirascope/py.typed +0 -0
  621. mirascope/v0/__init__.py +0 -43
  622. mirascope/v0/anthropic.py +0 -54
  623. mirascope/v0/base/__init__.py +0 -12
  624. mirascope/v0/base/calls.py +0 -118
  625. mirascope/v0/base/extractors.py +0 -122
  626. mirascope/v0/base/ops_utils.py +0 -207
  627. mirascope/v0/base/prompts.py +0 -48
  628. mirascope/v0/base/types.py +0 -14
  629. mirascope/v0/base/utils.py +0 -21
  630. mirascope/v0/openai.py +0 -54
  631. mirascope-1.0.5.dist-info/METADATA +0 -519
  632. mirascope-1.0.5.dist-info/RECORD +0 -198
@@ -0,0 +1,2593 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+ from json.decoder import JSONDecodeError
5
+
6
+ from ..core.api_error import ApiError
7
+ from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
8
+ from ..core.http_response import AsyncHttpResponse, HttpResponse
9
+ from ..core.jsonable_encoder import jsonable_encoder
10
+ from ..core.pydantic_utilities import parse_obj_as
11
+ from ..core.request_options import RequestOptions
12
+ from ..errors.bad_request_error import BadRequestError
13
+ from ..errors.conflict_error import ConflictError
14
+ from ..errors.forbidden_error import ForbiddenError
15
+ from ..errors.internal_server_error import InternalServerError
16
+ from ..errors.not_found_error import NotFoundError
17
+ from ..errors.payment_required_error import PaymentRequiredError
18
+ from ..errors.service_unavailable_error import ServiceUnavailableError
19
+ from ..errors.too_many_requests_error import TooManyRequestsError
20
+ from ..types.not_found_error_body import NotFoundErrorBody
21
+ from ..types.permission_denied_error import PermissionDeniedError
22
+ from ..types.plan_limit_exceeded_error import PlanLimitExceededError
23
+ from ..types.rate_limit_error import RateLimitError
24
+ from .types.organizations_create_payment_intent_response import (
25
+ OrganizationsCreatePaymentIntentResponse,
26
+ )
27
+ from .types.organizations_create_response import OrganizationsCreateResponse
28
+ from .types.organizations_get_response import OrganizationsGetResponse
29
+ from .types.organizations_list_response_item import OrganizationsListResponseItem
30
+ from .types.organizations_preview_subscription_change_request_target_plan import (
31
+ OrganizationsPreviewSubscriptionChangeRequestTargetPlan,
32
+ )
33
+ from .types.organizations_preview_subscription_change_response import (
34
+ OrganizationsPreviewSubscriptionChangeResponse,
35
+ )
36
+ from .types.organizations_router_balance_response import (
37
+ OrganizationsRouterBalanceResponse,
38
+ )
39
+ from .types.organizations_subscription_response import OrganizationsSubscriptionResponse
40
+ from .types.organizations_update_response import OrganizationsUpdateResponse
41
+ from .types.organizations_update_subscription_request_target_plan import (
42
+ OrganizationsUpdateSubscriptionRequestTargetPlan,
43
+ )
44
+ from .types.organizations_update_subscription_response import (
45
+ OrganizationsUpdateSubscriptionResponse,
46
+ )
47
+
48
+ # this is used as the default value for optional parameters
49
+ OMIT = typing.cast(typing.Any, ...)
50
+
51
+
52
+ class RawOrganizationsClient:
53
+ def __init__(self, *, client_wrapper: SyncClientWrapper):
54
+ self._client_wrapper = client_wrapper
55
+
56
+ def list(
57
+ self, *, request_options: typing.Optional[RequestOptions] = None
58
+ ) -> HttpResponse[typing.List[OrganizationsListResponseItem]]:
59
+ """
60
+ Parameters
61
+ ----------
62
+ request_options : typing.Optional[RequestOptions]
63
+ Request-specific configuration.
64
+
65
+ Returns
66
+ -------
67
+ HttpResponse[typing.List[OrganizationsListResponseItem]]
68
+ Success
69
+ """
70
+ _response = self._client_wrapper.httpx_client.request(
71
+ "organizations",
72
+ method="GET",
73
+ request_options=request_options,
74
+ )
75
+ try:
76
+ if 200 <= _response.status_code < 300:
77
+ _data = typing.cast(
78
+ typing.List[OrganizationsListResponseItem],
79
+ parse_obj_as(
80
+ type_=typing.List[OrganizationsListResponseItem], # type: ignore
81
+ object_=_response.json(),
82
+ ),
83
+ )
84
+ return HttpResponse(response=_response, data=_data)
85
+ if _response.status_code == 400:
86
+ raise BadRequestError(
87
+ headers=dict(_response.headers),
88
+ body=typing.cast(
89
+ typing.Optional[typing.Any],
90
+ parse_obj_as(
91
+ type_=typing.Optional[typing.Any], # type: ignore
92
+ object_=_response.json(),
93
+ ),
94
+ ),
95
+ )
96
+ if _response.status_code == 429:
97
+ raise TooManyRequestsError(
98
+ headers=dict(_response.headers),
99
+ body=typing.cast(
100
+ RateLimitError,
101
+ parse_obj_as(
102
+ type_=RateLimitError, # type: ignore
103
+ object_=_response.json(),
104
+ ),
105
+ ),
106
+ )
107
+ if _response.status_code == 500:
108
+ raise InternalServerError(
109
+ headers=dict(_response.headers),
110
+ body=typing.cast(
111
+ typing.Optional[typing.Any],
112
+ parse_obj_as(
113
+ type_=typing.Optional[typing.Any], # type: ignore
114
+ object_=_response.json(),
115
+ ),
116
+ ),
117
+ )
118
+ if _response.status_code == 503:
119
+ raise ServiceUnavailableError(
120
+ headers=dict(_response.headers),
121
+ body=typing.cast(
122
+ typing.Optional[typing.Any],
123
+ parse_obj_as(
124
+ type_=typing.Optional[typing.Any], # type: ignore
125
+ object_=_response.json(),
126
+ ),
127
+ ),
128
+ )
129
+ _response_json = _response.json()
130
+ except JSONDecodeError:
131
+ raise ApiError(
132
+ status_code=_response.status_code,
133
+ headers=dict(_response.headers),
134
+ body=_response.text,
135
+ )
136
+ raise ApiError(
137
+ status_code=_response.status_code,
138
+ headers=dict(_response.headers),
139
+ body=_response_json,
140
+ )
141
+
142
+ def create(
143
+ self,
144
+ *,
145
+ name: str,
146
+ slug: str,
147
+ request_options: typing.Optional[RequestOptions] = None,
148
+ ) -> HttpResponse[OrganizationsCreateResponse]:
149
+ """
150
+ Parameters
151
+ ----------
152
+ name : str
153
+ a string at most 100 character(s) long
154
+
155
+ slug : str
156
+ a string matching the pattern ^[a-z0-9][a-z0-9_-]*[a-z0-9]$
157
+
158
+ request_options : typing.Optional[RequestOptions]
159
+ Request-specific configuration.
160
+
161
+ Returns
162
+ -------
163
+ HttpResponse[OrganizationsCreateResponse]
164
+ Success
165
+ """
166
+ _response = self._client_wrapper.httpx_client.request(
167
+ "organizations",
168
+ method="POST",
169
+ json={
170
+ "name": name,
171
+ "slug": slug,
172
+ },
173
+ headers={
174
+ "content-type": "application/json",
175
+ },
176
+ request_options=request_options,
177
+ omit=OMIT,
178
+ )
179
+ try:
180
+ if 200 <= _response.status_code < 300:
181
+ _data = typing.cast(
182
+ OrganizationsCreateResponse,
183
+ parse_obj_as(
184
+ type_=OrganizationsCreateResponse, # type: ignore
185
+ object_=_response.json(),
186
+ ),
187
+ )
188
+ return HttpResponse(response=_response, data=_data)
189
+ if _response.status_code == 400:
190
+ raise BadRequestError(
191
+ headers=dict(_response.headers),
192
+ body=typing.cast(
193
+ typing.Optional[typing.Any],
194
+ parse_obj_as(
195
+ type_=typing.Optional[typing.Any], # type: ignore
196
+ object_=_response.json(),
197
+ ),
198
+ ),
199
+ )
200
+ if _response.status_code == 404:
201
+ raise NotFoundError(
202
+ headers=dict(_response.headers),
203
+ body=typing.cast(
204
+ NotFoundErrorBody,
205
+ parse_obj_as(
206
+ type_=NotFoundErrorBody, # type: ignore
207
+ object_=_response.json(),
208
+ ),
209
+ ),
210
+ )
211
+ if _response.status_code == 409:
212
+ raise ConflictError(
213
+ headers=dict(_response.headers),
214
+ body=typing.cast(
215
+ typing.Optional[typing.Any],
216
+ parse_obj_as(
217
+ type_=typing.Optional[typing.Any], # type: ignore
218
+ object_=_response.json(),
219
+ ),
220
+ ),
221
+ )
222
+ if _response.status_code == 429:
223
+ raise TooManyRequestsError(
224
+ headers=dict(_response.headers),
225
+ body=typing.cast(
226
+ RateLimitError,
227
+ parse_obj_as(
228
+ type_=RateLimitError, # type: ignore
229
+ object_=_response.json(),
230
+ ),
231
+ ),
232
+ )
233
+ if _response.status_code == 500:
234
+ raise InternalServerError(
235
+ headers=dict(_response.headers),
236
+ body=typing.cast(
237
+ typing.Optional[typing.Any],
238
+ parse_obj_as(
239
+ type_=typing.Optional[typing.Any], # type: ignore
240
+ object_=_response.json(),
241
+ ),
242
+ ),
243
+ )
244
+ if _response.status_code == 503:
245
+ raise ServiceUnavailableError(
246
+ headers=dict(_response.headers),
247
+ body=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
+ )
255
+ _response_json = _response.json()
256
+ except JSONDecodeError:
257
+ raise ApiError(
258
+ status_code=_response.status_code,
259
+ headers=dict(_response.headers),
260
+ body=_response.text,
261
+ )
262
+ raise ApiError(
263
+ status_code=_response.status_code,
264
+ headers=dict(_response.headers),
265
+ body=_response_json,
266
+ )
267
+
268
+ def get(
269
+ self, id: str, *, request_options: typing.Optional[RequestOptions] = None
270
+ ) -> HttpResponse[OrganizationsGetResponse]:
271
+ """
272
+ Parameters
273
+ ----------
274
+ id : str
275
+
276
+ request_options : typing.Optional[RequestOptions]
277
+ Request-specific configuration.
278
+
279
+ Returns
280
+ -------
281
+ HttpResponse[OrganizationsGetResponse]
282
+ Success
283
+ """
284
+ _response = self._client_wrapper.httpx_client.request(
285
+ f"organizations/{jsonable_encoder(id)}",
286
+ method="GET",
287
+ request_options=request_options,
288
+ )
289
+ try:
290
+ if 200 <= _response.status_code < 300:
291
+ _data = typing.cast(
292
+ OrganizationsGetResponse,
293
+ parse_obj_as(
294
+ type_=OrganizationsGetResponse, # type: ignore
295
+ object_=_response.json(),
296
+ ),
297
+ )
298
+ return HttpResponse(response=_response, data=_data)
299
+ if _response.status_code == 400:
300
+ raise BadRequestError(
301
+ headers=dict(_response.headers),
302
+ body=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
+ )
310
+ if _response.status_code == 403:
311
+ raise ForbiddenError(
312
+ headers=dict(_response.headers),
313
+ body=typing.cast(
314
+ PermissionDeniedError,
315
+ parse_obj_as(
316
+ type_=PermissionDeniedError, # type: ignore
317
+ object_=_response.json(),
318
+ ),
319
+ ),
320
+ )
321
+ if _response.status_code == 404:
322
+ raise NotFoundError(
323
+ headers=dict(_response.headers),
324
+ body=typing.cast(
325
+ NotFoundErrorBody,
326
+ parse_obj_as(
327
+ type_=NotFoundErrorBody, # type: ignore
328
+ object_=_response.json(),
329
+ ),
330
+ ),
331
+ )
332
+ if _response.status_code == 429:
333
+ raise TooManyRequestsError(
334
+ headers=dict(_response.headers),
335
+ body=typing.cast(
336
+ RateLimitError,
337
+ parse_obj_as(
338
+ type_=RateLimitError, # type: ignore
339
+ object_=_response.json(),
340
+ ),
341
+ ),
342
+ )
343
+ if _response.status_code == 500:
344
+ raise InternalServerError(
345
+ headers=dict(_response.headers),
346
+ body=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
+ )
354
+ if _response.status_code == 503:
355
+ raise ServiceUnavailableError(
356
+ headers=dict(_response.headers),
357
+ body=typing.cast(
358
+ typing.Optional[typing.Any],
359
+ parse_obj_as(
360
+ type_=typing.Optional[typing.Any], # type: ignore
361
+ object_=_response.json(),
362
+ ),
363
+ ),
364
+ )
365
+ _response_json = _response.json()
366
+ except JSONDecodeError:
367
+ raise ApiError(
368
+ status_code=_response.status_code,
369
+ headers=dict(_response.headers),
370
+ body=_response.text,
371
+ )
372
+ raise ApiError(
373
+ status_code=_response.status_code,
374
+ headers=dict(_response.headers),
375
+ body=_response_json,
376
+ )
377
+
378
+ def update(
379
+ self,
380
+ id: str,
381
+ *,
382
+ name: typing.Optional[str] = OMIT,
383
+ slug: typing.Optional[str] = OMIT,
384
+ request_options: typing.Optional[RequestOptions] = None,
385
+ ) -> HttpResponse[OrganizationsUpdateResponse]:
386
+ """
387
+ Parameters
388
+ ----------
389
+ id : str
390
+
391
+ name : typing.Optional[str]
392
+ a string at most 100 character(s) long
393
+
394
+ slug : typing.Optional[str]
395
+ a string matching the pattern ^[a-z0-9][a-z0-9_-]*[a-z0-9]$
396
+
397
+ request_options : typing.Optional[RequestOptions]
398
+ Request-specific configuration.
399
+
400
+ Returns
401
+ -------
402
+ HttpResponse[OrganizationsUpdateResponse]
403
+ Success
404
+ """
405
+ _response = self._client_wrapper.httpx_client.request(
406
+ f"organizations/{jsonable_encoder(id)}",
407
+ method="PUT",
408
+ json={
409
+ "name": name,
410
+ "slug": slug,
411
+ },
412
+ headers={
413
+ "content-type": "application/json",
414
+ },
415
+ request_options=request_options,
416
+ omit=OMIT,
417
+ )
418
+ try:
419
+ if 200 <= _response.status_code < 300:
420
+ _data = typing.cast(
421
+ OrganizationsUpdateResponse,
422
+ parse_obj_as(
423
+ type_=OrganizationsUpdateResponse, # type: ignore
424
+ object_=_response.json(),
425
+ ),
426
+ )
427
+ return HttpResponse(response=_response, data=_data)
428
+ if _response.status_code == 400:
429
+ raise BadRequestError(
430
+ headers=dict(_response.headers),
431
+ body=typing.cast(
432
+ typing.Optional[typing.Any],
433
+ parse_obj_as(
434
+ type_=typing.Optional[typing.Any], # type: ignore
435
+ object_=_response.json(),
436
+ ),
437
+ ),
438
+ )
439
+ if _response.status_code == 403:
440
+ raise ForbiddenError(
441
+ headers=dict(_response.headers),
442
+ body=typing.cast(
443
+ PermissionDeniedError,
444
+ parse_obj_as(
445
+ type_=PermissionDeniedError, # type: ignore
446
+ object_=_response.json(),
447
+ ),
448
+ ),
449
+ )
450
+ if _response.status_code == 404:
451
+ raise NotFoundError(
452
+ headers=dict(_response.headers),
453
+ body=typing.cast(
454
+ NotFoundErrorBody,
455
+ parse_obj_as(
456
+ type_=NotFoundErrorBody, # type: ignore
457
+ object_=_response.json(),
458
+ ),
459
+ ),
460
+ )
461
+ if _response.status_code == 429:
462
+ raise TooManyRequestsError(
463
+ headers=dict(_response.headers),
464
+ body=typing.cast(
465
+ RateLimitError,
466
+ parse_obj_as(
467
+ type_=RateLimitError, # type: ignore
468
+ object_=_response.json(),
469
+ ),
470
+ ),
471
+ )
472
+ if _response.status_code == 500:
473
+ raise InternalServerError(
474
+ headers=dict(_response.headers),
475
+ body=typing.cast(
476
+ typing.Optional[typing.Any],
477
+ parse_obj_as(
478
+ type_=typing.Optional[typing.Any], # type: ignore
479
+ object_=_response.json(),
480
+ ),
481
+ ),
482
+ )
483
+ if _response.status_code == 503:
484
+ raise ServiceUnavailableError(
485
+ headers=dict(_response.headers),
486
+ body=typing.cast(
487
+ typing.Optional[typing.Any],
488
+ parse_obj_as(
489
+ type_=typing.Optional[typing.Any], # type: ignore
490
+ object_=_response.json(),
491
+ ),
492
+ ),
493
+ )
494
+ _response_json = _response.json()
495
+ except JSONDecodeError:
496
+ raise ApiError(
497
+ status_code=_response.status_code,
498
+ headers=dict(_response.headers),
499
+ body=_response.text,
500
+ )
501
+ raise ApiError(
502
+ status_code=_response.status_code,
503
+ headers=dict(_response.headers),
504
+ body=_response_json,
505
+ )
506
+
507
+ def delete(
508
+ self, id: str, *, request_options: typing.Optional[RequestOptions] = None
509
+ ) -> HttpResponse[None]:
510
+ """
511
+ Parameters
512
+ ----------
513
+ id : str
514
+
515
+ request_options : typing.Optional[RequestOptions]
516
+ Request-specific configuration.
517
+
518
+ Returns
519
+ -------
520
+ HttpResponse[None]
521
+ """
522
+ _response = self._client_wrapper.httpx_client.request(
523
+ f"organizations/{jsonable_encoder(id)}",
524
+ method="DELETE",
525
+ request_options=request_options,
526
+ )
527
+ try:
528
+ if 200 <= _response.status_code < 300:
529
+ return HttpResponse(response=_response, data=None)
530
+ if _response.status_code == 400:
531
+ raise BadRequestError(
532
+ headers=dict(_response.headers),
533
+ body=typing.cast(
534
+ typing.Optional[typing.Any],
535
+ parse_obj_as(
536
+ type_=typing.Optional[typing.Any], # type: ignore
537
+ object_=_response.json(),
538
+ ),
539
+ ),
540
+ )
541
+ if _response.status_code == 403:
542
+ raise ForbiddenError(
543
+ headers=dict(_response.headers),
544
+ body=typing.cast(
545
+ PermissionDeniedError,
546
+ parse_obj_as(
547
+ type_=PermissionDeniedError, # type: ignore
548
+ object_=_response.json(),
549
+ ),
550
+ ),
551
+ )
552
+ if _response.status_code == 404:
553
+ raise NotFoundError(
554
+ headers=dict(_response.headers),
555
+ body=typing.cast(
556
+ NotFoundErrorBody,
557
+ parse_obj_as(
558
+ type_=NotFoundErrorBody, # type: ignore
559
+ object_=_response.json(),
560
+ ),
561
+ ),
562
+ )
563
+ if _response.status_code == 409:
564
+ raise ConflictError(
565
+ headers=dict(_response.headers),
566
+ body=typing.cast(
567
+ typing.Optional[typing.Any],
568
+ parse_obj_as(
569
+ type_=typing.Optional[typing.Any], # type: ignore
570
+ object_=_response.json(),
571
+ ),
572
+ ),
573
+ )
574
+ if _response.status_code == 429:
575
+ raise TooManyRequestsError(
576
+ headers=dict(_response.headers),
577
+ body=typing.cast(
578
+ RateLimitError,
579
+ parse_obj_as(
580
+ type_=RateLimitError, # type: ignore
581
+ object_=_response.json(),
582
+ ),
583
+ ),
584
+ )
585
+ if _response.status_code == 500:
586
+ raise InternalServerError(
587
+ headers=dict(_response.headers),
588
+ body=typing.cast(
589
+ typing.Optional[typing.Any],
590
+ parse_obj_as(
591
+ type_=typing.Optional[typing.Any], # type: ignore
592
+ object_=_response.json(),
593
+ ),
594
+ ),
595
+ )
596
+ if _response.status_code == 503:
597
+ raise ServiceUnavailableError(
598
+ headers=dict(_response.headers),
599
+ body=typing.cast(
600
+ typing.Optional[typing.Any],
601
+ parse_obj_as(
602
+ type_=typing.Optional[typing.Any], # type: ignore
603
+ object_=_response.json(),
604
+ ),
605
+ ),
606
+ )
607
+ _response_json = _response.json()
608
+ except JSONDecodeError:
609
+ raise ApiError(
610
+ status_code=_response.status_code,
611
+ headers=dict(_response.headers),
612
+ body=_response.text,
613
+ )
614
+ raise ApiError(
615
+ status_code=_response.status_code,
616
+ headers=dict(_response.headers),
617
+ body=_response_json,
618
+ )
619
+
620
+ def routerbalance(
621
+ self, id: str, *, request_options: typing.Optional[RequestOptions] = None
622
+ ) -> HttpResponse[OrganizationsRouterBalanceResponse]:
623
+ """
624
+ Parameters
625
+ ----------
626
+ id : str
627
+
628
+ request_options : typing.Optional[RequestOptions]
629
+ Request-specific configuration.
630
+
631
+ Returns
632
+ -------
633
+ HttpResponse[OrganizationsRouterBalanceResponse]
634
+ Success
635
+ """
636
+ _response = self._client_wrapper.httpx_client.request(
637
+ f"organizations/{jsonable_encoder(id)}/router-balance",
638
+ method="GET",
639
+ request_options=request_options,
640
+ )
641
+ try:
642
+ if 200 <= _response.status_code < 300:
643
+ _data = typing.cast(
644
+ OrganizationsRouterBalanceResponse,
645
+ parse_obj_as(
646
+ type_=OrganizationsRouterBalanceResponse, # type: ignore
647
+ object_=_response.json(),
648
+ ),
649
+ )
650
+ return HttpResponse(response=_response, data=_data)
651
+ if _response.status_code == 400:
652
+ raise BadRequestError(
653
+ headers=dict(_response.headers),
654
+ body=typing.cast(
655
+ typing.Optional[typing.Any],
656
+ parse_obj_as(
657
+ type_=typing.Optional[typing.Any], # type: ignore
658
+ object_=_response.json(),
659
+ ),
660
+ ),
661
+ )
662
+ if _response.status_code == 403:
663
+ raise ForbiddenError(
664
+ headers=dict(_response.headers),
665
+ body=typing.cast(
666
+ PermissionDeniedError,
667
+ parse_obj_as(
668
+ type_=PermissionDeniedError, # type: ignore
669
+ object_=_response.json(),
670
+ ),
671
+ ),
672
+ )
673
+ if _response.status_code == 404:
674
+ raise NotFoundError(
675
+ headers=dict(_response.headers),
676
+ body=typing.cast(
677
+ NotFoundErrorBody,
678
+ parse_obj_as(
679
+ type_=NotFoundErrorBody, # type: ignore
680
+ object_=_response.json(),
681
+ ),
682
+ ),
683
+ )
684
+ if _response.status_code == 429:
685
+ raise TooManyRequestsError(
686
+ headers=dict(_response.headers),
687
+ body=typing.cast(
688
+ RateLimitError,
689
+ parse_obj_as(
690
+ type_=RateLimitError, # type: ignore
691
+ object_=_response.json(),
692
+ ),
693
+ ),
694
+ )
695
+ if _response.status_code == 500:
696
+ raise InternalServerError(
697
+ headers=dict(_response.headers),
698
+ body=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
+ )
706
+ if _response.status_code == 503:
707
+ raise ServiceUnavailableError(
708
+ headers=dict(_response.headers),
709
+ body=typing.cast(
710
+ typing.Optional[typing.Any],
711
+ parse_obj_as(
712
+ type_=typing.Optional[typing.Any], # type: ignore
713
+ object_=_response.json(),
714
+ ),
715
+ ),
716
+ )
717
+ _response_json = _response.json()
718
+ except JSONDecodeError:
719
+ raise ApiError(
720
+ status_code=_response.status_code,
721
+ headers=dict(_response.headers),
722
+ body=_response.text,
723
+ )
724
+ raise ApiError(
725
+ status_code=_response.status_code,
726
+ headers=dict(_response.headers),
727
+ body=_response_json,
728
+ )
729
+
730
+ def createpaymentintent(
731
+ self,
732
+ id: str,
733
+ *,
734
+ amount: float,
735
+ request_options: typing.Optional[RequestOptions] = None,
736
+ ) -> HttpResponse[OrganizationsCreatePaymentIntentResponse]:
737
+ """
738
+ Parameters
739
+ ----------
740
+ id : str
741
+
742
+ amount : float
743
+ a positive number
744
+
745
+ request_options : typing.Optional[RequestOptions]
746
+ Request-specific configuration.
747
+
748
+ Returns
749
+ -------
750
+ HttpResponse[OrganizationsCreatePaymentIntentResponse]
751
+ Success
752
+ """
753
+ _response = self._client_wrapper.httpx_client.request(
754
+ f"organizations/{jsonable_encoder(id)}/credits/payment-intent",
755
+ method="POST",
756
+ json={
757
+ "amount": amount,
758
+ },
759
+ headers={
760
+ "content-type": "application/json",
761
+ },
762
+ request_options=request_options,
763
+ omit=OMIT,
764
+ )
765
+ try:
766
+ if 200 <= _response.status_code < 300:
767
+ _data = typing.cast(
768
+ OrganizationsCreatePaymentIntentResponse,
769
+ parse_obj_as(
770
+ type_=OrganizationsCreatePaymentIntentResponse, # type: ignore
771
+ object_=_response.json(),
772
+ ),
773
+ )
774
+ return HttpResponse(response=_response, data=_data)
775
+ if _response.status_code == 400:
776
+ raise BadRequestError(
777
+ headers=dict(_response.headers),
778
+ body=typing.cast(
779
+ typing.Optional[typing.Any],
780
+ parse_obj_as(
781
+ type_=typing.Optional[typing.Any], # type: ignore
782
+ object_=_response.json(),
783
+ ),
784
+ ),
785
+ )
786
+ if _response.status_code == 403:
787
+ raise ForbiddenError(
788
+ headers=dict(_response.headers),
789
+ body=typing.cast(
790
+ PermissionDeniedError,
791
+ parse_obj_as(
792
+ type_=PermissionDeniedError, # type: ignore
793
+ object_=_response.json(),
794
+ ),
795
+ ),
796
+ )
797
+ if _response.status_code == 404:
798
+ raise NotFoundError(
799
+ headers=dict(_response.headers),
800
+ body=typing.cast(
801
+ NotFoundErrorBody,
802
+ parse_obj_as(
803
+ type_=NotFoundErrorBody, # type: ignore
804
+ object_=_response.json(),
805
+ ),
806
+ ),
807
+ )
808
+ if _response.status_code == 429:
809
+ raise TooManyRequestsError(
810
+ headers=dict(_response.headers),
811
+ body=typing.cast(
812
+ RateLimitError,
813
+ parse_obj_as(
814
+ type_=RateLimitError, # type: ignore
815
+ object_=_response.json(),
816
+ ),
817
+ ),
818
+ )
819
+ if _response.status_code == 500:
820
+ raise InternalServerError(
821
+ headers=dict(_response.headers),
822
+ body=typing.cast(
823
+ typing.Optional[typing.Any],
824
+ parse_obj_as(
825
+ type_=typing.Optional[typing.Any], # type: ignore
826
+ object_=_response.json(),
827
+ ),
828
+ ),
829
+ )
830
+ if _response.status_code == 503:
831
+ raise ServiceUnavailableError(
832
+ headers=dict(_response.headers),
833
+ body=typing.cast(
834
+ typing.Optional[typing.Any],
835
+ parse_obj_as(
836
+ type_=typing.Optional[typing.Any], # type: ignore
837
+ object_=_response.json(),
838
+ ),
839
+ ),
840
+ )
841
+ _response_json = _response.json()
842
+ except JSONDecodeError:
843
+ raise ApiError(
844
+ status_code=_response.status_code,
845
+ headers=dict(_response.headers),
846
+ body=_response.text,
847
+ )
848
+ raise ApiError(
849
+ status_code=_response.status_code,
850
+ headers=dict(_response.headers),
851
+ body=_response_json,
852
+ )
853
+
854
+ def subscription(
855
+ self, id: str, *, request_options: typing.Optional[RequestOptions] = None
856
+ ) -> HttpResponse[OrganizationsSubscriptionResponse]:
857
+ """
858
+ Parameters
859
+ ----------
860
+ id : str
861
+
862
+ request_options : typing.Optional[RequestOptions]
863
+ Request-specific configuration.
864
+
865
+ Returns
866
+ -------
867
+ HttpResponse[OrganizationsSubscriptionResponse]
868
+ Success
869
+ """
870
+ _response = self._client_wrapper.httpx_client.request(
871
+ f"organizations/{jsonable_encoder(id)}/subscription",
872
+ method="GET",
873
+ request_options=request_options,
874
+ )
875
+ try:
876
+ if 200 <= _response.status_code < 300:
877
+ _data = typing.cast(
878
+ OrganizationsSubscriptionResponse,
879
+ parse_obj_as(
880
+ type_=OrganizationsSubscriptionResponse, # type: ignore
881
+ object_=_response.json(),
882
+ ),
883
+ )
884
+ return HttpResponse(response=_response, data=_data)
885
+ if _response.status_code == 400:
886
+ raise BadRequestError(
887
+ headers=dict(_response.headers),
888
+ body=typing.cast(
889
+ typing.Optional[typing.Any],
890
+ parse_obj_as(
891
+ type_=typing.Optional[typing.Any], # type: ignore
892
+ object_=_response.json(),
893
+ ),
894
+ ),
895
+ )
896
+ if _response.status_code == 403:
897
+ raise ForbiddenError(
898
+ headers=dict(_response.headers),
899
+ body=typing.cast(
900
+ PermissionDeniedError,
901
+ parse_obj_as(
902
+ type_=PermissionDeniedError, # type: ignore
903
+ object_=_response.json(),
904
+ ),
905
+ ),
906
+ )
907
+ if _response.status_code == 404:
908
+ raise NotFoundError(
909
+ headers=dict(_response.headers),
910
+ body=typing.cast(
911
+ NotFoundErrorBody,
912
+ parse_obj_as(
913
+ type_=NotFoundErrorBody, # type: ignore
914
+ object_=_response.json(),
915
+ ),
916
+ ),
917
+ )
918
+ if _response.status_code == 429:
919
+ raise TooManyRequestsError(
920
+ headers=dict(_response.headers),
921
+ body=typing.cast(
922
+ RateLimitError,
923
+ parse_obj_as(
924
+ type_=RateLimitError, # type: ignore
925
+ object_=_response.json(),
926
+ ),
927
+ ),
928
+ )
929
+ if _response.status_code == 500:
930
+ raise InternalServerError(
931
+ headers=dict(_response.headers),
932
+ body=typing.cast(
933
+ typing.Optional[typing.Any],
934
+ parse_obj_as(
935
+ type_=typing.Optional[typing.Any], # type: ignore
936
+ object_=_response.json(),
937
+ ),
938
+ ),
939
+ )
940
+ if _response.status_code == 503:
941
+ raise ServiceUnavailableError(
942
+ headers=dict(_response.headers),
943
+ body=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
+ )
951
+ _response_json = _response.json()
952
+ except JSONDecodeError:
953
+ raise ApiError(
954
+ status_code=_response.status_code,
955
+ headers=dict(_response.headers),
956
+ body=_response.text,
957
+ )
958
+ raise ApiError(
959
+ status_code=_response.status_code,
960
+ headers=dict(_response.headers),
961
+ body=_response_json,
962
+ )
963
+
964
+ def previewsubscriptionchange(
965
+ self,
966
+ id: str,
967
+ *,
968
+ target_plan: OrganizationsPreviewSubscriptionChangeRequestTargetPlan,
969
+ request_options: typing.Optional[RequestOptions] = None,
970
+ ) -> HttpResponse[OrganizationsPreviewSubscriptionChangeResponse]:
971
+ """
972
+ Parameters
973
+ ----------
974
+ id : str
975
+
976
+ target_plan : OrganizationsPreviewSubscriptionChangeRequestTargetPlan
977
+
978
+ request_options : typing.Optional[RequestOptions]
979
+ Request-specific configuration.
980
+
981
+ Returns
982
+ -------
983
+ HttpResponse[OrganizationsPreviewSubscriptionChangeResponse]
984
+ Success
985
+ """
986
+ _response = self._client_wrapper.httpx_client.request(
987
+ f"organizations/{jsonable_encoder(id)}/subscription/preview",
988
+ method="POST",
989
+ json={
990
+ "targetPlan": target_plan,
991
+ },
992
+ headers={
993
+ "content-type": "application/json",
994
+ },
995
+ request_options=request_options,
996
+ omit=OMIT,
997
+ )
998
+ try:
999
+ if 200 <= _response.status_code < 300:
1000
+ _data = typing.cast(
1001
+ OrganizationsPreviewSubscriptionChangeResponse,
1002
+ parse_obj_as(
1003
+ type_=OrganizationsPreviewSubscriptionChangeResponse, # type: ignore
1004
+ object_=_response.json(),
1005
+ ),
1006
+ )
1007
+ return HttpResponse(response=_response, data=_data)
1008
+ if _response.status_code == 400:
1009
+ raise BadRequestError(
1010
+ headers=dict(_response.headers),
1011
+ body=typing.cast(
1012
+ typing.Optional[typing.Any],
1013
+ parse_obj_as(
1014
+ type_=typing.Optional[typing.Any], # type: ignore
1015
+ object_=_response.json(),
1016
+ ),
1017
+ ),
1018
+ )
1019
+ if _response.status_code == 403:
1020
+ raise ForbiddenError(
1021
+ headers=dict(_response.headers),
1022
+ body=typing.cast(
1023
+ PermissionDeniedError,
1024
+ parse_obj_as(
1025
+ type_=PermissionDeniedError, # type: ignore
1026
+ object_=_response.json(),
1027
+ ),
1028
+ ),
1029
+ )
1030
+ if _response.status_code == 404:
1031
+ raise NotFoundError(
1032
+ headers=dict(_response.headers),
1033
+ body=typing.cast(
1034
+ NotFoundErrorBody,
1035
+ parse_obj_as(
1036
+ type_=NotFoundErrorBody, # type: ignore
1037
+ object_=_response.json(),
1038
+ ),
1039
+ ),
1040
+ )
1041
+ if _response.status_code == 429:
1042
+ raise TooManyRequestsError(
1043
+ headers=dict(_response.headers),
1044
+ body=typing.cast(
1045
+ RateLimitError,
1046
+ parse_obj_as(
1047
+ type_=RateLimitError, # type: ignore
1048
+ object_=_response.json(),
1049
+ ),
1050
+ ),
1051
+ )
1052
+ if _response.status_code == 500:
1053
+ raise InternalServerError(
1054
+ headers=dict(_response.headers),
1055
+ body=typing.cast(
1056
+ typing.Optional[typing.Any],
1057
+ parse_obj_as(
1058
+ type_=typing.Optional[typing.Any], # type: ignore
1059
+ object_=_response.json(),
1060
+ ),
1061
+ ),
1062
+ )
1063
+ if _response.status_code == 503:
1064
+ raise ServiceUnavailableError(
1065
+ headers=dict(_response.headers),
1066
+ body=typing.cast(
1067
+ typing.Optional[typing.Any],
1068
+ parse_obj_as(
1069
+ type_=typing.Optional[typing.Any], # type: ignore
1070
+ object_=_response.json(),
1071
+ ),
1072
+ ),
1073
+ )
1074
+ _response_json = _response.json()
1075
+ except JSONDecodeError:
1076
+ raise ApiError(
1077
+ status_code=_response.status_code,
1078
+ headers=dict(_response.headers),
1079
+ body=_response.text,
1080
+ )
1081
+ raise ApiError(
1082
+ status_code=_response.status_code,
1083
+ headers=dict(_response.headers),
1084
+ body=_response_json,
1085
+ )
1086
+
1087
+ def updatesubscription(
1088
+ self,
1089
+ id: str,
1090
+ *,
1091
+ target_plan: OrganizationsUpdateSubscriptionRequestTargetPlan,
1092
+ request_options: typing.Optional[RequestOptions] = None,
1093
+ ) -> HttpResponse[OrganizationsUpdateSubscriptionResponse]:
1094
+ """
1095
+ Parameters
1096
+ ----------
1097
+ id : str
1098
+
1099
+ target_plan : OrganizationsUpdateSubscriptionRequestTargetPlan
1100
+
1101
+ request_options : typing.Optional[RequestOptions]
1102
+ Request-specific configuration.
1103
+
1104
+ Returns
1105
+ -------
1106
+ HttpResponse[OrganizationsUpdateSubscriptionResponse]
1107
+ Success
1108
+ """
1109
+ _response = self._client_wrapper.httpx_client.request(
1110
+ f"organizations/{jsonable_encoder(id)}/subscription/update",
1111
+ method="POST",
1112
+ json={
1113
+ "targetPlan": target_plan,
1114
+ },
1115
+ headers={
1116
+ "content-type": "application/json",
1117
+ },
1118
+ request_options=request_options,
1119
+ omit=OMIT,
1120
+ )
1121
+ try:
1122
+ if 200 <= _response.status_code < 300:
1123
+ _data = typing.cast(
1124
+ OrganizationsUpdateSubscriptionResponse,
1125
+ parse_obj_as(
1126
+ type_=OrganizationsUpdateSubscriptionResponse, # type: ignore
1127
+ object_=_response.json(),
1128
+ ),
1129
+ )
1130
+ return HttpResponse(response=_response, data=_data)
1131
+ if _response.status_code == 400:
1132
+ raise BadRequestError(
1133
+ headers=dict(_response.headers),
1134
+ body=typing.cast(
1135
+ typing.Optional[typing.Any],
1136
+ parse_obj_as(
1137
+ type_=typing.Optional[typing.Any], # type: ignore
1138
+ object_=_response.json(),
1139
+ ),
1140
+ ),
1141
+ )
1142
+ if _response.status_code == 402:
1143
+ raise PaymentRequiredError(
1144
+ headers=dict(_response.headers),
1145
+ body=typing.cast(
1146
+ PlanLimitExceededError,
1147
+ parse_obj_as(
1148
+ type_=PlanLimitExceededError, # type: ignore
1149
+ object_=_response.json(),
1150
+ ),
1151
+ ),
1152
+ )
1153
+ if _response.status_code == 403:
1154
+ raise ForbiddenError(
1155
+ headers=dict(_response.headers),
1156
+ body=typing.cast(
1157
+ PermissionDeniedError,
1158
+ parse_obj_as(
1159
+ type_=PermissionDeniedError, # type: ignore
1160
+ object_=_response.json(),
1161
+ ),
1162
+ ),
1163
+ )
1164
+ if _response.status_code == 404:
1165
+ raise NotFoundError(
1166
+ headers=dict(_response.headers),
1167
+ body=typing.cast(
1168
+ NotFoundErrorBody,
1169
+ parse_obj_as(
1170
+ type_=NotFoundErrorBody, # type: ignore
1171
+ object_=_response.json(),
1172
+ ),
1173
+ ),
1174
+ )
1175
+ if _response.status_code == 429:
1176
+ raise TooManyRequestsError(
1177
+ headers=dict(_response.headers),
1178
+ body=typing.cast(
1179
+ RateLimitError,
1180
+ parse_obj_as(
1181
+ type_=RateLimitError, # type: ignore
1182
+ object_=_response.json(),
1183
+ ),
1184
+ ),
1185
+ )
1186
+ if _response.status_code == 500:
1187
+ raise InternalServerError(
1188
+ headers=dict(_response.headers),
1189
+ body=typing.cast(
1190
+ typing.Optional[typing.Any],
1191
+ parse_obj_as(
1192
+ type_=typing.Optional[typing.Any], # type: ignore
1193
+ object_=_response.json(),
1194
+ ),
1195
+ ),
1196
+ )
1197
+ if _response.status_code == 503:
1198
+ raise ServiceUnavailableError(
1199
+ headers=dict(_response.headers),
1200
+ body=typing.cast(
1201
+ typing.Optional[typing.Any],
1202
+ parse_obj_as(
1203
+ type_=typing.Optional[typing.Any], # type: ignore
1204
+ object_=_response.json(),
1205
+ ),
1206
+ ),
1207
+ )
1208
+ _response_json = _response.json()
1209
+ except JSONDecodeError:
1210
+ raise ApiError(
1211
+ status_code=_response.status_code,
1212
+ headers=dict(_response.headers),
1213
+ body=_response.text,
1214
+ )
1215
+ raise ApiError(
1216
+ status_code=_response.status_code,
1217
+ headers=dict(_response.headers),
1218
+ body=_response_json,
1219
+ )
1220
+
1221
+ def cancelscheduleddowngrade(
1222
+ self, id: str, *, request_options: typing.Optional[RequestOptions] = None
1223
+ ) -> HttpResponse[None]:
1224
+ """
1225
+ Parameters
1226
+ ----------
1227
+ id : str
1228
+
1229
+ request_options : typing.Optional[RequestOptions]
1230
+ Request-specific configuration.
1231
+
1232
+ Returns
1233
+ -------
1234
+ HttpResponse[None]
1235
+ """
1236
+ _response = self._client_wrapper.httpx_client.request(
1237
+ f"organizations/{jsonable_encoder(id)}/subscription/cancel-downgrade",
1238
+ method="POST",
1239
+ request_options=request_options,
1240
+ )
1241
+ try:
1242
+ if 200 <= _response.status_code < 300:
1243
+ return HttpResponse(response=_response, data=None)
1244
+ if _response.status_code == 400:
1245
+ raise BadRequestError(
1246
+ headers=dict(_response.headers),
1247
+ body=typing.cast(
1248
+ typing.Optional[typing.Any],
1249
+ parse_obj_as(
1250
+ type_=typing.Optional[typing.Any], # type: ignore
1251
+ object_=_response.json(),
1252
+ ),
1253
+ ),
1254
+ )
1255
+ if _response.status_code == 403:
1256
+ raise ForbiddenError(
1257
+ headers=dict(_response.headers),
1258
+ body=typing.cast(
1259
+ PermissionDeniedError,
1260
+ parse_obj_as(
1261
+ type_=PermissionDeniedError, # type: ignore
1262
+ object_=_response.json(),
1263
+ ),
1264
+ ),
1265
+ )
1266
+ if _response.status_code == 404:
1267
+ raise NotFoundError(
1268
+ headers=dict(_response.headers),
1269
+ body=typing.cast(
1270
+ NotFoundErrorBody,
1271
+ parse_obj_as(
1272
+ type_=NotFoundErrorBody, # type: ignore
1273
+ object_=_response.json(),
1274
+ ),
1275
+ ),
1276
+ )
1277
+ if _response.status_code == 429:
1278
+ raise TooManyRequestsError(
1279
+ headers=dict(_response.headers),
1280
+ body=typing.cast(
1281
+ RateLimitError,
1282
+ parse_obj_as(
1283
+ type_=RateLimitError, # type: ignore
1284
+ object_=_response.json(),
1285
+ ),
1286
+ ),
1287
+ )
1288
+ if _response.status_code == 500:
1289
+ raise InternalServerError(
1290
+ headers=dict(_response.headers),
1291
+ body=typing.cast(
1292
+ typing.Optional[typing.Any],
1293
+ parse_obj_as(
1294
+ type_=typing.Optional[typing.Any], # type: ignore
1295
+ object_=_response.json(),
1296
+ ),
1297
+ ),
1298
+ )
1299
+ if _response.status_code == 503:
1300
+ raise ServiceUnavailableError(
1301
+ headers=dict(_response.headers),
1302
+ body=typing.cast(
1303
+ typing.Optional[typing.Any],
1304
+ parse_obj_as(
1305
+ type_=typing.Optional[typing.Any], # type: ignore
1306
+ object_=_response.json(),
1307
+ ),
1308
+ ),
1309
+ )
1310
+ _response_json = _response.json()
1311
+ except JSONDecodeError:
1312
+ raise ApiError(
1313
+ status_code=_response.status_code,
1314
+ headers=dict(_response.headers),
1315
+ body=_response.text,
1316
+ )
1317
+ raise ApiError(
1318
+ status_code=_response.status_code,
1319
+ headers=dict(_response.headers),
1320
+ body=_response_json,
1321
+ )
1322
+
1323
+
1324
+ class AsyncRawOrganizationsClient:
1325
+ def __init__(self, *, client_wrapper: AsyncClientWrapper):
1326
+ self._client_wrapper = client_wrapper
1327
+
1328
+ async def list(
1329
+ self, *, request_options: typing.Optional[RequestOptions] = None
1330
+ ) -> AsyncHttpResponse[typing.List[OrganizationsListResponseItem]]:
1331
+ """
1332
+ Parameters
1333
+ ----------
1334
+ request_options : typing.Optional[RequestOptions]
1335
+ Request-specific configuration.
1336
+
1337
+ Returns
1338
+ -------
1339
+ AsyncHttpResponse[typing.List[OrganizationsListResponseItem]]
1340
+ Success
1341
+ """
1342
+ _response = await self._client_wrapper.httpx_client.request(
1343
+ "organizations",
1344
+ method="GET",
1345
+ request_options=request_options,
1346
+ )
1347
+ try:
1348
+ if 200 <= _response.status_code < 300:
1349
+ _data = typing.cast(
1350
+ typing.List[OrganizationsListResponseItem],
1351
+ parse_obj_as(
1352
+ type_=typing.List[OrganizationsListResponseItem], # type: ignore
1353
+ object_=_response.json(),
1354
+ ),
1355
+ )
1356
+ return AsyncHttpResponse(response=_response, data=_data)
1357
+ if _response.status_code == 400:
1358
+ raise BadRequestError(
1359
+ headers=dict(_response.headers),
1360
+ body=typing.cast(
1361
+ typing.Optional[typing.Any],
1362
+ parse_obj_as(
1363
+ type_=typing.Optional[typing.Any], # type: ignore
1364
+ object_=_response.json(),
1365
+ ),
1366
+ ),
1367
+ )
1368
+ if _response.status_code == 429:
1369
+ raise TooManyRequestsError(
1370
+ headers=dict(_response.headers),
1371
+ body=typing.cast(
1372
+ RateLimitError,
1373
+ parse_obj_as(
1374
+ type_=RateLimitError, # type: ignore
1375
+ object_=_response.json(),
1376
+ ),
1377
+ ),
1378
+ )
1379
+ if _response.status_code == 500:
1380
+ raise InternalServerError(
1381
+ headers=dict(_response.headers),
1382
+ body=typing.cast(
1383
+ typing.Optional[typing.Any],
1384
+ parse_obj_as(
1385
+ type_=typing.Optional[typing.Any], # type: ignore
1386
+ object_=_response.json(),
1387
+ ),
1388
+ ),
1389
+ )
1390
+ if _response.status_code == 503:
1391
+ raise ServiceUnavailableError(
1392
+ headers=dict(_response.headers),
1393
+ body=typing.cast(
1394
+ typing.Optional[typing.Any],
1395
+ parse_obj_as(
1396
+ type_=typing.Optional[typing.Any], # type: ignore
1397
+ object_=_response.json(),
1398
+ ),
1399
+ ),
1400
+ )
1401
+ _response_json = _response.json()
1402
+ except JSONDecodeError:
1403
+ raise ApiError(
1404
+ status_code=_response.status_code,
1405
+ headers=dict(_response.headers),
1406
+ body=_response.text,
1407
+ )
1408
+ raise ApiError(
1409
+ status_code=_response.status_code,
1410
+ headers=dict(_response.headers),
1411
+ body=_response_json,
1412
+ )
1413
+
1414
+ async def create(
1415
+ self,
1416
+ *,
1417
+ name: str,
1418
+ slug: str,
1419
+ request_options: typing.Optional[RequestOptions] = None,
1420
+ ) -> AsyncHttpResponse[OrganizationsCreateResponse]:
1421
+ """
1422
+ Parameters
1423
+ ----------
1424
+ name : str
1425
+ a string at most 100 character(s) long
1426
+
1427
+ slug : str
1428
+ a string matching the pattern ^[a-z0-9][a-z0-9_-]*[a-z0-9]$
1429
+
1430
+ request_options : typing.Optional[RequestOptions]
1431
+ Request-specific configuration.
1432
+
1433
+ Returns
1434
+ -------
1435
+ AsyncHttpResponse[OrganizationsCreateResponse]
1436
+ Success
1437
+ """
1438
+ _response = await self._client_wrapper.httpx_client.request(
1439
+ "organizations",
1440
+ method="POST",
1441
+ json={
1442
+ "name": name,
1443
+ "slug": slug,
1444
+ },
1445
+ headers={
1446
+ "content-type": "application/json",
1447
+ },
1448
+ request_options=request_options,
1449
+ omit=OMIT,
1450
+ )
1451
+ try:
1452
+ if 200 <= _response.status_code < 300:
1453
+ _data = typing.cast(
1454
+ OrganizationsCreateResponse,
1455
+ parse_obj_as(
1456
+ type_=OrganizationsCreateResponse, # type: ignore
1457
+ object_=_response.json(),
1458
+ ),
1459
+ )
1460
+ return AsyncHttpResponse(response=_response, data=_data)
1461
+ if _response.status_code == 400:
1462
+ raise BadRequestError(
1463
+ headers=dict(_response.headers),
1464
+ body=typing.cast(
1465
+ typing.Optional[typing.Any],
1466
+ parse_obj_as(
1467
+ type_=typing.Optional[typing.Any], # type: ignore
1468
+ object_=_response.json(),
1469
+ ),
1470
+ ),
1471
+ )
1472
+ if _response.status_code == 404:
1473
+ raise NotFoundError(
1474
+ headers=dict(_response.headers),
1475
+ body=typing.cast(
1476
+ NotFoundErrorBody,
1477
+ parse_obj_as(
1478
+ type_=NotFoundErrorBody, # type: ignore
1479
+ object_=_response.json(),
1480
+ ),
1481
+ ),
1482
+ )
1483
+ if _response.status_code == 409:
1484
+ raise ConflictError(
1485
+ headers=dict(_response.headers),
1486
+ body=typing.cast(
1487
+ typing.Optional[typing.Any],
1488
+ parse_obj_as(
1489
+ type_=typing.Optional[typing.Any], # type: ignore
1490
+ object_=_response.json(),
1491
+ ),
1492
+ ),
1493
+ )
1494
+ if _response.status_code == 429:
1495
+ raise TooManyRequestsError(
1496
+ headers=dict(_response.headers),
1497
+ body=typing.cast(
1498
+ RateLimitError,
1499
+ parse_obj_as(
1500
+ type_=RateLimitError, # type: ignore
1501
+ object_=_response.json(),
1502
+ ),
1503
+ ),
1504
+ )
1505
+ if _response.status_code == 500:
1506
+ raise InternalServerError(
1507
+ headers=dict(_response.headers),
1508
+ body=typing.cast(
1509
+ typing.Optional[typing.Any],
1510
+ parse_obj_as(
1511
+ type_=typing.Optional[typing.Any], # type: ignore
1512
+ object_=_response.json(),
1513
+ ),
1514
+ ),
1515
+ )
1516
+ if _response.status_code == 503:
1517
+ raise ServiceUnavailableError(
1518
+ headers=dict(_response.headers),
1519
+ body=typing.cast(
1520
+ typing.Optional[typing.Any],
1521
+ parse_obj_as(
1522
+ type_=typing.Optional[typing.Any], # type: ignore
1523
+ object_=_response.json(),
1524
+ ),
1525
+ ),
1526
+ )
1527
+ _response_json = _response.json()
1528
+ except JSONDecodeError:
1529
+ raise ApiError(
1530
+ status_code=_response.status_code,
1531
+ headers=dict(_response.headers),
1532
+ body=_response.text,
1533
+ )
1534
+ raise ApiError(
1535
+ status_code=_response.status_code,
1536
+ headers=dict(_response.headers),
1537
+ body=_response_json,
1538
+ )
1539
+
1540
+ async def get(
1541
+ self, id: str, *, request_options: typing.Optional[RequestOptions] = None
1542
+ ) -> AsyncHttpResponse[OrganizationsGetResponse]:
1543
+ """
1544
+ Parameters
1545
+ ----------
1546
+ id : str
1547
+
1548
+ request_options : typing.Optional[RequestOptions]
1549
+ Request-specific configuration.
1550
+
1551
+ Returns
1552
+ -------
1553
+ AsyncHttpResponse[OrganizationsGetResponse]
1554
+ Success
1555
+ """
1556
+ _response = await self._client_wrapper.httpx_client.request(
1557
+ f"organizations/{jsonable_encoder(id)}",
1558
+ method="GET",
1559
+ request_options=request_options,
1560
+ )
1561
+ try:
1562
+ if 200 <= _response.status_code < 300:
1563
+ _data = typing.cast(
1564
+ OrganizationsGetResponse,
1565
+ parse_obj_as(
1566
+ type_=OrganizationsGetResponse, # type: ignore
1567
+ object_=_response.json(),
1568
+ ),
1569
+ )
1570
+ return AsyncHttpResponse(response=_response, data=_data)
1571
+ if _response.status_code == 400:
1572
+ raise BadRequestError(
1573
+ headers=dict(_response.headers),
1574
+ body=typing.cast(
1575
+ typing.Optional[typing.Any],
1576
+ parse_obj_as(
1577
+ type_=typing.Optional[typing.Any], # type: ignore
1578
+ object_=_response.json(),
1579
+ ),
1580
+ ),
1581
+ )
1582
+ if _response.status_code == 403:
1583
+ raise ForbiddenError(
1584
+ headers=dict(_response.headers),
1585
+ body=typing.cast(
1586
+ PermissionDeniedError,
1587
+ parse_obj_as(
1588
+ type_=PermissionDeniedError, # type: ignore
1589
+ object_=_response.json(),
1590
+ ),
1591
+ ),
1592
+ )
1593
+ if _response.status_code == 404:
1594
+ raise NotFoundError(
1595
+ headers=dict(_response.headers),
1596
+ body=typing.cast(
1597
+ NotFoundErrorBody,
1598
+ parse_obj_as(
1599
+ type_=NotFoundErrorBody, # type: ignore
1600
+ object_=_response.json(),
1601
+ ),
1602
+ ),
1603
+ )
1604
+ if _response.status_code == 429:
1605
+ raise TooManyRequestsError(
1606
+ headers=dict(_response.headers),
1607
+ body=typing.cast(
1608
+ RateLimitError,
1609
+ parse_obj_as(
1610
+ type_=RateLimitError, # type: ignore
1611
+ object_=_response.json(),
1612
+ ),
1613
+ ),
1614
+ )
1615
+ if _response.status_code == 500:
1616
+ raise InternalServerError(
1617
+ headers=dict(_response.headers),
1618
+ body=typing.cast(
1619
+ typing.Optional[typing.Any],
1620
+ parse_obj_as(
1621
+ type_=typing.Optional[typing.Any], # type: ignore
1622
+ object_=_response.json(),
1623
+ ),
1624
+ ),
1625
+ )
1626
+ if _response.status_code == 503:
1627
+ raise ServiceUnavailableError(
1628
+ headers=dict(_response.headers),
1629
+ body=typing.cast(
1630
+ typing.Optional[typing.Any],
1631
+ parse_obj_as(
1632
+ type_=typing.Optional[typing.Any], # type: ignore
1633
+ object_=_response.json(),
1634
+ ),
1635
+ ),
1636
+ )
1637
+ _response_json = _response.json()
1638
+ except JSONDecodeError:
1639
+ raise ApiError(
1640
+ status_code=_response.status_code,
1641
+ headers=dict(_response.headers),
1642
+ body=_response.text,
1643
+ )
1644
+ raise ApiError(
1645
+ status_code=_response.status_code,
1646
+ headers=dict(_response.headers),
1647
+ body=_response_json,
1648
+ )
1649
+
1650
+ async def update(
1651
+ self,
1652
+ id: str,
1653
+ *,
1654
+ name: typing.Optional[str] = OMIT,
1655
+ slug: typing.Optional[str] = OMIT,
1656
+ request_options: typing.Optional[RequestOptions] = None,
1657
+ ) -> AsyncHttpResponse[OrganizationsUpdateResponse]:
1658
+ """
1659
+ Parameters
1660
+ ----------
1661
+ id : str
1662
+
1663
+ name : typing.Optional[str]
1664
+ a string at most 100 character(s) long
1665
+
1666
+ slug : typing.Optional[str]
1667
+ a string matching the pattern ^[a-z0-9][a-z0-9_-]*[a-z0-9]$
1668
+
1669
+ request_options : typing.Optional[RequestOptions]
1670
+ Request-specific configuration.
1671
+
1672
+ Returns
1673
+ -------
1674
+ AsyncHttpResponse[OrganizationsUpdateResponse]
1675
+ Success
1676
+ """
1677
+ _response = await self._client_wrapper.httpx_client.request(
1678
+ f"organizations/{jsonable_encoder(id)}",
1679
+ method="PUT",
1680
+ json={
1681
+ "name": name,
1682
+ "slug": slug,
1683
+ },
1684
+ headers={
1685
+ "content-type": "application/json",
1686
+ },
1687
+ request_options=request_options,
1688
+ omit=OMIT,
1689
+ )
1690
+ try:
1691
+ if 200 <= _response.status_code < 300:
1692
+ _data = typing.cast(
1693
+ OrganizationsUpdateResponse,
1694
+ parse_obj_as(
1695
+ type_=OrganizationsUpdateResponse, # type: ignore
1696
+ object_=_response.json(),
1697
+ ),
1698
+ )
1699
+ return AsyncHttpResponse(response=_response, data=_data)
1700
+ if _response.status_code == 400:
1701
+ raise BadRequestError(
1702
+ headers=dict(_response.headers),
1703
+ body=typing.cast(
1704
+ typing.Optional[typing.Any],
1705
+ parse_obj_as(
1706
+ type_=typing.Optional[typing.Any], # type: ignore
1707
+ object_=_response.json(),
1708
+ ),
1709
+ ),
1710
+ )
1711
+ if _response.status_code == 403:
1712
+ raise ForbiddenError(
1713
+ headers=dict(_response.headers),
1714
+ body=typing.cast(
1715
+ PermissionDeniedError,
1716
+ parse_obj_as(
1717
+ type_=PermissionDeniedError, # type: ignore
1718
+ object_=_response.json(),
1719
+ ),
1720
+ ),
1721
+ )
1722
+ if _response.status_code == 404:
1723
+ raise NotFoundError(
1724
+ headers=dict(_response.headers),
1725
+ body=typing.cast(
1726
+ NotFoundErrorBody,
1727
+ parse_obj_as(
1728
+ type_=NotFoundErrorBody, # type: ignore
1729
+ object_=_response.json(),
1730
+ ),
1731
+ ),
1732
+ )
1733
+ if _response.status_code == 429:
1734
+ raise TooManyRequestsError(
1735
+ headers=dict(_response.headers),
1736
+ body=typing.cast(
1737
+ RateLimitError,
1738
+ parse_obj_as(
1739
+ type_=RateLimitError, # type: ignore
1740
+ object_=_response.json(),
1741
+ ),
1742
+ ),
1743
+ )
1744
+ if _response.status_code == 500:
1745
+ raise InternalServerError(
1746
+ headers=dict(_response.headers),
1747
+ body=typing.cast(
1748
+ typing.Optional[typing.Any],
1749
+ parse_obj_as(
1750
+ type_=typing.Optional[typing.Any], # type: ignore
1751
+ object_=_response.json(),
1752
+ ),
1753
+ ),
1754
+ )
1755
+ if _response.status_code == 503:
1756
+ raise ServiceUnavailableError(
1757
+ headers=dict(_response.headers),
1758
+ body=typing.cast(
1759
+ typing.Optional[typing.Any],
1760
+ parse_obj_as(
1761
+ type_=typing.Optional[typing.Any], # type: ignore
1762
+ object_=_response.json(),
1763
+ ),
1764
+ ),
1765
+ )
1766
+ _response_json = _response.json()
1767
+ except JSONDecodeError:
1768
+ raise ApiError(
1769
+ status_code=_response.status_code,
1770
+ headers=dict(_response.headers),
1771
+ body=_response.text,
1772
+ )
1773
+ raise ApiError(
1774
+ status_code=_response.status_code,
1775
+ headers=dict(_response.headers),
1776
+ body=_response_json,
1777
+ )
1778
+
1779
+ async def delete(
1780
+ self, id: str, *, request_options: typing.Optional[RequestOptions] = None
1781
+ ) -> AsyncHttpResponse[None]:
1782
+ """
1783
+ Parameters
1784
+ ----------
1785
+ id : str
1786
+
1787
+ request_options : typing.Optional[RequestOptions]
1788
+ Request-specific configuration.
1789
+
1790
+ Returns
1791
+ -------
1792
+ AsyncHttpResponse[None]
1793
+ """
1794
+ _response = await self._client_wrapper.httpx_client.request(
1795
+ f"organizations/{jsonable_encoder(id)}",
1796
+ method="DELETE",
1797
+ request_options=request_options,
1798
+ )
1799
+ try:
1800
+ if 200 <= _response.status_code < 300:
1801
+ return AsyncHttpResponse(response=_response, data=None)
1802
+ if _response.status_code == 400:
1803
+ raise BadRequestError(
1804
+ headers=dict(_response.headers),
1805
+ body=typing.cast(
1806
+ typing.Optional[typing.Any],
1807
+ parse_obj_as(
1808
+ type_=typing.Optional[typing.Any], # type: ignore
1809
+ object_=_response.json(),
1810
+ ),
1811
+ ),
1812
+ )
1813
+ if _response.status_code == 403:
1814
+ raise ForbiddenError(
1815
+ headers=dict(_response.headers),
1816
+ body=typing.cast(
1817
+ PermissionDeniedError,
1818
+ parse_obj_as(
1819
+ type_=PermissionDeniedError, # type: ignore
1820
+ object_=_response.json(),
1821
+ ),
1822
+ ),
1823
+ )
1824
+ if _response.status_code == 404:
1825
+ raise NotFoundError(
1826
+ headers=dict(_response.headers),
1827
+ body=typing.cast(
1828
+ NotFoundErrorBody,
1829
+ parse_obj_as(
1830
+ type_=NotFoundErrorBody, # type: ignore
1831
+ object_=_response.json(),
1832
+ ),
1833
+ ),
1834
+ )
1835
+ if _response.status_code == 409:
1836
+ raise ConflictError(
1837
+ headers=dict(_response.headers),
1838
+ body=typing.cast(
1839
+ typing.Optional[typing.Any],
1840
+ parse_obj_as(
1841
+ type_=typing.Optional[typing.Any], # type: ignore
1842
+ object_=_response.json(),
1843
+ ),
1844
+ ),
1845
+ )
1846
+ if _response.status_code == 429:
1847
+ raise TooManyRequestsError(
1848
+ headers=dict(_response.headers),
1849
+ body=typing.cast(
1850
+ RateLimitError,
1851
+ parse_obj_as(
1852
+ type_=RateLimitError, # type: ignore
1853
+ object_=_response.json(),
1854
+ ),
1855
+ ),
1856
+ )
1857
+ if _response.status_code == 500:
1858
+ raise InternalServerError(
1859
+ headers=dict(_response.headers),
1860
+ body=typing.cast(
1861
+ typing.Optional[typing.Any],
1862
+ parse_obj_as(
1863
+ type_=typing.Optional[typing.Any], # type: ignore
1864
+ object_=_response.json(),
1865
+ ),
1866
+ ),
1867
+ )
1868
+ if _response.status_code == 503:
1869
+ raise ServiceUnavailableError(
1870
+ headers=dict(_response.headers),
1871
+ body=typing.cast(
1872
+ typing.Optional[typing.Any],
1873
+ parse_obj_as(
1874
+ type_=typing.Optional[typing.Any], # type: ignore
1875
+ object_=_response.json(),
1876
+ ),
1877
+ ),
1878
+ )
1879
+ _response_json = _response.json()
1880
+ except JSONDecodeError:
1881
+ raise ApiError(
1882
+ status_code=_response.status_code,
1883
+ headers=dict(_response.headers),
1884
+ body=_response.text,
1885
+ )
1886
+ raise ApiError(
1887
+ status_code=_response.status_code,
1888
+ headers=dict(_response.headers),
1889
+ body=_response_json,
1890
+ )
1891
+
1892
+ async def routerbalance(
1893
+ self, id: str, *, request_options: typing.Optional[RequestOptions] = None
1894
+ ) -> AsyncHttpResponse[OrganizationsRouterBalanceResponse]:
1895
+ """
1896
+ Parameters
1897
+ ----------
1898
+ id : str
1899
+
1900
+ request_options : typing.Optional[RequestOptions]
1901
+ Request-specific configuration.
1902
+
1903
+ Returns
1904
+ -------
1905
+ AsyncHttpResponse[OrganizationsRouterBalanceResponse]
1906
+ Success
1907
+ """
1908
+ _response = await self._client_wrapper.httpx_client.request(
1909
+ f"organizations/{jsonable_encoder(id)}/router-balance",
1910
+ method="GET",
1911
+ request_options=request_options,
1912
+ )
1913
+ try:
1914
+ if 200 <= _response.status_code < 300:
1915
+ _data = typing.cast(
1916
+ OrganizationsRouterBalanceResponse,
1917
+ parse_obj_as(
1918
+ type_=OrganizationsRouterBalanceResponse, # type: ignore
1919
+ object_=_response.json(),
1920
+ ),
1921
+ )
1922
+ return AsyncHttpResponse(response=_response, data=_data)
1923
+ if _response.status_code == 400:
1924
+ raise BadRequestError(
1925
+ headers=dict(_response.headers),
1926
+ body=typing.cast(
1927
+ typing.Optional[typing.Any],
1928
+ parse_obj_as(
1929
+ type_=typing.Optional[typing.Any], # type: ignore
1930
+ object_=_response.json(),
1931
+ ),
1932
+ ),
1933
+ )
1934
+ if _response.status_code == 403:
1935
+ raise ForbiddenError(
1936
+ headers=dict(_response.headers),
1937
+ body=typing.cast(
1938
+ PermissionDeniedError,
1939
+ parse_obj_as(
1940
+ type_=PermissionDeniedError, # type: ignore
1941
+ object_=_response.json(),
1942
+ ),
1943
+ ),
1944
+ )
1945
+ if _response.status_code == 404:
1946
+ raise NotFoundError(
1947
+ headers=dict(_response.headers),
1948
+ body=typing.cast(
1949
+ NotFoundErrorBody,
1950
+ parse_obj_as(
1951
+ type_=NotFoundErrorBody, # type: ignore
1952
+ object_=_response.json(),
1953
+ ),
1954
+ ),
1955
+ )
1956
+ if _response.status_code == 429:
1957
+ raise TooManyRequestsError(
1958
+ headers=dict(_response.headers),
1959
+ body=typing.cast(
1960
+ RateLimitError,
1961
+ parse_obj_as(
1962
+ type_=RateLimitError, # type: ignore
1963
+ object_=_response.json(),
1964
+ ),
1965
+ ),
1966
+ )
1967
+ if _response.status_code == 500:
1968
+ raise InternalServerError(
1969
+ headers=dict(_response.headers),
1970
+ body=typing.cast(
1971
+ typing.Optional[typing.Any],
1972
+ parse_obj_as(
1973
+ type_=typing.Optional[typing.Any], # type: ignore
1974
+ object_=_response.json(),
1975
+ ),
1976
+ ),
1977
+ )
1978
+ if _response.status_code == 503:
1979
+ raise ServiceUnavailableError(
1980
+ headers=dict(_response.headers),
1981
+ body=typing.cast(
1982
+ typing.Optional[typing.Any],
1983
+ parse_obj_as(
1984
+ type_=typing.Optional[typing.Any], # type: ignore
1985
+ object_=_response.json(),
1986
+ ),
1987
+ ),
1988
+ )
1989
+ _response_json = _response.json()
1990
+ except JSONDecodeError:
1991
+ raise ApiError(
1992
+ status_code=_response.status_code,
1993
+ headers=dict(_response.headers),
1994
+ body=_response.text,
1995
+ )
1996
+ raise ApiError(
1997
+ status_code=_response.status_code,
1998
+ headers=dict(_response.headers),
1999
+ body=_response_json,
2000
+ )
2001
+
2002
+ async def createpaymentintent(
2003
+ self,
2004
+ id: str,
2005
+ *,
2006
+ amount: float,
2007
+ request_options: typing.Optional[RequestOptions] = None,
2008
+ ) -> AsyncHttpResponse[OrganizationsCreatePaymentIntentResponse]:
2009
+ """
2010
+ Parameters
2011
+ ----------
2012
+ id : str
2013
+
2014
+ amount : float
2015
+ a positive number
2016
+
2017
+ request_options : typing.Optional[RequestOptions]
2018
+ Request-specific configuration.
2019
+
2020
+ Returns
2021
+ -------
2022
+ AsyncHttpResponse[OrganizationsCreatePaymentIntentResponse]
2023
+ Success
2024
+ """
2025
+ _response = await self._client_wrapper.httpx_client.request(
2026
+ f"organizations/{jsonable_encoder(id)}/credits/payment-intent",
2027
+ method="POST",
2028
+ json={
2029
+ "amount": amount,
2030
+ },
2031
+ headers={
2032
+ "content-type": "application/json",
2033
+ },
2034
+ request_options=request_options,
2035
+ omit=OMIT,
2036
+ )
2037
+ try:
2038
+ if 200 <= _response.status_code < 300:
2039
+ _data = typing.cast(
2040
+ OrganizationsCreatePaymentIntentResponse,
2041
+ parse_obj_as(
2042
+ type_=OrganizationsCreatePaymentIntentResponse, # type: ignore
2043
+ object_=_response.json(),
2044
+ ),
2045
+ )
2046
+ return AsyncHttpResponse(response=_response, data=_data)
2047
+ if _response.status_code == 400:
2048
+ raise BadRequestError(
2049
+ headers=dict(_response.headers),
2050
+ body=typing.cast(
2051
+ typing.Optional[typing.Any],
2052
+ parse_obj_as(
2053
+ type_=typing.Optional[typing.Any], # type: ignore
2054
+ object_=_response.json(),
2055
+ ),
2056
+ ),
2057
+ )
2058
+ if _response.status_code == 403:
2059
+ raise ForbiddenError(
2060
+ headers=dict(_response.headers),
2061
+ body=typing.cast(
2062
+ PermissionDeniedError,
2063
+ parse_obj_as(
2064
+ type_=PermissionDeniedError, # type: ignore
2065
+ object_=_response.json(),
2066
+ ),
2067
+ ),
2068
+ )
2069
+ if _response.status_code == 404:
2070
+ raise NotFoundError(
2071
+ headers=dict(_response.headers),
2072
+ body=typing.cast(
2073
+ NotFoundErrorBody,
2074
+ parse_obj_as(
2075
+ type_=NotFoundErrorBody, # type: ignore
2076
+ object_=_response.json(),
2077
+ ),
2078
+ ),
2079
+ )
2080
+ if _response.status_code == 429:
2081
+ raise TooManyRequestsError(
2082
+ headers=dict(_response.headers),
2083
+ body=typing.cast(
2084
+ RateLimitError,
2085
+ parse_obj_as(
2086
+ type_=RateLimitError, # type: ignore
2087
+ object_=_response.json(),
2088
+ ),
2089
+ ),
2090
+ )
2091
+ if _response.status_code == 500:
2092
+ raise InternalServerError(
2093
+ headers=dict(_response.headers),
2094
+ body=typing.cast(
2095
+ typing.Optional[typing.Any],
2096
+ parse_obj_as(
2097
+ type_=typing.Optional[typing.Any], # type: ignore
2098
+ object_=_response.json(),
2099
+ ),
2100
+ ),
2101
+ )
2102
+ if _response.status_code == 503:
2103
+ raise ServiceUnavailableError(
2104
+ headers=dict(_response.headers),
2105
+ body=typing.cast(
2106
+ typing.Optional[typing.Any],
2107
+ parse_obj_as(
2108
+ type_=typing.Optional[typing.Any], # type: ignore
2109
+ object_=_response.json(),
2110
+ ),
2111
+ ),
2112
+ )
2113
+ _response_json = _response.json()
2114
+ except JSONDecodeError:
2115
+ raise ApiError(
2116
+ status_code=_response.status_code,
2117
+ headers=dict(_response.headers),
2118
+ body=_response.text,
2119
+ )
2120
+ raise ApiError(
2121
+ status_code=_response.status_code,
2122
+ headers=dict(_response.headers),
2123
+ body=_response_json,
2124
+ )
2125
+
2126
+ async def subscription(
2127
+ self, id: str, *, request_options: typing.Optional[RequestOptions] = None
2128
+ ) -> AsyncHttpResponse[OrganizationsSubscriptionResponse]:
2129
+ """
2130
+ Parameters
2131
+ ----------
2132
+ id : str
2133
+
2134
+ request_options : typing.Optional[RequestOptions]
2135
+ Request-specific configuration.
2136
+
2137
+ Returns
2138
+ -------
2139
+ AsyncHttpResponse[OrganizationsSubscriptionResponse]
2140
+ Success
2141
+ """
2142
+ _response = await self._client_wrapper.httpx_client.request(
2143
+ f"organizations/{jsonable_encoder(id)}/subscription",
2144
+ method="GET",
2145
+ request_options=request_options,
2146
+ )
2147
+ try:
2148
+ if 200 <= _response.status_code < 300:
2149
+ _data = typing.cast(
2150
+ OrganizationsSubscriptionResponse,
2151
+ parse_obj_as(
2152
+ type_=OrganizationsSubscriptionResponse, # type: ignore
2153
+ object_=_response.json(),
2154
+ ),
2155
+ )
2156
+ return AsyncHttpResponse(response=_response, data=_data)
2157
+ if _response.status_code == 400:
2158
+ raise BadRequestError(
2159
+ headers=dict(_response.headers),
2160
+ body=typing.cast(
2161
+ typing.Optional[typing.Any],
2162
+ parse_obj_as(
2163
+ type_=typing.Optional[typing.Any], # type: ignore
2164
+ object_=_response.json(),
2165
+ ),
2166
+ ),
2167
+ )
2168
+ if _response.status_code == 403:
2169
+ raise ForbiddenError(
2170
+ headers=dict(_response.headers),
2171
+ body=typing.cast(
2172
+ PermissionDeniedError,
2173
+ parse_obj_as(
2174
+ type_=PermissionDeniedError, # type: ignore
2175
+ object_=_response.json(),
2176
+ ),
2177
+ ),
2178
+ )
2179
+ if _response.status_code == 404:
2180
+ raise NotFoundError(
2181
+ headers=dict(_response.headers),
2182
+ body=typing.cast(
2183
+ NotFoundErrorBody,
2184
+ parse_obj_as(
2185
+ type_=NotFoundErrorBody, # type: ignore
2186
+ object_=_response.json(),
2187
+ ),
2188
+ ),
2189
+ )
2190
+ if _response.status_code == 429:
2191
+ raise TooManyRequestsError(
2192
+ headers=dict(_response.headers),
2193
+ body=typing.cast(
2194
+ RateLimitError,
2195
+ parse_obj_as(
2196
+ type_=RateLimitError, # type: ignore
2197
+ object_=_response.json(),
2198
+ ),
2199
+ ),
2200
+ )
2201
+ if _response.status_code == 500:
2202
+ raise InternalServerError(
2203
+ headers=dict(_response.headers),
2204
+ body=typing.cast(
2205
+ typing.Optional[typing.Any],
2206
+ parse_obj_as(
2207
+ type_=typing.Optional[typing.Any], # type: ignore
2208
+ object_=_response.json(),
2209
+ ),
2210
+ ),
2211
+ )
2212
+ if _response.status_code == 503:
2213
+ raise ServiceUnavailableError(
2214
+ headers=dict(_response.headers),
2215
+ body=typing.cast(
2216
+ typing.Optional[typing.Any],
2217
+ parse_obj_as(
2218
+ type_=typing.Optional[typing.Any], # type: ignore
2219
+ object_=_response.json(),
2220
+ ),
2221
+ ),
2222
+ )
2223
+ _response_json = _response.json()
2224
+ except JSONDecodeError:
2225
+ raise ApiError(
2226
+ status_code=_response.status_code,
2227
+ headers=dict(_response.headers),
2228
+ body=_response.text,
2229
+ )
2230
+ raise ApiError(
2231
+ status_code=_response.status_code,
2232
+ headers=dict(_response.headers),
2233
+ body=_response_json,
2234
+ )
2235
+
2236
+ async def previewsubscriptionchange(
2237
+ self,
2238
+ id: str,
2239
+ *,
2240
+ target_plan: OrganizationsPreviewSubscriptionChangeRequestTargetPlan,
2241
+ request_options: typing.Optional[RequestOptions] = None,
2242
+ ) -> AsyncHttpResponse[OrganizationsPreviewSubscriptionChangeResponse]:
2243
+ """
2244
+ Parameters
2245
+ ----------
2246
+ id : str
2247
+
2248
+ target_plan : OrganizationsPreviewSubscriptionChangeRequestTargetPlan
2249
+
2250
+ request_options : typing.Optional[RequestOptions]
2251
+ Request-specific configuration.
2252
+
2253
+ Returns
2254
+ -------
2255
+ AsyncHttpResponse[OrganizationsPreviewSubscriptionChangeResponse]
2256
+ Success
2257
+ """
2258
+ _response = await self._client_wrapper.httpx_client.request(
2259
+ f"organizations/{jsonable_encoder(id)}/subscription/preview",
2260
+ method="POST",
2261
+ json={
2262
+ "targetPlan": target_plan,
2263
+ },
2264
+ headers={
2265
+ "content-type": "application/json",
2266
+ },
2267
+ request_options=request_options,
2268
+ omit=OMIT,
2269
+ )
2270
+ try:
2271
+ if 200 <= _response.status_code < 300:
2272
+ _data = typing.cast(
2273
+ OrganizationsPreviewSubscriptionChangeResponse,
2274
+ parse_obj_as(
2275
+ type_=OrganizationsPreviewSubscriptionChangeResponse, # type: ignore
2276
+ object_=_response.json(),
2277
+ ),
2278
+ )
2279
+ return AsyncHttpResponse(response=_response, data=_data)
2280
+ if _response.status_code == 400:
2281
+ raise BadRequestError(
2282
+ headers=dict(_response.headers),
2283
+ body=typing.cast(
2284
+ typing.Optional[typing.Any],
2285
+ parse_obj_as(
2286
+ type_=typing.Optional[typing.Any], # type: ignore
2287
+ object_=_response.json(),
2288
+ ),
2289
+ ),
2290
+ )
2291
+ if _response.status_code == 403:
2292
+ raise ForbiddenError(
2293
+ headers=dict(_response.headers),
2294
+ body=typing.cast(
2295
+ PermissionDeniedError,
2296
+ parse_obj_as(
2297
+ type_=PermissionDeniedError, # type: ignore
2298
+ object_=_response.json(),
2299
+ ),
2300
+ ),
2301
+ )
2302
+ if _response.status_code == 404:
2303
+ raise NotFoundError(
2304
+ headers=dict(_response.headers),
2305
+ body=typing.cast(
2306
+ NotFoundErrorBody,
2307
+ parse_obj_as(
2308
+ type_=NotFoundErrorBody, # type: ignore
2309
+ object_=_response.json(),
2310
+ ),
2311
+ ),
2312
+ )
2313
+ if _response.status_code == 429:
2314
+ raise TooManyRequestsError(
2315
+ headers=dict(_response.headers),
2316
+ body=typing.cast(
2317
+ RateLimitError,
2318
+ parse_obj_as(
2319
+ type_=RateLimitError, # type: ignore
2320
+ object_=_response.json(),
2321
+ ),
2322
+ ),
2323
+ )
2324
+ if _response.status_code == 500:
2325
+ raise InternalServerError(
2326
+ headers=dict(_response.headers),
2327
+ body=typing.cast(
2328
+ typing.Optional[typing.Any],
2329
+ parse_obj_as(
2330
+ type_=typing.Optional[typing.Any], # type: ignore
2331
+ object_=_response.json(),
2332
+ ),
2333
+ ),
2334
+ )
2335
+ if _response.status_code == 503:
2336
+ raise ServiceUnavailableError(
2337
+ headers=dict(_response.headers),
2338
+ body=typing.cast(
2339
+ typing.Optional[typing.Any],
2340
+ parse_obj_as(
2341
+ type_=typing.Optional[typing.Any], # type: ignore
2342
+ object_=_response.json(),
2343
+ ),
2344
+ ),
2345
+ )
2346
+ _response_json = _response.json()
2347
+ except JSONDecodeError:
2348
+ raise ApiError(
2349
+ status_code=_response.status_code,
2350
+ headers=dict(_response.headers),
2351
+ body=_response.text,
2352
+ )
2353
+ raise ApiError(
2354
+ status_code=_response.status_code,
2355
+ headers=dict(_response.headers),
2356
+ body=_response_json,
2357
+ )
2358
+
2359
+ async def updatesubscription(
2360
+ self,
2361
+ id: str,
2362
+ *,
2363
+ target_plan: OrganizationsUpdateSubscriptionRequestTargetPlan,
2364
+ request_options: typing.Optional[RequestOptions] = None,
2365
+ ) -> AsyncHttpResponse[OrganizationsUpdateSubscriptionResponse]:
2366
+ """
2367
+ Parameters
2368
+ ----------
2369
+ id : str
2370
+
2371
+ target_plan : OrganizationsUpdateSubscriptionRequestTargetPlan
2372
+
2373
+ request_options : typing.Optional[RequestOptions]
2374
+ Request-specific configuration.
2375
+
2376
+ Returns
2377
+ -------
2378
+ AsyncHttpResponse[OrganizationsUpdateSubscriptionResponse]
2379
+ Success
2380
+ """
2381
+ _response = await self._client_wrapper.httpx_client.request(
2382
+ f"organizations/{jsonable_encoder(id)}/subscription/update",
2383
+ method="POST",
2384
+ json={
2385
+ "targetPlan": target_plan,
2386
+ },
2387
+ headers={
2388
+ "content-type": "application/json",
2389
+ },
2390
+ request_options=request_options,
2391
+ omit=OMIT,
2392
+ )
2393
+ try:
2394
+ if 200 <= _response.status_code < 300:
2395
+ _data = typing.cast(
2396
+ OrganizationsUpdateSubscriptionResponse,
2397
+ parse_obj_as(
2398
+ type_=OrganizationsUpdateSubscriptionResponse, # type: ignore
2399
+ object_=_response.json(),
2400
+ ),
2401
+ )
2402
+ return AsyncHttpResponse(response=_response, data=_data)
2403
+ if _response.status_code == 400:
2404
+ raise BadRequestError(
2405
+ headers=dict(_response.headers),
2406
+ body=typing.cast(
2407
+ typing.Optional[typing.Any],
2408
+ parse_obj_as(
2409
+ type_=typing.Optional[typing.Any], # type: ignore
2410
+ object_=_response.json(),
2411
+ ),
2412
+ ),
2413
+ )
2414
+ if _response.status_code == 402:
2415
+ raise PaymentRequiredError(
2416
+ headers=dict(_response.headers),
2417
+ body=typing.cast(
2418
+ PlanLimitExceededError,
2419
+ parse_obj_as(
2420
+ type_=PlanLimitExceededError, # type: ignore
2421
+ object_=_response.json(),
2422
+ ),
2423
+ ),
2424
+ )
2425
+ if _response.status_code == 403:
2426
+ raise ForbiddenError(
2427
+ headers=dict(_response.headers),
2428
+ body=typing.cast(
2429
+ PermissionDeniedError,
2430
+ parse_obj_as(
2431
+ type_=PermissionDeniedError, # type: ignore
2432
+ object_=_response.json(),
2433
+ ),
2434
+ ),
2435
+ )
2436
+ if _response.status_code == 404:
2437
+ raise NotFoundError(
2438
+ headers=dict(_response.headers),
2439
+ body=typing.cast(
2440
+ NotFoundErrorBody,
2441
+ parse_obj_as(
2442
+ type_=NotFoundErrorBody, # type: ignore
2443
+ object_=_response.json(),
2444
+ ),
2445
+ ),
2446
+ )
2447
+ if _response.status_code == 429:
2448
+ raise TooManyRequestsError(
2449
+ headers=dict(_response.headers),
2450
+ body=typing.cast(
2451
+ RateLimitError,
2452
+ parse_obj_as(
2453
+ type_=RateLimitError, # type: ignore
2454
+ object_=_response.json(),
2455
+ ),
2456
+ ),
2457
+ )
2458
+ if _response.status_code == 500:
2459
+ raise InternalServerError(
2460
+ headers=dict(_response.headers),
2461
+ body=typing.cast(
2462
+ typing.Optional[typing.Any],
2463
+ parse_obj_as(
2464
+ type_=typing.Optional[typing.Any], # type: ignore
2465
+ object_=_response.json(),
2466
+ ),
2467
+ ),
2468
+ )
2469
+ if _response.status_code == 503:
2470
+ raise ServiceUnavailableError(
2471
+ headers=dict(_response.headers),
2472
+ body=typing.cast(
2473
+ typing.Optional[typing.Any],
2474
+ parse_obj_as(
2475
+ type_=typing.Optional[typing.Any], # type: ignore
2476
+ object_=_response.json(),
2477
+ ),
2478
+ ),
2479
+ )
2480
+ _response_json = _response.json()
2481
+ except JSONDecodeError:
2482
+ raise ApiError(
2483
+ status_code=_response.status_code,
2484
+ headers=dict(_response.headers),
2485
+ body=_response.text,
2486
+ )
2487
+ raise ApiError(
2488
+ status_code=_response.status_code,
2489
+ headers=dict(_response.headers),
2490
+ body=_response_json,
2491
+ )
2492
+
2493
+ async def cancelscheduleddowngrade(
2494
+ self, id: str, *, request_options: typing.Optional[RequestOptions] = None
2495
+ ) -> AsyncHttpResponse[None]:
2496
+ """
2497
+ Parameters
2498
+ ----------
2499
+ id : str
2500
+
2501
+ request_options : typing.Optional[RequestOptions]
2502
+ Request-specific configuration.
2503
+
2504
+ Returns
2505
+ -------
2506
+ AsyncHttpResponse[None]
2507
+ """
2508
+ _response = await self._client_wrapper.httpx_client.request(
2509
+ f"organizations/{jsonable_encoder(id)}/subscription/cancel-downgrade",
2510
+ method="POST",
2511
+ request_options=request_options,
2512
+ )
2513
+ try:
2514
+ if 200 <= _response.status_code < 300:
2515
+ return AsyncHttpResponse(response=_response, data=None)
2516
+ if _response.status_code == 400:
2517
+ raise BadRequestError(
2518
+ headers=dict(_response.headers),
2519
+ body=typing.cast(
2520
+ typing.Optional[typing.Any],
2521
+ parse_obj_as(
2522
+ type_=typing.Optional[typing.Any], # type: ignore
2523
+ object_=_response.json(),
2524
+ ),
2525
+ ),
2526
+ )
2527
+ if _response.status_code == 403:
2528
+ raise ForbiddenError(
2529
+ headers=dict(_response.headers),
2530
+ body=typing.cast(
2531
+ PermissionDeniedError,
2532
+ parse_obj_as(
2533
+ type_=PermissionDeniedError, # type: ignore
2534
+ object_=_response.json(),
2535
+ ),
2536
+ ),
2537
+ )
2538
+ if _response.status_code == 404:
2539
+ raise NotFoundError(
2540
+ headers=dict(_response.headers),
2541
+ body=typing.cast(
2542
+ NotFoundErrorBody,
2543
+ parse_obj_as(
2544
+ type_=NotFoundErrorBody, # type: ignore
2545
+ object_=_response.json(),
2546
+ ),
2547
+ ),
2548
+ )
2549
+ if _response.status_code == 429:
2550
+ raise TooManyRequestsError(
2551
+ headers=dict(_response.headers),
2552
+ body=typing.cast(
2553
+ RateLimitError,
2554
+ parse_obj_as(
2555
+ type_=RateLimitError, # type: ignore
2556
+ object_=_response.json(),
2557
+ ),
2558
+ ),
2559
+ )
2560
+ if _response.status_code == 500:
2561
+ raise InternalServerError(
2562
+ headers=dict(_response.headers),
2563
+ body=typing.cast(
2564
+ typing.Optional[typing.Any],
2565
+ parse_obj_as(
2566
+ type_=typing.Optional[typing.Any], # type: ignore
2567
+ object_=_response.json(),
2568
+ ),
2569
+ ),
2570
+ )
2571
+ if _response.status_code == 503:
2572
+ raise ServiceUnavailableError(
2573
+ headers=dict(_response.headers),
2574
+ body=typing.cast(
2575
+ typing.Optional[typing.Any],
2576
+ parse_obj_as(
2577
+ type_=typing.Optional[typing.Any], # type: ignore
2578
+ object_=_response.json(),
2579
+ ),
2580
+ ),
2581
+ )
2582
+ _response_json = _response.json()
2583
+ except JSONDecodeError:
2584
+ raise ApiError(
2585
+ status_code=_response.status_code,
2586
+ headers=dict(_response.headers),
2587
+ body=_response.text,
2588
+ )
2589
+ raise ApiError(
2590
+ status_code=_response.status_code,
2591
+ headers=dict(_response.headers),
2592
+ body=_response_json,
2593
+ )