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