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