Debian Codegraph @

src/auth0/management/keys/signing/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.get_signing_keys_response_content import GetSigningKeysResponseContent
19 from ...types.revoked_signing_keys_response_content import RevokedSigningKeysResponseContent
20 from ...types.rotate_signing_keys_response_content import RotateSigningKeysResponseContent
21 from ...types.signing_keys import SigningKeys
22 from pydantic import ValidationError
23
24
25 class RawSigningClient:
26 def __init__(self, *, client_wrapper: SyncClientWrapper):
27 self._client_wrapper = client_wrapper
28
29 def list(
30 self, *, request_options: typing.Optional[RequestOptions] = None
31 ) -> HttpResponse[typing.List[SigningKeys]]:
32 """
33 Retrieve details of all the application signing keys associated with your tenant.
34
35 Parameters
36 ----------
37 request_options : typing.Optional[RequestOptions]
38 Request-specific configuration.
39
40 Returns
41 -------
42 HttpResponse[typing.List[SigningKeys]]
43 The signing keys were retrieved.
44 """
45 _response = self._client_wrapper.httpx_client.request(
46 "keys/signing",
47 method="GET",
48 request_options=request_options,
49 )
50 try:
51 if 200 <= _response.status_code < 300:
52 _data = typing.cast(
53 typing.List[SigningKeys],
54 parse_obj_as(
55 type_=typing.List[SigningKeys], # type: ignore
56 object_=_response.json(),
57 ),
58 )
59 return HttpResponse(response=_response, data=_data)
60 if _response.status_code == 400:
61 raise BadRequestError(
62 headers=dict(_response.headers),
63 body=typing.cast(
64 typing.Any,
65 parse_obj_as(
66 type_=typing.Any, # type: ignore
67 object_=_response.json(),
68 ),
69 ),
70 )
71 if _response.status_code == 401:
72 raise UnauthorizedError(
73 headers=dict(_response.headers),
74 body=typing.cast(
75 typing.Any,
76 parse_obj_as(
77 type_=typing.Any, # type: ignore
78 object_=_response.json(),
79 ),
80 ),
81 )
82 if _response.status_code == 403:
83 raise ForbiddenError(
84 headers=dict(_response.headers),
85 body=typing.cast(
86 typing.Any,
87 parse_obj_as(
88 type_=typing.Any, # type: ignore
89 object_=_response.json(),
90 ),
91 ),
92 )
93 if _response.status_code == 429:
94 raise TooManyRequestsError(
95 headers=dict(_response.headers),
96 body=typing.cast(
97 typing.Any,
98 parse_obj_as(
99 type_=typing.Any, # type: ignore
100 object_=_response.json(),
101 ),
102 ),
103 )
104 _response_json = _response.json()
105 except JSONDecodeError:
106 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
107 except ValidationError as e:
108 raise ParsingError(
109 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
110 )
111 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
112
113 def rotate(
114 self, *, request_options: typing.Optional[RequestOptions] = None
115 ) -> HttpResponse[RotateSigningKeysResponseContent]:
116 """
117 Rotate the application signing key of your tenant.
118
119 Parameters
120 ----------
121 request_options : typing.Optional[RequestOptions]
122 Request-specific configuration.
123
124 Returns
125 -------
126 HttpResponse[RotateSigningKeysResponseContent]
127 Signing key rotated successfully.
128 """
129 _response = self._client_wrapper.httpx_client.request(
130 "keys/signing/rotate",
131 method="POST",
132 request_options=request_options,
133 )
134 try:
135 if 200 <= _response.status_code < 300:
136 _data = typing.cast(
137 RotateSigningKeysResponseContent,
138 parse_obj_as(
139 type_=RotateSigningKeysResponseContent, # type: ignore
140 object_=_response.json(),
141 ),
142 )
143 return HttpResponse(response=_response, data=_data)
144 if _response.status_code == 401:
145 raise UnauthorizedError(
146 headers=dict(_response.headers),
147 body=typing.cast(
148 typing.Any,
149 parse_obj_as(
150 type_=typing.Any, # type: ignore
151 object_=_response.json(),
152 ),
153 ),
154 )
155 if _response.status_code == 403:
156 raise ForbiddenError(
157 headers=dict(_response.headers),
158 body=typing.cast(
159 typing.Any,
160 parse_obj_as(
161 type_=typing.Any, # type: ignore
162 object_=_response.json(),
163 ),
164 ),
165 )
166 if _response.status_code == 429:
167 raise TooManyRequestsError(
168 headers=dict(_response.headers),
169 body=typing.cast(
170 typing.Any,
171 parse_obj_as(
172 type_=typing.Any, # type: ignore
173 object_=_response.json(),
174 ),
175 ),
176 )
177 _response_json = _response.json()
178 except JSONDecodeError:
179 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
180 except ValidationError as e:
181 raise ParsingError(
182 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
183 )
184 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
185
186 def get(
187 self, kid: str, *, request_options: typing.Optional[RequestOptions] = None
188 ) -> HttpResponse[GetSigningKeysResponseContent]:
189 """
190 Retrieve details of the application signing key with the given ID.
191
192 Parameters
193 ----------
194 kid : str
195 Key id of the key to retrieve
196
197 request_options : typing.Optional[RequestOptions]
198 Request-specific configuration.
199
200 Returns
201 -------
202 HttpResponse[GetSigningKeysResponseContent]
203 The signing keys were retrieved.
204 """
205 _response = self._client_wrapper.httpx_client.request(
206 f"keys/signing/{encode_path_param(kid)}",
207 method="GET",
208 request_options=request_options,
209 )
210 try:
211 if 200 <= _response.status_code < 300:
212 _data = typing.cast(
213 GetSigningKeysResponseContent,
214 parse_obj_as(
215 type_=GetSigningKeysResponseContent, # type: ignore
216 object_=_response.json(),
217 ),
218 )
219 return HttpResponse(response=_response, data=_data)
220 if _response.status_code == 400:
221 raise BadRequestError(
222 headers=dict(_response.headers),
223 body=typing.cast(
224 typing.Any,
225 parse_obj_as(
226 type_=typing.Any, # type: ignore
227 object_=_response.json(),
228 ),
229 ),
230 )
231 if _response.status_code == 401:
232 raise UnauthorizedError(
233 headers=dict(_response.headers),
234 body=typing.cast(
235 typing.Any,
236 parse_obj_as(
237 type_=typing.Any, # type: ignore
238 object_=_response.json(),
239 ),
240 ),
241 )
242 if _response.status_code == 403:
243 raise ForbiddenError(
244 headers=dict(_response.headers),
245 body=typing.cast(
246 typing.Any,
247 parse_obj_as(
248 type_=typing.Any, # type: ignore
249 object_=_response.json(),
250 ),
251 ),
252 )
253 if _response.status_code == 404:
254 raise NotFoundError(
255 headers=dict(_response.headers),
256 body=typing.cast(
257 typing.Any,
258 parse_obj_as(
259 type_=typing.Any, # type: ignore
260 object_=_response.json(),
261 ),
262 ),
263 )
264 if _response.status_code == 429:
265 raise TooManyRequestsError(
266 headers=dict(_response.headers),
267 body=typing.cast(
268 typing.Any,
269 parse_obj_as(
270 type_=typing.Any, # type: ignore
271 object_=_response.json(),
272 ),
273 ),
274 )
275 _response_json = _response.json()
276 except JSONDecodeError:
277 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
278 except ValidationError as e:
279 raise ParsingError(
280 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
281 )
282 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
283
284 def revoke(
285 self, kid: str, *, request_options: typing.Optional[RequestOptions] = None
286 ) -> HttpResponse[RevokedSigningKeysResponseContent]:
287 """
288 Revoke the application signing key with the given ID.
289
290 Parameters
291 ----------
292 kid : str
293 Key id of the key to revoke
294
295 request_options : typing.Optional[RequestOptions]
296 Request-specific configuration.
297
298 Returns
299 -------
300 HttpResponse[RevokedSigningKeysResponseContent]
301 Signing key revoked successfully.
302 """
303 _response = self._client_wrapper.httpx_client.request(
304 f"keys/signing/{encode_path_param(kid)}/revoke",
305 method="PUT",
306 request_options=request_options,
307 )
308 try:
309 if 200 <= _response.status_code < 300:
310 _data = typing.cast(
311 RevokedSigningKeysResponseContent,
312 parse_obj_as(
313 type_=RevokedSigningKeysResponseContent, # type: ignore
314 object_=_response.json(),
315 ),
316 )
317 return HttpResponse(response=_response, data=_data)
318 if _response.status_code == 401:
319 raise UnauthorizedError(
320 headers=dict(_response.headers),
321 body=typing.cast(
322 typing.Any,
323 parse_obj_as(
324 type_=typing.Any, # type: ignore
325 object_=_response.json(),
326 ),
327 ),
328 )
329 if _response.status_code == 403:
330 raise ForbiddenError(
331 headers=dict(_response.headers),
332 body=typing.cast(
333 typing.Any,
334 parse_obj_as(
335 type_=typing.Any, # type: ignore
336 object_=_response.json(),
337 ),
338 ),
339 )
340 if _response.status_code == 404:
341 raise NotFoundError(
342 headers=dict(_response.headers),
343 body=typing.cast(
344 typing.Any,
345 parse_obj_as(
346 type_=typing.Any, # type: ignore
347 object_=_response.json(),
348 ),
349 ),
350 )
351 if _response.status_code == 429:
352 raise TooManyRequestsError(
353 headers=dict(_response.headers),
354 body=typing.cast(
355 typing.Any,
356 parse_obj_as(
357 type_=typing.Any, # type: ignore
358 object_=_response.json(),
359 ),
360 ),
361 )
362 _response_json = _response.json()
363 except JSONDecodeError:
364 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
365 except ValidationError as e:
366 raise ParsingError(
367 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
368 )
369 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
370
371
372 class AsyncRawSigningClient:
373 def __init__(self, *, client_wrapper: AsyncClientWrapper):
374 self._client_wrapper = client_wrapper
375
376 async def list(
377 self, *, request_options: typing.Optional[RequestOptions] = None
378 ) -> AsyncHttpResponse[typing.List[SigningKeys]]:
379 """
380 Retrieve details of all the application signing keys associated with your tenant.
381
382 Parameters
383 ----------
384 request_options : typing.Optional[RequestOptions]
385 Request-specific configuration.
386
387 Returns
388 -------
389 AsyncHttpResponse[typing.List[SigningKeys]]
390 The signing keys were retrieved.
391 """
392 _response = await self._client_wrapper.httpx_client.request(
393 "keys/signing",
394 method="GET",
395 request_options=request_options,
396 )
397 try:
398 if 200 <= _response.status_code < 300:
399 _data = typing.cast(
400 typing.List[SigningKeys],
401 parse_obj_as(
402 type_=typing.List[SigningKeys], # type: ignore
403 object_=_response.json(),
404 ),
405 )
406 return AsyncHttpResponse(response=_response, data=_data)
407 if _response.status_code == 400:
408 raise BadRequestError(
409 headers=dict(_response.headers),
410 body=typing.cast(
411 typing.Any,
412 parse_obj_as(
413 type_=typing.Any, # type: ignore
414 object_=_response.json(),
415 ),
416 ),
417 )
418 if _response.status_code == 401:
419 raise UnauthorizedError(
420 headers=dict(_response.headers),
421 body=typing.cast(
422 typing.Any,
423 parse_obj_as(
424 type_=typing.Any, # type: ignore
425 object_=_response.json(),
426 ),
427 ),
428 )
429 if _response.status_code == 403:
430 raise ForbiddenError(
431 headers=dict(_response.headers),
432 body=typing.cast(
433 typing.Any,
434 parse_obj_as(
435 type_=typing.Any, # type: ignore
436 object_=_response.json(),
437 ),
438 ),
439 )
440 if _response.status_code == 429:
441 raise TooManyRequestsError(
442 headers=dict(_response.headers),
443 body=typing.cast(
444 typing.Any,
445 parse_obj_as(
446 type_=typing.Any, # type: ignore
447 object_=_response.json(),
448 ),
449 ),
450 )
451 _response_json = _response.json()
452 except JSONDecodeError:
453 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
454 except ValidationError as e:
455 raise ParsingError(
456 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
457 )
458 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
459
460 async def rotate(
461 self, *, request_options: typing.Optional[RequestOptions] = None
462 ) -> AsyncHttpResponse[RotateSigningKeysResponseContent]:
463 """
464 Rotate the application signing key of your tenant.
465
466 Parameters
467 ----------
468 request_options : typing.Optional[RequestOptions]
469 Request-specific configuration.
470
471 Returns
472 -------
473 AsyncHttpResponse[RotateSigningKeysResponseContent]
474 Signing key rotated successfully.
475 """
476 _response = await self._client_wrapper.httpx_client.request(
477 "keys/signing/rotate",
478 method="POST",
479 request_options=request_options,
480 )
481 try:
482 if 200 <= _response.status_code < 300:
483 _data = typing.cast(
484 RotateSigningKeysResponseContent,
485 parse_obj_as(
486 type_=RotateSigningKeysResponseContent, # type: ignore
487 object_=_response.json(),
488 ),
489 )
490 return AsyncHttpResponse(response=_response, data=_data)
491 if _response.status_code == 401:
492 raise UnauthorizedError(
493 headers=dict(_response.headers),
494 body=typing.cast(
495 typing.Any,
496 parse_obj_as(
497 type_=typing.Any, # type: ignore
498 object_=_response.json(),
499 ),
500 ),
501 )
502 if _response.status_code == 403:
503 raise ForbiddenError(
504 headers=dict(_response.headers),
505 body=typing.cast(
506 typing.Any,
507 parse_obj_as(
508 type_=typing.Any, # type: ignore
509 object_=_response.json(),
510 ),
511 ),
512 )
513 if _response.status_code == 429:
514 raise TooManyRequestsError(
515 headers=dict(_response.headers),
516 body=typing.cast(
517 typing.Any,
518 parse_obj_as(
519 type_=typing.Any, # type: ignore
520 object_=_response.json(),
521 ),
522 ),
523 )
524 _response_json = _response.json()
525 except JSONDecodeError:
526 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
527 except ValidationError as e:
528 raise ParsingError(
529 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
530 )
531 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
532
533 async def get(
534 self, kid: str, *, request_options: typing.Optional[RequestOptions] = None
535 ) -> AsyncHttpResponse[GetSigningKeysResponseContent]:
536 """
537 Retrieve details of the application signing key with the given ID.
538
539 Parameters
540 ----------
541 kid : str
542 Key id of the key to retrieve
543
544 request_options : typing.Optional[RequestOptions]
545 Request-specific configuration.
546
547 Returns
548 -------
549 AsyncHttpResponse[GetSigningKeysResponseContent]
550 The signing keys were retrieved.
551 """
552 _response = await self._client_wrapper.httpx_client.request(
553 f"keys/signing/{encode_path_param(kid)}",
554 method="GET",
555 request_options=request_options,
556 )
557 try:
558 if 200 <= _response.status_code < 300:
559 _data = typing.cast(
560 GetSigningKeysResponseContent,
561 parse_obj_as(
562 type_=GetSigningKeysResponseContent, # type: ignore
563 object_=_response.json(),
564 ),
565 )
566 return AsyncHttpResponse(response=_response, data=_data)
567 if _response.status_code == 400:
568 raise BadRequestError(
569 headers=dict(_response.headers),
570 body=typing.cast(
571 typing.Any,
572 parse_obj_as(
573 type_=typing.Any, # type: ignore
574 object_=_response.json(),
575 ),
576 ),
577 )
578 if _response.status_code == 401:
579 raise UnauthorizedError(
580 headers=dict(_response.headers),
581 body=typing.cast(
582 typing.Any,
583 parse_obj_as(
584 type_=typing.Any, # type: ignore
585 object_=_response.json(),
586 ),
587 ),
588 )
589 if _response.status_code == 403:
590 raise ForbiddenError(
591 headers=dict(_response.headers),
592 body=typing.cast(
593 typing.Any,
594 parse_obj_as(
595 type_=typing.Any, # type: ignore
596 object_=_response.json(),
597 ),
598 ),
599 )
600 if _response.status_code == 404:
601 raise NotFoundError(
602 headers=dict(_response.headers),
603 body=typing.cast(
604 typing.Any,
605 parse_obj_as(
606 type_=typing.Any, # type: ignore
607 object_=_response.json(),
608 ),
609 ),
610 )
611 if _response.status_code == 429:
612 raise TooManyRequestsError(
613 headers=dict(_response.headers),
614 body=typing.cast(
615 typing.Any,
616 parse_obj_as(
617 type_=typing.Any, # type: ignore
618 object_=_response.json(),
619 ),
620 ),
621 )
622 _response_json = _response.json()
623 except JSONDecodeError:
624 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
625 except ValidationError as e:
626 raise ParsingError(
627 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
628 )
629 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
630
631 async def revoke(
632 self, kid: str, *, request_options: typing.Optional[RequestOptions] = None
633 ) -> AsyncHttpResponse[RevokedSigningKeysResponseContent]:
634 """
635 Revoke the application signing key with the given ID.
636
637 Parameters
638 ----------
639 kid : str
640 Key id of the key to revoke
641
642 request_options : typing.Optional[RequestOptions]
643 Request-specific configuration.
644
645 Returns
646 -------
647 AsyncHttpResponse[RevokedSigningKeysResponseContent]
648 Signing key revoked successfully.
649 """
650 _response = await self._client_wrapper.httpx_client.request(
651 f"keys/signing/{encode_path_param(kid)}/revoke",
652 method="PUT",
653 request_options=request_options,
654 )
655 try:
656 if 200 <= _response.status_code < 300:
657 _data = typing.cast(
658 RevokedSigningKeysResponseContent,
659 parse_obj_as(
660 type_=RevokedSigningKeysResponseContent, # type: ignore
661 object_=_response.json(),
662 ),
663 )
664 return AsyncHttpResponse(response=_response, data=_data)
665 if _response.status_code == 401:
666 raise UnauthorizedError(
667 headers=dict(_response.headers),
668 body=typing.cast(
669 typing.Any,
670 parse_obj_as(
671 type_=typing.Any, # 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 typing.Any,
681 parse_obj_as(
682 type_=typing.Any, # 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 typing.Any,
692 parse_obj_as(
693 type_=typing.Any, # type: ignore
694 object_=_response.json(),
695 ),
696 ),
697 )
698 if _response.status_code == 429:
699 raise TooManyRequestsError(
700 headers=dict(_response.headers),
701 body=typing.cast(
702 typing.Any,
703 parse_obj_as(
704 type_=typing.Any, # type: ignore
705 object_=_response.json(),
706 ),
707 ),
708 )
709 _response_json = _response.json()
710 except JSONDecodeError:
711 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
712 except ValidationError as e:
713 raise ParsingError(
714 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
715 )
716 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)