Debian Codegraph @

src/auth0/management/user_blocks/raw_client.py

raw symbols SCIP
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 encode_path_param
10 from ..core.parse_error import ParsingError
11 from ..core.pydantic_utilities import parse_obj_as
12 from ..core.request_options import RequestOptions
13 from ..errors.bad_request_error import BadRequestError
14 from ..errors.forbidden_error import ForbiddenError
15 from ..errors.not_found_error import NotFoundError
16 from ..errors.too_many_requests_error import TooManyRequestsError
17 from ..errors.unauthorized_error import UnauthorizedError
18 from ..types.list_user_blocks_by_identifier_response_content import ListUserBlocksByIdentifierResponseContent
19 from ..types.list_user_blocks_response_content import ListUserBlocksResponseContent
20 from pydantic import ValidationError
21
22
23 class RawUserBlocksClient:
24 def __init__(self, *, client_wrapper: SyncClientWrapper):
25 self._client_wrapper = client_wrapper
26
27 def list_by_identifier(
28 self,
29 *,
30 identifier: str,
31 consider_brute_force_enablement: typing.Optional[bool] = None,
32 request_options: typing.Optional[RequestOptions] = None,
33 ) -> HttpResponse[ListUserBlocksByIdentifierResponseContent]:
34 """
35 Retrieve details of all [Brute-force Protection](https://auth0.com/docs/secure/attack-protection/brute-force-protection) blocks for a user with the given identifier (username, phone number, or email).
36
37 Parameters
38 ----------
39 identifier : str
40 Should be any of a username, phone number, or email.
41
42 consider_brute_force_enablement : typing.Optional[bool]
43
44 If true and Brute Force Protection is enabled and configured to block logins, will return a list of blocked IP addresses.
45 If true and Brute Force Protection is disabled, will return an empty list.
46
47
48 request_options : typing.Optional[RequestOptions]
49 Request-specific configuration.
50
51 Returns
52 -------
53 HttpResponse[ListUserBlocksByIdentifierResponseContent]
54 User successfully retrieved.
55 """
56 _response = self._client_wrapper.httpx_client.request(
57 "user-blocks",
58 method="GET",
59 params={
60 "identifier": identifier,
61 "consider_brute_force_enablement": consider_brute_force_enablement,
62 },
63 request_options=request_options,
64 )
65 try:
66 if 200 <= _response.status_code < 300:
67 _data = typing.cast(
68 ListUserBlocksByIdentifierResponseContent,
69 parse_obj_as(
70 type_=ListUserBlocksByIdentifierResponseContent, # type: ignore
71 object_=_response.json(),
72 ),
73 )
74 return HttpResponse(response=_response, data=_data)
75 if _response.status_code == 400:
76 raise BadRequestError(
77 headers=dict(_response.headers),
78 body=typing.cast(
79 typing.Any,
80 parse_obj_as(
81 type_=typing.Any, # type: ignore
82 object_=_response.json(),
83 ),
84 ),
85 )
86 if _response.status_code == 401:
87 raise UnauthorizedError(
88 headers=dict(_response.headers),
89 body=typing.cast(
90 typing.Any,
91 parse_obj_as(
92 type_=typing.Any, # type: ignore
93 object_=_response.json(),
94 ),
95 ),
96 )
97 if _response.status_code == 403:
98 raise ForbiddenError(
99 headers=dict(_response.headers),
100 body=typing.cast(
101 typing.Any,
102 parse_obj_as(
103 type_=typing.Any, # type: ignore
104 object_=_response.json(),
105 ),
106 ),
107 )
108 if _response.status_code == 429:
109 raise TooManyRequestsError(
110 headers=dict(_response.headers),
111 body=typing.cast(
112 typing.Any,
113 parse_obj_as(
114 type_=typing.Any, # type: ignore
115 object_=_response.json(),
116 ),
117 ),
118 )
119 _response_json = _response.json()
120 except JSONDecodeError:
121 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
122 except ValidationError as e:
123 raise ParsingError(
124 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
125 )
126 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
127
128 def delete_by_identifier(
129 self, *, identifier: str, request_options: typing.Optional[RequestOptions] = None
130 ) -> HttpResponse[None]:
131 """
132 Remove all [Brute-force Protection](https://auth0.com/docs/secure/attack-protection/brute-force-protection) blocks for the user with the given identifier (username, phone number, or email).
133
134 Note: This endpoint does not unblock users that were [blocked by a tenant administrator](https://auth0.com/docs/user-profile#block-and-unblock-a-user).
135
136 Parameters
137 ----------
138 identifier : str
139 Should be any of a username, phone number, or email.
140
141 request_options : typing.Optional[RequestOptions]
142 Request-specific configuration.
143
144 Returns
145 -------
146 HttpResponse[None]
147 """
148 _response = self._client_wrapper.httpx_client.request(
149 "user-blocks",
150 method="DELETE",
151 params={
152 "identifier": identifier,
153 },
154 request_options=request_options,
155 )
156 try:
157 if 200 <= _response.status_code < 300:
158 return HttpResponse(response=_response, data=None)
159 if _response.status_code == 400:
160 raise BadRequestError(
161 headers=dict(_response.headers),
162 body=typing.cast(
163 typing.Any,
164 parse_obj_as(
165 type_=typing.Any, # type: ignore
166 object_=_response.json(),
167 ),
168 ),
169 )
170 if _response.status_code == 401:
171 raise UnauthorizedError(
172 headers=dict(_response.headers),
173 body=typing.cast(
174 typing.Any,
175 parse_obj_as(
176 type_=typing.Any, # type: ignore
177 object_=_response.json(),
178 ),
179 ),
180 )
181 if _response.status_code == 403:
182 raise ForbiddenError(
183 headers=dict(_response.headers),
184 body=typing.cast(
185 typing.Any,
186 parse_obj_as(
187 type_=typing.Any, # type: ignore
188 object_=_response.json(),
189 ),
190 ),
191 )
192 if _response.status_code == 429:
193 raise TooManyRequestsError(
194 headers=dict(_response.headers),
195 body=typing.cast(
196 typing.Any,
197 parse_obj_as(
198 type_=typing.Any, # type: ignore
199 object_=_response.json(),
200 ),
201 ),
202 )
203 _response_json = _response.json()
204 except JSONDecodeError:
205 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
206 except ValidationError as e:
207 raise ParsingError(
208 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
209 )
210 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
211
212 def list(
213 self,
214 id: str,
215 *,
216 consider_brute_force_enablement: typing.Optional[bool] = None,
217 request_options: typing.Optional[RequestOptions] = None,
218 ) -> HttpResponse[ListUserBlocksResponseContent]:
219 """
220 Retrieve details of all [Brute-force Protection](https://auth0.com/docs/secure/attack-protection/brute-force-protection) blocks for the user with the given ID.
221
222 Parameters
223 ----------
224 id : str
225 user_id of the user blocks to retrieve.
226
227 consider_brute_force_enablement : typing.Optional[bool]
228
229 If true and Brute Force Protection is enabled and configured to block logins, will return a list of blocked IP addresses.
230 If true and Brute Force Protection is disabled, will return an empty list.
231
232
233 request_options : typing.Optional[RequestOptions]
234 Request-specific configuration.
235
236 Returns
237 -------
238 HttpResponse[ListUserBlocksResponseContent]
239 User block successfully retrieved.
240 """
241 _response = self._client_wrapper.httpx_client.request(
242 f"user-blocks/{encode_path_param(id)}",
243 method="GET",
244 params={
245 "consider_brute_force_enablement": consider_brute_force_enablement,
246 },
247 request_options=request_options,
248 )
249 try:
250 if 200 <= _response.status_code < 300:
251 _data = typing.cast(
252 ListUserBlocksResponseContent,
253 parse_obj_as(
254 type_=ListUserBlocksResponseContent, # type: ignore
255 object_=_response.json(),
256 ),
257 )
258 return HttpResponse(response=_response, data=_data)
259 if _response.status_code == 400:
260 raise BadRequestError(
261 headers=dict(_response.headers),
262 body=typing.cast(
263 typing.Any,
264 parse_obj_as(
265 type_=typing.Any, # type: ignore
266 object_=_response.json(),
267 ),
268 ),
269 )
270 if _response.status_code == 401:
271 raise UnauthorizedError(
272 headers=dict(_response.headers),
273 body=typing.cast(
274 typing.Any,
275 parse_obj_as(
276 type_=typing.Any, # type: ignore
277 object_=_response.json(),
278 ),
279 ),
280 )
281 if _response.status_code == 403:
282 raise ForbiddenError(
283 headers=dict(_response.headers),
284 body=typing.cast(
285 typing.Any,
286 parse_obj_as(
287 type_=typing.Any, # type: ignore
288 object_=_response.json(),
289 ),
290 ),
291 )
292 if _response.status_code == 404:
293 raise NotFoundError(
294 headers=dict(_response.headers),
295 body=typing.cast(
296 typing.Any,
297 parse_obj_as(
298 type_=typing.Any, # type: ignore
299 object_=_response.json(),
300 ),
301 ),
302 )
303 if _response.status_code == 429:
304 raise TooManyRequestsError(
305 headers=dict(_response.headers),
306 body=typing.cast(
307 typing.Any,
308 parse_obj_as(
309 type_=typing.Any, # type: ignore
310 object_=_response.json(),
311 ),
312 ),
313 )
314 _response_json = _response.json()
315 except JSONDecodeError:
316 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
317 except ValidationError as e:
318 raise ParsingError(
319 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
320 )
321 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
322
323 def delete(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> HttpResponse[None]:
324 """
325 Remove all [Brute-force Protection](https://auth0.com/docs/secure/attack-protection/brute-force-protection) blocks for the user with the given ID.
326
327 Note: This endpoint does not unblock users that were [blocked by a tenant administrator](https://auth0.com/docs/user-profile#block-and-unblock-a-user).
328
329 Parameters
330 ----------
331 id : str
332 The user_id of the user to update.
333
334 request_options : typing.Optional[RequestOptions]
335 Request-specific configuration.
336
337 Returns
338 -------
339 HttpResponse[None]
340 """
341 _response = self._client_wrapper.httpx_client.request(
342 f"user-blocks/{encode_path_param(id)}",
343 method="DELETE",
344 request_options=request_options,
345 )
346 try:
347 if 200 <= _response.status_code < 300:
348 return HttpResponse(response=_response, data=None)
349 if _response.status_code == 400:
350 raise BadRequestError(
351 headers=dict(_response.headers),
352 body=typing.cast(
353 typing.Any,
354 parse_obj_as(
355 type_=typing.Any, # type: ignore
356 object_=_response.json(),
357 ),
358 ),
359 )
360 if _response.status_code == 401:
361 raise UnauthorizedError(
362 headers=dict(_response.headers),
363 body=typing.cast(
364 typing.Any,
365 parse_obj_as(
366 type_=typing.Any, # type: ignore
367 object_=_response.json(),
368 ),
369 ),
370 )
371 if _response.status_code == 403:
372 raise ForbiddenError(
373 headers=dict(_response.headers),
374 body=typing.cast(
375 typing.Any,
376 parse_obj_as(
377 type_=typing.Any, # type: ignore
378 object_=_response.json(),
379 ),
380 ),
381 )
382 if _response.status_code == 404:
383 raise NotFoundError(
384 headers=dict(_response.headers),
385 body=typing.cast(
386 typing.Any,
387 parse_obj_as(
388 type_=typing.Any, # type: ignore
389 object_=_response.json(),
390 ),
391 ),
392 )
393 if _response.status_code == 429:
394 raise TooManyRequestsError(
395 headers=dict(_response.headers),
396 body=typing.cast(
397 typing.Any,
398 parse_obj_as(
399 type_=typing.Any, # type: ignore
400 object_=_response.json(),
401 ),
402 ),
403 )
404 _response_json = _response.json()
405 except JSONDecodeError:
406 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
407 except ValidationError as e:
408 raise ParsingError(
409 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
410 )
411 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
412
413
414 class AsyncRawUserBlocksClient:
415 def __init__(self, *, client_wrapper: AsyncClientWrapper):
416 self._client_wrapper = client_wrapper
417
418 async def list_by_identifier(
419 self,
420 *,
421 identifier: str,
422 consider_brute_force_enablement: typing.Optional[bool] = None,
423 request_options: typing.Optional[RequestOptions] = None,
424 ) -> AsyncHttpResponse[ListUserBlocksByIdentifierResponseContent]:
425 """
426 Retrieve details of all [Brute-force Protection](https://auth0.com/docs/secure/attack-protection/brute-force-protection) blocks for a user with the given identifier (username, phone number, or email).
427
428 Parameters
429 ----------
430 identifier : str
431 Should be any of a username, phone number, or email.
432
433 consider_brute_force_enablement : typing.Optional[bool]
434
435 If true and Brute Force Protection is enabled and configured to block logins, will return a list of blocked IP addresses.
436 If true and Brute Force Protection is disabled, will return an empty list.
437
438
439 request_options : typing.Optional[RequestOptions]
440 Request-specific configuration.
441
442 Returns
443 -------
444 AsyncHttpResponse[ListUserBlocksByIdentifierResponseContent]
445 User successfully retrieved.
446 """
447 _response = await self._client_wrapper.httpx_client.request(
448 "user-blocks",
449 method="GET",
450 params={
451 "identifier": identifier,
452 "consider_brute_force_enablement": consider_brute_force_enablement,
453 },
454 request_options=request_options,
455 )
456 try:
457 if 200 <= _response.status_code < 300:
458 _data = typing.cast(
459 ListUserBlocksByIdentifierResponseContent,
460 parse_obj_as(
461 type_=ListUserBlocksByIdentifierResponseContent, # type: ignore
462 object_=_response.json(),
463 ),
464 )
465 return AsyncHttpResponse(response=_response, data=_data)
466 if _response.status_code == 400:
467 raise BadRequestError(
468 headers=dict(_response.headers),
469 body=typing.cast(
470 typing.Any,
471 parse_obj_as(
472 type_=typing.Any, # type: ignore
473 object_=_response.json(),
474 ),
475 ),
476 )
477 if _response.status_code == 401:
478 raise UnauthorizedError(
479 headers=dict(_response.headers),
480 body=typing.cast(
481 typing.Any,
482 parse_obj_as(
483 type_=typing.Any, # type: ignore
484 object_=_response.json(),
485 ),
486 ),
487 )
488 if _response.status_code == 403:
489 raise ForbiddenError(
490 headers=dict(_response.headers),
491 body=typing.cast(
492 typing.Any,
493 parse_obj_as(
494 type_=typing.Any, # type: ignore
495 object_=_response.json(),
496 ),
497 ),
498 )
499 if _response.status_code == 429:
500 raise TooManyRequestsError(
501 headers=dict(_response.headers),
502 body=typing.cast(
503 typing.Any,
504 parse_obj_as(
505 type_=typing.Any, # type: ignore
506 object_=_response.json(),
507 ),
508 ),
509 )
510 _response_json = _response.json()
511 except JSONDecodeError:
512 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
513 except ValidationError as e:
514 raise ParsingError(
515 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
516 )
517 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
518
519 async def delete_by_identifier(
520 self, *, identifier: str, request_options: typing.Optional[RequestOptions] = None
521 ) -> AsyncHttpResponse[None]:
522 """
523 Remove all [Brute-force Protection](https://auth0.com/docs/secure/attack-protection/brute-force-protection) blocks for the user with the given identifier (username, phone number, or email).
524
525 Note: This endpoint does not unblock users that were [blocked by a tenant administrator](https://auth0.com/docs/user-profile#block-and-unblock-a-user).
526
527 Parameters
528 ----------
529 identifier : str
530 Should be any of a username, phone number, or email.
531
532 request_options : typing.Optional[RequestOptions]
533 Request-specific configuration.
534
535 Returns
536 -------
537 AsyncHttpResponse[None]
538 """
539 _response = await self._client_wrapper.httpx_client.request(
540 "user-blocks",
541 method="DELETE",
542 params={
543 "identifier": identifier,
544 },
545 request_options=request_options,
546 )
547 try:
548 if 200 <= _response.status_code < 300:
549 return AsyncHttpResponse(response=_response, data=None)
550 if _response.status_code == 400:
551 raise BadRequestError(
552 headers=dict(_response.headers),
553 body=typing.cast(
554 typing.Any,
555 parse_obj_as(
556 type_=typing.Any, # type: ignore
557 object_=_response.json(),
558 ),
559 ),
560 )
561 if _response.status_code == 401:
562 raise UnauthorizedError(
563 headers=dict(_response.headers),
564 body=typing.cast(
565 typing.Any,
566 parse_obj_as(
567 type_=typing.Any, # type: ignore
568 object_=_response.json(),
569 ),
570 ),
571 )
572 if _response.status_code == 403:
573 raise ForbiddenError(
574 headers=dict(_response.headers),
575 body=typing.cast(
576 typing.Any,
577 parse_obj_as(
578 type_=typing.Any, # type: ignore
579 object_=_response.json(),
580 ),
581 ),
582 )
583 if _response.status_code == 429:
584 raise TooManyRequestsError(
585 headers=dict(_response.headers),
586 body=typing.cast(
587 typing.Any,
588 parse_obj_as(
589 type_=typing.Any, # type: ignore
590 object_=_response.json(),
591 ),
592 ),
593 )
594 _response_json = _response.json()
595 except JSONDecodeError:
596 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
597 except ValidationError as e:
598 raise ParsingError(
599 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
600 )
601 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
602
603 async def list(
604 self,
605 id: str,
606 *,
607 consider_brute_force_enablement: typing.Optional[bool] = None,
608 request_options: typing.Optional[RequestOptions] = None,
609 ) -> AsyncHttpResponse[ListUserBlocksResponseContent]:
610 """
611 Retrieve details of all [Brute-force Protection](https://auth0.com/docs/secure/attack-protection/brute-force-protection) blocks for the user with the given ID.
612
613 Parameters
614 ----------
615 id : str
616 user_id of the user blocks to retrieve.
617
618 consider_brute_force_enablement : typing.Optional[bool]
619
620 If true and Brute Force Protection is enabled and configured to block logins, will return a list of blocked IP addresses.
621 If true and Brute Force Protection is disabled, will return an empty list.
622
623
624 request_options : typing.Optional[RequestOptions]
625 Request-specific configuration.
626
627 Returns
628 -------
629 AsyncHttpResponse[ListUserBlocksResponseContent]
630 User block successfully retrieved.
631 """
632 _response = await self._client_wrapper.httpx_client.request(
633 f"user-blocks/{encode_path_param(id)}",
634 method="GET",
635 params={
636 "consider_brute_force_enablement": consider_brute_force_enablement,
637 },
638 request_options=request_options,
639 )
640 try:
641 if 200 <= _response.status_code < 300:
642 _data = typing.cast(
643 ListUserBlocksResponseContent,
644 parse_obj_as(
645 type_=ListUserBlocksResponseContent, # type: ignore
646 object_=_response.json(),
647 ),
648 )
649 return AsyncHttpResponse(response=_response, data=_data)
650 if _response.status_code == 400:
651 raise BadRequestError(
652 headers=dict(_response.headers),
653 body=typing.cast(
654 typing.Any,
655 parse_obj_as(
656 type_=typing.Any, # type: ignore
657 object_=_response.json(),
658 ),
659 ),
660 )
661 if _response.status_code == 401:
662 raise UnauthorizedError(
663 headers=dict(_response.headers),
664 body=typing.cast(
665 typing.Any,
666 parse_obj_as(
667 type_=typing.Any, # type: ignore
668 object_=_response.json(),
669 ),
670 ),
671 )
672 if _response.status_code == 403:
673 raise ForbiddenError(
674 headers=dict(_response.headers),
675 body=typing.cast(
676 typing.Any,
677 parse_obj_as(
678 type_=typing.Any, # type: ignore
679 object_=_response.json(),
680 ),
681 ),
682 )
683 if _response.status_code == 404:
684 raise NotFoundError(
685 headers=dict(_response.headers),
686 body=typing.cast(
687 typing.Any,
688 parse_obj_as(
689 type_=typing.Any, # type: ignore
690 object_=_response.json(),
691 ),
692 ),
693 )
694 if _response.status_code == 429:
695 raise TooManyRequestsError(
696 headers=dict(_response.headers),
697 body=typing.cast(
698 typing.Any,
699 parse_obj_as(
700 type_=typing.Any, # type: ignore
701 object_=_response.json(),
702 ),
703 ),
704 )
705 _response_json = _response.json()
706 except JSONDecodeError:
707 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
708 except ValidationError as e:
709 raise ParsingError(
710 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
711 )
712 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
713
714 async def delete(
715 self, id: str, *, request_options: typing.Optional[RequestOptions] = None
716 ) -> AsyncHttpResponse[None]:
717 """
718 Remove all [Brute-force Protection](https://auth0.com/docs/secure/attack-protection/brute-force-protection) blocks for the user with the given ID.
719
720 Note: This endpoint does not unblock users that were [blocked by a tenant administrator](https://auth0.com/docs/user-profile#block-and-unblock-a-user).
721
722 Parameters
723 ----------
724 id : str
725 The user_id of the user to update.
726
727 request_options : typing.Optional[RequestOptions]
728 Request-specific configuration.
729
730 Returns
731 -------
732 AsyncHttpResponse[None]
733 """
734 _response = await self._client_wrapper.httpx_client.request(
735 f"user-blocks/{encode_path_param(id)}",
736 method="DELETE",
737 request_options=request_options,
738 )
739 try:
740 if 200 <= _response.status_code < 300:
741 return AsyncHttpResponse(response=_response, data=None)
742 if _response.status_code == 400:
743 raise BadRequestError(
744 headers=dict(_response.headers),
745 body=typing.cast(
746 typing.Any,
747 parse_obj_as(
748 type_=typing.Any, # type: ignore
749 object_=_response.json(),
750 ),
751 ),
752 )
753 if _response.status_code == 401:
754 raise UnauthorizedError(
755 headers=dict(_response.headers),
756 body=typing.cast(
757 typing.Any,
758 parse_obj_as(
759 type_=typing.Any, # type: ignore
760 object_=_response.json(),
761 ),
762 ),
763 )
764 if _response.status_code == 403:
765 raise ForbiddenError(
766 headers=dict(_response.headers),
767 body=typing.cast(
768 typing.Any,
769 parse_obj_as(
770 type_=typing.Any, # type: ignore
771 object_=_response.json(),
772 ),
773 ),
774 )
775 if _response.status_code == 404:
776 raise NotFoundError(
777 headers=dict(_response.headers),
778 body=typing.cast(
779 typing.Any,
780 parse_obj_as(
781 type_=typing.Any, # type: ignore
782 object_=_response.json(),
783 ),
784 ),
785 )
786 if _response.status_code == 429:
787 raise TooManyRequestsError(
788 headers=dict(_response.headers),
789 body=typing.cast(
790 typing.Any,
791 parse_obj_as(
792 type_=typing.Any, # type: ignore
793 object_=_response.json(),
794 ),
795 ),
796 )
797 _response_json = _response.json()
798 except JSONDecodeError:
799 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
800 except ValidationError as e:
801 raise ParsingError(
802 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
803 )
804 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)