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