Debian Codegraph @

src/auth0/management/token_exchange_profiles/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.pagination import AsyncPager, SyncPager
11 from ..core.parse_error import ParsingError
12 from ..core.pydantic_utilities import parse_obj_as
13 from ..core.request_options import RequestOptions
14 from ..errors.bad_request_error import BadRequestError
15 from ..errors.conflict_error import ConflictError
16 from ..errors.forbidden_error import ForbiddenError
17 from ..errors.not_found_error import NotFoundError
18 from ..errors.too_many_requests_error import TooManyRequestsError
19 from ..errors.unauthorized_error import UnauthorizedError
20 from ..types.create_token_exchange_profile_response_content import CreateTokenExchangeProfileResponseContent
21 from ..types.get_token_exchange_profile_response_content import GetTokenExchangeProfileResponseContent
22 from ..types.list_token_exchange_profile_response_content import ListTokenExchangeProfileResponseContent
23 from ..types.token_exchange_profile_response_content import TokenExchangeProfileResponseContent
24 from ..types.token_exchange_profile_type_enum import TokenExchangeProfileTypeEnum
25 from pydantic import ValidationError
26
27 # this is used as the default value for optional parameters
28 OMIT = typing.cast(typing.Any, ...)
29
30
31 class RawTokenExchangeProfilesClient:
32 def __init__(self, *, client_wrapper: SyncClientWrapper):
33 self._client_wrapper = client_wrapper
34
35 def list(
36 self,
37 *,
38 from_: typing.Optional[str] = None,
39 take: typing.Optional[int] = 50,
40 request_options: typing.Optional[RequestOptions] = None,
41 ) -> SyncPager[TokenExchangeProfileResponseContent, ListTokenExchangeProfileResponseContent]:
42 """
43 Retrieve a list of all Token Exchange Profiles available in your tenant.
44
45 By using this feature, you agree to the applicable Free Trial terms in [Okta’s Master Subscription Agreement](https://www.okta.com/legal/). It is your responsibility to securely validate the user’s subject_token. See [User Guide](https://auth0.com/docs/authenticate/custom-token-exchange) for more details.
46
47 This endpoint supports Checkpoint pagination. To search by checkpoint, use the following parameters:
48
49 - `from`: Optional id from which to start selection.
50 - `take`: The total amount of entries to retrieve when using the from parameter. Defaults to 50.
51
52 **Note**: The first time you call this endpoint using checkpoint pagination, omit the `from` parameter. If there are more results, a `next` value is included in the response. You can use this for subsequent API calls. When `next` is no longer included in the response, no pages are remaining.
53
54 Parameters
55 ----------
56 from_ : typing.Optional[str]
57 Optional Id from which to start selection.
58
59 take : typing.Optional[int]
60 Number of results per page. Defaults to 50.
61
62 request_options : typing.Optional[RequestOptions]
63 Request-specific configuration.
64
65 Returns
66 -------
67 SyncPager[TokenExchangeProfileResponseContent, ListTokenExchangeProfileResponseContent]
68 Token Exchange Profile successfully retrieved.
69 """
70 _response = self._client_wrapper.httpx_client.request(
71 "token-exchange-profiles",
72 method="GET",
73 params={
74 "from": from_,
75 "take": take,
76 },
77 request_options=request_options,
78 )
79 try:
80 if 200 <= _response.status_code < 300:
81 _parsed_response = typing.cast(
82 ListTokenExchangeProfileResponseContent,
83 parse_obj_as(
84 type_=ListTokenExchangeProfileResponseContent, # type: ignore
85 object_=_response.json(),
86 ),
87 )
88 _items = _parsed_response.token_exchange_profiles
89 _parsed_next = _parsed_response.next
90 _has_next = _parsed_next is not None and _parsed_next != ""
91 _get_next = lambda: self.list(
92 from_=_parsed_next,
93 take=take,
94 request_options=request_options,
95 )
96 return SyncPager(has_next=_has_next, items=_items, get_next=_get_next, response=_parsed_response)
97 if _response.status_code == 400:
98 raise BadRequestError(
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 == 401:
109 raise UnauthorizedError(
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 if _response.status_code == 403:
120 raise ForbiddenError(
121 headers=dict(_response.headers),
122 body=typing.cast(
123 typing.Any,
124 parse_obj_as(
125 type_=typing.Any, # type: ignore
126 object_=_response.json(),
127 ),
128 ),
129 )
130 if _response.status_code == 429:
131 raise TooManyRequestsError(
132 headers=dict(_response.headers),
133 body=typing.cast(
134 typing.Any,
135 parse_obj_as(
136 type_=typing.Any, # type: ignore
137 object_=_response.json(),
138 ),
139 ),
140 )
141 _response_json = _response.json()
142 except JSONDecodeError:
143 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
144 except ValidationError as e:
145 raise ParsingError(
146 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
147 )
148 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
149
150 def create(
151 self,
152 *,
153 name: str,
154 subject_token_type: str,
155 action_id: str,
156 type: TokenExchangeProfileTypeEnum,
157 request_options: typing.Optional[RequestOptions] = None,
158 ) -> HttpResponse[CreateTokenExchangeProfileResponseContent]:
159 """
160 Create a new Token Exchange Profile within your tenant.
161
162 By using this feature, you agree to the applicable Free Trial terms in [Okta’s Master Subscription Agreement](https://www.okta.com/legal/). It is your responsibility to securely validate the user’s subject_token. See [User Guide](https://auth0.com/docs/authenticate/custom-token-exchange) for more details.
163
164 Parameters
165 ----------
166 name : str
167 Friendly name of this profile.
168
169 subject_token_type : str
170 Subject token type for this profile. When receiving a token exchange request on the Authentication API, the corresponding token exchange profile with a matching subject_token_type will be executed. This must be a URI.
171
172 action_id : str
173 The ID of the Custom Token Exchange action to execute for this profile, in order to validate the subject_token. The action must use the custom-token-exchange trigger.
174
175 type : TokenExchangeProfileTypeEnum
176
177 request_options : typing.Optional[RequestOptions]
178 Request-specific configuration.
179
180 Returns
181 -------
182 HttpResponse[CreateTokenExchangeProfileResponseContent]
183 Token exchange profile successfully created.
184 """
185 _response = self._client_wrapper.httpx_client.request(
186 "token-exchange-profiles",
187 method="POST",
188 json={
189 "name": name,
190 "subject_token_type": subject_token_type,
191 "action_id": action_id,
192 "type": type,
193 },
194 headers={
195 "content-type": "application/json",
196 },
197 request_options=request_options,
198 omit=OMIT,
199 )
200 try:
201 if 200 <= _response.status_code < 300:
202 _data = typing.cast(
203 CreateTokenExchangeProfileResponseContent,
204 parse_obj_as(
205 type_=CreateTokenExchangeProfileResponseContent, # type: ignore
206 object_=_response.json(),
207 ),
208 )
209 return HttpResponse(response=_response, data=_data)
210 if _response.status_code == 400:
211 raise BadRequestError(
212 headers=dict(_response.headers),
213 body=typing.cast(
214 typing.Any,
215 parse_obj_as(
216 type_=typing.Any, # type: ignore
217 object_=_response.json(),
218 ),
219 ),
220 )
221 if _response.status_code == 401:
222 raise UnauthorizedError(
223 headers=dict(_response.headers),
224 body=typing.cast(
225 typing.Any,
226 parse_obj_as(
227 type_=typing.Any, # type: ignore
228 object_=_response.json(),
229 ),
230 ),
231 )
232 if _response.status_code == 403:
233 raise ForbiddenError(
234 headers=dict(_response.headers),
235 body=typing.cast(
236 typing.Any,
237 parse_obj_as(
238 type_=typing.Any, # type: ignore
239 object_=_response.json(),
240 ),
241 ),
242 )
243 if _response.status_code == 409:
244 raise ConflictError(
245 headers=dict(_response.headers),
246 body=typing.cast(
247 typing.Any,
248 parse_obj_as(
249 type_=typing.Any, # type: ignore
250 object_=_response.json(),
251 ),
252 ),
253 )
254 if _response.status_code == 429:
255 raise TooManyRequestsError(
256 headers=dict(_response.headers),
257 body=typing.cast(
258 typing.Any,
259 parse_obj_as(
260 type_=typing.Any, # type: ignore
261 object_=_response.json(),
262 ),
263 ),
264 )
265 _response_json = _response.json()
266 except JSONDecodeError:
267 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
268 except ValidationError as e:
269 raise ParsingError(
270 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
271 )
272 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
273
274 def get(
275 self, id: str, *, request_options: typing.Optional[RequestOptions] = None
276 ) -> HttpResponse[GetTokenExchangeProfileResponseContent]:
277 """
278 Retrieve details about a single Token Exchange Profile specified by ID.
279
280 By using this feature, you agree to the applicable Free Trial terms in [Okta’s Master Subscription Agreement](https://www.okta.com/legal/). It is your responsibility to securely validate the user’s subject_token. See [User Guide](https://auth0.com/docs/authenticate/custom-token-exchange) for more details.
281
282 Parameters
283 ----------
284 id : str
285 ID of the Token Exchange Profile to retrieve.
286
287 request_options : typing.Optional[RequestOptions]
288 Request-specific configuration.
289
290 Returns
291 -------
292 HttpResponse[GetTokenExchangeProfileResponseContent]
293 Token Exchange Profile successfully retrieved.
294 """
295 _response = self._client_wrapper.httpx_client.request(
296 f"token-exchange-profiles/{encode_path_param(id)}",
297 method="GET",
298 request_options=request_options,
299 )
300 try:
301 if 200 <= _response.status_code < 300:
302 _data = typing.cast(
303 GetTokenExchangeProfileResponseContent,
304 parse_obj_as(
305 type_=GetTokenExchangeProfileResponseContent, # type: ignore
306 object_=_response.json(),
307 ),
308 )
309 return HttpResponse(response=_response, data=_data)
310 if _response.status_code == 400:
311 raise BadRequestError(
312 headers=dict(_response.headers),
313 body=typing.cast(
314 typing.Any,
315 parse_obj_as(
316 type_=typing.Any, # type: ignore
317 object_=_response.json(),
318 ),
319 ),
320 )
321 if _response.status_code == 401:
322 raise UnauthorizedError(
323 headers=dict(_response.headers),
324 body=typing.cast(
325 typing.Any,
326 parse_obj_as(
327 type_=typing.Any, # type: ignore
328 object_=_response.json(),
329 ),
330 ),
331 )
332 if _response.status_code == 403:
333 raise ForbiddenError(
334 headers=dict(_response.headers),
335 body=typing.cast(
336 typing.Any,
337 parse_obj_as(
338 type_=typing.Any, # type: ignore
339 object_=_response.json(),
340 ),
341 ),
342 )
343 if _response.status_code == 404:
344 raise NotFoundError(
345 headers=dict(_response.headers),
346 body=typing.cast(
347 typing.Any,
348 parse_obj_as(
349 type_=typing.Any, # type: ignore
350 object_=_response.json(),
351 ),
352 ),
353 )
354 if _response.status_code == 429:
355 raise TooManyRequestsError(
356 headers=dict(_response.headers),
357 body=typing.cast(
358 typing.Any,
359 parse_obj_as(
360 type_=typing.Any, # type: ignore
361 object_=_response.json(),
362 ),
363 ),
364 )
365 _response_json = _response.json()
366 except JSONDecodeError:
367 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
368 except ValidationError as e:
369 raise ParsingError(
370 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
371 )
372 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
373
374 def delete(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> HttpResponse[None]:
375 """
376 Delete a Token Exchange Profile within your tenant.
377
378 By using this feature, you agree to the applicable Free Trial terms in [Okta's Master Subscription Agreement](https://www.okta.com/legal/). It is your responsibility to securely validate the user's subject_token. See [User Guide](https://auth0.com/docs/authenticate/custom-token-exchange) for more details.
379
380 Parameters
381 ----------
382 id : str
383 ID of the Token Exchange Profile to delete.
384
385 request_options : typing.Optional[RequestOptions]
386 Request-specific configuration.
387
388 Returns
389 -------
390 HttpResponse[None]
391 """
392 _response = self._client_wrapper.httpx_client.request(
393 f"token-exchange-profiles/{encode_path_param(id)}",
394 method="DELETE",
395 request_options=request_options,
396 )
397 try:
398 if 200 <= _response.status_code < 300:
399 return HttpResponse(response=_response, data=None)
400 if _response.status_code == 401:
401 raise UnauthorizedError(
402 headers=dict(_response.headers),
403 body=typing.cast(
404 typing.Any,
405 parse_obj_as(
406 type_=typing.Any, # type: ignore
407 object_=_response.json(),
408 ),
409 ),
410 )
411 if _response.status_code == 403:
412 raise ForbiddenError(
413 headers=dict(_response.headers),
414 body=typing.cast(
415 typing.Any,
416 parse_obj_as(
417 type_=typing.Any, # type: ignore
418 object_=_response.json(),
419 ),
420 ),
421 )
422 if _response.status_code == 429:
423 raise TooManyRequestsError(
424 headers=dict(_response.headers),
425 body=typing.cast(
426 typing.Any,
427 parse_obj_as(
428 type_=typing.Any, # type: ignore
429 object_=_response.json(),
430 ),
431 ),
432 )
433 _response_json = _response.json()
434 except JSONDecodeError:
435 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
436 except ValidationError as e:
437 raise ParsingError(
438 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
439 )
440 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
441
442 def update(
443 self,
444 id: str,
445 *,
446 name: typing.Optional[str] = OMIT,
447 subject_token_type: typing.Optional[str] = OMIT,
448 request_options: typing.Optional[RequestOptions] = None,
449 ) -> HttpResponse[None]:
450 """
451 Update a Token Exchange Profile within your tenant.
452
453 By using this feature, you agree to the applicable Free Trial terms in [Okta's Master Subscription Agreement](https://www.okta.com/legal/). It is your responsibility to securely validate the user's subject_token. See [User Guide](https://auth0.com/docs/authenticate/custom-token-exchange) for more details.
454
455 Parameters
456 ----------
457 id : str
458 ID of the Token Exchange Profile to update.
459
460 name : typing.Optional[str]
461 Friendly name of this profile.
462
463 subject_token_type : typing.Optional[str]
464 Subject token type for this profile. When receiving a token exchange request on the Authentication API, the corresponding token exchange profile with a matching subject_token_type will be executed. This must be a URI.
465
466 request_options : typing.Optional[RequestOptions]
467 Request-specific configuration.
468
469 Returns
470 -------
471 HttpResponse[None]
472 """
473 _response = self._client_wrapper.httpx_client.request(
474 f"token-exchange-profiles/{encode_path_param(id)}",
475 method="PATCH",
476 json={
477 "name": name,
478 "subject_token_type": subject_token_type,
479 },
480 headers={
481 "content-type": "application/json",
482 },
483 request_options=request_options,
484 omit=OMIT,
485 )
486 try:
487 if 200 <= _response.status_code < 300:
488 return HttpResponse(response=_response, data=None)
489 if _response.status_code == 400:
490 raise BadRequestError(
491 headers=dict(_response.headers),
492 body=typing.cast(
493 typing.Any,
494 parse_obj_as(
495 type_=typing.Any, # type: ignore
496 object_=_response.json(),
497 ),
498 ),
499 )
500 if _response.status_code == 401:
501 raise UnauthorizedError(
502 headers=dict(_response.headers),
503 body=typing.cast(
504 typing.Any,
505 parse_obj_as(
506 type_=typing.Any, # type: ignore
507 object_=_response.json(),
508 ),
509 ),
510 )
511 if _response.status_code == 403:
512 raise ForbiddenError(
513 headers=dict(_response.headers),
514 body=typing.cast(
515 typing.Any,
516 parse_obj_as(
517 type_=typing.Any, # type: ignore
518 object_=_response.json(),
519 ),
520 ),
521 )
522 if _response.status_code == 404:
523 raise NotFoundError(
524 headers=dict(_response.headers),
525 body=typing.cast(
526 typing.Any,
527 parse_obj_as(
528 type_=typing.Any, # type: ignore
529 object_=_response.json(),
530 ),
531 ),
532 )
533 if _response.status_code == 409:
534 raise ConflictError(
535 headers=dict(_response.headers),
536 body=typing.cast(
537 typing.Any,
538 parse_obj_as(
539 type_=typing.Any, # type: ignore
540 object_=_response.json(),
541 ),
542 ),
543 )
544 if _response.status_code == 429:
545 raise TooManyRequestsError(
546 headers=dict(_response.headers),
547 body=typing.cast(
548 typing.Any,
549 parse_obj_as(
550 type_=typing.Any, # type: ignore
551 object_=_response.json(),
552 ),
553 ),
554 )
555 _response_json = _response.json()
556 except JSONDecodeError:
557 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
558 except ValidationError as e:
559 raise ParsingError(
560 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
561 )
562 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
563
564
565 class AsyncRawTokenExchangeProfilesClient:
566 def __init__(self, *, client_wrapper: AsyncClientWrapper):
567 self._client_wrapper = client_wrapper
568
569 async def list(
570 self,
571 *,
572 from_: typing.Optional[str] = None,
573 take: typing.Optional[int] = 50,
574 request_options: typing.Optional[RequestOptions] = None,
575 ) -> AsyncPager[TokenExchangeProfileResponseContent, ListTokenExchangeProfileResponseContent]:
576 """
577 Retrieve a list of all Token Exchange Profiles available in your tenant.
578
579 By using this feature, you agree to the applicable Free Trial terms in [Okta’s Master Subscription Agreement](https://www.okta.com/legal/). It is your responsibility to securely validate the user’s subject_token. See [User Guide](https://auth0.com/docs/authenticate/custom-token-exchange) for more details.
580
581 This endpoint supports Checkpoint pagination. To search by checkpoint, use the following parameters:
582
583 - `from`: Optional id from which to start selection.
584 - `take`: The total amount of entries to retrieve when using the from parameter. Defaults to 50.
585
586 **Note**: The first time you call this endpoint using checkpoint pagination, omit the `from` parameter. If there are more results, a `next` value is included in the response. You can use this for subsequent API calls. When `next` is no longer included in the response, no pages are remaining.
587
588 Parameters
589 ----------
590 from_ : typing.Optional[str]
591 Optional Id from which to start selection.
592
593 take : typing.Optional[int]
594 Number of results per page. Defaults to 50.
595
596 request_options : typing.Optional[RequestOptions]
597 Request-specific configuration.
598
599 Returns
600 -------
601 AsyncPager[TokenExchangeProfileResponseContent, ListTokenExchangeProfileResponseContent]
602 Token Exchange Profile successfully retrieved.
603 """
604 _response = await self._client_wrapper.httpx_client.request(
605 "token-exchange-profiles",
606 method="GET",
607 params={
608 "from": from_,
609 "take": take,
610 },
611 request_options=request_options,
612 )
613 try:
614 if 200 <= _response.status_code < 300:
615 _parsed_response = typing.cast(
616 ListTokenExchangeProfileResponseContent,
617 parse_obj_as(
618 type_=ListTokenExchangeProfileResponseContent, # type: ignore
619 object_=_response.json(),
620 ),
621 )
622 _items = _parsed_response.token_exchange_profiles
623 _parsed_next = _parsed_response.next
624 _has_next = _parsed_next is not None and _parsed_next != ""
625
626 async def _get_next():
627 return await self.list(
628 from_=_parsed_next,
629 take=take,
630 request_options=request_options,
631 )
632
633 return AsyncPager(has_next=_has_next, items=_items, get_next=_get_next, response=_parsed_response)
634 if _response.status_code == 400:
635 raise BadRequestError(
636 headers=dict(_response.headers),
637 body=typing.cast(
638 typing.Any,
639 parse_obj_as(
640 type_=typing.Any, # type: ignore
641 object_=_response.json(),
642 ),
643 ),
644 )
645 if _response.status_code == 401:
646 raise UnauthorizedError(
647 headers=dict(_response.headers),
648 body=typing.cast(
649 typing.Any,
650 parse_obj_as(
651 type_=typing.Any, # type: ignore
652 object_=_response.json(),
653 ),
654 ),
655 )
656 if _response.status_code == 403:
657 raise ForbiddenError(
658 headers=dict(_response.headers),
659 body=typing.cast(
660 typing.Any,
661 parse_obj_as(
662 type_=typing.Any, # type: ignore
663 object_=_response.json(),
664 ),
665 ),
666 )
667 if _response.status_code == 429:
668 raise TooManyRequestsError(
669 headers=dict(_response.headers),
670 body=typing.cast(
671 typing.Any,
672 parse_obj_as(
673 type_=typing.Any, # type: ignore
674 object_=_response.json(),
675 ),
676 ),
677 )
678 _response_json = _response.json()
679 except JSONDecodeError:
680 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
681 except ValidationError as e:
682 raise ParsingError(
683 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
684 )
685 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
686
687 async def create(
688 self,
689 *,
690 name: str,
691 subject_token_type: str,
692 action_id: str,
693 type: TokenExchangeProfileTypeEnum,
694 request_options: typing.Optional[RequestOptions] = None,
695 ) -> AsyncHttpResponse[CreateTokenExchangeProfileResponseContent]:
696 """
697 Create a new Token Exchange Profile within your tenant.
698
699 By using this feature, you agree to the applicable Free Trial terms in [Okta’s Master Subscription Agreement](https://www.okta.com/legal/). It is your responsibility to securely validate the user’s subject_token. See [User Guide](https://auth0.com/docs/authenticate/custom-token-exchange) for more details.
700
701 Parameters
702 ----------
703 name : str
704 Friendly name of this profile.
705
706 subject_token_type : str
707 Subject token type for this profile. When receiving a token exchange request on the Authentication API, the corresponding token exchange profile with a matching subject_token_type will be executed. This must be a URI.
708
709 action_id : str
710 The ID of the Custom Token Exchange action to execute for this profile, in order to validate the subject_token. The action must use the custom-token-exchange trigger.
711
712 type : TokenExchangeProfileTypeEnum
713
714 request_options : typing.Optional[RequestOptions]
715 Request-specific configuration.
716
717 Returns
718 -------
719 AsyncHttpResponse[CreateTokenExchangeProfileResponseContent]
720 Token exchange profile successfully created.
721 """
722 _response = await self._client_wrapper.httpx_client.request(
723 "token-exchange-profiles",
724 method="POST",
725 json={
726 "name": name,
727 "subject_token_type": subject_token_type,
728 "action_id": action_id,
729 "type": type,
730 },
731 headers={
732 "content-type": "application/json",
733 },
734 request_options=request_options,
735 omit=OMIT,
736 )
737 try:
738 if 200 <= _response.status_code < 300:
739 _data = typing.cast(
740 CreateTokenExchangeProfileResponseContent,
741 parse_obj_as(
742 type_=CreateTokenExchangeProfileResponseContent, # type: ignore
743 object_=_response.json(),
744 ),
745 )
746 return AsyncHttpResponse(response=_response, data=_data)
747 if _response.status_code == 400:
748 raise BadRequestError(
749 headers=dict(_response.headers),
750 body=typing.cast(
751 typing.Any,
752 parse_obj_as(
753 type_=typing.Any, # type: ignore
754 object_=_response.json(),
755 ),
756 ),
757 )
758 if _response.status_code == 401:
759 raise UnauthorizedError(
760 headers=dict(_response.headers),
761 body=typing.cast(
762 typing.Any,
763 parse_obj_as(
764 type_=typing.Any, # type: ignore
765 object_=_response.json(),
766 ),
767 ),
768 )
769 if _response.status_code == 403:
770 raise ForbiddenError(
771 headers=dict(_response.headers),
772 body=typing.cast(
773 typing.Any,
774 parse_obj_as(
775 type_=typing.Any, # type: ignore
776 object_=_response.json(),
777 ),
778 ),
779 )
780 if _response.status_code == 409:
781 raise ConflictError(
782 headers=dict(_response.headers),
783 body=typing.cast(
784 typing.Any,
785 parse_obj_as(
786 type_=typing.Any, # type: ignore
787 object_=_response.json(),
788 ),
789 ),
790 )
791 if _response.status_code == 429:
792 raise TooManyRequestsError(
793 headers=dict(_response.headers),
794 body=typing.cast(
795 typing.Any,
796 parse_obj_as(
797 type_=typing.Any, # type: ignore
798 object_=_response.json(),
799 ),
800 ),
801 )
802 _response_json = _response.json()
803 except JSONDecodeError:
804 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
805 except ValidationError as e:
806 raise ParsingError(
807 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
808 )
809 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
810
811 async def get(
812 self, id: str, *, request_options: typing.Optional[RequestOptions] = None
813 ) -> AsyncHttpResponse[GetTokenExchangeProfileResponseContent]:
814 """
815 Retrieve details about a single Token Exchange Profile specified by ID.
816
817 By using this feature, you agree to the applicable Free Trial terms in [Okta’s Master Subscription Agreement](https://www.okta.com/legal/). It is your responsibility to securely validate the user’s subject_token. See [User Guide](https://auth0.com/docs/authenticate/custom-token-exchange) for more details.
818
819 Parameters
820 ----------
821 id : str
822 ID of the Token Exchange Profile to retrieve.
823
824 request_options : typing.Optional[RequestOptions]
825 Request-specific configuration.
826
827 Returns
828 -------
829 AsyncHttpResponse[GetTokenExchangeProfileResponseContent]
830 Token Exchange Profile successfully retrieved.
831 """
832 _response = await self._client_wrapper.httpx_client.request(
833 f"token-exchange-profiles/{encode_path_param(id)}",
834 method="GET",
835 request_options=request_options,
836 )
837 try:
838 if 200 <= _response.status_code < 300:
839 _data = typing.cast(
840 GetTokenExchangeProfileResponseContent,
841 parse_obj_as(
842 type_=GetTokenExchangeProfileResponseContent, # type: ignore
843 object_=_response.json(),
844 ),
845 )
846 return AsyncHttpResponse(response=_response, data=_data)
847 if _response.status_code == 400:
848 raise BadRequestError(
849 headers=dict(_response.headers),
850 body=typing.cast(
851 typing.Any,
852 parse_obj_as(
853 type_=typing.Any, # type: ignore
854 object_=_response.json(),
855 ),
856 ),
857 )
858 if _response.status_code == 401:
859 raise UnauthorizedError(
860 headers=dict(_response.headers),
861 body=typing.cast(
862 typing.Any,
863 parse_obj_as(
864 type_=typing.Any, # type: ignore
865 object_=_response.json(),
866 ),
867 ),
868 )
869 if _response.status_code == 403:
870 raise ForbiddenError(
871 headers=dict(_response.headers),
872 body=typing.cast(
873 typing.Any,
874 parse_obj_as(
875 type_=typing.Any, # type: ignore
876 object_=_response.json(),
877 ),
878 ),
879 )
880 if _response.status_code == 404:
881 raise NotFoundError(
882 headers=dict(_response.headers),
883 body=typing.cast(
884 typing.Any,
885 parse_obj_as(
886 type_=typing.Any, # type: ignore
887 object_=_response.json(),
888 ),
889 ),
890 )
891 if _response.status_code == 429:
892 raise TooManyRequestsError(
893 headers=dict(_response.headers),
894 body=typing.cast(
895 typing.Any,
896 parse_obj_as(
897 type_=typing.Any, # type: ignore
898 object_=_response.json(),
899 ),
900 ),
901 )
902 _response_json = _response.json()
903 except JSONDecodeError:
904 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
905 except ValidationError as e:
906 raise ParsingError(
907 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
908 )
909 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
910
911 async def delete(
912 self, id: str, *, request_options: typing.Optional[RequestOptions] = None
913 ) -> AsyncHttpResponse[None]:
914 """
915 Delete a Token Exchange Profile within your tenant.
916
917 By using this feature, you agree to the applicable Free Trial terms in [Okta's Master Subscription Agreement](https://www.okta.com/legal/). It is your responsibility to securely validate the user's subject_token. See [User Guide](https://auth0.com/docs/authenticate/custom-token-exchange) for more details.
918
919 Parameters
920 ----------
921 id : str
922 ID of the Token Exchange Profile to delete.
923
924 request_options : typing.Optional[RequestOptions]
925 Request-specific configuration.
926
927 Returns
928 -------
929 AsyncHttpResponse[None]
930 """
931 _response = await self._client_wrapper.httpx_client.request(
932 f"token-exchange-profiles/{encode_path_param(id)}",
933 method="DELETE",
934 request_options=request_options,
935 )
936 try:
937 if 200 <= _response.status_code < 300:
938 return AsyncHttpResponse(response=_response, data=None)
939 if _response.status_code == 401:
940 raise UnauthorizedError(
941 headers=dict(_response.headers),
942 body=typing.cast(
943 typing.Any,
944 parse_obj_as(
945 type_=typing.Any, # type: ignore
946 object_=_response.json(),
947 ),
948 ),
949 )
950 if _response.status_code == 403:
951 raise ForbiddenError(
952 headers=dict(_response.headers),
953 body=typing.cast(
954 typing.Any,
955 parse_obj_as(
956 type_=typing.Any, # type: ignore
957 object_=_response.json(),
958 ),
959 ),
960 )
961 if _response.status_code == 429:
962 raise TooManyRequestsError(
963 headers=dict(_response.headers),
964 body=typing.cast(
965 typing.Any,
966 parse_obj_as(
967 type_=typing.Any, # type: ignore
968 object_=_response.json(),
969 ),
970 ),
971 )
972 _response_json = _response.json()
973 except JSONDecodeError:
974 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
975 except ValidationError as e:
976 raise ParsingError(
977 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
978 )
979 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
980
981 async def update(
982 self,
983 id: str,
984 *,
985 name: typing.Optional[str] = OMIT,
986 subject_token_type: typing.Optional[str] = OMIT,
987 request_options: typing.Optional[RequestOptions] = None,
988 ) -> AsyncHttpResponse[None]:
989 """
990 Update a Token Exchange Profile within your tenant.
991
992 By using this feature, you agree to the applicable Free Trial terms in [Okta's Master Subscription Agreement](https://www.okta.com/legal/). It is your responsibility to securely validate the user's subject_token. See [User Guide](https://auth0.com/docs/authenticate/custom-token-exchange) for more details.
993
994 Parameters
995 ----------
996 id : str
997 ID of the Token Exchange Profile to update.
998
999 name : typing.Optional[str]
1000 Friendly name of this profile.
1001
1002 subject_token_type : typing.Optional[str]
1003 Subject token type for this profile. When receiving a token exchange request on the Authentication API, the corresponding token exchange profile with a matching subject_token_type will be executed. This must be a URI.
1004
1005 request_options : typing.Optional[RequestOptions]
1006 Request-specific configuration.
1007
1008 Returns
1009 -------
1010 AsyncHttpResponse[None]
1011 """
1012 _response = await self._client_wrapper.httpx_client.request(
1013 f"token-exchange-profiles/{encode_path_param(id)}",
1014 method="PATCH",
1015 json={
1016 "name": name,
1017 "subject_token_type": subject_token_type,
1018 },
1019 headers={
1020 "content-type": "application/json",
1021 },
1022 request_options=request_options,
1023 omit=OMIT,
1024 )
1025 try:
1026 if 200 <= _response.status_code < 300:
1027 return AsyncHttpResponse(response=_response, data=None)
1028 if _response.status_code == 400:
1029 raise BadRequestError(
1030 headers=dict(_response.headers),
1031 body=typing.cast(
1032 typing.Any,
1033 parse_obj_as(
1034 type_=typing.Any, # type: ignore
1035 object_=_response.json(),
1036 ),
1037 ),
1038 )
1039 if _response.status_code == 401:
1040 raise UnauthorizedError(
1041 headers=dict(_response.headers),
1042 body=typing.cast(
1043 typing.Any,
1044 parse_obj_as(
1045 type_=typing.Any, # type: ignore
1046 object_=_response.json(),
1047 ),
1048 ),
1049 )
1050 if _response.status_code == 403:
1051 raise ForbiddenError(
1052 headers=dict(_response.headers),
1053 body=typing.cast(
1054 typing.Any,
1055 parse_obj_as(
1056 type_=typing.Any, # type: ignore
1057 object_=_response.json(),
1058 ),
1059 ),
1060 )
1061 if _response.status_code == 404:
1062 raise NotFoundError(
1063 headers=dict(_response.headers),
1064 body=typing.cast(
1065 typing.Any,
1066 parse_obj_as(
1067 type_=typing.Any, # type: ignore
1068 object_=_response.json(),
1069 ),
1070 ),
1071 )
1072 if _response.status_code == 409:
1073 raise ConflictError(
1074 headers=dict(_response.headers),
1075 body=typing.cast(
1076 typing.Any,
1077 parse_obj_as(
1078 type_=typing.Any, # type: ignore
1079 object_=_response.json(),
1080 ),
1081 ),
1082 )
1083 if _response.status_code == 429:
1084 raise TooManyRequestsError(
1085 headers=dict(_response.headers),
1086 body=typing.cast(
1087 typing.Any,
1088 parse_obj_as(
1089 type_=typing.Any, # type: ignore
1090 object_=_response.json(),
1091 ),
1092 ),
1093 )
1094 _response_json = _response.json()
1095 except JSONDecodeError:
1096 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1097 except ValidationError as e:
1098 raise ParsingError(
1099 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
1100 )
1101 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)