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,1890 @@
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 ..core.serialization import convert_and_respect_annotation_metadata
13
+ from ..errors.bad_request_error import BadRequestError
14
+ from ..errors.conflict_error import ConflictError
15
+ from ..errors.forbidden_error import ForbiddenError
16
+ from ..errors.internal_server_error import InternalServerError
17
+ from ..errors.not_found_error import NotFoundError
18
+ from ..errors.service_unavailable_error import ServiceUnavailableError
19
+ from ..errors.too_many_requests_error import TooManyRequestsError
20
+ from ..errors.unauthorized_error import UnauthorizedError
21
+ from ..types.not_found_error_body import NotFoundErrorBody
22
+ from ..types.permission_denied_error import PermissionDeniedError
23
+ from ..types.rate_limit_error import RateLimitError
24
+ from ..types.unauthorized_error_body import UnauthorizedErrorBody
25
+ from .types.functions_create_request_dependencies_value import (
26
+ FunctionsCreateRequestDependenciesValue,
27
+ )
28
+ from .types.functions_create_response import FunctionsCreateResponse
29
+ from .types.functions_find_by_hash_response import FunctionsFindByHashResponse
30
+ from .types.functions_get_by_env_response import FunctionsGetByEnvResponse
31
+ from .types.functions_get_response import FunctionsGetResponse
32
+ from .types.functions_list_by_env_response import FunctionsListByEnvResponse
33
+ from .types.functions_list_response import FunctionsListResponse
34
+
35
+ # this is used as the default value for optional parameters
36
+ OMIT = typing.cast(typing.Any, ...)
37
+
38
+
39
+ class RawFunctionsClient:
40
+ def __init__(self, *, client_wrapper: SyncClientWrapper):
41
+ self._client_wrapper = client_wrapper
42
+
43
+ def list(
44
+ self, *, request_options: typing.Optional[RequestOptions] = None
45
+ ) -> HttpResponse[FunctionsListResponse]:
46
+ """
47
+ Parameters
48
+ ----------
49
+ request_options : typing.Optional[RequestOptions]
50
+ Request-specific configuration.
51
+
52
+ Returns
53
+ -------
54
+ HttpResponse[FunctionsListResponse]
55
+ Success
56
+ """
57
+ _response = self._client_wrapper.httpx_client.request(
58
+ "functions",
59
+ method="GET",
60
+ request_options=request_options,
61
+ )
62
+ try:
63
+ if 200 <= _response.status_code < 300:
64
+ _data = typing.cast(
65
+ FunctionsListResponse,
66
+ parse_obj_as(
67
+ type_=FunctionsListResponse, # type: ignore
68
+ object_=_response.json(),
69
+ ),
70
+ )
71
+ return HttpResponse(response=_response, data=_data)
72
+ if _response.status_code == 400:
73
+ raise BadRequestError(
74
+ headers=dict(_response.headers),
75
+ body=typing.cast(
76
+ typing.Optional[typing.Any],
77
+ parse_obj_as(
78
+ type_=typing.Optional[typing.Any], # type: ignore
79
+ object_=_response.json(),
80
+ ),
81
+ ),
82
+ )
83
+ if _response.status_code == 401:
84
+ raise UnauthorizedError(
85
+ headers=dict(_response.headers),
86
+ body=typing.cast(
87
+ UnauthorizedErrorBody,
88
+ parse_obj_as(
89
+ type_=UnauthorizedErrorBody, # type: ignore
90
+ object_=_response.json(),
91
+ ),
92
+ ),
93
+ )
94
+ if _response.status_code == 403:
95
+ raise ForbiddenError(
96
+ headers=dict(_response.headers),
97
+ body=typing.cast(
98
+ PermissionDeniedError,
99
+ parse_obj_as(
100
+ type_=PermissionDeniedError, # type: ignore
101
+ object_=_response.json(),
102
+ ),
103
+ ),
104
+ )
105
+ if _response.status_code == 404:
106
+ raise NotFoundError(
107
+ headers=dict(_response.headers),
108
+ body=typing.cast(
109
+ NotFoundErrorBody,
110
+ parse_obj_as(
111
+ type_=NotFoundErrorBody, # type: ignore
112
+ object_=_response.json(),
113
+ ),
114
+ ),
115
+ )
116
+ if _response.status_code == 429:
117
+ raise TooManyRequestsError(
118
+ headers=dict(_response.headers),
119
+ body=typing.cast(
120
+ RateLimitError,
121
+ parse_obj_as(
122
+ type_=RateLimitError, # type: ignore
123
+ object_=_response.json(),
124
+ ),
125
+ ),
126
+ )
127
+ if _response.status_code == 500:
128
+ raise InternalServerError(
129
+ headers=dict(_response.headers),
130
+ body=typing.cast(
131
+ typing.Optional[typing.Any],
132
+ parse_obj_as(
133
+ type_=typing.Optional[typing.Any], # type: ignore
134
+ object_=_response.json(),
135
+ ),
136
+ ),
137
+ )
138
+ if _response.status_code == 503:
139
+ raise ServiceUnavailableError(
140
+ headers=dict(_response.headers),
141
+ body=typing.cast(
142
+ typing.Optional[typing.Any],
143
+ parse_obj_as(
144
+ type_=typing.Optional[typing.Any], # type: ignore
145
+ object_=_response.json(),
146
+ ),
147
+ ),
148
+ )
149
+ _response_json = _response.json()
150
+ except JSONDecodeError:
151
+ raise ApiError(
152
+ status_code=_response.status_code,
153
+ headers=dict(_response.headers),
154
+ body=_response.text,
155
+ )
156
+ raise ApiError(
157
+ status_code=_response.status_code,
158
+ headers=dict(_response.headers),
159
+ body=_response_json,
160
+ )
161
+
162
+ def create(
163
+ self,
164
+ *,
165
+ code: str,
166
+ hash: str,
167
+ signature: str,
168
+ signature_hash: str,
169
+ name: str,
170
+ description: typing.Optional[str] = OMIT,
171
+ tags: typing.Optional[typing.Sequence[str]] = OMIT,
172
+ metadata: typing.Optional[typing.Dict[str, typing.Optional[str]]] = OMIT,
173
+ dependencies: typing.Optional[
174
+ typing.Dict[str, typing.Optional[FunctionsCreateRequestDependenciesValue]]
175
+ ] = OMIT,
176
+ request_options: typing.Optional[RequestOptions] = None,
177
+ ) -> HttpResponse[FunctionsCreateResponse]:
178
+ """
179
+ Parameters
180
+ ----------
181
+ code : str
182
+
183
+ hash : str
184
+
185
+ signature : str
186
+
187
+ signature_hash : str
188
+
189
+ name : str
190
+
191
+ description : typing.Optional[str]
192
+
193
+ tags : typing.Optional[typing.Sequence[str]]
194
+
195
+ metadata : typing.Optional[typing.Dict[str, typing.Optional[str]]]
196
+
197
+ dependencies : typing.Optional[typing.Dict[str, typing.Optional[FunctionsCreateRequestDependenciesValue]]]
198
+
199
+ request_options : typing.Optional[RequestOptions]
200
+ Request-specific configuration.
201
+
202
+ Returns
203
+ -------
204
+ HttpResponse[FunctionsCreateResponse]
205
+ Success
206
+ """
207
+ _response = self._client_wrapper.httpx_client.request(
208
+ "functions",
209
+ method="POST",
210
+ json={
211
+ "code": code,
212
+ "hash": hash,
213
+ "signature": signature,
214
+ "signatureHash": signature_hash,
215
+ "name": name,
216
+ "description": description,
217
+ "tags": tags,
218
+ "metadata": metadata,
219
+ "dependencies": convert_and_respect_annotation_metadata(
220
+ object_=dependencies,
221
+ annotation=typing.Optional[
222
+ typing.Dict[
223
+ str,
224
+ typing.Optional[FunctionsCreateRequestDependenciesValue],
225
+ ]
226
+ ],
227
+ direction="write",
228
+ ),
229
+ },
230
+ headers={
231
+ "content-type": "application/json",
232
+ },
233
+ request_options=request_options,
234
+ omit=OMIT,
235
+ )
236
+ try:
237
+ if 200 <= _response.status_code < 300:
238
+ _data = typing.cast(
239
+ FunctionsCreateResponse,
240
+ parse_obj_as(
241
+ type_=FunctionsCreateResponse, # type: ignore
242
+ object_=_response.json(),
243
+ ),
244
+ )
245
+ return HttpResponse(response=_response, data=_data)
246
+ if _response.status_code == 400:
247
+ raise BadRequestError(
248
+ headers=dict(_response.headers),
249
+ body=typing.cast(
250
+ typing.Optional[typing.Any],
251
+ parse_obj_as(
252
+ type_=typing.Optional[typing.Any], # type: ignore
253
+ object_=_response.json(),
254
+ ),
255
+ ),
256
+ )
257
+ if _response.status_code == 401:
258
+ raise UnauthorizedError(
259
+ headers=dict(_response.headers),
260
+ body=typing.cast(
261
+ UnauthorizedErrorBody,
262
+ parse_obj_as(
263
+ type_=UnauthorizedErrorBody, # type: ignore
264
+ object_=_response.json(),
265
+ ),
266
+ ),
267
+ )
268
+ if _response.status_code == 403:
269
+ raise ForbiddenError(
270
+ headers=dict(_response.headers),
271
+ body=typing.cast(
272
+ PermissionDeniedError,
273
+ parse_obj_as(
274
+ type_=PermissionDeniedError, # type: ignore
275
+ object_=_response.json(),
276
+ ),
277
+ ),
278
+ )
279
+ if _response.status_code == 404:
280
+ raise NotFoundError(
281
+ headers=dict(_response.headers),
282
+ body=typing.cast(
283
+ NotFoundErrorBody,
284
+ parse_obj_as(
285
+ type_=NotFoundErrorBody, # type: ignore
286
+ object_=_response.json(),
287
+ ),
288
+ ),
289
+ )
290
+ if _response.status_code == 409:
291
+ raise ConflictError(
292
+ headers=dict(_response.headers),
293
+ body=typing.cast(
294
+ typing.Optional[typing.Any],
295
+ parse_obj_as(
296
+ type_=typing.Optional[typing.Any], # type: ignore
297
+ object_=_response.json(),
298
+ ),
299
+ ),
300
+ )
301
+ if _response.status_code == 429:
302
+ raise TooManyRequestsError(
303
+ headers=dict(_response.headers),
304
+ body=typing.cast(
305
+ RateLimitError,
306
+ parse_obj_as(
307
+ type_=RateLimitError, # type: ignore
308
+ object_=_response.json(),
309
+ ),
310
+ ),
311
+ )
312
+ if _response.status_code == 500:
313
+ raise InternalServerError(
314
+ headers=dict(_response.headers),
315
+ body=typing.cast(
316
+ typing.Optional[typing.Any],
317
+ parse_obj_as(
318
+ type_=typing.Optional[typing.Any], # type: ignore
319
+ object_=_response.json(),
320
+ ),
321
+ ),
322
+ )
323
+ if _response.status_code == 503:
324
+ raise ServiceUnavailableError(
325
+ headers=dict(_response.headers),
326
+ body=typing.cast(
327
+ typing.Optional[typing.Any],
328
+ parse_obj_as(
329
+ type_=typing.Optional[typing.Any], # type: ignore
330
+ object_=_response.json(),
331
+ ),
332
+ ),
333
+ )
334
+ _response_json = _response.json()
335
+ except JSONDecodeError:
336
+ raise ApiError(
337
+ status_code=_response.status_code,
338
+ headers=dict(_response.headers),
339
+ body=_response.text,
340
+ )
341
+ raise ApiError(
342
+ status_code=_response.status_code,
343
+ headers=dict(_response.headers),
344
+ body=_response_json,
345
+ )
346
+
347
+ def get(
348
+ self, id: str, *, request_options: typing.Optional[RequestOptions] = None
349
+ ) -> HttpResponse[FunctionsGetResponse]:
350
+ """
351
+ Parameters
352
+ ----------
353
+ id : str
354
+
355
+ request_options : typing.Optional[RequestOptions]
356
+ Request-specific configuration.
357
+
358
+ Returns
359
+ -------
360
+ HttpResponse[FunctionsGetResponse]
361
+ Success
362
+ """
363
+ _response = self._client_wrapper.httpx_client.request(
364
+ f"functions/{jsonable_encoder(id)}",
365
+ method="GET",
366
+ request_options=request_options,
367
+ )
368
+ try:
369
+ if 200 <= _response.status_code < 300:
370
+ _data = typing.cast(
371
+ FunctionsGetResponse,
372
+ parse_obj_as(
373
+ type_=FunctionsGetResponse, # type: ignore
374
+ object_=_response.json(),
375
+ ),
376
+ )
377
+ return HttpResponse(response=_response, data=_data)
378
+ if _response.status_code == 400:
379
+ raise BadRequestError(
380
+ headers=dict(_response.headers),
381
+ body=typing.cast(
382
+ typing.Optional[typing.Any],
383
+ parse_obj_as(
384
+ type_=typing.Optional[typing.Any], # type: ignore
385
+ object_=_response.json(),
386
+ ),
387
+ ),
388
+ )
389
+ if _response.status_code == 401:
390
+ raise UnauthorizedError(
391
+ headers=dict(_response.headers),
392
+ body=typing.cast(
393
+ UnauthorizedErrorBody,
394
+ parse_obj_as(
395
+ type_=UnauthorizedErrorBody, # type: ignore
396
+ object_=_response.json(),
397
+ ),
398
+ ),
399
+ )
400
+ if _response.status_code == 403:
401
+ raise ForbiddenError(
402
+ headers=dict(_response.headers),
403
+ body=typing.cast(
404
+ PermissionDeniedError,
405
+ parse_obj_as(
406
+ type_=PermissionDeniedError, # type: ignore
407
+ object_=_response.json(),
408
+ ),
409
+ ),
410
+ )
411
+ if _response.status_code == 404:
412
+ raise NotFoundError(
413
+ headers=dict(_response.headers),
414
+ body=typing.cast(
415
+ NotFoundErrorBody,
416
+ parse_obj_as(
417
+ type_=NotFoundErrorBody, # type: ignore
418
+ object_=_response.json(),
419
+ ),
420
+ ),
421
+ )
422
+ if _response.status_code == 429:
423
+ raise TooManyRequestsError(
424
+ headers=dict(_response.headers),
425
+ body=typing.cast(
426
+ RateLimitError,
427
+ parse_obj_as(
428
+ type_=RateLimitError, # type: ignore
429
+ object_=_response.json(),
430
+ ),
431
+ ),
432
+ )
433
+ if _response.status_code == 500:
434
+ raise InternalServerError(
435
+ headers=dict(_response.headers),
436
+ body=typing.cast(
437
+ typing.Optional[typing.Any],
438
+ parse_obj_as(
439
+ type_=typing.Optional[typing.Any], # type: ignore
440
+ object_=_response.json(),
441
+ ),
442
+ ),
443
+ )
444
+ if _response.status_code == 503:
445
+ raise ServiceUnavailableError(
446
+ headers=dict(_response.headers),
447
+ body=typing.cast(
448
+ typing.Optional[typing.Any],
449
+ parse_obj_as(
450
+ type_=typing.Optional[typing.Any], # type: ignore
451
+ object_=_response.json(),
452
+ ),
453
+ ),
454
+ )
455
+ _response_json = _response.json()
456
+ except JSONDecodeError:
457
+ raise ApiError(
458
+ status_code=_response.status_code,
459
+ headers=dict(_response.headers),
460
+ body=_response.text,
461
+ )
462
+ raise ApiError(
463
+ status_code=_response.status_code,
464
+ headers=dict(_response.headers),
465
+ body=_response_json,
466
+ )
467
+
468
+ def delete(
469
+ self, id: str, *, request_options: typing.Optional[RequestOptions] = None
470
+ ) -> HttpResponse[None]:
471
+ """
472
+ Parameters
473
+ ----------
474
+ id : str
475
+
476
+ request_options : typing.Optional[RequestOptions]
477
+ Request-specific configuration.
478
+
479
+ Returns
480
+ -------
481
+ HttpResponse[None]
482
+ """
483
+ _response = self._client_wrapper.httpx_client.request(
484
+ f"functions/{jsonable_encoder(id)}",
485
+ method="DELETE",
486
+ request_options=request_options,
487
+ )
488
+ try:
489
+ if 200 <= _response.status_code < 300:
490
+ return HttpResponse(response=_response, data=None)
491
+ if _response.status_code == 400:
492
+ raise BadRequestError(
493
+ headers=dict(_response.headers),
494
+ body=typing.cast(
495
+ typing.Optional[typing.Any],
496
+ parse_obj_as(
497
+ type_=typing.Optional[typing.Any], # type: ignore
498
+ object_=_response.json(),
499
+ ),
500
+ ),
501
+ )
502
+ if _response.status_code == 401:
503
+ raise UnauthorizedError(
504
+ headers=dict(_response.headers),
505
+ body=typing.cast(
506
+ UnauthorizedErrorBody,
507
+ parse_obj_as(
508
+ type_=UnauthorizedErrorBody, # type: ignore
509
+ object_=_response.json(),
510
+ ),
511
+ ),
512
+ )
513
+ if _response.status_code == 403:
514
+ raise ForbiddenError(
515
+ headers=dict(_response.headers),
516
+ body=typing.cast(
517
+ PermissionDeniedError,
518
+ parse_obj_as(
519
+ type_=PermissionDeniedError, # type: ignore
520
+ object_=_response.json(),
521
+ ),
522
+ ),
523
+ )
524
+ if _response.status_code == 404:
525
+ raise NotFoundError(
526
+ headers=dict(_response.headers),
527
+ body=typing.cast(
528
+ NotFoundErrorBody,
529
+ parse_obj_as(
530
+ type_=NotFoundErrorBody, # type: ignore
531
+ object_=_response.json(),
532
+ ),
533
+ ),
534
+ )
535
+ if _response.status_code == 429:
536
+ raise TooManyRequestsError(
537
+ headers=dict(_response.headers),
538
+ body=typing.cast(
539
+ RateLimitError,
540
+ parse_obj_as(
541
+ type_=RateLimitError, # type: ignore
542
+ object_=_response.json(),
543
+ ),
544
+ ),
545
+ )
546
+ if _response.status_code == 500:
547
+ raise InternalServerError(
548
+ headers=dict(_response.headers),
549
+ body=typing.cast(
550
+ typing.Optional[typing.Any],
551
+ parse_obj_as(
552
+ type_=typing.Optional[typing.Any], # type: ignore
553
+ object_=_response.json(),
554
+ ),
555
+ ),
556
+ )
557
+ if _response.status_code == 503:
558
+ raise ServiceUnavailableError(
559
+ headers=dict(_response.headers),
560
+ body=typing.cast(
561
+ typing.Optional[typing.Any],
562
+ parse_obj_as(
563
+ type_=typing.Optional[typing.Any], # type: ignore
564
+ object_=_response.json(),
565
+ ),
566
+ ),
567
+ )
568
+ _response_json = _response.json()
569
+ except JSONDecodeError:
570
+ raise ApiError(
571
+ status_code=_response.status_code,
572
+ headers=dict(_response.headers),
573
+ body=_response.text,
574
+ )
575
+ raise ApiError(
576
+ status_code=_response.status_code,
577
+ headers=dict(_response.headers),
578
+ body=_response_json,
579
+ )
580
+
581
+ def findbyhash(
582
+ self, hash: str, *, request_options: typing.Optional[RequestOptions] = None
583
+ ) -> HttpResponse[FunctionsFindByHashResponse]:
584
+ """
585
+ Parameters
586
+ ----------
587
+ hash : str
588
+
589
+ request_options : typing.Optional[RequestOptions]
590
+ Request-specific configuration.
591
+
592
+ Returns
593
+ -------
594
+ HttpResponse[FunctionsFindByHashResponse]
595
+ Success
596
+ """
597
+ _response = self._client_wrapper.httpx_client.request(
598
+ f"functions/hash/{jsonable_encoder(hash)}",
599
+ method="GET",
600
+ request_options=request_options,
601
+ )
602
+ try:
603
+ if 200 <= _response.status_code < 300:
604
+ _data = typing.cast(
605
+ FunctionsFindByHashResponse,
606
+ parse_obj_as(
607
+ type_=FunctionsFindByHashResponse, # type: ignore
608
+ object_=_response.json(),
609
+ ),
610
+ )
611
+ return HttpResponse(response=_response, data=_data)
612
+ if _response.status_code == 400:
613
+ raise BadRequestError(
614
+ headers=dict(_response.headers),
615
+ body=typing.cast(
616
+ typing.Optional[typing.Any],
617
+ parse_obj_as(
618
+ type_=typing.Optional[typing.Any], # type: ignore
619
+ object_=_response.json(),
620
+ ),
621
+ ),
622
+ )
623
+ if _response.status_code == 401:
624
+ raise UnauthorizedError(
625
+ headers=dict(_response.headers),
626
+ body=typing.cast(
627
+ UnauthorizedErrorBody,
628
+ parse_obj_as(
629
+ type_=UnauthorizedErrorBody, # type: ignore
630
+ object_=_response.json(),
631
+ ),
632
+ ),
633
+ )
634
+ if _response.status_code == 403:
635
+ raise ForbiddenError(
636
+ headers=dict(_response.headers),
637
+ body=typing.cast(
638
+ PermissionDeniedError,
639
+ parse_obj_as(
640
+ type_=PermissionDeniedError, # type: ignore
641
+ object_=_response.json(),
642
+ ),
643
+ ),
644
+ )
645
+ if _response.status_code == 404:
646
+ raise NotFoundError(
647
+ headers=dict(_response.headers),
648
+ body=typing.cast(
649
+ NotFoundErrorBody,
650
+ parse_obj_as(
651
+ type_=NotFoundErrorBody, # type: ignore
652
+ object_=_response.json(),
653
+ ),
654
+ ),
655
+ )
656
+ if _response.status_code == 429:
657
+ raise TooManyRequestsError(
658
+ headers=dict(_response.headers),
659
+ body=typing.cast(
660
+ RateLimitError,
661
+ parse_obj_as(
662
+ type_=RateLimitError, # type: ignore
663
+ object_=_response.json(),
664
+ ),
665
+ ),
666
+ )
667
+ if _response.status_code == 500:
668
+ raise InternalServerError(
669
+ headers=dict(_response.headers),
670
+ body=typing.cast(
671
+ typing.Optional[typing.Any],
672
+ parse_obj_as(
673
+ type_=typing.Optional[typing.Any], # type: ignore
674
+ object_=_response.json(),
675
+ ),
676
+ ),
677
+ )
678
+ if _response.status_code == 503:
679
+ raise ServiceUnavailableError(
680
+ headers=dict(_response.headers),
681
+ body=typing.cast(
682
+ typing.Optional[typing.Any],
683
+ parse_obj_as(
684
+ type_=typing.Optional[typing.Any], # type: ignore
685
+ object_=_response.json(),
686
+ ),
687
+ ),
688
+ )
689
+ _response_json = _response.json()
690
+ except JSONDecodeError:
691
+ raise ApiError(
692
+ status_code=_response.status_code,
693
+ headers=dict(_response.headers),
694
+ body=_response.text,
695
+ )
696
+ raise ApiError(
697
+ status_code=_response.status_code,
698
+ headers=dict(_response.headers),
699
+ body=_response_json,
700
+ )
701
+
702
+ def getbyenv(
703
+ self,
704
+ organization_id: str,
705
+ project_id: str,
706
+ environment_id: str,
707
+ function_id: str,
708
+ *,
709
+ request_options: typing.Optional[RequestOptions] = None,
710
+ ) -> HttpResponse[FunctionsGetByEnvResponse]:
711
+ """
712
+ Parameters
713
+ ----------
714
+ organization_id : str
715
+
716
+ project_id : str
717
+
718
+ environment_id : str
719
+
720
+ function_id : str
721
+
722
+ request_options : typing.Optional[RequestOptions]
723
+ Request-specific configuration.
724
+
725
+ Returns
726
+ -------
727
+ HttpResponse[FunctionsGetByEnvResponse]
728
+ Success
729
+ """
730
+ _response = self._client_wrapper.httpx_client.request(
731
+ f"organizations/{jsonable_encoder(organization_id)}/projects/{jsonable_encoder(project_id)}/environments/{jsonable_encoder(environment_id)}/functions/{jsonable_encoder(function_id)}",
732
+ method="GET",
733
+ request_options=request_options,
734
+ )
735
+ try:
736
+ if 200 <= _response.status_code < 300:
737
+ _data = typing.cast(
738
+ FunctionsGetByEnvResponse,
739
+ parse_obj_as(
740
+ type_=FunctionsGetByEnvResponse, # type: ignore
741
+ object_=_response.json(),
742
+ ),
743
+ )
744
+ return HttpResponse(response=_response, data=_data)
745
+ if _response.status_code == 400:
746
+ raise BadRequestError(
747
+ headers=dict(_response.headers),
748
+ body=typing.cast(
749
+ typing.Optional[typing.Any],
750
+ parse_obj_as(
751
+ type_=typing.Optional[typing.Any], # type: ignore
752
+ object_=_response.json(),
753
+ ),
754
+ ),
755
+ )
756
+ if _response.status_code == 401:
757
+ raise UnauthorizedError(
758
+ headers=dict(_response.headers),
759
+ body=typing.cast(
760
+ UnauthorizedErrorBody,
761
+ parse_obj_as(
762
+ type_=UnauthorizedErrorBody, # type: ignore
763
+ object_=_response.json(),
764
+ ),
765
+ ),
766
+ )
767
+ if _response.status_code == 403:
768
+ raise ForbiddenError(
769
+ headers=dict(_response.headers),
770
+ body=typing.cast(
771
+ PermissionDeniedError,
772
+ parse_obj_as(
773
+ type_=PermissionDeniedError, # type: ignore
774
+ object_=_response.json(),
775
+ ),
776
+ ),
777
+ )
778
+ if _response.status_code == 404:
779
+ raise NotFoundError(
780
+ headers=dict(_response.headers),
781
+ body=typing.cast(
782
+ NotFoundErrorBody,
783
+ parse_obj_as(
784
+ type_=NotFoundErrorBody, # type: ignore
785
+ object_=_response.json(),
786
+ ),
787
+ ),
788
+ )
789
+ if _response.status_code == 429:
790
+ raise TooManyRequestsError(
791
+ headers=dict(_response.headers),
792
+ body=typing.cast(
793
+ RateLimitError,
794
+ parse_obj_as(
795
+ type_=RateLimitError, # type: ignore
796
+ object_=_response.json(),
797
+ ),
798
+ ),
799
+ )
800
+ if _response.status_code == 500:
801
+ raise InternalServerError(
802
+ headers=dict(_response.headers),
803
+ body=typing.cast(
804
+ typing.Optional[typing.Any],
805
+ parse_obj_as(
806
+ type_=typing.Optional[typing.Any], # type: ignore
807
+ object_=_response.json(),
808
+ ),
809
+ ),
810
+ )
811
+ if _response.status_code == 503:
812
+ raise ServiceUnavailableError(
813
+ headers=dict(_response.headers),
814
+ body=typing.cast(
815
+ typing.Optional[typing.Any],
816
+ parse_obj_as(
817
+ type_=typing.Optional[typing.Any], # type: ignore
818
+ object_=_response.json(),
819
+ ),
820
+ ),
821
+ )
822
+ _response_json = _response.json()
823
+ except JSONDecodeError:
824
+ raise ApiError(
825
+ status_code=_response.status_code,
826
+ headers=dict(_response.headers),
827
+ body=_response.text,
828
+ )
829
+ raise ApiError(
830
+ status_code=_response.status_code,
831
+ headers=dict(_response.headers),
832
+ body=_response_json,
833
+ )
834
+
835
+ def listbyenv(
836
+ self,
837
+ organization_id: str,
838
+ project_id: str,
839
+ environment_id: str,
840
+ *,
841
+ request_options: typing.Optional[RequestOptions] = None,
842
+ ) -> HttpResponse[FunctionsListByEnvResponse]:
843
+ """
844
+ Parameters
845
+ ----------
846
+ organization_id : str
847
+
848
+ project_id : str
849
+
850
+ environment_id : str
851
+
852
+ request_options : typing.Optional[RequestOptions]
853
+ Request-specific configuration.
854
+
855
+ Returns
856
+ -------
857
+ HttpResponse[FunctionsListByEnvResponse]
858
+ Success
859
+ """
860
+ _response = self._client_wrapper.httpx_client.request(
861
+ f"organizations/{jsonable_encoder(organization_id)}/projects/{jsonable_encoder(project_id)}/environments/{jsonable_encoder(environment_id)}/functions",
862
+ method="GET",
863
+ request_options=request_options,
864
+ )
865
+ try:
866
+ if 200 <= _response.status_code < 300:
867
+ _data = typing.cast(
868
+ FunctionsListByEnvResponse,
869
+ parse_obj_as(
870
+ type_=FunctionsListByEnvResponse, # type: ignore
871
+ object_=_response.json(),
872
+ ),
873
+ )
874
+ return HttpResponse(response=_response, data=_data)
875
+ if _response.status_code == 400:
876
+ raise BadRequestError(
877
+ headers=dict(_response.headers),
878
+ body=typing.cast(
879
+ typing.Optional[typing.Any],
880
+ parse_obj_as(
881
+ type_=typing.Optional[typing.Any], # type: ignore
882
+ object_=_response.json(),
883
+ ),
884
+ ),
885
+ )
886
+ if _response.status_code == 401:
887
+ raise UnauthorizedError(
888
+ headers=dict(_response.headers),
889
+ body=typing.cast(
890
+ UnauthorizedErrorBody,
891
+ parse_obj_as(
892
+ type_=UnauthorizedErrorBody, # type: ignore
893
+ object_=_response.json(),
894
+ ),
895
+ ),
896
+ )
897
+ if _response.status_code == 403:
898
+ raise ForbiddenError(
899
+ headers=dict(_response.headers),
900
+ body=typing.cast(
901
+ PermissionDeniedError,
902
+ parse_obj_as(
903
+ type_=PermissionDeniedError, # type: ignore
904
+ object_=_response.json(),
905
+ ),
906
+ ),
907
+ )
908
+ if _response.status_code == 404:
909
+ raise NotFoundError(
910
+ headers=dict(_response.headers),
911
+ body=typing.cast(
912
+ NotFoundErrorBody,
913
+ parse_obj_as(
914
+ type_=NotFoundErrorBody, # type: ignore
915
+ object_=_response.json(),
916
+ ),
917
+ ),
918
+ )
919
+ if _response.status_code == 429:
920
+ raise TooManyRequestsError(
921
+ headers=dict(_response.headers),
922
+ body=typing.cast(
923
+ RateLimitError,
924
+ parse_obj_as(
925
+ type_=RateLimitError, # type: ignore
926
+ object_=_response.json(),
927
+ ),
928
+ ),
929
+ )
930
+ if _response.status_code == 500:
931
+ raise InternalServerError(
932
+ headers=dict(_response.headers),
933
+ body=typing.cast(
934
+ typing.Optional[typing.Any],
935
+ parse_obj_as(
936
+ type_=typing.Optional[typing.Any], # type: ignore
937
+ object_=_response.json(),
938
+ ),
939
+ ),
940
+ )
941
+ if _response.status_code == 503:
942
+ raise ServiceUnavailableError(
943
+ headers=dict(_response.headers),
944
+ body=typing.cast(
945
+ typing.Optional[typing.Any],
946
+ parse_obj_as(
947
+ type_=typing.Optional[typing.Any], # type: ignore
948
+ object_=_response.json(),
949
+ ),
950
+ ),
951
+ )
952
+ _response_json = _response.json()
953
+ except JSONDecodeError:
954
+ raise ApiError(
955
+ status_code=_response.status_code,
956
+ headers=dict(_response.headers),
957
+ body=_response.text,
958
+ )
959
+ raise ApiError(
960
+ status_code=_response.status_code,
961
+ headers=dict(_response.headers),
962
+ body=_response_json,
963
+ )
964
+
965
+
966
+ class AsyncRawFunctionsClient:
967
+ def __init__(self, *, client_wrapper: AsyncClientWrapper):
968
+ self._client_wrapper = client_wrapper
969
+
970
+ async def list(
971
+ self, *, request_options: typing.Optional[RequestOptions] = None
972
+ ) -> AsyncHttpResponse[FunctionsListResponse]:
973
+ """
974
+ Parameters
975
+ ----------
976
+ request_options : typing.Optional[RequestOptions]
977
+ Request-specific configuration.
978
+
979
+ Returns
980
+ -------
981
+ AsyncHttpResponse[FunctionsListResponse]
982
+ Success
983
+ """
984
+ _response = await self._client_wrapper.httpx_client.request(
985
+ "functions",
986
+ method="GET",
987
+ request_options=request_options,
988
+ )
989
+ try:
990
+ if 200 <= _response.status_code < 300:
991
+ _data = typing.cast(
992
+ FunctionsListResponse,
993
+ parse_obj_as(
994
+ type_=FunctionsListResponse, # type: ignore
995
+ object_=_response.json(),
996
+ ),
997
+ )
998
+ return AsyncHttpResponse(response=_response, data=_data)
999
+ if _response.status_code == 400:
1000
+ raise BadRequestError(
1001
+ headers=dict(_response.headers),
1002
+ body=typing.cast(
1003
+ typing.Optional[typing.Any],
1004
+ parse_obj_as(
1005
+ type_=typing.Optional[typing.Any], # type: ignore
1006
+ object_=_response.json(),
1007
+ ),
1008
+ ),
1009
+ )
1010
+ if _response.status_code == 401:
1011
+ raise UnauthorizedError(
1012
+ headers=dict(_response.headers),
1013
+ body=typing.cast(
1014
+ UnauthorizedErrorBody,
1015
+ parse_obj_as(
1016
+ type_=UnauthorizedErrorBody, # type: ignore
1017
+ object_=_response.json(),
1018
+ ),
1019
+ ),
1020
+ )
1021
+ if _response.status_code == 403:
1022
+ raise ForbiddenError(
1023
+ headers=dict(_response.headers),
1024
+ body=typing.cast(
1025
+ PermissionDeniedError,
1026
+ parse_obj_as(
1027
+ type_=PermissionDeniedError, # type: ignore
1028
+ object_=_response.json(),
1029
+ ),
1030
+ ),
1031
+ )
1032
+ if _response.status_code == 404:
1033
+ raise NotFoundError(
1034
+ headers=dict(_response.headers),
1035
+ body=typing.cast(
1036
+ NotFoundErrorBody,
1037
+ parse_obj_as(
1038
+ type_=NotFoundErrorBody, # type: ignore
1039
+ object_=_response.json(),
1040
+ ),
1041
+ ),
1042
+ )
1043
+ if _response.status_code == 429:
1044
+ raise TooManyRequestsError(
1045
+ headers=dict(_response.headers),
1046
+ body=typing.cast(
1047
+ RateLimitError,
1048
+ parse_obj_as(
1049
+ type_=RateLimitError, # type: ignore
1050
+ object_=_response.json(),
1051
+ ),
1052
+ ),
1053
+ )
1054
+ if _response.status_code == 500:
1055
+ raise InternalServerError(
1056
+ headers=dict(_response.headers),
1057
+ body=typing.cast(
1058
+ typing.Optional[typing.Any],
1059
+ parse_obj_as(
1060
+ type_=typing.Optional[typing.Any], # type: ignore
1061
+ object_=_response.json(),
1062
+ ),
1063
+ ),
1064
+ )
1065
+ if _response.status_code == 503:
1066
+ raise ServiceUnavailableError(
1067
+ headers=dict(_response.headers),
1068
+ body=typing.cast(
1069
+ typing.Optional[typing.Any],
1070
+ parse_obj_as(
1071
+ type_=typing.Optional[typing.Any], # type: ignore
1072
+ object_=_response.json(),
1073
+ ),
1074
+ ),
1075
+ )
1076
+ _response_json = _response.json()
1077
+ except JSONDecodeError:
1078
+ raise ApiError(
1079
+ status_code=_response.status_code,
1080
+ headers=dict(_response.headers),
1081
+ body=_response.text,
1082
+ )
1083
+ raise ApiError(
1084
+ status_code=_response.status_code,
1085
+ headers=dict(_response.headers),
1086
+ body=_response_json,
1087
+ )
1088
+
1089
+ async def create(
1090
+ self,
1091
+ *,
1092
+ code: str,
1093
+ hash: str,
1094
+ signature: str,
1095
+ signature_hash: str,
1096
+ name: str,
1097
+ description: typing.Optional[str] = OMIT,
1098
+ tags: typing.Optional[typing.Sequence[str]] = OMIT,
1099
+ metadata: typing.Optional[typing.Dict[str, typing.Optional[str]]] = OMIT,
1100
+ dependencies: typing.Optional[
1101
+ typing.Dict[str, typing.Optional[FunctionsCreateRequestDependenciesValue]]
1102
+ ] = OMIT,
1103
+ request_options: typing.Optional[RequestOptions] = None,
1104
+ ) -> AsyncHttpResponse[FunctionsCreateResponse]:
1105
+ """
1106
+ Parameters
1107
+ ----------
1108
+ code : str
1109
+
1110
+ hash : str
1111
+
1112
+ signature : str
1113
+
1114
+ signature_hash : str
1115
+
1116
+ name : str
1117
+
1118
+ description : typing.Optional[str]
1119
+
1120
+ tags : typing.Optional[typing.Sequence[str]]
1121
+
1122
+ metadata : typing.Optional[typing.Dict[str, typing.Optional[str]]]
1123
+
1124
+ dependencies : typing.Optional[typing.Dict[str, typing.Optional[FunctionsCreateRequestDependenciesValue]]]
1125
+
1126
+ request_options : typing.Optional[RequestOptions]
1127
+ Request-specific configuration.
1128
+
1129
+ Returns
1130
+ -------
1131
+ AsyncHttpResponse[FunctionsCreateResponse]
1132
+ Success
1133
+ """
1134
+ _response = await self._client_wrapper.httpx_client.request(
1135
+ "functions",
1136
+ method="POST",
1137
+ json={
1138
+ "code": code,
1139
+ "hash": hash,
1140
+ "signature": signature,
1141
+ "signatureHash": signature_hash,
1142
+ "name": name,
1143
+ "description": description,
1144
+ "tags": tags,
1145
+ "metadata": metadata,
1146
+ "dependencies": convert_and_respect_annotation_metadata(
1147
+ object_=dependencies,
1148
+ annotation=typing.Optional[
1149
+ typing.Dict[
1150
+ str,
1151
+ typing.Optional[FunctionsCreateRequestDependenciesValue],
1152
+ ]
1153
+ ],
1154
+ direction="write",
1155
+ ),
1156
+ },
1157
+ headers={
1158
+ "content-type": "application/json",
1159
+ },
1160
+ request_options=request_options,
1161
+ omit=OMIT,
1162
+ )
1163
+ try:
1164
+ if 200 <= _response.status_code < 300:
1165
+ _data = typing.cast(
1166
+ FunctionsCreateResponse,
1167
+ parse_obj_as(
1168
+ type_=FunctionsCreateResponse, # type: ignore
1169
+ object_=_response.json(),
1170
+ ),
1171
+ )
1172
+ return AsyncHttpResponse(response=_response, data=_data)
1173
+ if _response.status_code == 400:
1174
+ raise BadRequestError(
1175
+ headers=dict(_response.headers),
1176
+ body=typing.cast(
1177
+ typing.Optional[typing.Any],
1178
+ parse_obj_as(
1179
+ type_=typing.Optional[typing.Any], # type: ignore
1180
+ object_=_response.json(),
1181
+ ),
1182
+ ),
1183
+ )
1184
+ if _response.status_code == 401:
1185
+ raise UnauthorizedError(
1186
+ headers=dict(_response.headers),
1187
+ body=typing.cast(
1188
+ UnauthorizedErrorBody,
1189
+ parse_obj_as(
1190
+ type_=UnauthorizedErrorBody, # type: ignore
1191
+ object_=_response.json(),
1192
+ ),
1193
+ ),
1194
+ )
1195
+ if _response.status_code == 403:
1196
+ raise ForbiddenError(
1197
+ headers=dict(_response.headers),
1198
+ body=typing.cast(
1199
+ PermissionDeniedError,
1200
+ parse_obj_as(
1201
+ type_=PermissionDeniedError, # type: ignore
1202
+ object_=_response.json(),
1203
+ ),
1204
+ ),
1205
+ )
1206
+ if _response.status_code == 404:
1207
+ raise NotFoundError(
1208
+ headers=dict(_response.headers),
1209
+ body=typing.cast(
1210
+ NotFoundErrorBody,
1211
+ parse_obj_as(
1212
+ type_=NotFoundErrorBody, # type: ignore
1213
+ object_=_response.json(),
1214
+ ),
1215
+ ),
1216
+ )
1217
+ if _response.status_code == 409:
1218
+ raise ConflictError(
1219
+ headers=dict(_response.headers),
1220
+ body=typing.cast(
1221
+ typing.Optional[typing.Any],
1222
+ parse_obj_as(
1223
+ type_=typing.Optional[typing.Any], # type: ignore
1224
+ object_=_response.json(),
1225
+ ),
1226
+ ),
1227
+ )
1228
+ if _response.status_code == 429:
1229
+ raise TooManyRequestsError(
1230
+ headers=dict(_response.headers),
1231
+ body=typing.cast(
1232
+ RateLimitError,
1233
+ parse_obj_as(
1234
+ type_=RateLimitError, # type: ignore
1235
+ object_=_response.json(),
1236
+ ),
1237
+ ),
1238
+ )
1239
+ if _response.status_code == 500:
1240
+ raise InternalServerError(
1241
+ headers=dict(_response.headers),
1242
+ body=typing.cast(
1243
+ typing.Optional[typing.Any],
1244
+ parse_obj_as(
1245
+ type_=typing.Optional[typing.Any], # type: ignore
1246
+ object_=_response.json(),
1247
+ ),
1248
+ ),
1249
+ )
1250
+ if _response.status_code == 503:
1251
+ raise ServiceUnavailableError(
1252
+ headers=dict(_response.headers),
1253
+ body=typing.cast(
1254
+ typing.Optional[typing.Any],
1255
+ parse_obj_as(
1256
+ type_=typing.Optional[typing.Any], # type: ignore
1257
+ object_=_response.json(),
1258
+ ),
1259
+ ),
1260
+ )
1261
+ _response_json = _response.json()
1262
+ except JSONDecodeError:
1263
+ raise ApiError(
1264
+ status_code=_response.status_code,
1265
+ headers=dict(_response.headers),
1266
+ body=_response.text,
1267
+ )
1268
+ raise ApiError(
1269
+ status_code=_response.status_code,
1270
+ headers=dict(_response.headers),
1271
+ body=_response_json,
1272
+ )
1273
+
1274
+ async def get(
1275
+ self, id: str, *, request_options: typing.Optional[RequestOptions] = None
1276
+ ) -> AsyncHttpResponse[FunctionsGetResponse]:
1277
+ """
1278
+ Parameters
1279
+ ----------
1280
+ id : str
1281
+
1282
+ request_options : typing.Optional[RequestOptions]
1283
+ Request-specific configuration.
1284
+
1285
+ Returns
1286
+ -------
1287
+ AsyncHttpResponse[FunctionsGetResponse]
1288
+ Success
1289
+ """
1290
+ _response = await self._client_wrapper.httpx_client.request(
1291
+ f"functions/{jsonable_encoder(id)}",
1292
+ method="GET",
1293
+ request_options=request_options,
1294
+ )
1295
+ try:
1296
+ if 200 <= _response.status_code < 300:
1297
+ _data = typing.cast(
1298
+ FunctionsGetResponse,
1299
+ parse_obj_as(
1300
+ type_=FunctionsGetResponse, # type: ignore
1301
+ object_=_response.json(),
1302
+ ),
1303
+ )
1304
+ return AsyncHttpResponse(response=_response, data=_data)
1305
+ if _response.status_code == 400:
1306
+ raise BadRequestError(
1307
+ headers=dict(_response.headers),
1308
+ body=typing.cast(
1309
+ typing.Optional[typing.Any],
1310
+ parse_obj_as(
1311
+ type_=typing.Optional[typing.Any], # type: ignore
1312
+ object_=_response.json(),
1313
+ ),
1314
+ ),
1315
+ )
1316
+ if _response.status_code == 401:
1317
+ raise UnauthorizedError(
1318
+ headers=dict(_response.headers),
1319
+ body=typing.cast(
1320
+ UnauthorizedErrorBody,
1321
+ parse_obj_as(
1322
+ type_=UnauthorizedErrorBody, # type: ignore
1323
+ object_=_response.json(),
1324
+ ),
1325
+ ),
1326
+ )
1327
+ if _response.status_code == 403:
1328
+ raise ForbiddenError(
1329
+ headers=dict(_response.headers),
1330
+ body=typing.cast(
1331
+ PermissionDeniedError,
1332
+ parse_obj_as(
1333
+ type_=PermissionDeniedError, # type: ignore
1334
+ object_=_response.json(),
1335
+ ),
1336
+ ),
1337
+ )
1338
+ if _response.status_code == 404:
1339
+ raise NotFoundError(
1340
+ headers=dict(_response.headers),
1341
+ body=typing.cast(
1342
+ NotFoundErrorBody,
1343
+ parse_obj_as(
1344
+ type_=NotFoundErrorBody, # type: ignore
1345
+ object_=_response.json(),
1346
+ ),
1347
+ ),
1348
+ )
1349
+ if _response.status_code == 429:
1350
+ raise TooManyRequestsError(
1351
+ headers=dict(_response.headers),
1352
+ body=typing.cast(
1353
+ RateLimitError,
1354
+ parse_obj_as(
1355
+ type_=RateLimitError, # type: ignore
1356
+ object_=_response.json(),
1357
+ ),
1358
+ ),
1359
+ )
1360
+ if _response.status_code == 500:
1361
+ raise InternalServerError(
1362
+ headers=dict(_response.headers),
1363
+ body=typing.cast(
1364
+ typing.Optional[typing.Any],
1365
+ parse_obj_as(
1366
+ type_=typing.Optional[typing.Any], # type: ignore
1367
+ object_=_response.json(),
1368
+ ),
1369
+ ),
1370
+ )
1371
+ if _response.status_code == 503:
1372
+ raise ServiceUnavailableError(
1373
+ headers=dict(_response.headers),
1374
+ body=typing.cast(
1375
+ typing.Optional[typing.Any],
1376
+ parse_obj_as(
1377
+ type_=typing.Optional[typing.Any], # type: ignore
1378
+ object_=_response.json(),
1379
+ ),
1380
+ ),
1381
+ )
1382
+ _response_json = _response.json()
1383
+ except JSONDecodeError:
1384
+ raise ApiError(
1385
+ status_code=_response.status_code,
1386
+ headers=dict(_response.headers),
1387
+ body=_response.text,
1388
+ )
1389
+ raise ApiError(
1390
+ status_code=_response.status_code,
1391
+ headers=dict(_response.headers),
1392
+ body=_response_json,
1393
+ )
1394
+
1395
+ async def delete(
1396
+ self, id: str, *, request_options: typing.Optional[RequestOptions] = None
1397
+ ) -> AsyncHttpResponse[None]:
1398
+ """
1399
+ Parameters
1400
+ ----------
1401
+ id : str
1402
+
1403
+ request_options : typing.Optional[RequestOptions]
1404
+ Request-specific configuration.
1405
+
1406
+ Returns
1407
+ -------
1408
+ AsyncHttpResponse[None]
1409
+ """
1410
+ _response = await self._client_wrapper.httpx_client.request(
1411
+ f"functions/{jsonable_encoder(id)}",
1412
+ method="DELETE",
1413
+ request_options=request_options,
1414
+ )
1415
+ try:
1416
+ if 200 <= _response.status_code < 300:
1417
+ return AsyncHttpResponse(response=_response, data=None)
1418
+ if _response.status_code == 400:
1419
+ raise BadRequestError(
1420
+ headers=dict(_response.headers),
1421
+ body=typing.cast(
1422
+ typing.Optional[typing.Any],
1423
+ parse_obj_as(
1424
+ type_=typing.Optional[typing.Any], # type: ignore
1425
+ object_=_response.json(),
1426
+ ),
1427
+ ),
1428
+ )
1429
+ if _response.status_code == 401:
1430
+ raise UnauthorizedError(
1431
+ headers=dict(_response.headers),
1432
+ body=typing.cast(
1433
+ UnauthorizedErrorBody,
1434
+ parse_obj_as(
1435
+ type_=UnauthorizedErrorBody, # type: ignore
1436
+ object_=_response.json(),
1437
+ ),
1438
+ ),
1439
+ )
1440
+ if _response.status_code == 403:
1441
+ raise ForbiddenError(
1442
+ headers=dict(_response.headers),
1443
+ body=typing.cast(
1444
+ PermissionDeniedError,
1445
+ parse_obj_as(
1446
+ type_=PermissionDeniedError, # type: ignore
1447
+ object_=_response.json(),
1448
+ ),
1449
+ ),
1450
+ )
1451
+ if _response.status_code == 404:
1452
+ raise NotFoundError(
1453
+ headers=dict(_response.headers),
1454
+ body=typing.cast(
1455
+ NotFoundErrorBody,
1456
+ parse_obj_as(
1457
+ type_=NotFoundErrorBody, # type: ignore
1458
+ object_=_response.json(),
1459
+ ),
1460
+ ),
1461
+ )
1462
+ if _response.status_code == 429:
1463
+ raise TooManyRequestsError(
1464
+ headers=dict(_response.headers),
1465
+ body=typing.cast(
1466
+ RateLimitError,
1467
+ parse_obj_as(
1468
+ type_=RateLimitError, # type: ignore
1469
+ object_=_response.json(),
1470
+ ),
1471
+ ),
1472
+ )
1473
+ if _response.status_code == 500:
1474
+ raise InternalServerError(
1475
+ headers=dict(_response.headers),
1476
+ body=typing.cast(
1477
+ typing.Optional[typing.Any],
1478
+ parse_obj_as(
1479
+ type_=typing.Optional[typing.Any], # type: ignore
1480
+ object_=_response.json(),
1481
+ ),
1482
+ ),
1483
+ )
1484
+ if _response.status_code == 503:
1485
+ raise ServiceUnavailableError(
1486
+ headers=dict(_response.headers),
1487
+ body=typing.cast(
1488
+ typing.Optional[typing.Any],
1489
+ parse_obj_as(
1490
+ type_=typing.Optional[typing.Any], # type: ignore
1491
+ object_=_response.json(),
1492
+ ),
1493
+ ),
1494
+ )
1495
+ _response_json = _response.json()
1496
+ except JSONDecodeError:
1497
+ raise ApiError(
1498
+ status_code=_response.status_code,
1499
+ headers=dict(_response.headers),
1500
+ body=_response.text,
1501
+ )
1502
+ raise ApiError(
1503
+ status_code=_response.status_code,
1504
+ headers=dict(_response.headers),
1505
+ body=_response_json,
1506
+ )
1507
+
1508
+ async def findbyhash(
1509
+ self, hash: str, *, request_options: typing.Optional[RequestOptions] = None
1510
+ ) -> AsyncHttpResponse[FunctionsFindByHashResponse]:
1511
+ """
1512
+ Parameters
1513
+ ----------
1514
+ hash : str
1515
+
1516
+ request_options : typing.Optional[RequestOptions]
1517
+ Request-specific configuration.
1518
+
1519
+ Returns
1520
+ -------
1521
+ AsyncHttpResponse[FunctionsFindByHashResponse]
1522
+ Success
1523
+ """
1524
+ _response = await self._client_wrapper.httpx_client.request(
1525
+ f"functions/hash/{jsonable_encoder(hash)}",
1526
+ method="GET",
1527
+ request_options=request_options,
1528
+ )
1529
+ try:
1530
+ if 200 <= _response.status_code < 300:
1531
+ _data = typing.cast(
1532
+ FunctionsFindByHashResponse,
1533
+ parse_obj_as(
1534
+ type_=FunctionsFindByHashResponse, # type: ignore
1535
+ object_=_response.json(),
1536
+ ),
1537
+ )
1538
+ return AsyncHttpResponse(response=_response, data=_data)
1539
+ if _response.status_code == 400:
1540
+ raise BadRequestError(
1541
+ headers=dict(_response.headers),
1542
+ body=typing.cast(
1543
+ typing.Optional[typing.Any],
1544
+ parse_obj_as(
1545
+ type_=typing.Optional[typing.Any], # type: ignore
1546
+ object_=_response.json(),
1547
+ ),
1548
+ ),
1549
+ )
1550
+ if _response.status_code == 401:
1551
+ raise UnauthorizedError(
1552
+ headers=dict(_response.headers),
1553
+ body=typing.cast(
1554
+ UnauthorizedErrorBody,
1555
+ parse_obj_as(
1556
+ type_=UnauthorizedErrorBody, # type: ignore
1557
+ object_=_response.json(),
1558
+ ),
1559
+ ),
1560
+ )
1561
+ if _response.status_code == 403:
1562
+ raise ForbiddenError(
1563
+ headers=dict(_response.headers),
1564
+ body=typing.cast(
1565
+ PermissionDeniedError,
1566
+ parse_obj_as(
1567
+ type_=PermissionDeniedError, # type: ignore
1568
+ object_=_response.json(),
1569
+ ),
1570
+ ),
1571
+ )
1572
+ if _response.status_code == 404:
1573
+ raise NotFoundError(
1574
+ headers=dict(_response.headers),
1575
+ body=typing.cast(
1576
+ NotFoundErrorBody,
1577
+ parse_obj_as(
1578
+ type_=NotFoundErrorBody, # type: ignore
1579
+ object_=_response.json(),
1580
+ ),
1581
+ ),
1582
+ )
1583
+ if _response.status_code == 429:
1584
+ raise TooManyRequestsError(
1585
+ headers=dict(_response.headers),
1586
+ body=typing.cast(
1587
+ RateLimitError,
1588
+ parse_obj_as(
1589
+ type_=RateLimitError, # type: ignore
1590
+ object_=_response.json(),
1591
+ ),
1592
+ ),
1593
+ )
1594
+ if _response.status_code == 500:
1595
+ raise InternalServerError(
1596
+ headers=dict(_response.headers),
1597
+ body=typing.cast(
1598
+ typing.Optional[typing.Any],
1599
+ parse_obj_as(
1600
+ type_=typing.Optional[typing.Any], # type: ignore
1601
+ object_=_response.json(),
1602
+ ),
1603
+ ),
1604
+ )
1605
+ if _response.status_code == 503:
1606
+ raise ServiceUnavailableError(
1607
+ headers=dict(_response.headers),
1608
+ body=typing.cast(
1609
+ typing.Optional[typing.Any],
1610
+ parse_obj_as(
1611
+ type_=typing.Optional[typing.Any], # type: ignore
1612
+ object_=_response.json(),
1613
+ ),
1614
+ ),
1615
+ )
1616
+ _response_json = _response.json()
1617
+ except JSONDecodeError:
1618
+ raise ApiError(
1619
+ status_code=_response.status_code,
1620
+ headers=dict(_response.headers),
1621
+ body=_response.text,
1622
+ )
1623
+ raise ApiError(
1624
+ status_code=_response.status_code,
1625
+ headers=dict(_response.headers),
1626
+ body=_response_json,
1627
+ )
1628
+
1629
+ async def getbyenv(
1630
+ self,
1631
+ organization_id: str,
1632
+ project_id: str,
1633
+ environment_id: str,
1634
+ function_id: str,
1635
+ *,
1636
+ request_options: typing.Optional[RequestOptions] = None,
1637
+ ) -> AsyncHttpResponse[FunctionsGetByEnvResponse]:
1638
+ """
1639
+ Parameters
1640
+ ----------
1641
+ organization_id : str
1642
+
1643
+ project_id : str
1644
+
1645
+ environment_id : str
1646
+
1647
+ function_id : str
1648
+
1649
+ request_options : typing.Optional[RequestOptions]
1650
+ Request-specific configuration.
1651
+
1652
+ Returns
1653
+ -------
1654
+ AsyncHttpResponse[FunctionsGetByEnvResponse]
1655
+ Success
1656
+ """
1657
+ _response = await self._client_wrapper.httpx_client.request(
1658
+ f"organizations/{jsonable_encoder(organization_id)}/projects/{jsonable_encoder(project_id)}/environments/{jsonable_encoder(environment_id)}/functions/{jsonable_encoder(function_id)}",
1659
+ method="GET",
1660
+ request_options=request_options,
1661
+ )
1662
+ try:
1663
+ if 200 <= _response.status_code < 300:
1664
+ _data = typing.cast(
1665
+ FunctionsGetByEnvResponse,
1666
+ parse_obj_as(
1667
+ type_=FunctionsGetByEnvResponse, # type: ignore
1668
+ object_=_response.json(),
1669
+ ),
1670
+ )
1671
+ return AsyncHttpResponse(response=_response, data=_data)
1672
+ if _response.status_code == 400:
1673
+ raise BadRequestError(
1674
+ headers=dict(_response.headers),
1675
+ body=typing.cast(
1676
+ typing.Optional[typing.Any],
1677
+ parse_obj_as(
1678
+ type_=typing.Optional[typing.Any], # type: ignore
1679
+ object_=_response.json(),
1680
+ ),
1681
+ ),
1682
+ )
1683
+ if _response.status_code == 401:
1684
+ raise UnauthorizedError(
1685
+ headers=dict(_response.headers),
1686
+ body=typing.cast(
1687
+ UnauthorizedErrorBody,
1688
+ parse_obj_as(
1689
+ type_=UnauthorizedErrorBody, # type: ignore
1690
+ object_=_response.json(),
1691
+ ),
1692
+ ),
1693
+ )
1694
+ if _response.status_code == 403:
1695
+ raise ForbiddenError(
1696
+ headers=dict(_response.headers),
1697
+ body=typing.cast(
1698
+ PermissionDeniedError,
1699
+ parse_obj_as(
1700
+ type_=PermissionDeniedError, # type: ignore
1701
+ object_=_response.json(),
1702
+ ),
1703
+ ),
1704
+ )
1705
+ if _response.status_code == 404:
1706
+ raise NotFoundError(
1707
+ headers=dict(_response.headers),
1708
+ body=typing.cast(
1709
+ NotFoundErrorBody,
1710
+ parse_obj_as(
1711
+ type_=NotFoundErrorBody, # type: ignore
1712
+ object_=_response.json(),
1713
+ ),
1714
+ ),
1715
+ )
1716
+ if _response.status_code == 429:
1717
+ raise TooManyRequestsError(
1718
+ headers=dict(_response.headers),
1719
+ body=typing.cast(
1720
+ RateLimitError,
1721
+ parse_obj_as(
1722
+ type_=RateLimitError, # type: ignore
1723
+ object_=_response.json(),
1724
+ ),
1725
+ ),
1726
+ )
1727
+ if _response.status_code == 500:
1728
+ raise InternalServerError(
1729
+ headers=dict(_response.headers),
1730
+ body=typing.cast(
1731
+ typing.Optional[typing.Any],
1732
+ parse_obj_as(
1733
+ type_=typing.Optional[typing.Any], # type: ignore
1734
+ object_=_response.json(),
1735
+ ),
1736
+ ),
1737
+ )
1738
+ if _response.status_code == 503:
1739
+ raise ServiceUnavailableError(
1740
+ headers=dict(_response.headers),
1741
+ body=typing.cast(
1742
+ typing.Optional[typing.Any],
1743
+ parse_obj_as(
1744
+ type_=typing.Optional[typing.Any], # type: ignore
1745
+ object_=_response.json(),
1746
+ ),
1747
+ ),
1748
+ )
1749
+ _response_json = _response.json()
1750
+ except JSONDecodeError:
1751
+ raise ApiError(
1752
+ status_code=_response.status_code,
1753
+ headers=dict(_response.headers),
1754
+ body=_response.text,
1755
+ )
1756
+ raise ApiError(
1757
+ status_code=_response.status_code,
1758
+ headers=dict(_response.headers),
1759
+ body=_response_json,
1760
+ )
1761
+
1762
+ async def listbyenv(
1763
+ self,
1764
+ organization_id: str,
1765
+ project_id: str,
1766
+ environment_id: str,
1767
+ *,
1768
+ request_options: typing.Optional[RequestOptions] = None,
1769
+ ) -> AsyncHttpResponse[FunctionsListByEnvResponse]:
1770
+ """
1771
+ Parameters
1772
+ ----------
1773
+ organization_id : str
1774
+
1775
+ project_id : str
1776
+
1777
+ environment_id : str
1778
+
1779
+ request_options : typing.Optional[RequestOptions]
1780
+ Request-specific configuration.
1781
+
1782
+ Returns
1783
+ -------
1784
+ AsyncHttpResponse[FunctionsListByEnvResponse]
1785
+ Success
1786
+ """
1787
+ _response = await self._client_wrapper.httpx_client.request(
1788
+ f"organizations/{jsonable_encoder(organization_id)}/projects/{jsonable_encoder(project_id)}/environments/{jsonable_encoder(environment_id)}/functions",
1789
+ method="GET",
1790
+ request_options=request_options,
1791
+ )
1792
+ try:
1793
+ if 200 <= _response.status_code < 300:
1794
+ _data = typing.cast(
1795
+ FunctionsListByEnvResponse,
1796
+ parse_obj_as(
1797
+ type_=FunctionsListByEnvResponse, # type: ignore
1798
+ object_=_response.json(),
1799
+ ),
1800
+ )
1801
+ return AsyncHttpResponse(response=_response, data=_data)
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 == 401:
1814
+ raise UnauthorizedError(
1815
+ headers=dict(_response.headers),
1816
+ body=typing.cast(
1817
+ UnauthorizedErrorBody,
1818
+ parse_obj_as(
1819
+ type_=UnauthorizedErrorBody, # type: ignore
1820
+ object_=_response.json(),
1821
+ ),
1822
+ ),
1823
+ )
1824
+ if _response.status_code == 403:
1825
+ raise ForbiddenError(
1826
+ headers=dict(_response.headers),
1827
+ body=typing.cast(
1828
+ PermissionDeniedError,
1829
+ parse_obj_as(
1830
+ type_=PermissionDeniedError, # type: ignore
1831
+ object_=_response.json(),
1832
+ ),
1833
+ ),
1834
+ )
1835
+ if _response.status_code == 404:
1836
+ raise NotFoundError(
1837
+ headers=dict(_response.headers),
1838
+ body=typing.cast(
1839
+ NotFoundErrorBody,
1840
+ parse_obj_as(
1841
+ type_=NotFoundErrorBody, # 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
+ )