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,1058 @@
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
+ slug: str,
132
+ request_options: typing.Optional[RequestOptions] = None,
133
+ ) -> HttpResponse[ProjectsCreateResponse]:
134
+ """
135
+ Parameters
136
+ ----------
137
+ organization_id : str
138
+
139
+ name : str
140
+ a string at most 100 character(s) long
141
+
142
+ slug : str
143
+ a string matching the pattern ^[a-z0-9][a-z0-9_-]*[a-z0-9]$
144
+
145
+ request_options : typing.Optional[RequestOptions]
146
+ Request-specific configuration.
147
+
148
+ Returns
149
+ -------
150
+ HttpResponse[ProjectsCreateResponse]
151
+ Success
152
+ """
153
+ _response = self._client_wrapper.httpx_client.request(
154
+ f"organizations/{jsonable_encoder(organization_id)}/projects",
155
+ method="POST",
156
+ json={
157
+ "name": name,
158
+ "slug": slug,
159
+ },
160
+ headers={
161
+ "content-type": "application/json",
162
+ },
163
+ request_options=request_options,
164
+ omit=OMIT,
165
+ )
166
+ try:
167
+ if 200 <= _response.status_code < 300:
168
+ _data = typing.cast(
169
+ ProjectsCreateResponse,
170
+ parse_obj_as(
171
+ type_=ProjectsCreateResponse, # type: ignore
172
+ object_=_response.json(),
173
+ ),
174
+ )
175
+ return HttpResponse(response=_response, data=_data)
176
+ if _response.status_code == 400:
177
+ raise BadRequestError(
178
+ headers=dict(_response.headers),
179
+ body=typing.cast(
180
+ HttpApiDecodeError,
181
+ parse_obj_as(
182
+ type_=HttpApiDecodeError, # type: ignore
183
+ object_=_response.json(),
184
+ ),
185
+ ),
186
+ )
187
+ if _response.status_code == 403:
188
+ raise ForbiddenError(
189
+ headers=dict(_response.headers),
190
+ body=typing.cast(
191
+ PermissionDeniedError,
192
+ parse_obj_as(
193
+ type_=PermissionDeniedError, # type: ignore
194
+ object_=_response.json(),
195
+ ),
196
+ ),
197
+ )
198
+ if _response.status_code == 404:
199
+ raise NotFoundError(
200
+ headers=dict(_response.headers),
201
+ body=typing.cast(
202
+ NotFoundErrorBody,
203
+ parse_obj_as(
204
+ type_=NotFoundErrorBody, # type: ignore
205
+ object_=_response.json(),
206
+ ),
207
+ ),
208
+ )
209
+ if _response.status_code == 409:
210
+ raise ConflictError(
211
+ headers=dict(_response.headers),
212
+ body=typing.cast(
213
+ AlreadyExistsError,
214
+ parse_obj_as(
215
+ type_=AlreadyExistsError, # type: ignore
216
+ object_=_response.json(),
217
+ ),
218
+ ),
219
+ )
220
+ if _response.status_code == 500:
221
+ raise InternalServerError(
222
+ headers=dict(_response.headers),
223
+ body=typing.cast(
224
+ DatabaseError,
225
+ parse_obj_as(
226
+ type_=DatabaseError, # type: ignore
227
+ object_=_response.json(),
228
+ ),
229
+ ),
230
+ )
231
+ _response_json = _response.json()
232
+ except JSONDecodeError:
233
+ raise ApiError(
234
+ status_code=_response.status_code,
235
+ headers=dict(_response.headers),
236
+ body=_response.text,
237
+ )
238
+ raise ApiError(
239
+ status_code=_response.status_code,
240
+ headers=dict(_response.headers),
241
+ body=_response_json,
242
+ )
243
+
244
+ def get(
245
+ self,
246
+ organization_id: str,
247
+ project_id: str,
248
+ *,
249
+ request_options: typing.Optional[RequestOptions] = None,
250
+ ) -> HttpResponse[ProjectsGetResponse]:
251
+ """
252
+ Parameters
253
+ ----------
254
+ organization_id : str
255
+
256
+ project_id : str
257
+
258
+ request_options : typing.Optional[RequestOptions]
259
+ Request-specific configuration.
260
+
261
+ Returns
262
+ -------
263
+ HttpResponse[ProjectsGetResponse]
264
+ Success
265
+ """
266
+ _response = self._client_wrapper.httpx_client.request(
267
+ f"organizations/{jsonable_encoder(organization_id)}/projects/{jsonable_encoder(project_id)}",
268
+ method="GET",
269
+ request_options=request_options,
270
+ )
271
+ try:
272
+ if 200 <= _response.status_code < 300:
273
+ _data = typing.cast(
274
+ ProjectsGetResponse,
275
+ parse_obj_as(
276
+ type_=ProjectsGetResponse, # type: ignore
277
+ object_=_response.json(),
278
+ ),
279
+ )
280
+ return HttpResponse(response=_response, data=_data)
281
+ if _response.status_code == 400:
282
+ raise BadRequestError(
283
+ headers=dict(_response.headers),
284
+ body=typing.cast(
285
+ HttpApiDecodeError,
286
+ parse_obj_as(
287
+ type_=HttpApiDecodeError, # type: ignore
288
+ object_=_response.json(),
289
+ ),
290
+ ),
291
+ )
292
+ if _response.status_code == 403:
293
+ raise ForbiddenError(
294
+ headers=dict(_response.headers),
295
+ body=typing.cast(
296
+ PermissionDeniedError,
297
+ parse_obj_as(
298
+ type_=PermissionDeniedError, # type: ignore
299
+ object_=_response.json(),
300
+ ),
301
+ ),
302
+ )
303
+ if _response.status_code == 404:
304
+ raise NotFoundError(
305
+ headers=dict(_response.headers),
306
+ body=typing.cast(
307
+ NotFoundErrorBody,
308
+ parse_obj_as(
309
+ type_=NotFoundErrorBody, # type: ignore
310
+ object_=_response.json(),
311
+ ),
312
+ ),
313
+ )
314
+ if _response.status_code == 500:
315
+ raise InternalServerError(
316
+ headers=dict(_response.headers),
317
+ body=typing.cast(
318
+ DatabaseError,
319
+ parse_obj_as(
320
+ type_=DatabaseError, # type: ignore
321
+ object_=_response.json(),
322
+ ),
323
+ ),
324
+ )
325
+ _response_json = _response.json()
326
+ except JSONDecodeError:
327
+ raise ApiError(
328
+ status_code=_response.status_code,
329
+ headers=dict(_response.headers),
330
+ body=_response.text,
331
+ )
332
+ raise ApiError(
333
+ status_code=_response.status_code,
334
+ headers=dict(_response.headers),
335
+ body=_response_json,
336
+ )
337
+
338
+ def update(
339
+ self,
340
+ organization_id: str,
341
+ project_id: str,
342
+ *,
343
+ name: typing.Optional[str] = OMIT,
344
+ slug: typing.Optional[str] = OMIT,
345
+ request_options: typing.Optional[RequestOptions] = None,
346
+ ) -> HttpResponse[ProjectsUpdateResponse]:
347
+ """
348
+ Parameters
349
+ ----------
350
+ organization_id : str
351
+
352
+ project_id : str
353
+
354
+ name : typing.Optional[str]
355
+ a string at most 100 character(s) long
356
+
357
+ slug : typing.Optional[str]
358
+ a string matching the pattern ^[a-z0-9][a-z0-9_-]*[a-z0-9]$
359
+
360
+ request_options : typing.Optional[RequestOptions]
361
+ Request-specific configuration.
362
+
363
+ Returns
364
+ -------
365
+ HttpResponse[ProjectsUpdateResponse]
366
+ Success
367
+ """
368
+ _response = self._client_wrapper.httpx_client.request(
369
+ f"organizations/{jsonable_encoder(organization_id)}/projects/{jsonable_encoder(project_id)}",
370
+ method="PUT",
371
+ json={
372
+ "name": name,
373
+ "slug": slug,
374
+ },
375
+ headers={
376
+ "content-type": "application/json",
377
+ },
378
+ request_options=request_options,
379
+ omit=OMIT,
380
+ )
381
+ try:
382
+ if 200 <= _response.status_code < 300:
383
+ _data = typing.cast(
384
+ ProjectsUpdateResponse,
385
+ parse_obj_as(
386
+ type_=ProjectsUpdateResponse, # type: ignore
387
+ object_=_response.json(),
388
+ ),
389
+ )
390
+ return HttpResponse(response=_response, data=_data)
391
+ if _response.status_code == 400:
392
+ raise BadRequestError(
393
+ headers=dict(_response.headers),
394
+ body=typing.cast(
395
+ HttpApiDecodeError,
396
+ parse_obj_as(
397
+ type_=HttpApiDecodeError, # type: ignore
398
+ object_=_response.json(),
399
+ ),
400
+ ),
401
+ )
402
+ if _response.status_code == 403:
403
+ raise ForbiddenError(
404
+ headers=dict(_response.headers),
405
+ body=typing.cast(
406
+ PermissionDeniedError,
407
+ parse_obj_as(
408
+ type_=PermissionDeniedError, # type: ignore
409
+ object_=_response.json(),
410
+ ),
411
+ ),
412
+ )
413
+ if _response.status_code == 404:
414
+ raise NotFoundError(
415
+ headers=dict(_response.headers),
416
+ body=typing.cast(
417
+ NotFoundErrorBody,
418
+ parse_obj_as(
419
+ type_=NotFoundErrorBody, # type: ignore
420
+ object_=_response.json(),
421
+ ),
422
+ ),
423
+ )
424
+ if _response.status_code == 409:
425
+ raise ConflictError(
426
+ headers=dict(_response.headers),
427
+ body=typing.cast(
428
+ AlreadyExistsError,
429
+ parse_obj_as(
430
+ type_=AlreadyExistsError, # type: ignore
431
+ object_=_response.json(),
432
+ ),
433
+ ),
434
+ )
435
+ if _response.status_code == 500:
436
+ raise InternalServerError(
437
+ headers=dict(_response.headers),
438
+ body=typing.cast(
439
+ DatabaseError,
440
+ parse_obj_as(
441
+ type_=DatabaseError, # type: ignore
442
+ object_=_response.json(),
443
+ ),
444
+ ),
445
+ )
446
+ _response_json = _response.json()
447
+ except JSONDecodeError:
448
+ raise ApiError(
449
+ status_code=_response.status_code,
450
+ headers=dict(_response.headers),
451
+ body=_response.text,
452
+ )
453
+ raise ApiError(
454
+ status_code=_response.status_code,
455
+ headers=dict(_response.headers),
456
+ body=_response_json,
457
+ )
458
+
459
+ def delete(
460
+ self,
461
+ organization_id: str,
462
+ project_id: str,
463
+ *,
464
+ request_options: typing.Optional[RequestOptions] = None,
465
+ ) -> HttpResponse[None]:
466
+ """
467
+ Parameters
468
+ ----------
469
+ organization_id : str
470
+
471
+ project_id : str
472
+
473
+ request_options : typing.Optional[RequestOptions]
474
+ Request-specific configuration.
475
+
476
+ Returns
477
+ -------
478
+ HttpResponse[None]
479
+ """
480
+ _response = self._client_wrapper.httpx_client.request(
481
+ f"organizations/{jsonable_encoder(organization_id)}/projects/{jsonable_encoder(project_id)}",
482
+ method="DELETE",
483
+ request_options=request_options,
484
+ )
485
+ try:
486
+ if 200 <= _response.status_code < 300:
487
+ return HttpResponse(response=_response, data=None)
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 == 403:
500
+ raise ForbiddenError(
501
+ headers=dict(_response.headers),
502
+ body=typing.cast(
503
+ PermissionDeniedError,
504
+ parse_obj_as(
505
+ type_=PermissionDeniedError, # type: ignore
506
+ object_=_response.json(),
507
+ ),
508
+ ),
509
+ )
510
+ if _response.status_code == 404:
511
+ raise NotFoundError(
512
+ headers=dict(_response.headers),
513
+ body=typing.cast(
514
+ NotFoundErrorBody,
515
+ parse_obj_as(
516
+ type_=NotFoundErrorBody, # type: ignore
517
+ object_=_response.json(),
518
+ ),
519
+ ),
520
+ )
521
+ if _response.status_code == 500:
522
+ raise InternalServerError(
523
+ headers=dict(_response.headers),
524
+ body=typing.cast(
525
+ DatabaseError,
526
+ parse_obj_as(
527
+ type_=DatabaseError, # type: ignore
528
+ object_=_response.json(),
529
+ ),
530
+ ),
531
+ )
532
+ _response_json = _response.json()
533
+ except JSONDecodeError:
534
+ raise ApiError(
535
+ status_code=_response.status_code,
536
+ headers=dict(_response.headers),
537
+ body=_response.text,
538
+ )
539
+ raise ApiError(
540
+ status_code=_response.status_code,
541
+ headers=dict(_response.headers),
542
+ body=_response_json,
543
+ )
544
+
545
+
546
+ class AsyncRawProjectsClient:
547
+ def __init__(self, *, client_wrapper: AsyncClientWrapper):
548
+ self._client_wrapper = client_wrapper
549
+
550
+ async def list(
551
+ self,
552
+ organization_id: str,
553
+ *,
554
+ request_options: typing.Optional[RequestOptions] = None,
555
+ ) -> AsyncHttpResponse[typing.List[ProjectsListResponseItem]]:
556
+ """
557
+ Parameters
558
+ ----------
559
+ organization_id : str
560
+
561
+ request_options : typing.Optional[RequestOptions]
562
+ Request-specific configuration.
563
+
564
+ Returns
565
+ -------
566
+ AsyncHttpResponse[typing.List[ProjectsListResponseItem]]
567
+ Success
568
+ """
569
+ _response = await self._client_wrapper.httpx_client.request(
570
+ f"organizations/{jsonable_encoder(organization_id)}/projects",
571
+ method="GET",
572
+ request_options=request_options,
573
+ )
574
+ try:
575
+ if 200 <= _response.status_code < 300:
576
+ _data = typing.cast(
577
+ typing.List[ProjectsListResponseItem],
578
+ parse_obj_as(
579
+ type_=typing.List[ProjectsListResponseItem], # type: ignore
580
+ object_=_response.json(),
581
+ ),
582
+ )
583
+ return AsyncHttpResponse(response=_response, data=_data)
584
+ if _response.status_code == 400:
585
+ raise BadRequestError(
586
+ headers=dict(_response.headers),
587
+ body=typing.cast(
588
+ HttpApiDecodeError,
589
+ parse_obj_as(
590
+ type_=HttpApiDecodeError, # type: ignore
591
+ object_=_response.json(),
592
+ ),
593
+ ),
594
+ )
595
+ if _response.status_code == 403:
596
+ raise ForbiddenError(
597
+ headers=dict(_response.headers),
598
+ body=typing.cast(
599
+ PermissionDeniedError,
600
+ parse_obj_as(
601
+ type_=PermissionDeniedError, # type: ignore
602
+ object_=_response.json(),
603
+ ),
604
+ ),
605
+ )
606
+ if _response.status_code == 404:
607
+ raise NotFoundError(
608
+ headers=dict(_response.headers),
609
+ body=typing.cast(
610
+ NotFoundErrorBody,
611
+ parse_obj_as(
612
+ type_=NotFoundErrorBody, # type: ignore
613
+ object_=_response.json(),
614
+ ),
615
+ ),
616
+ )
617
+ if _response.status_code == 500:
618
+ raise InternalServerError(
619
+ headers=dict(_response.headers),
620
+ body=typing.cast(
621
+ DatabaseError,
622
+ parse_obj_as(
623
+ type_=DatabaseError, # type: ignore
624
+ object_=_response.json(),
625
+ ),
626
+ ),
627
+ )
628
+ _response_json = _response.json()
629
+ except JSONDecodeError:
630
+ raise ApiError(
631
+ status_code=_response.status_code,
632
+ headers=dict(_response.headers),
633
+ body=_response.text,
634
+ )
635
+ raise ApiError(
636
+ status_code=_response.status_code,
637
+ headers=dict(_response.headers),
638
+ body=_response_json,
639
+ )
640
+
641
+ async def create(
642
+ self,
643
+ organization_id: str,
644
+ *,
645
+ name: str,
646
+ slug: str,
647
+ request_options: typing.Optional[RequestOptions] = None,
648
+ ) -> AsyncHttpResponse[ProjectsCreateResponse]:
649
+ """
650
+ Parameters
651
+ ----------
652
+ organization_id : str
653
+
654
+ name : str
655
+ a string at most 100 character(s) long
656
+
657
+ slug : str
658
+ a string matching the pattern ^[a-z0-9][a-z0-9_-]*[a-z0-9]$
659
+
660
+ request_options : typing.Optional[RequestOptions]
661
+ Request-specific configuration.
662
+
663
+ Returns
664
+ -------
665
+ AsyncHttpResponse[ProjectsCreateResponse]
666
+ Success
667
+ """
668
+ _response = await self._client_wrapper.httpx_client.request(
669
+ f"organizations/{jsonable_encoder(organization_id)}/projects",
670
+ method="POST",
671
+ json={
672
+ "name": name,
673
+ "slug": slug,
674
+ },
675
+ headers={
676
+ "content-type": "application/json",
677
+ },
678
+ request_options=request_options,
679
+ omit=OMIT,
680
+ )
681
+ try:
682
+ if 200 <= _response.status_code < 300:
683
+ _data = typing.cast(
684
+ ProjectsCreateResponse,
685
+ parse_obj_as(
686
+ type_=ProjectsCreateResponse, # type: ignore
687
+ object_=_response.json(),
688
+ ),
689
+ )
690
+ return AsyncHttpResponse(response=_response, data=_data)
691
+ if _response.status_code == 400:
692
+ raise BadRequestError(
693
+ headers=dict(_response.headers),
694
+ body=typing.cast(
695
+ HttpApiDecodeError,
696
+ parse_obj_as(
697
+ type_=HttpApiDecodeError, # type: ignore
698
+ object_=_response.json(),
699
+ ),
700
+ ),
701
+ )
702
+ if _response.status_code == 403:
703
+ raise ForbiddenError(
704
+ headers=dict(_response.headers),
705
+ body=typing.cast(
706
+ PermissionDeniedError,
707
+ parse_obj_as(
708
+ type_=PermissionDeniedError, # type: ignore
709
+ object_=_response.json(),
710
+ ),
711
+ ),
712
+ )
713
+ if _response.status_code == 404:
714
+ raise NotFoundError(
715
+ headers=dict(_response.headers),
716
+ body=typing.cast(
717
+ NotFoundErrorBody,
718
+ parse_obj_as(
719
+ type_=NotFoundErrorBody, # type: ignore
720
+ object_=_response.json(),
721
+ ),
722
+ ),
723
+ )
724
+ if _response.status_code == 409:
725
+ raise ConflictError(
726
+ headers=dict(_response.headers),
727
+ body=typing.cast(
728
+ AlreadyExistsError,
729
+ parse_obj_as(
730
+ type_=AlreadyExistsError, # type: ignore
731
+ object_=_response.json(),
732
+ ),
733
+ ),
734
+ )
735
+ if _response.status_code == 500:
736
+ raise InternalServerError(
737
+ headers=dict(_response.headers),
738
+ body=typing.cast(
739
+ DatabaseError,
740
+ parse_obj_as(
741
+ type_=DatabaseError, # type: ignore
742
+ object_=_response.json(),
743
+ ),
744
+ ),
745
+ )
746
+ _response_json = _response.json()
747
+ except JSONDecodeError:
748
+ raise ApiError(
749
+ status_code=_response.status_code,
750
+ headers=dict(_response.headers),
751
+ body=_response.text,
752
+ )
753
+ raise ApiError(
754
+ status_code=_response.status_code,
755
+ headers=dict(_response.headers),
756
+ body=_response_json,
757
+ )
758
+
759
+ async def get(
760
+ self,
761
+ organization_id: str,
762
+ project_id: str,
763
+ *,
764
+ request_options: typing.Optional[RequestOptions] = None,
765
+ ) -> AsyncHttpResponse[ProjectsGetResponse]:
766
+ """
767
+ Parameters
768
+ ----------
769
+ organization_id : str
770
+
771
+ project_id : str
772
+
773
+ request_options : typing.Optional[RequestOptions]
774
+ Request-specific configuration.
775
+
776
+ Returns
777
+ -------
778
+ AsyncHttpResponse[ProjectsGetResponse]
779
+ Success
780
+ """
781
+ _response = await self._client_wrapper.httpx_client.request(
782
+ f"organizations/{jsonable_encoder(organization_id)}/projects/{jsonable_encoder(project_id)}",
783
+ method="GET",
784
+ request_options=request_options,
785
+ )
786
+ try:
787
+ if 200 <= _response.status_code < 300:
788
+ _data = typing.cast(
789
+ ProjectsGetResponse,
790
+ parse_obj_as(
791
+ type_=ProjectsGetResponse, # type: ignore
792
+ object_=_response.json(),
793
+ ),
794
+ )
795
+ return AsyncHttpResponse(response=_response, data=_data)
796
+ if _response.status_code == 400:
797
+ raise BadRequestError(
798
+ headers=dict(_response.headers),
799
+ body=typing.cast(
800
+ HttpApiDecodeError,
801
+ parse_obj_as(
802
+ type_=HttpApiDecodeError, # type: ignore
803
+ object_=_response.json(),
804
+ ),
805
+ ),
806
+ )
807
+ if _response.status_code == 403:
808
+ raise ForbiddenError(
809
+ headers=dict(_response.headers),
810
+ body=typing.cast(
811
+ PermissionDeniedError,
812
+ parse_obj_as(
813
+ type_=PermissionDeniedError, # type: ignore
814
+ object_=_response.json(),
815
+ ),
816
+ ),
817
+ )
818
+ if _response.status_code == 404:
819
+ raise NotFoundError(
820
+ headers=dict(_response.headers),
821
+ body=typing.cast(
822
+ NotFoundErrorBody,
823
+ parse_obj_as(
824
+ type_=NotFoundErrorBody, # type: ignore
825
+ object_=_response.json(),
826
+ ),
827
+ ),
828
+ )
829
+ if _response.status_code == 500:
830
+ raise InternalServerError(
831
+ headers=dict(_response.headers),
832
+ body=typing.cast(
833
+ DatabaseError,
834
+ parse_obj_as(
835
+ type_=DatabaseError, # type: ignore
836
+ object_=_response.json(),
837
+ ),
838
+ ),
839
+ )
840
+ _response_json = _response.json()
841
+ except JSONDecodeError:
842
+ raise ApiError(
843
+ status_code=_response.status_code,
844
+ headers=dict(_response.headers),
845
+ body=_response.text,
846
+ )
847
+ raise ApiError(
848
+ status_code=_response.status_code,
849
+ headers=dict(_response.headers),
850
+ body=_response_json,
851
+ )
852
+
853
+ async def update(
854
+ self,
855
+ organization_id: str,
856
+ project_id: str,
857
+ *,
858
+ name: typing.Optional[str] = OMIT,
859
+ slug: typing.Optional[str] = OMIT,
860
+ request_options: typing.Optional[RequestOptions] = None,
861
+ ) -> AsyncHttpResponse[ProjectsUpdateResponse]:
862
+ """
863
+ Parameters
864
+ ----------
865
+ organization_id : str
866
+
867
+ project_id : str
868
+
869
+ name : typing.Optional[str]
870
+ a string at most 100 character(s) long
871
+
872
+ slug : typing.Optional[str]
873
+ a string matching the pattern ^[a-z0-9][a-z0-9_-]*[a-z0-9]$
874
+
875
+ request_options : typing.Optional[RequestOptions]
876
+ Request-specific configuration.
877
+
878
+ Returns
879
+ -------
880
+ AsyncHttpResponse[ProjectsUpdateResponse]
881
+ Success
882
+ """
883
+ _response = await self._client_wrapper.httpx_client.request(
884
+ f"organizations/{jsonable_encoder(organization_id)}/projects/{jsonable_encoder(project_id)}",
885
+ method="PUT",
886
+ json={
887
+ "name": name,
888
+ "slug": slug,
889
+ },
890
+ headers={
891
+ "content-type": "application/json",
892
+ },
893
+ request_options=request_options,
894
+ omit=OMIT,
895
+ )
896
+ try:
897
+ if 200 <= _response.status_code < 300:
898
+ _data = typing.cast(
899
+ ProjectsUpdateResponse,
900
+ parse_obj_as(
901
+ type_=ProjectsUpdateResponse, # type: ignore
902
+ object_=_response.json(),
903
+ ),
904
+ )
905
+ return AsyncHttpResponse(response=_response, data=_data)
906
+ if _response.status_code == 400:
907
+ raise BadRequestError(
908
+ headers=dict(_response.headers),
909
+ body=typing.cast(
910
+ HttpApiDecodeError,
911
+ parse_obj_as(
912
+ type_=HttpApiDecodeError, # type: ignore
913
+ object_=_response.json(),
914
+ ),
915
+ ),
916
+ )
917
+ if _response.status_code == 403:
918
+ raise ForbiddenError(
919
+ headers=dict(_response.headers),
920
+ body=typing.cast(
921
+ PermissionDeniedError,
922
+ parse_obj_as(
923
+ type_=PermissionDeniedError, # type: ignore
924
+ object_=_response.json(),
925
+ ),
926
+ ),
927
+ )
928
+ if _response.status_code == 404:
929
+ raise NotFoundError(
930
+ headers=dict(_response.headers),
931
+ body=typing.cast(
932
+ NotFoundErrorBody,
933
+ parse_obj_as(
934
+ type_=NotFoundErrorBody, # type: ignore
935
+ object_=_response.json(),
936
+ ),
937
+ ),
938
+ )
939
+ if _response.status_code == 409:
940
+ raise ConflictError(
941
+ headers=dict(_response.headers),
942
+ body=typing.cast(
943
+ AlreadyExistsError,
944
+ parse_obj_as(
945
+ type_=AlreadyExistsError, # type: ignore
946
+ object_=_response.json(),
947
+ ),
948
+ ),
949
+ )
950
+ if _response.status_code == 500:
951
+ raise InternalServerError(
952
+ headers=dict(_response.headers),
953
+ body=typing.cast(
954
+ DatabaseError,
955
+ parse_obj_as(
956
+ type_=DatabaseError, # type: ignore
957
+ object_=_response.json(),
958
+ ),
959
+ ),
960
+ )
961
+ _response_json = _response.json()
962
+ except JSONDecodeError:
963
+ raise ApiError(
964
+ status_code=_response.status_code,
965
+ headers=dict(_response.headers),
966
+ body=_response.text,
967
+ )
968
+ raise ApiError(
969
+ status_code=_response.status_code,
970
+ headers=dict(_response.headers),
971
+ body=_response_json,
972
+ )
973
+
974
+ async def delete(
975
+ self,
976
+ organization_id: str,
977
+ project_id: str,
978
+ *,
979
+ request_options: typing.Optional[RequestOptions] = None,
980
+ ) -> AsyncHttpResponse[None]:
981
+ """
982
+ Parameters
983
+ ----------
984
+ organization_id : str
985
+
986
+ project_id : str
987
+
988
+ request_options : typing.Optional[RequestOptions]
989
+ Request-specific configuration.
990
+
991
+ Returns
992
+ -------
993
+ AsyncHttpResponse[None]
994
+ """
995
+ _response = await self._client_wrapper.httpx_client.request(
996
+ f"organizations/{jsonable_encoder(organization_id)}/projects/{jsonable_encoder(project_id)}",
997
+ method="DELETE",
998
+ request_options=request_options,
999
+ )
1000
+ try:
1001
+ if 200 <= _response.status_code < 300:
1002
+ return AsyncHttpResponse(response=_response, data=None)
1003
+ if _response.status_code == 400:
1004
+ raise BadRequestError(
1005
+ headers=dict(_response.headers),
1006
+ body=typing.cast(
1007
+ HttpApiDecodeError,
1008
+ parse_obj_as(
1009
+ type_=HttpApiDecodeError, # type: ignore
1010
+ object_=_response.json(),
1011
+ ),
1012
+ ),
1013
+ )
1014
+ if _response.status_code == 403:
1015
+ raise ForbiddenError(
1016
+ headers=dict(_response.headers),
1017
+ body=typing.cast(
1018
+ PermissionDeniedError,
1019
+ parse_obj_as(
1020
+ type_=PermissionDeniedError, # type: ignore
1021
+ object_=_response.json(),
1022
+ ),
1023
+ ),
1024
+ )
1025
+ if _response.status_code == 404:
1026
+ raise NotFoundError(
1027
+ headers=dict(_response.headers),
1028
+ body=typing.cast(
1029
+ NotFoundErrorBody,
1030
+ parse_obj_as(
1031
+ type_=NotFoundErrorBody, # type: ignore
1032
+ object_=_response.json(),
1033
+ ),
1034
+ ),
1035
+ )
1036
+ if _response.status_code == 500:
1037
+ raise InternalServerError(
1038
+ headers=dict(_response.headers),
1039
+ body=typing.cast(
1040
+ DatabaseError,
1041
+ parse_obj_as(
1042
+ type_=DatabaseError, # type: ignore
1043
+ object_=_response.json(),
1044
+ ),
1045
+ ),
1046
+ )
1047
+ _response_json = _response.json()
1048
+ except JSONDecodeError:
1049
+ raise ApiError(
1050
+ status_code=_response.status_code,
1051
+ headers=dict(_response.headers),
1052
+ body=_response.text,
1053
+ )
1054
+ raise ApiError(
1055
+ status_code=_response.status_code,
1056
+ headers=dict(_response.headers),
1057
+ body=_response_json,
1058
+ )