mirascope 2.0.0a2__py3-none-any.whl → 2.0.0a4__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 (252) hide show
  1. mirascope/__init__.py +2 -2
  2. mirascope/api/__init__.py +6 -0
  3. mirascope/api/_generated/README.md +207 -0
  4. mirascope/api/_generated/__init__.py +141 -0
  5. mirascope/api/_generated/client.py +163 -0
  6. mirascope/api/_generated/core/__init__.py +52 -0
  7. mirascope/api/_generated/core/api_error.py +23 -0
  8. mirascope/api/_generated/core/client_wrapper.py +58 -0
  9. mirascope/api/_generated/core/datetime_utils.py +30 -0
  10. mirascope/api/_generated/core/file.py +70 -0
  11. mirascope/api/_generated/core/force_multipart.py +16 -0
  12. mirascope/api/_generated/core/http_client.py +619 -0
  13. mirascope/api/_generated/core/http_response.py +55 -0
  14. mirascope/api/_generated/core/jsonable_encoder.py +102 -0
  15. mirascope/api/_generated/core/pydantic_utilities.py +310 -0
  16. mirascope/api/_generated/core/query_encoder.py +60 -0
  17. mirascope/api/_generated/core/remove_none_from_dict.py +11 -0
  18. mirascope/api/_generated/core/request_options.py +35 -0
  19. mirascope/api/_generated/core/serialization.py +282 -0
  20. mirascope/api/_generated/docs/__init__.py +4 -0
  21. mirascope/api/_generated/docs/client.py +95 -0
  22. mirascope/api/_generated/docs/raw_client.py +132 -0
  23. mirascope/api/_generated/environment.py +9 -0
  24. mirascope/api/_generated/errors/__init__.py +17 -0
  25. mirascope/api/_generated/errors/bad_request_error.py +15 -0
  26. mirascope/api/_generated/errors/conflict_error.py +15 -0
  27. mirascope/api/_generated/errors/forbidden_error.py +15 -0
  28. mirascope/api/_generated/errors/internal_server_error.py +15 -0
  29. mirascope/api/_generated/errors/not_found_error.py +15 -0
  30. mirascope/api/_generated/health/__init__.py +7 -0
  31. mirascope/api/_generated/health/client.py +96 -0
  32. mirascope/api/_generated/health/raw_client.py +129 -0
  33. mirascope/api/_generated/health/types/__init__.py +8 -0
  34. mirascope/api/_generated/health/types/health_check_response.py +24 -0
  35. mirascope/api/_generated/health/types/health_check_response_status.py +5 -0
  36. mirascope/api/_generated/organizations/__init__.py +25 -0
  37. mirascope/api/_generated/organizations/client.py +380 -0
  38. mirascope/api/_generated/organizations/raw_client.py +876 -0
  39. mirascope/api/_generated/organizations/types/__init__.py +23 -0
  40. mirascope/api/_generated/organizations/types/organizations_create_response.py +24 -0
  41. mirascope/api/_generated/organizations/types/organizations_create_response_role.py +7 -0
  42. mirascope/api/_generated/organizations/types/organizations_get_response.py +24 -0
  43. mirascope/api/_generated/organizations/types/organizations_get_response_role.py +7 -0
  44. mirascope/api/_generated/organizations/types/organizations_list_response_item.py +24 -0
  45. mirascope/api/_generated/organizations/types/organizations_list_response_item_role.py +7 -0
  46. mirascope/api/_generated/organizations/types/organizations_update_response.py +24 -0
  47. mirascope/api/_generated/organizations/types/organizations_update_response_role.py +7 -0
  48. mirascope/api/_generated/projects/__init__.py +17 -0
  49. mirascope/api/_generated/projects/client.py +458 -0
  50. mirascope/api/_generated/projects/raw_client.py +1016 -0
  51. mirascope/api/_generated/projects/types/__init__.py +15 -0
  52. mirascope/api/_generated/projects/types/projects_create_response.py +30 -0
  53. mirascope/api/_generated/projects/types/projects_get_response.py +30 -0
  54. mirascope/api/_generated/projects/types/projects_list_response_item.py +30 -0
  55. mirascope/api/_generated/projects/types/projects_update_response.py +30 -0
  56. mirascope/api/_generated/reference.md +753 -0
  57. mirascope/api/_generated/traces/__init__.py +55 -0
  58. mirascope/api/_generated/traces/client.py +162 -0
  59. mirascope/api/_generated/traces/raw_client.py +168 -0
  60. mirascope/api/_generated/traces/types/__init__.py +95 -0
  61. mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item.py +36 -0
  62. mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_resource.py +31 -0
  63. mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_resource_attributes_item.py +25 -0
  64. mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_resource_attributes_item_value.py +54 -0
  65. mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_resource_attributes_item_value_array_value.py +23 -0
  66. mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_resource_attributes_item_value_kvlist_value.py +28 -0
  67. mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_resource_attributes_item_value_kvlist_value_values_item.py +24 -0
  68. mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item.py +35 -0
  69. mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item_scope.py +35 -0
  70. mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item_scope_attributes_item.py +27 -0
  71. mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item_scope_attributes_item_value.py +54 -0
  72. mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item_scope_attributes_item_value_array_value.py +23 -0
  73. mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item_scope_attributes_item_value_kvlist_value.py +28 -0
  74. mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item_scope_attributes_item_value_kvlist_value_values_item.py +24 -0
  75. mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item_spans_item.py +60 -0
  76. mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item_spans_item_attributes_item.py +29 -0
  77. mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item_spans_item_attributes_item_value.py +54 -0
  78. mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item_spans_item_attributes_item_value_array_value.py +23 -0
  79. mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item_spans_item_attributes_item_value_kvlist_value.py +28 -0
  80. mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item_spans_item_attributes_item_value_kvlist_value_values_item.py +24 -0
  81. mirascope/api/_generated/traces/types/traces_create_request_resource_spans_item_scope_spans_item_spans_item_status.py +24 -0
  82. mirascope/api/_generated/traces/types/traces_create_response.py +27 -0
  83. mirascope/api/_generated/traces/types/traces_create_response_partial_success.py +28 -0
  84. mirascope/api/_generated/types/__init__.py +37 -0
  85. mirascope/api/_generated/types/already_exists_error.py +24 -0
  86. mirascope/api/_generated/types/already_exists_error_tag.py +5 -0
  87. mirascope/api/_generated/types/database_error.py +24 -0
  88. mirascope/api/_generated/types/database_error_tag.py +5 -0
  89. mirascope/api/_generated/types/http_api_decode_error.py +29 -0
  90. mirascope/api/_generated/types/http_api_decode_error_tag.py +5 -0
  91. mirascope/api/_generated/types/issue.py +40 -0
  92. mirascope/api/_generated/types/issue_tag.py +17 -0
  93. mirascope/api/_generated/types/not_found_error_body.py +24 -0
  94. mirascope/api/_generated/types/not_found_error_tag.py +5 -0
  95. mirascope/api/_generated/types/permission_denied_error.py +24 -0
  96. mirascope/api/_generated/types/permission_denied_error_tag.py +7 -0
  97. mirascope/api/_generated/types/property_key.py +7 -0
  98. mirascope/api/_generated/types/property_key_key.py +27 -0
  99. mirascope/api/_generated/types/property_key_key_tag.py +5 -0
  100. mirascope/api/client.py +255 -0
  101. mirascope/api/settings.py +81 -0
  102. mirascope/llm/__init__.py +45 -11
  103. mirascope/llm/calls/calls.py +81 -57
  104. mirascope/llm/calls/decorator.py +121 -115
  105. mirascope/llm/content/__init__.py +3 -2
  106. mirascope/llm/context/_utils.py +19 -6
  107. mirascope/llm/exceptions.py +30 -16
  108. mirascope/llm/formatting/_utils.py +9 -5
  109. mirascope/llm/formatting/format.py +2 -2
  110. mirascope/llm/formatting/from_call_args.py +2 -2
  111. mirascope/llm/messages/message.py +13 -5
  112. mirascope/llm/models/__init__.py +2 -2
  113. mirascope/llm/models/models.py +189 -81
  114. mirascope/llm/prompts/__init__.py +13 -12
  115. mirascope/llm/prompts/_utils.py +27 -24
  116. mirascope/llm/prompts/decorator.py +133 -204
  117. mirascope/llm/prompts/prompts.py +424 -0
  118. mirascope/llm/prompts/protocols.py +25 -59
  119. mirascope/llm/providers/__init__.py +44 -0
  120. mirascope/llm/{clients → providers}/_missing_import_stubs.py +8 -6
  121. mirascope/llm/providers/anthropic/__init__.py +29 -0
  122. mirascope/llm/providers/anthropic/_utils/__init__.py +23 -0
  123. mirascope/llm/providers/anthropic/_utils/beta_decode.py +271 -0
  124. mirascope/llm/providers/anthropic/_utils/beta_encode.py +216 -0
  125. mirascope/llm/{clients → providers}/anthropic/_utils/decode.py +44 -11
  126. mirascope/llm/providers/anthropic/_utils/encode.py +356 -0
  127. mirascope/llm/providers/anthropic/beta_provider.py +322 -0
  128. mirascope/llm/providers/anthropic/model_id.py +23 -0
  129. mirascope/llm/providers/anthropic/model_info.py +87 -0
  130. mirascope/llm/providers/anthropic/provider.py +416 -0
  131. mirascope/llm/{clients → providers}/base/__init__.py +3 -3
  132. mirascope/llm/{clients → providers}/base/_utils.py +25 -8
  133. mirascope/llm/{clients/base/client.py → providers/base/base_provider.py} +255 -126
  134. mirascope/llm/providers/google/__init__.py +21 -0
  135. mirascope/llm/{clients → providers}/google/_utils/decode.py +61 -7
  136. mirascope/llm/{clients → providers}/google/_utils/encode.py +44 -30
  137. mirascope/llm/providers/google/model_id.py +22 -0
  138. mirascope/llm/providers/google/model_info.py +62 -0
  139. mirascope/llm/providers/google/provider.py +442 -0
  140. mirascope/llm/providers/load_provider.py +54 -0
  141. mirascope/llm/providers/mlx/__init__.py +24 -0
  142. mirascope/llm/providers/mlx/_utils.py +129 -0
  143. mirascope/llm/providers/mlx/encoding/__init__.py +8 -0
  144. mirascope/llm/providers/mlx/encoding/base.py +69 -0
  145. mirascope/llm/providers/mlx/encoding/transformers.py +147 -0
  146. mirascope/llm/providers/mlx/mlx.py +237 -0
  147. mirascope/llm/providers/mlx/model_id.py +17 -0
  148. mirascope/llm/providers/mlx/provider.py +415 -0
  149. mirascope/llm/providers/model_id.py +16 -0
  150. mirascope/llm/providers/ollama/__init__.py +19 -0
  151. mirascope/llm/providers/ollama/provider.py +71 -0
  152. mirascope/llm/providers/openai/__init__.py +6 -0
  153. mirascope/llm/providers/openai/completions/__init__.py +25 -0
  154. mirascope/llm/{clients → providers}/openai/completions/_utils/__init__.py +2 -0
  155. mirascope/llm/{clients → providers}/openai/completions/_utils/decode.py +60 -6
  156. mirascope/llm/{clients → providers}/openai/completions/_utils/encode.py +37 -26
  157. mirascope/llm/providers/openai/completions/base_provider.py +513 -0
  158. mirascope/llm/providers/openai/completions/provider.py +22 -0
  159. mirascope/llm/providers/openai/model_id.py +31 -0
  160. mirascope/llm/providers/openai/model_info.py +303 -0
  161. mirascope/llm/providers/openai/provider.py +398 -0
  162. mirascope/llm/providers/openai/responses/__init__.py +21 -0
  163. mirascope/llm/{clients → providers}/openai/responses/_utils/decode.py +59 -6
  164. mirascope/llm/{clients → providers}/openai/responses/_utils/encode.py +34 -23
  165. mirascope/llm/providers/openai/responses/provider.py +469 -0
  166. mirascope/llm/providers/provider_id.py +23 -0
  167. mirascope/llm/providers/provider_registry.py +169 -0
  168. mirascope/llm/providers/together/__init__.py +19 -0
  169. mirascope/llm/providers/together/provider.py +40 -0
  170. mirascope/llm/responses/__init__.py +3 -0
  171. mirascope/llm/responses/base_response.py +14 -5
  172. mirascope/llm/responses/base_stream_response.py +35 -6
  173. mirascope/llm/responses/finish_reason.py +1 -0
  174. mirascope/llm/responses/response.py +33 -13
  175. mirascope/llm/responses/root_response.py +12 -13
  176. mirascope/llm/responses/stream_response.py +35 -23
  177. mirascope/llm/responses/usage.py +95 -0
  178. mirascope/llm/tools/__init__.py +9 -2
  179. mirascope/llm/tools/_utils.py +12 -3
  180. mirascope/llm/tools/protocols.py +4 -4
  181. mirascope/llm/tools/tool_schema.py +44 -9
  182. mirascope/llm/tools/tools.py +10 -9
  183. mirascope/ops/__init__.py +156 -0
  184. mirascope/ops/_internal/__init__.py +5 -0
  185. mirascope/ops/_internal/closure.py +1118 -0
  186. mirascope/ops/_internal/configuration.py +126 -0
  187. mirascope/ops/_internal/context.py +76 -0
  188. mirascope/ops/_internal/exporters/__init__.py +26 -0
  189. mirascope/ops/_internal/exporters/exporters.py +342 -0
  190. mirascope/ops/_internal/exporters/processors.py +104 -0
  191. mirascope/ops/_internal/exporters/types.py +165 -0
  192. mirascope/ops/_internal/exporters/utils.py +29 -0
  193. mirascope/ops/_internal/instrumentation/__init__.py +8 -0
  194. mirascope/ops/_internal/instrumentation/llm/__init__.py +8 -0
  195. mirascope/ops/_internal/instrumentation/llm/encode.py +238 -0
  196. mirascope/ops/_internal/instrumentation/llm/gen_ai_types/__init__.py +38 -0
  197. mirascope/ops/_internal/instrumentation/llm/gen_ai_types/gen_ai_input_messages.py +31 -0
  198. mirascope/ops/_internal/instrumentation/llm/gen_ai_types/gen_ai_output_messages.py +38 -0
  199. mirascope/ops/_internal/instrumentation/llm/gen_ai_types/gen_ai_system_instructions.py +18 -0
  200. mirascope/ops/_internal/instrumentation/llm/gen_ai_types/shared.py +100 -0
  201. mirascope/ops/_internal/instrumentation/llm/llm.py +1288 -0
  202. mirascope/ops/_internal/propagation.py +198 -0
  203. mirascope/ops/_internal/protocols.py +51 -0
  204. mirascope/ops/_internal/session.py +139 -0
  205. mirascope/ops/_internal/spans.py +232 -0
  206. mirascope/ops/_internal/traced_calls.py +371 -0
  207. mirascope/ops/_internal/traced_functions.py +394 -0
  208. mirascope/ops/_internal/tracing.py +276 -0
  209. mirascope/ops/_internal/types.py +13 -0
  210. mirascope/ops/_internal/utils.py +75 -0
  211. mirascope/ops/_internal/versioned_calls.py +512 -0
  212. mirascope/ops/_internal/versioned_functions.py +346 -0
  213. mirascope/ops/_internal/versioning.py +303 -0
  214. mirascope/ops/exceptions.py +21 -0
  215. {mirascope-2.0.0a2.dist-info → mirascope-2.0.0a4.dist-info}/METADATA +78 -3
  216. mirascope-2.0.0a4.dist-info/RECORD +247 -0
  217. {mirascope-2.0.0a2.dist-info → mirascope-2.0.0a4.dist-info}/WHEEL +1 -1
  218. mirascope/graphs/__init__.py +0 -22
  219. mirascope/graphs/finite_state_machine.py +0 -625
  220. mirascope/llm/agents/__init__.py +0 -15
  221. mirascope/llm/agents/agent.py +0 -97
  222. mirascope/llm/agents/agent_template.py +0 -45
  223. mirascope/llm/agents/decorator.py +0 -176
  224. mirascope/llm/calls/base_call.py +0 -33
  225. mirascope/llm/clients/__init__.py +0 -34
  226. mirascope/llm/clients/anthropic/__init__.py +0 -25
  227. mirascope/llm/clients/anthropic/_utils/encode.py +0 -243
  228. mirascope/llm/clients/anthropic/clients.py +0 -819
  229. mirascope/llm/clients/anthropic/model_ids.py +0 -8
  230. mirascope/llm/clients/google/__init__.py +0 -20
  231. mirascope/llm/clients/google/clients.py +0 -853
  232. mirascope/llm/clients/google/model_ids.py +0 -15
  233. mirascope/llm/clients/openai/__init__.py +0 -25
  234. mirascope/llm/clients/openai/completions/__init__.py +0 -28
  235. mirascope/llm/clients/openai/completions/_utils/model_features.py +0 -81
  236. mirascope/llm/clients/openai/completions/clients.py +0 -833
  237. mirascope/llm/clients/openai/completions/model_ids.py +0 -8
  238. mirascope/llm/clients/openai/responses/__init__.py +0 -26
  239. mirascope/llm/clients/openai/responses/_utils/__init__.py +0 -13
  240. mirascope/llm/clients/openai/responses/_utils/model_features.py +0 -87
  241. mirascope/llm/clients/openai/responses/clients.py +0 -832
  242. mirascope/llm/clients/openai/responses/model_ids.py +0 -8
  243. mirascope/llm/clients/openai/shared/__init__.py +0 -7
  244. mirascope/llm/clients/openai/shared/_utils.py +0 -55
  245. mirascope/llm/clients/providers.py +0 -175
  246. mirascope-2.0.0a2.dist-info/RECORD +0 -102
  247. /mirascope/llm/{clients → providers}/base/kwargs.py +0 -0
  248. /mirascope/llm/{clients → providers}/base/params.py +0 -0
  249. /mirascope/llm/{clients/anthropic → providers/google}/_utils/__init__.py +0 -0
  250. /mirascope/llm/{clients → providers}/google/message.py +0 -0
  251. /mirascope/llm/{clients/google → providers/openai/responses}/_utils/__init__.py +0 -0
  252. {mirascope-2.0.0a2.dist-info → mirascope-2.0.0a4.dist-info}/licenses/LICENSE +0 -0
@@ -0,0 +1,876 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+ from json.decoder import JSONDecodeError
5
+
6
+ from ..core.api_error import ApiError
7
+ from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
8
+ from ..core.http_response import AsyncHttpResponse, HttpResponse
9
+ from ..core.jsonable_encoder import jsonable_encoder
10
+ from ..core.pydantic_utilities import parse_obj_as
11
+ from ..core.request_options import RequestOptions
12
+ from ..errors.bad_request_error import BadRequestError
13
+ from ..errors.conflict_error import ConflictError
14
+ from ..errors.forbidden_error import ForbiddenError
15
+ from ..errors.internal_server_error import InternalServerError
16
+ from ..errors.not_found_error import NotFoundError
17
+ from ..types.already_exists_error import AlreadyExistsError
18
+ from ..types.database_error import DatabaseError
19
+ from ..types.http_api_decode_error import HttpApiDecodeError
20
+ from ..types.not_found_error_body import NotFoundErrorBody
21
+ from ..types.permission_denied_error import PermissionDeniedError
22
+ from .types.organizations_create_response import OrganizationsCreateResponse
23
+ from .types.organizations_get_response import OrganizationsGetResponse
24
+ from .types.organizations_list_response_item import OrganizationsListResponseItem
25
+ from .types.organizations_update_response import OrganizationsUpdateResponse
26
+
27
+ # this is used as the default value for optional parameters
28
+ OMIT = typing.cast(typing.Any, ...)
29
+
30
+
31
+ class RawOrganizationsClient:
32
+ def __init__(self, *, client_wrapper: SyncClientWrapper):
33
+ self._client_wrapper = client_wrapper
34
+
35
+ def list(
36
+ self, *, request_options: typing.Optional[RequestOptions] = None
37
+ ) -> HttpResponse[typing.List[OrganizationsListResponseItem]]:
38
+ """
39
+ Parameters
40
+ ----------
41
+ request_options : typing.Optional[RequestOptions]
42
+ Request-specific configuration.
43
+
44
+ Returns
45
+ -------
46
+ HttpResponse[typing.List[OrganizationsListResponseItem]]
47
+ Success
48
+ """
49
+ _response = self._client_wrapper.httpx_client.request(
50
+ "organizations",
51
+ method="GET",
52
+ request_options=request_options,
53
+ )
54
+ try:
55
+ if 200 <= _response.status_code < 300:
56
+ _data = typing.cast(
57
+ typing.List[OrganizationsListResponseItem],
58
+ parse_obj_as(
59
+ type_=typing.List[OrganizationsListResponseItem], # type: ignore
60
+ object_=_response.json(),
61
+ ),
62
+ )
63
+ return HttpResponse(response=_response, data=_data)
64
+ if _response.status_code == 400:
65
+ raise BadRequestError(
66
+ headers=dict(_response.headers),
67
+ body=typing.cast(
68
+ HttpApiDecodeError,
69
+ parse_obj_as(
70
+ type_=HttpApiDecodeError, # type: ignore
71
+ object_=_response.json(),
72
+ ),
73
+ ),
74
+ )
75
+ if _response.status_code == 500:
76
+ raise InternalServerError(
77
+ headers=dict(_response.headers),
78
+ body=typing.cast(
79
+ DatabaseError,
80
+ parse_obj_as(
81
+ type_=DatabaseError, # type: ignore
82
+ object_=_response.json(),
83
+ ),
84
+ ),
85
+ )
86
+ _response_json = _response.json()
87
+ except JSONDecodeError:
88
+ raise ApiError(
89
+ status_code=_response.status_code,
90
+ headers=dict(_response.headers),
91
+ body=_response.text,
92
+ )
93
+ raise ApiError(
94
+ status_code=_response.status_code,
95
+ headers=dict(_response.headers),
96
+ body=_response_json,
97
+ )
98
+
99
+ def create(
100
+ self, *, name: str, request_options: typing.Optional[RequestOptions] = None
101
+ ) -> HttpResponse[OrganizationsCreateResponse]:
102
+ """
103
+ Parameters
104
+ ----------
105
+ name : str
106
+ a string at most 100 character(s) long
107
+
108
+ request_options : typing.Optional[RequestOptions]
109
+ Request-specific configuration.
110
+
111
+ Returns
112
+ -------
113
+ HttpResponse[OrganizationsCreateResponse]
114
+ Success
115
+ """
116
+ _response = self._client_wrapper.httpx_client.request(
117
+ "organizations",
118
+ method="POST",
119
+ json={
120
+ "name": name,
121
+ },
122
+ headers={
123
+ "content-type": "application/json",
124
+ },
125
+ request_options=request_options,
126
+ omit=OMIT,
127
+ )
128
+ try:
129
+ if 200 <= _response.status_code < 300:
130
+ _data = typing.cast(
131
+ OrganizationsCreateResponse,
132
+ parse_obj_as(
133
+ type_=OrganizationsCreateResponse, # type: ignore
134
+ object_=_response.json(),
135
+ ),
136
+ )
137
+ return HttpResponse(response=_response, data=_data)
138
+ if _response.status_code == 400:
139
+ raise BadRequestError(
140
+ headers=dict(_response.headers),
141
+ body=typing.cast(
142
+ HttpApiDecodeError,
143
+ parse_obj_as(
144
+ type_=HttpApiDecodeError, # type: ignore
145
+ object_=_response.json(),
146
+ ),
147
+ ),
148
+ )
149
+ if _response.status_code == 409:
150
+ raise ConflictError(
151
+ headers=dict(_response.headers),
152
+ body=typing.cast(
153
+ AlreadyExistsError,
154
+ parse_obj_as(
155
+ type_=AlreadyExistsError, # type: ignore
156
+ object_=_response.json(),
157
+ ),
158
+ ),
159
+ )
160
+ if _response.status_code == 500:
161
+ raise InternalServerError(
162
+ headers=dict(_response.headers),
163
+ body=typing.cast(
164
+ DatabaseError,
165
+ parse_obj_as(
166
+ type_=DatabaseError, # type: ignore
167
+ object_=_response.json(),
168
+ ),
169
+ ),
170
+ )
171
+ _response_json = _response.json()
172
+ except JSONDecodeError:
173
+ raise ApiError(
174
+ status_code=_response.status_code,
175
+ headers=dict(_response.headers),
176
+ body=_response.text,
177
+ )
178
+ raise ApiError(
179
+ status_code=_response.status_code,
180
+ headers=dict(_response.headers),
181
+ body=_response_json,
182
+ )
183
+
184
+ def get(
185
+ self, id: str, *, request_options: typing.Optional[RequestOptions] = None
186
+ ) -> HttpResponse[OrganizationsGetResponse]:
187
+ """
188
+ Parameters
189
+ ----------
190
+ id : str
191
+
192
+ request_options : typing.Optional[RequestOptions]
193
+ Request-specific configuration.
194
+
195
+ Returns
196
+ -------
197
+ HttpResponse[OrganizationsGetResponse]
198
+ Success
199
+ """
200
+ _response = self._client_wrapper.httpx_client.request(
201
+ f"organizations/{jsonable_encoder(id)}",
202
+ method="GET",
203
+ request_options=request_options,
204
+ )
205
+ try:
206
+ if 200 <= _response.status_code < 300:
207
+ _data = typing.cast(
208
+ OrganizationsGetResponse,
209
+ parse_obj_as(
210
+ type_=OrganizationsGetResponse, # type: ignore
211
+ object_=_response.json(),
212
+ ),
213
+ )
214
+ return HttpResponse(response=_response, data=_data)
215
+ if _response.status_code == 400:
216
+ raise BadRequestError(
217
+ headers=dict(_response.headers),
218
+ body=typing.cast(
219
+ HttpApiDecodeError,
220
+ parse_obj_as(
221
+ type_=HttpApiDecodeError, # type: ignore
222
+ object_=_response.json(),
223
+ ),
224
+ ),
225
+ )
226
+ if _response.status_code == 403:
227
+ raise ForbiddenError(
228
+ headers=dict(_response.headers),
229
+ body=typing.cast(
230
+ PermissionDeniedError,
231
+ parse_obj_as(
232
+ type_=PermissionDeniedError, # type: ignore
233
+ object_=_response.json(),
234
+ ),
235
+ ),
236
+ )
237
+ if _response.status_code == 404:
238
+ raise NotFoundError(
239
+ headers=dict(_response.headers),
240
+ body=typing.cast(
241
+ NotFoundErrorBody,
242
+ parse_obj_as(
243
+ type_=NotFoundErrorBody, # type: ignore
244
+ object_=_response.json(),
245
+ ),
246
+ ),
247
+ )
248
+ if _response.status_code == 500:
249
+ raise InternalServerError(
250
+ headers=dict(_response.headers),
251
+ body=typing.cast(
252
+ DatabaseError,
253
+ parse_obj_as(
254
+ type_=DatabaseError, # type: ignore
255
+ object_=_response.json(),
256
+ ),
257
+ ),
258
+ )
259
+ _response_json = _response.json()
260
+ except JSONDecodeError:
261
+ raise ApiError(
262
+ status_code=_response.status_code,
263
+ headers=dict(_response.headers),
264
+ body=_response.text,
265
+ )
266
+ raise ApiError(
267
+ status_code=_response.status_code,
268
+ headers=dict(_response.headers),
269
+ body=_response_json,
270
+ )
271
+
272
+ def update(
273
+ self,
274
+ id: str,
275
+ *,
276
+ name: str,
277
+ request_options: typing.Optional[RequestOptions] = None,
278
+ ) -> HttpResponse[OrganizationsUpdateResponse]:
279
+ """
280
+ Parameters
281
+ ----------
282
+ id : str
283
+
284
+ name : str
285
+ a string at most 100 character(s) long
286
+
287
+ request_options : typing.Optional[RequestOptions]
288
+ Request-specific configuration.
289
+
290
+ Returns
291
+ -------
292
+ HttpResponse[OrganizationsUpdateResponse]
293
+ Success
294
+ """
295
+ _response = self._client_wrapper.httpx_client.request(
296
+ f"organizations/{jsonable_encoder(id)}",
297
+ method="PUT",
298
+ json={
299
+ "name": name,
300
+ },
301
+ headers={
302
+ "content-type": "application/json",
303
+ },
304
+ request_options=request_options,
305
+ omit=OMIT,
306
+ )
307
+ try:
308
+ if 200 <= _response.status_code < 300:
309
+ _data = typing.cast(
310
+ OrganizationsUpdateResponse,
311
+ parse_obj_as(
312
+ type_=OrganizationsUpdateResponse, # type: ignore
313
+ object_=_response.json(),
314
+ ),
315
+ )
316
+ return HttpResponse(response=_response, data=_data)
317
+ if _response.status_code == 400:
318
+ raise BadRequestError(
319
+ headers=dict(_response.headers),
320
+ body=typing.cast(
321
+ HttpApiDecodeError,
322
+ parse_obj_as(
323
+ type_=HttpApiDecodeError, # type: ignore
324
+ object_=_response.json(),
325
+ ),
326
+ ),
327
+ )
328
+ if _response.status_code == 403:
329
+ raise ForbiddenError(
330
+ headers=dict(_response.headers),
331
+ body=typing.cast(
332
+ PermissionDeniedError,
333
+ parse_obj_as(
334
+ type_=PermissionDeniedError, # type: ignore
335
+ object_=_response.json(),
336
+ ),
337
+ ),
338
+ )
339
+ if _response.status_code == 404:
340
+ raise NotFoundError(
341
+ headers=dict(_response.headers),
342
+ body=typing.cast(
343
+ NotFoundErrorBody,
344
+ parse_obj_as(
345
+ type_=NotFoundErrorBody, # type: ignore
346
+ object_=_response.json(),
347
+ ),
348
+ ),
349
+ )
350
+ if _response.status_code == 500:
351
+ raise InternalServerError(
352
+ headers=dict(_response.headers),
353
+ body=typing.cast(
354
+ DatabaseError,
355
+ parse_obj_as(
356
+ type_=DatabaseError, # type: ignore
357
+ object_=_response.json(),
358
+ ),
359
+ ),
360
+ )
361
+ _response_json = _response.json()
362
+ except JSONDecodeError:
363
+ raise ApiError(
364
+ status_code=_response.status_code,
365
+ headers=dict(_response.headers),
366
+ body=_response.text,
367
+ )
368
+ raise ApiError(
369
+ status_code=_response.status_code,
370
+ headers=dict(_response.headers),
371
+ body=_response_json,
372
+ )
373
+
374
+ def delete(
375
+ self, id: str, *, request_options: typing.Optional[RequestOptions] = None
376
+ ) -> HttpResponse[None]:
377
+ """
378
+ Parameters
379
+ ----------
380
+ id : str
381
+
382
+ request_options : typing.Optional[RequestOptions]
383
+ Request-specific configuration.
384
+
385
+ Returns
386
+ -------
387
+ HttpResponse[None]
388
+ """
389
+ _response = self._client_wrapper.httpx_client.request(
390
+ f"organizations/{jsonable_encoder(id)}",
391
+ method="DELETE",
392
+ request_options=request_options,
393
+ )
394
+ try:
395
+ if 200 <= _response.status_code < 300:
396
+ return HttpResponse(response=_response, data=None)
397
+ if _response.status_code == 400:
398
+ raise BadRequestError(
399
+ headers=dict(_response.headers),
400
+ body=typing.cast(
401
+ HttpApiDecodeError,
402
+ parse_obj_as(
403
+ type_=HttpApiDecodeError, # type: ignore
404
+ object_=_response.json(),
405
+ ),
406
+ ),
407
+ )
408
+ if _response.status_code == 403:
409
+ raise ForbiddenError(
410
+ headers=dict(_response.headers),
411
+ body=typing.cast(
412
+ PermissionDeniedError,
413
+ parse_obj_as(
414
+ type_=PermissionDeniedError, # type: ignore
415
+ object_=_response.json(),
416
+ ),
417
+ ),
418
+ )
419
+ if _response.status_code == 404:
420
+ raise NotFoundError(
421
+ headers=dict(_response.headers),
422
+ body=typing.cast(
423
+ NotFoundErrorBody,
424
+ parse_obj_as(
425
+ type_=NotFoundErrorBody, # type: ignore
426
+ object_=_response.json(),
427
+ ),
428
+ ),
429
+ )
430
+ if _response.status_code == 500:
431
+ raise InternalServerError(
432
+ headers=dict(_response.headers),
433
+ body=typing.cast(
434
+ DatabaseError,
435
+ parse_obj_as(
436
+ type_=DatabaseError, # type: ignore
437
+ object_=_response.json(),
438
+ ),
439
+ ),
440
+ )
441
+ _response_json = _response.json()
442
+ except JSONDecodeError:
443
+ raise ApiError(
444
+ status_code=_response.status_code,
445
+ headers=dict(_response.headers),
446
+ body=_response.text,
447
+ )
448
+ raise ApiError(
449
+ status_code=_response.status_code,
450
+ headers=dict(_response.headers),
451
+ body=_response_json,
452
+ )
453
+
454
+
455
+ class AsyncRawOrganizationsClient:
456
+ def __init__(self, *, client_wrapper: AsyncClientWrapper):
457
+ self._client_wrapper = client_wrapper
458
+
459
+ async def list(
460
+ self, *, request_options: typing.Optional[RequestOptions] = None
461
+ ) -> AsyncHttpResponse[typing.List[OrganizationsListResponseItem]]:
462
+ """
463
+ Parameters
464
+ ----------
465
+ request_options : typing.Optional[RequestOptions]
466
+ Request-specific configuration.
467
+
468
+ Returns
469
+ -------
470
+ AsyncHttpResponse[typing.List[OrganizationsListResponseItem]]
471
+ Success
472
+ """
473
+ _response = await self._client_wrapper.httpx_client.request(
474
+ "organizations",
475
+ method="GET",
476
+ request_options=request_options,
477
+ )
478
+ try:
479
+ if 200 <= _response.status_code < 300:
480
+ _data = typing.cast(
481
+ typing.List[OrganizationsListResponseItem],
482
+ parse_obj_as(
483
+ type_=typing.List[OrganizationsListResponseItem], # type: ignore
484
+ object_=_response.json(),
485
+ ),
486
+ )
487
+ return AsyncHttpResponse(response=_response, data=_data)
488
+ if _response.status_code == 400:
489
+ raise BadRequestError(
490
+ headers=dict(_response.headers),
491
+ body=typing.cast(
492
+ HttpApiDecodeError,
493
+ parse_obj_as(
494
+ type_=HttpApiDecodeError, # type: ignore
495
+ object_=_response.json(),
496
+ ),
497
+ ),
498
+ )
499
+ if _response.status_code == 500:
500
+ raise InternalServerError(
501
+ headers=dict(_response.headers),
502
+ body=typing.cast(
503
+ DatabaseError,
504
+ parse_obj_as(
505
+ type_=DatabaseError, # type: ignore
506
+ object_=_response.json(),
507
+ ),
508
+ ),
509
+ )
510
+ _response_json = _response.json()
511
+ except JSONDecodeError:
512
+ raise ApiError(
513
+ status_code=_response.status_code,
514
+ headers=dict(_response.headers),
515
+ body=_response.text,
516
+ )
517
+ raise ApiError(
518
+ status_code=_response.status_code,
519
+ headers=dict(_response.headers),
520
+ body=_response_json,
521
+ )
522
+
523
+ async def create(
524
+ self, *, name: str, request_options: typing.Optional[RequestOptions] = None
525
+ ) -> AsyncHttpResponse[OrganizationsCreateResponse]:
526
+ """
527
+ Parameters
528
+ ----------
529
+ name : str
530
+ a string at most 100 character(s) long
531
+
532
+ request_options : typing.Optional[RequestOptions]
533
+ Request-specific configuration.
534
+
535
+ Returns
536
+ -------
537
+ AsyncHttpResponse[OrganizationsCreateResponse]
538
+ Success
539
+ """
540
+ _response = await self._client_wrapper.httpx_client.request(
541
+ "organizations",
542
+ method="POST",
543
+ json={
544
+ "name": name,
545
+ },
546
+ headers={
547
+ "content-type": "application/json",
548
+ },
549
+ request_options=request_options,
550
+ omit=OMIT,
551
+ )
552
+ try:
553
+ if 200 <= _response.status_code < 300:
554
+ _data = typing.cast(
555
+ OrganizationsCreateResponse,
556
+ parse_obj_as(
557
+ type_=OrganizationsCreateResponse, # type: ignore
558
+ object_=_response.json(),
559
+ ),
560
+ )
561
+ return AsyncHttpResponse(response=_response, data=_data)
562
+ if _response.status_code == 400:
563
+ raise BadRequestError(
564
+ headers=dict(_response.headers),
565
+ body=typing.cast(
566
+ HttpApiDecodeError,
567
+ parse_obj_as(
568
+ type_=HttpApiDecodeError, # type: ignore
569
+ object_=_response.json(),
570
+ ),
571
+ ),
572
+ )
573
+ if _response.status_code == 409:
574
+ raise ConflictError(
575
+ headers=dict(_response.headers),
576
+ body=typing.cast(
577
+ AlreadyExistsError,
578
+ parse_obj_as(
579
+ type_=AlreadyExistsError, # type: ignore
580
+ object_=_response.json(),
581
+ ),
582
+ ),
583
+ )
584
+ if _response.status_code == 500:
585
+ raise InternalServerError(
586
+ headers=dict(_response.headers),
587
+ body=typing.cast(
588
+ DatabaseError,
589
+ parse_obj_as(
590
+ type_=DatabaseError, # type: ignore
591
+ object_=_response.json(),
592
+ ),
593
+ ),
594
+ )
595
+ _response_json = _response.json()
596
+ except JSONDecodeError:
597
+ raise ApiError(
598
+ status_code=_response.status_code,
599
+ headers=dict(_response.headers),
600
+ body=_response.text,
601
+ )
602
+ raise ApiError(
603
+ status_code=_response.status_code,
604
+ headers=dict(_response.headers),
605
+ body=_response_json,
606
+ )
607
+
608
+ async def get(
609
+ self, id: str, *, request_options: typing.Optional[RequestOptions] = None
610
+ ) -> AsyncHttpResponse[OrganizationsGetResponse]:
611
+ """
612
+ Parameters
613
+ ----------
614
+ id : str
615
+
616
+ request_options : typing.Optional[RequestOptions]
617
+ Request-specific configuration.
618
+
619
+ Returns
620
+ -------
621
+ AsyncHttpResponse[OrganizationsGetResponse]
622
+ Success
623
+ """
624
+ _response = await self._client_wrapper.httpx_client.request(
625
+ f"organizations/{jsonable_encoder(id)}",
626
+ method="GET",
627
+ request_options=request_options,
628
+ )
629
+ try:
630
+ if 200 <= _response.status_code < 300:
631
+ _data = typing.cast(
632
+ OrganizationsGetResponse,
633
+ parse_obj_as(
634
+ type_=OrganizationsGetResponse, # type: ignore
635
+ object_=_response.json(),
636
+ ),
637
+ )
638
+ return AsyncHttpResponse(response=_response, data=_data)
639
+ if _response.status_code == 400:
640
+ raise BadRequestError(
641
+ headers=dict(_response.headers),
642
+ body=typing.cast(
643
+ HttpApiDecodeError,
644
+ parse_obj_as(
645
+ type_=HttpApiDecodeError, # type: ignore
646
+ object_=_response.json(),
647
+ ),
648
+ ),
649
+ )
650
+ if _response.status_code == 403:
651
+ raise ForbiddenError(
652
+ headers=dict(_response.headers),
653
+ body=typing.cast(
654
+ PermissionDeniedError,
655
+ parse_obj_as(
656
+ type_=PermissionDeniedError, # type: ignore
657
+ object_=_response.json(),
658
+ ),
659
+ ),
660
+ )
661
+ if _response.status_code == 404:
662
+ raise NotFoundError(
663
+ headers=dict(_response.headers),
664
+ body=typing.cast(
665
+ NotFoundErrorBody,
666
+ parse_obj_as(
667
+ type_=NotFoundErrorBody, # type: ignore
668
+ object_=_response.json(),
669
+ ),
670
+ ),
671
+ )
672
+ if _response.status_code == 500:
673
+ raise InternalServerError(
674
+ headers=dict(_response.headers),
675
+ body=typing.cast(
676
+ DatabaseError,
677
+ parse_obj_as(
678
+ type_=DatabaseError, # type: ignore
679
+ object_=_response.json(),
680
+ ),
681
+ ),
682
+ )
683
+ _response_json = _response.json()
684
+ except JSONDecodeError:
685
+ raise ApiError(
686
+ status_code=_response.status_code,
687
+ headers=dict(_response.headers),
688
+ body=_response.text,
689
+ )
690
+ raise ApiError(
691
+ status_code=_response.status_code,
692
+ headers=dict(_response.headers),
693
+ body=_response_json,
694
+ )
695
+
696
+ async def update(
697
+ self,
698
+ id: str,
699
+ *,
700
+ name: str,
701
+ request_options: typing.Optional[RequestOptions] = None,
702
+ ) -> AsyncHttpResponse[OrganizationsUpdateResponse]:
703
+ """
704
+ Parameters
705
+ ----------
706
+ id : str
707
+
708
+ name : str
709
+ a string at most 100 character(s) long
710
+
711
+ request_options : typing.Optional[RequestOptions]
712
+ Request-specific configuration.
713
+
714
+ Returns
715
+ -------
716
+ AsyncHttpResponse[OrganizationsUpdateResponse]
717
+ Success
718
+ """
719
+ _response = await self._client_wrapper.httpx_client.request(
720
+ f"organizations/{jsonable_encoder(id)}",
721
+ method="PUT",
722
+ json={
723
+ "name": name,
724
+ },
725
+ headers={
726
+ "content-type": "application/json",
727
+ },
728
+ request_options=request_options,
729
+ omit=OMIT,
730
+ )
731
+ try:
732
+ if 200 <= _response.status_code < 300:
733
+ _data = typing.cast(
734
+ OrganizationsUpdateResponse,
735
+ parse_obj_as(
736
+ type_=OrganizationsUpdateResponse, # type: ignore
737
+ object_=_response.json(),
738
+ ),
739
+ )
740
+ return AsyncHttpResponse(response=_response, data=_data)
741
+ if _response.status_code == 400:
742
+ raise BadRequestError(
743
+ headers=dict(_response.headers),
744
+ body=typing.cast(
745
+ HttpApiDecodeError,
746
+ parse_obj_as(
747
+ type_=HttpApiDecodeError, # type: ignore
748
+ object_=_response.json(),
749
+ ),
750
+ ),
751
+ )
752
+ if _response.status_code == 403:
753
+ raise ForbiddenError(
754
+ headers=dict(_response.headers),
755
+ body=typing.cast(
756
+ PermissionDeniedError,
757
+ parse_obj_as(
758
+ type_=PermissionDeniedError, # type: ignore
759
+ object_=_response.json(),
760
+ ),
761
+ ),
762
+ )
763
+ if _response.status_code == 404:
764
+ raise NotFoundError(
765
+ headers=dict(_response.headers),
766
+ body=typing.cast(
767
+ NotFoundErrorBody,
768
+ parse_obj_as(
769
+ type_=NotFoundErrorBody, # type: ignore
770
+ object_=_response.json(),
771
+ ),
772
+ ),
773
+ )
774
+ if _response.status_code == 500:
775
+ raise InternalServerError(
776
+ headers=dict(_response.headers),
777
+ body=typing.cast(
778
+ DatabaseError,
779
+ parse_obj_as(
780
+ type_=DatabaseError, # type: ignore
781
+ object_=_response.json(),
782
+ ),
783
+ ),
784
+ )
785
+ _response_json = _response.json()
786
+ except JSONDecodeError:
787
+ raise ApiError(
788
+ status_code=_response.status_code,
789
+ headers=dict(_response.headers),
790
+ body=_response.text,
791
+ )
792
+ raise ApiError(
793
+ status_code=_response.status_code,
794
+ headers=dict(_response.headers),
795
+ body=_response_json,
796
+ )
797
+
798
+ async def delete(
799
+ self, id: str, *, request_options: typing.Optional[RequestOptions] = None
800
+ ) -> AsyncHttpResponse[None]:
801
+ """
802
+ Parameters
803
+ ----------
804
+ id : str
805
+
806
+ request_options : typing.Optional[RequestOptions]
807
+ Request-specific configuration.
808
+
809
+ Returns
810
+ -------
811
+ AsyncHttpResponse[None]
812
+ """
813
+ _response = await self._client_wrapper.httpx_client.request(
814
+ f"organizations/{jsonable_encoder(id)}",
815
+ method="DELETE",
816
+ request_options=request_options,
817
+ )
818
+ try:
819
+ if 200 <= _response.status_code < 300:
820
+ return AsyncHttpResponse(response=_response, data=None)
821
+ if _response.status_code == 400:
822
+ raise BadRequestError(
823
+ headers=dict(_response.headers),
824
+ body=typing.cast(
825
+ HttpApiDecodeError,
826
+ parse_obj_as(
827
+ type_=HttpApiDecodeError, # type: ignore
828
+ object_=_response.json(),
829
+ ),
830
+ ),
831
+ )
832
+ if _response.status_code == 403:
833
+ raise ForbiddenError(
834
+ headers=dict(_response.headers),
835
+ body=typing.cast(
836
+ PermissionDeniedError,
837
+ parse_obj_as(
838
+ type_=PermissionDeniedError, # type: ignore
839
+ object_=_response.json(),
840
+ ),
841
+ ),
842
+ )
843
+ if _response.status_code == 404:
844
+ raise NotFoundError(
845
+ headers=dict(_response.headers),
846
+ body=typing.cast(
847
+ NotFoundErrorBody,
848
+ parse_obj_as(
849
+ type_=NotFoundErrorBody, # type: ignore
850
+ object_=_response.json(),
851
+ ),
852
+ ),
853
+ )
854
+ if _response.status_code == 500:
855
+ raise InternalServerError(
856
+ headers=dict(_response.headers),
857
+ body=typing.cast(
858
+ DatabaseError,
859
+ parse_obj_as(
860
+ type_=DatabaseError, # type: ignore
861
+ object_=_response.json(),
862
+ ),
863
+ ),
864
+ )
865
+ _response_json = _response.json()
866
+ except JSONDecodeError:
867
+ raise ApiError(
868
+ status_code=_response.status_code,
869
+ headers=dict(_response.headers),
870
+ body=_response.text,
871
+ )
872
+ raise ApiError(
873
+ status_code=_response.status_code,
874
+ headers=dict(_response.headers),
875
+ body=_response_json,
876
+ )