Debian Codegraph @

src/auth0/management/self_service_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 ..core.serialization import convert_and_respect_annotation_metadata
15 from ..errors.bad_request_error import BadRequestError
16 from ..errors.conflict_error import ConflictError
17 from ..errors.forbidden_error import ForbiddenError
18 from ..errors.internal_server_error import InternalServerError
19 from ..errors.not_found_error import NotFoundError
20 from ..errors.too_many_requests_error import TooManyRequestsError
21 from ..errors.unauthorized_error import UnauthorizedError
22 from ..types.create_self_service_profile_response_content import CreateSelfServiceProfileResponseContent
23 from ..types.get_self_service_profile_response_content import GetSelfServiceProfileResponseContent
24 from ..types.list_self_service_profiles_paginated_response_content import (
25 ListSelfServiceProfilesPaginatedResponseContent,
26 )
27 from ..types.self_service_profile import SelfServiceProfile
28 from ..types.self_service_profile_allowed_strategy_enum import SelfServiceProfileAllowedStrategyEnum
29 from ..types.self_service_profile_branding import SelfServiceProfileBranding
30 from ..types.self_service_profile_branding_properties import SelfServiceProfileBrandingProperties
31 from ..types.self_service_profile_description import SelfServiceProfileDescription
32 from ..types.self_service_profile_user_attribute import SelfServiceProfileUserAttribute
33 from ..types.self_service_profile_user_attributes import SelfServiceProfileUserAttributes
34 from ..types.update_self_service_profile_response_content import UpdateSelfServiceProfileResponseContent
35 from pydantic import ValidationError
36
37 # this is used as the default value for optional parameters
38 OMIT = typing.cast(typing.Any, ...)
39
40
41 class RawSelfServiceProfilesClient:
42 def __init__(self, *, client_wrapper: SyncClientWrapper):
43 self._client_wrapper = client_wrapper
44
45 def list(
46 self,
47 *,
48 page: typing.Optional[int] = 0,
49 per_page: typing.Optional[int] = 50,
50 include_totals: typing.Optional[bool] = True,
51 request_options: typing.Optional[RequestOptions] = None,
52 ) -> SyncPager[SelfServiceProfile, ListSelfServiceProfilesPaginatedResponseContent]:
53 """
54 Retrieves self-service profiles.
55
56 Parameters
57 ----------
58 page : typing.Optional[int]
59 Page index of the results to return. First page is 0.
60
61 per_page : typing.Optional[int]
62 Number of results per page. Defaults to 50.
63
64 include_totals : typing.Optional[bool]
65 Return results inside an object that contains the total result count (true) or as a direct array of results (false, default).
66
67 request_options : typing.Optional[RequestOptions]
68 Request-specific configuration.
69
70 Returns
71 -------
72 SyncPager[SelfServiceProfile, ListSelfServiceProfilesPaginatedResponseContent]
73 List of existing profiles.
74 """
75 page = page if page is not None else 0
76
77 _response = self._client_wrapper.httpx_client.request(
78 "self-service-profiles",
79 method="GET",
80 params={
81 "page": page,
82 "per_page": per_page,
83 "include_totals": include_totals,
84 },
85 request_options=request_options,
86 )
87 try:
88 if 200 <= _response.status_code < 300:
89 _parsed_response = typing.cast(
90 ListSelfServiceProfilesPaginatedResponseContent,
91 parse_obj_as(
92 type_=ListSelfServiceProfilesPaginatedResponseContent, # type: ignore
93 object_=_response.json(),
94 ),
95 )
96 _items = _parsed_response.self_service_profiles
97 _has_next = len(_items or []) > 0
98 _get_next = lambda: self.list(
99 page=page + 1,
100 per_page=per_page,
101 include_totals=include_totals,
102 request_options=request_options,
103 )
104 return SyncPager(has_next=_has_next, items=_items, get_next=_get_next, response=_parsed_response)
105 if _response.status_code == 401:
106 raise UnauthorizedError(
107 headers=dict(_response.headers),
108 body=typing.cast(
109 typing.Any,
110 parse_obj_as(
111 type_=typing.Any, # type: ignore
112 object_=_response.json(),
113 ),
114 ),
115 )
116 if _response.status_code == 403:
117 raise ForbiddenError(
118 headers=dict(_response.headers),
119 body=typing.cast(
120 typing.Any,
121 parse_obj_as(
122 type_=typing.Any, # type: ignore
123 object_=_response.json(),
124 ),
125 ),
126 )
127 if _response.status_code == 429:
128 raise TooManyRequestsError(
129 headers=dict(_response.headers),
130 body=typing.cast(
131 typing.Any,
132 parse_obj_as(
133 type_=typing.Any, # type: ignore
134 object_=_response.json(),
135 ),
136 ),
137 )
138 if _response.status_code == 500:
139 raise InternalServerError(
140 headers=dict(_response.headers),
141 body=typing.cast(
142 typing.Any,
143 parse_obj_as(
144 type_=typing.Any, # type: ignore
145 object_=_response.json(),
146 ),
147 ),
148 )
149 _response_json = _response.json()
150 except JSONDecodeError:
151 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
152 except ValidationError as e:
153 raise ParsingError(
154 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
155 )
156 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
157
158 def create(
159 self,
160 *,
161 name: str,
162 description: typing.Optional[str] = OMIT,
163 branding: typing.Optional[SelfServiceProfileBrandingProperties] = OMIT,
164 allowed_strategies: typing.Optional[typing.Sequence[SelfServiceProfileAllowedStrategyEnum]] = OMIT,
165 user_attributes: typing.Optional[typing.Sequence[SelfServiceProfileUserAttribute]] = OMIT,
166 user_attribute_profile_id: typing.Optional[str] = OMIT,
167 request_options: typing.Optional[RequestOptions] = None,
168 ) -> HttpResponse[CreateSelfServiceProfileResponseContent]:
169 """
170 Creates a self-service profile.
171
172 Parameters
173 ----------
174 name : str
175 The name of the self-service Profile.
176
177 description : typing.Optional[str]
178 The description of the self-service Profile.
179
180 branding : typing.Optional[SelfServiceProfileBrandingProperties]
181
182 allowed_strategies : typing.Optional[typing.Sequence[SelfServiceProfileAllowedStrategyEnum]]
183 List of IdP strategies that will be shown to users during the Self-Service Enterprise Configuration flow. Possible values: [`oidc`, `samlp`, `waad`, `google-apps`, `adfs`, `okta`, `auth0-samlp`, `okta-samlp`, `keycloak-samlp`, `pingfederate`]
184
185 user_attributes : typing.Optional[typing.Sequence[SelfServiceProfileUserAttribute]]
186 List of attributes to be mapped that will be shown to the user during the Self-Service Enterprise Configuration flow.
187
188 user_attribute_profile_id : typing.Optional[str]
189 ID of the user-attribute-profile to associate with this self-service profile.
190
191 request_options : typing.Optional[RequestOptions]
192 Request-specific configuration.
193
194 Returns
195 -------
196 HttpResponse[CreateSelfServiceProfileResponseContent]
197 Self-service profile successfully created.
198 """
199 _response = self._client_wrapper.httpx_client.request(
200 "self-service-profiles",
201 method="POST",
202 json={
203 "name": name,
204 "description": description,
205 "branding": convert_and_respect_annotation_metadata(
206 object_=branding, annotation=SelfServiceProfileBrandingProperties, direction="write"
207 ),
208 "allowed_strategies": allowed_strategies,
209 "user_attributes": convert_and_respect_annotation_metadata(
210 object_=user_attributes,
211 annotation=typing.Sequence[SelfServiceProfileUserAttribute],
212 direction="write",
213 ),
214 "user_attribute_profile_id": user_attribute_profile_id,
215 },
216 headers={
217 "content-type": "application/json",
218 },
219 request_options=request_options,
220 omit=OMIT,
221 )
222 try:
223 if 200 <= _response.status_code < 300:
224 _data = typing.cast(
225 CreateSelfServiceProfileResponseContent,
226 parse_obj_as(
227 type_=CreateSelfServiceProfileResponseContent, # type: ignore
228 object_=_response.json(),
229 ),
230 )
231 return HttpResponse(response=_response, data=_data)
232 if _response.status_code == 400:
233 raise BadRequestError(
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 == 401:
244 raise UnauthorizedError(
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 == 403:
255 raise ForbiddenError(
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 if _response.status_code == 409:
266 raise ConflictError(
267 headers=dict(_response.headers),
268 body=typing.cast(
269 typing.Any,
270 parse_obj_as(
271 type_=typing.Any, # type: ignore
272 object_=_response.json(),
273 ),
274 ),
275 )
276 if _response.status_code == 429:
277 raise TooManyRequestsError(
278 headers=dict(_response.headers),
279 body=typing.cast(
280 typing.Any,
281 parse_obj_as(
282 type_=typing.Any, # type: ignore
283 object_=_response.json(),
284 ),
285 ),
286 )
287 if _response.status_code == 500:
288 raise InternalServerError(
289 headers=dict(_response.headers),
290 body=typing.cast(
291 typing.Any,
292 parse_obj_as(
293 type_=typing.Any, # type: ignore
294 object_=_response.json(),
295 ),
296 ),
297 )
298 _response_json = _response.json()
299 except JSONDecodeError:
300 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
301 except ValidationError as e:
302 raise ParsingError(
303 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
304 )
305 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
306
307 def get(
308 self, id: str, *, request_options: typing.Optional[RequestOptions] = None
309 ) -> HttpResponse[GetSelfServiceProfileResponseContent]:
310 """
311 Retrieves a self-service profile by Id.
312
313 Parameters
314 ----------
315 id : str
316 The id of the self-service profile to retrieve
317
318 request_options : typing.Optional[RequestOptions]
319 Request-specific configuration.
320
321 Returns
322 -------
323 HttpResponse[GetSelfServiceProfileResponseContent]
324 Record for existing self-service profile.
325 """
326 _response = self._client_wrapper.httpx_client.request(
327 f"self-service-profiles/{encode_path_param(id)}",
328 method="GET",
329 request_options=request_options,
330 )
331 try:
332 if 200 <= _response.status_code < 300:
333 _data = typing.cast(
334 GetSelfServiceProfileResponseContent,
335 parse_obj_as(
336 type_=GetSelfServiceProfileResponseContent, # type: ignore
337 object_=_response.json(),
338 ),
339 )
340 return HttpResponse(response=_response, data=_data)
341 if _response.status_code == 400:
342 raise BadRequestError(
343 headers=dict(_response.headers),
344 body=typing.cast(
345 typing.Any,
346 parse_obj_as(
347 type_=typing.Any, # type: ignore
348 object_=_response.json(),
349 ),
350 ),
351 )
352 if _response.status_code == 401:
353 raise UnauthorizedError(
354 headers=dict(_response.headers),
355 body=typing.cast(
356 typing.Any,
357 parse_obj_as(
358 type_=typing.Any, # type: ignore
359 object_=_response.json(),
360 ),
361 ),
362 )
363 if _response.status_code == 403:
364 raise ForbiddenError(
365 headers=dict(_response.headers),
366 body=typing.cast(
367 typing.Any,
368 parse_obj_as(
369 type_=typing.Any, # type: ignore
370 object_=_response.json(),
371 ),
372 ),
373 )
374 if _response.status_code == 404:
375 raise NotFoundError(
376 headers=dict(_response.headers),
377 body=typing.cast(
378 typing.Any,
379 parse_obj_as(
380 type_=typing.Any, # type: ignore
381 object_=_response.json(),
382 ),
383 ),
384 )
385 if _response.status_code == 429:
386 raise TooManyRequestsError(
387 headers=dict(_response.headers),
388 body=typing.cast(
389 typing.Any,
390 parse_obj_as(
391 type_=typing.Any, # type: ignore
392 object_=_response.json(),
393 ),
394 ),
395 )
396 if _response.status_code == 500:
397 raise InternalServerError(
398 headers=dict(_response.headers),
399 body=typing.cast(
400 typing.Any,
401 parse_obj_as(
402 type_=typing.Any, # type: ignore
403 object_=_response.json(),
404 ),
405 ),
406 )
407 _response_json = _response.json()
408 except JSONDecodeError:
409 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
410 except ValidationError as e:
411 raise ParsingError(
412 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
413 )
414 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
415
416 def delete(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> HttpResponse[None]:
417 """
418 Deletes a self-service profile by Id.
419
420 Parameters
421 ----------
422 id : str
423 The id of the self-service profile to delete
424
425 request_options : typing.Optional[RequestOptions]
426 Request-specific configuration.
427
428 Returns
429 -------
430 HttpResponse[None]
431 """
432 _response = self._client_wrapper.httpx_client.request(
433 f"self-service-profiles/{encode_path_param(id)}",
434 method="DELETE",
435 request_options=request_options,
436 )
437 try:
438 if 200 <= _response.status_code < 300:
439 return HttpResponse(response=_response, data=None)
440 if _response.status_code == 400:
441 raise BadRequestError(
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 if _response.status_code == 401:
452 raise UnauthorizedError(
453 headers=dict(_response.headers),
454 body=typing.cast(
455 typing.Any,
456 parse_obj_as(
457 type_=typing.Any, # type: ignore
458 object_=_response.json(),
459 ),
460 ),
461 )
462 if _response.status_code == 403:
463 raise ForbiddenError(
464 headers=dict(_response.headers),
465 body=typing.cast(
466 typing.Any,
467 parse_obj_as(
468 type_=typing.Any, # type: ignore
469 object_=_response.json(),
470 ),
471 ),
472 )
473 if _response.status_code == 429:
474 raise TooManyRequestsError(
475 headers=dict(_response.headers),
476 body=typing.cast(
477 typing.Any,
478 parse_obj_as(
479 type_=typing.Any, # type: ignore
480 object_=_response.json(),
481 ),
482 ),
483 )
484 if _response.status_code == 500:
485 raise InternalServerError(
486 headers=dict(_response.headers),
487 body=typing.cast(
488 typing.Any,
489 parse_obj_as(
490 type_=typing.Any, # type: ignore
491 object_=_response.json(),
492 ),
493 ),
494 )
495 _response_json = _response.json()
496 except JSONDecodeError:
497 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
498 except ValidationError as e:
499 raise ParsingError(
500 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
501 )
502 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
503
504 def update(
505 self,
506 id: str,
507 *,
508 name: typing.Optional[str] = OMIT,
509 description: typing.Optional[SelfServiceProfileDescription] = OMIT,
510 branding: typing.Optional[SelfServiceProfileBranding] = OMIT,
511 allowed_strategies: typing.Optional[typing.Sequence[SelfServiceProfileAllowedStrategyEnum]] = OMIT,
512 user_attributes: typing.Optional[SelfServiceProfileUserAttributes] = OMIT,
513 user_attribute_profile_id: typing.Optional[str] = OMIT,
514 request_options: typing.Optional[RequestOptions] = None,
515 ) -> HttpResponse[UpdateSelfServiceProfileResponseContent]:
516 """
517 Updates a self-service profile.
518
519 Parameters
520 ----------
521 id : str
522 The id of the self-service profile to update
523
524 name : typing.Optional[str]
525 The name of the self-service Profile.
526
527 description : typing.Optional[SelfServiceProfileDescription]
528
529 branding : typing.Optional[SelfServiceProfileBranding]
530
531 allowed_strategies : typing.Optional[typing.Sequence[SelfServiceProfileAllowedStrategyEnum]]
532 List of IdP strategies that will be shown to users during the Self-Service Enterprise Configuration flow. Possible values: [`oidc`, `samlp`, `waad`, `google-apps`, `adfs`, `okta`, `auth0-samlp`, `okta-samlp`, `keycloak-samlp`, `pingfederate`]
533
534 user_attributes : typing.Optional[SelfServiceProfileUserAttributes]
535
536 user_attribute_profile_id : typing.Optional[str]
537 ID of the user-attribute-profile to associate with this self-service profile.
538
539 request_options : typing.Optional[RequestOptions]
540 Request-specific configuration.
541
542 Returns
543 -------
544 HttpResponse[UpdateSelfServiceProfileResponseContent]
545 Self-service profile successfully updated.
546 """
547 _response = self._client_wrapper.httpx_client.request(
548 f"self-service-profiles/{encode_path_param(id)}",
549 method="PATCH",
550 json={
551 "name": name,
552 "description": description,
553 "branding": convert_and_respect_annotation_metadata(
554 object_=branding, annotation=SelfServiceProfileBranding, direction="write"
555 ),
556 "allowed_strategies": allowed_strategies,
557 "user_attributes": convert_and_respect_annotation_metadata(
558 object_=user_attributes,
559 annotation=typing.Optional[SelfServiceProfileUserAttributes],
560 direction="write",
561 ),
562 "user_attribute_profile_id": user_attribute_profile_id,
563 },
564 headers={
565 "content-type": "application/json",
566 },
567 request_options=request_options,
568 omit=OMIT,
569 )
570 try:
571 if 200 <= _response.status_code < 300:
572 _data = typing.cast(
573 UpdateSelfServiceProfileResponseContent,
574 parse_obj_as(
575 type_=UpdateSelfServiceProfileResponseContent, # type: ignore
576 object_=_response.json(),
577 ),
578 )
579 return HttpResponse(response=_response, data=_data)
580 if _response.status_code == 400:
581 raise BadRequestError(
582 headers=dict(_response.headers),
583 body=typing.cast(
584 typing.Any,
585 parse_obj_as(
586 type_=typing.Any, # type: ignore
587 object_=_response.json(),
588 ),
589 ),
590 )
591 if _response.status_code == 401:
592 raise UnauthorizedError(
593 headers=dict(_response.headers),
594 body=typing.cast(
595 typing.Any,
596 parse_obj_as(
597 type_=typing.Any, # type: ignore
598 object_=_response.json(),
599 ),
600 ),
601 )
602 if _response.status_code == 403:
603 raise ForbiddenError(
604 headers=dict(_response.headers),
605 body=typing.cast(
606 typing.Any,
607 parse_obj_as(
608 type_=typing.Any, # type: ignore
609 object_=_response.json(),
610 ),
611 ),
612 )
613 if _response.status_code == 404:
614 raise NotFoundError(
615 headers=dict(_response.headers),
616 body=typing.cast(
617 typing.Any,
618 parse_obj_as(
619 type_=typing.Any, # type: ignore
620 object_=_response.json(),
621 ),
622 ),
623 )
624 if _response.status_code == 429:
625 raise TooManyRequestsError(
626 headers=dict(_response.headers),
627 body=typing.cast(
628 typing.Any,
629 parse_obj_as(
630 type_=typing.Any, # type: ignore
631 object_=_response.json(),
632 ),
633 ),
634 )
635 if _response.status_code == 500:
636 raise InternalServerError(
637 headers=dict(_response.headers),
638 body=typing.cast(
639 typing.Any,
640 parse_obj_as(
641 type_=typing.Any, # type: ignore
642 object_=_response.json(),
643 ),
644 ),
645 )
646 _response_json = _response.json()
647 except JSONDecodeError:
648 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
649 except ValidationError as e:
650 raise ParsingError(
651 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
652 )
653 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
654
655
656 class AsyncRawSelfServiceProfilesClient:
657 def __init__(self, *, client_wrapper: AsyncClientWrapper):
658 self._client_wrapper = client_wrapper
659
660 async def list(
661 self,
662 *,
663 page: typing.Optional[int] = 0,
664 per_page: typing.Optional[int] = 50,
665 include_totals: typing.Optional[bool] = True,
666 request_options: typing.Optional[RequestOptions] = None,
667 ) -> AsyncPager[SelfServiceProfile, ListSelfServiceProfilesPaginatedResponseContent]:
668 """
669 Retrieves self-service profiles.
670
671 Parameters
672 ----------
673 page : typing.Optional[int]
674 Page index of the results to return. First page is 0.
675
676 per_page : typing.Optional[int]
677 Number of results per page. Defaults to 50.
678
679 include_totals : typing.Optional[bool]
680 Return results inside an object that contains the total result count (true) or as a direct array of results (false, default).
681
682 request_options : typing.Optional[RequestOptions]
683 Request-specific configuration.
684
685 Returns
686 -------
687 AsyncPager[SelfServiceProfile, ListSelfServiceProfilesPaginatedResponseContent]
688 List of existing profiles.
689 """
690 page = page if page is not None else 0
691
692 _response = await self._client_wrapper.httpx_client.request(
693 "self-service-profiles",
694 method="GET",
695 params={
696 "page": page,
697 "per_page": per_page,
698 "include_totals": include_totals,
699 },
700 request_options=request_options,
701 )
702 try:
703 if 200 <= _response.status_code < 300:
704 _parsed_response = typing.cast(
705 ListSelfServiceProfilesPaginatedResponseContent,
706 parse_obj_as(
707 type_=ListSelfServiceProfilesPaginatedResponseContent, # type: ignore
708 object_=_response.json(),
709 ),
710 )
711 _items = _parsed_response.self_service_profiles
712 _has_next = len(_items or []) > 0
713
714 async def _get_next():
715 return await self.list(
716 page=page + 1,
717 per_page=per_page,
718 include_totals=include_totals,
719 request_options=request_options,
720 )
721
722 return AsyncPager(has_next=_has_next, items=_items, get_next=_get_next, response=_parsed_response)
723 if _response.status_code == 401:
724 raise UnauthorizedError(
725 headers=dict(_response.headers),
726 body=typing.cast(
727 typing.Any,
728 parse_obj_as(
729 type_=typing.Any, # type: ignore
730 object_=_response.json(),
731 ),
732 ),
733 )
734 if _response.status_code == 403:
735 raise ForbiddenError(
736 headers=dict(_response.headers),
737 body=typing.cast(
738 typing.Any,
739 parse_obj_as(
740 type_=typing.Any, # type: ignore
741 object_=_response.json(),
742 ),
743 ),
744 )
745 if _response.status_code == 429:
746 raise TooManyRequestsError(
747 headers=dict(_response.headers),
748 body=typing.cast(
749 typing.Any,
750 parse_obj_as(
751 type_=typing.Any, # type: ignore
752 object_=_response.json(),
753 ),
754 ),
755 )
756 if _response.status_code == 500:
757 raise InternalServerError(
758 headers=dict(_response.headers),
759 body=typing.cast(
760 typing.Any,
761 parse_obj_as(
762 type_=typing.Any, # type: ignore
763 object_=_response.json(),
764 ),
765 ),
766 )
767 _response_json = _response.json()
768 except JSONDecodeError:
769 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
770 except ValidationError as e:
771 raise ParsingError(
772 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
773 )
774 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
775
776 async def create(
777 self,
778 *,
779 name: str,
780 description: typing.Optional[str] = OMIT,
781 branding: typing.Optional[SelfServiceProfileBrandingProperties] = OMIT,
782 allowed_strategies: typing.Optional[typing.Sequence[SelfServiceProfileAllowedStrategyEnum]] = OMIT,
783 user_attributes: typing.Optional[typing.Sequence[SelfServiceProfileUserAttribute]] = OMIT,
784 user_attribute_profile_id: typing.Optional[str] = OMIT,
785 request_options: typing.Optional[RequestOptions] = None,
786 ) -> AsyncHttpResponse[CreateSelfServiceProfileResponseContent]:
787 """
788 Creates a self-service profile.
789
790 Parameters
791 ----------
792 name : str
793 The name of the self-service Profile.
794
795 description : typing.Optional[str]
796 The description of the self-service Profile.
797
798 branding : typing.Optional[SelfServiceProfileBrandingProperties]
799
800 allowed_strategies : typing.Optional[typing.Sequence[SelfServiceProfileAllowedStrategyEnum]]
801 List of IdP strategies that will be shown to users during the Self-Service Enterprise Configuration flow. Possible values: [`oidc`, `samlp`, `waad`, `google-apps`, `adfs`, `okta`, `auth0-samlp`, `okta-samlp`, `keycloak-samlp`, `pingfederate`]
802
803 user_attributes : typing.Optional[typing.Sequence[SelfServiceProfileUserAttribute]]
804 List of attributes to be mapped that will be shown to the user during the Self-Service Enterprise Configuration flow.
805
806 user_attribute_profile_id : typing.Optional[str]
807 ID of the user-attribute-profile to associate with this self-service profile.
808
809 request_options : typing.Optional[RequestOptions]
810 Request-specific configuration.
811
812 Returns
813 -------
814 AsyncHttpResponse[CreateSelfServiceProfileResponseContent]
815 Self-service profile successfully created.
816 """
817 _response = await self._client_wrapper.httpx_client.request(
818 "self-service-profiles",
819 method="POST",
820 json={
821 "name": name,
822 "description": description,
823 "branding": convert_and_respect_annotation_metadata(
824 object_=branding, annotation=SelfServiceProfileBrandingProperties, direction="write"
825 ),
826 "allowed_strategies": allowed_strategies,
827 "user_attributes": convert_and_respect_annotation_metadata(
828 object_=user_attributes,
829 annotation=typing.Sequence[SelfServiceProfileUserAttribute],
830 direction="write",
831 ),
832 "user_attribute_profile_id": user_attribute_profile_id,
833 },
834 headers={
835 "content-type": "application/json",
836 },
837 request_options=request_options,
838 omit=OMIT,
839 )
840 try:
841 if 200 <= _response.status_code < 300:
842 _data = typing.cast(
843 CreateSelfServiceProfileResponseContent,
844 parse_obj_as(
845 type_=CreateSelfServiceProfileResponseContent, # type: ignore
846 object_=_response.json(),
847 ),
848 )
849 return AsyncHttpResponse(response=_response, data=_data)
850 if _response.status_code == 400:
851 raise BadRequestError(
852 headers=dict(_response.headers),
853 body=typing.cast(
854 typing.Any,
855 parse_obj_as(
856 type_=typing.Any, # type: ignore
857 object_=_response.json(),
858 ),
859 ),
860 )
861 if _response.status_code == 401:
862 raise UnauthorizedError(
863 headers=dict(_response.headers),
864 body=typing.cast(
865 typing.Any,
866 parse_obj_as(
867 type_=typing.Any, # type: ignore
868 object_=_response.json(),
869 ),
870 ),
871 )
872 if _response.status_code == 403:
873 raise ForbiddenError(
874 headers=dict(_response.headers),
875 body=typing.cast(
876 typing.Any,
877 parse_obj_as(
878 type_=typing.Any, # type: ignore
879 object_=_response.json(),
880 ),
881 ),
882 )
883 if _response.status_code == 409:
884 raise ConflictError(
885 headers=dict(_response.headers),
886 body=typing.cast(
887 typing.Any,
888 parse_obj_as(
889 type_=typing.Any, # type: ignore
890 object_=_response.json(),
891 ),
892 ),
893 )
894 if _response.status_code == 429:
895 raise TooManyRequestsError(
896 headers=dict(_response.headers),
897 body=typing.cast(
898 typing.Any,
899 parse_obj_as(
900 type_=typing.Any, # type: ignore
901 object_=_response.json(),
902 ),
903 ),
904 )
905 if _response.status_code == 500:
906 raise InternalServerError(
907 headers=dict(_response.headers),
908 body=typing.cast(
909 typing.Any,
910 parse_obj_as(
911 type_=typing.Any, # type: ignore
912 object_=_response.json(),
913 ),
914 ),
915 )
916 _response_json = _response.json()
917 except JSONDecodeError:
918 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
919 except ValidationError as e:
920 raise ParsingError(
921 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
922 )
923 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
924
925 async def get(
926 self, id: str, *, request_options: typing.Optional[RequestOptions] = None
927 ) -> AsyncHttpResponse[GetSelfServiceProfileResponseContent]:
928 """
929 Retrieves a self-service profile by Id.
930
931 Parameters
932 ----------
933 id : str
934 The id of the self-service profile to retrieve
935
936 request_options : typing.Optional[RequestOptions]
937 Request-specific configuration.
938
939 Returns
940 -------
941 AsyncHttpResponse[GetSelfServiceProfileResponseContent]
942 Record for existing self-service profile.
943 """
944 _response = await self._client_wrapper.httpx_client.request(
945 f"self-service-profiles/{encode_path_param(id)}",
946 method="GET",
947 request_options=request_options,
948 )
949 try:
950 if 200 <= _response.status_code < 300:
951 _data = typing.cast(
952 GetSelfServiceProfileResponseContent,
953 parse_obj_as(
954 type_=GetSelfServiceProfileResponseContent, # type: ignore
955 object_=_response.json(),
956 ),
957 )
958 return AsyncHttpResponse(response=_response, data=_data)
959 if _response.status_code == 400:
960 raise BadRequestError(
961 headers=dict(_response.headers),
962 body=typing.cast(
963 typing.Any,
964 parse_obj_as(
965 type_=typing.Any, # type: ignore
966 object_=_response.json(),
967 ),
968 ),
969 )
970 if _response.status_code == 401:
971 raise UnauthorizedError(
972 headers=dict(_response.headers),
973 body=typing.cast(
974 typing.Any,
975 parse_obj_as(
976 type_=typing.Any, # type: ignore
977 object_=_response.json(),
978 ),
979 ),
980 )
981 if _response.status_code == 403:
982 raise ForbiddenError(
983 headers=dict(_response.headers),
984 body=typing.cast(
985 typing.Any,
986 parse_obj_as(
987 type_=typing.Any, # type: ignore
988 object_=_response.json(),
989 ),
990 ),
991 )
992 if _response.status_code == 404:
993 raise NotFoundError(
994 headers=dict(_response.headers),
995 body=typing.cast(
996 typing.Any,
997 parse_obj_as(
998 type_=typing.Any, # type: ignore
999 object_=_response.json(),
1000 ),
1001 ),
1002 )
1003 if _response.status_code == 429:
1004 raise TooManyRequestsError(
1005 headers=dict(_response.headers),
1006 body=typing.cast(
1007 typing.Any,
1008 parse_obj_as(
1009 type_=typing.Any, # type: ignore
1010 object_=_response.json(),
1011 ),
1012 ),
1013 )
1014 if _response.status_code == 500:
1015 raise InternalServerError(
1016 headers=dict(_response.headers),
1017 body=typing.cast(
1018 typing.Any,
1019 parse_obj_as(
1020 type_=typing.Any, # type: ignore
1021 object_=_response.json(),
1022 ),
1023 ),
1024 )
1025 _response_json = _response.json()
1026 except JSONDecodeError:
1027 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1028 except ValidationError as e:
1029 raise ParsingError(
1030 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
1031 )
1032 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
1033
1034 async def delete(
1035 self, id: str, *, request_options: typing.Optional[RequestOptions] = None
1036 ) -> AsyncHttpResponse[None]:
1037 """
1038 Deletes a self-service profile by Id.
1039
1040 Parameters
1041 ----------
1042 id : str
1043 The id of the self-service profile to delete
1044
1045 request_options : typing.Optional[RequestOptions]
1046 Request-specific configuration.
1047
1048 Returns
1049 -------
1050 AsyncHttpResponse[None]
1051 """
1052 _response = await self._client_wrapper.httpx_client.request(
1053 f"self-service-profiles/{encode_path_param(id)}",
1054 method="DELETE",
1055 request_options=request_options,
1056 )
1057 try:
1058 if 200 <= _response.status_code < 300:
1059 return AsyncHttpResponse(response=_response, data=None)
1060 if _response.status_code == 400:
1061 raise BadRequestError(
1062 headers=dict(_response.headers),
1063 body=typing.cast(
1064 typing.Any,
1065 parse_obj_as(
1066 type_=typing.Any, # type: ignore
1067 object_=_response.json(),
1068 ),
1069 ),
1070 )
1071 if _response.status_code == 401:
1072 raise UnauthorizedError(
1073 headers=dict(_response.headers),
1074 body=typing.cast(
1075 typing.Any,
1076 parse_obj_as(
1077 type_=typing.Any, # type: ignore
1078 object_=_response.json(),
1079 ),
1080 ),
1081 )
1082 if _response.status_code == 403:
1083 raise ForbiddenError(
1084 headers=dict(_response.headers),
1085 body=typing.cast(
1086 typing.Any,
1087 parse_obj_as(
1088 type_=typing.Any, # type: ignore
1089 object_=_response.json(),
1090 ),
1091 ),
1092 )
1093 if _response.status_code == 429:
1094 raise TooManyRequestsError(
1095 headers=dict(_response.headers),
1096 body=typing.cast(
1097 typing.Any,
1098 parse_obj_as(
1099 type_=typing.Any, # type: ignore
1100 object_=_response.json(),
1101 ),
1102 ),
1103 )
1104 if _response.status_code == 500:
1105 raise InternalServerError(
1106 headers=dict(_response.headers),
1107 body=typing.cast(
1108 typing.Any,
1109 parse_obj_as(
1110 type_=typing.Any, # type: ignore
1111 object_=_response.json(),
1112 ),
1113 ),
1114 )
1115 _response_json = _response.json()
1116 except JSONDecodeError:
1117 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1118 except ValidationError as e:
1119 raise ParsingError(
1120 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
1121 )
1122 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
1123
1124 async def update(
1125 self,
1126 id: str,
1127 *,
1128 name: typing.Optional[str] = OMIT,
1129 description: typing.Optional[SelfServiceProfileDescription] = OMIT,
1130 branding: typing.Optional[SelfServiceProfileBranding] = OMIT,
1131 allowed_strategies: typing.Optional[typing.Sequence[SelfServiceProfileAllowedStrategyEnum]] = OMIT,
1132 user_attributes: typing.Optional[SelfServiceProfileUserAttributes] = OMIT,
1133 user_attribute_profile_id: typing.Optional[str] = OMIT,
1134 request_options: typing.Optional[RequestOptions] = None,
1135 ) -> AsyncHttpResponse[UpdateSelfServiceProfileResponseContent]:
1136 """
1137 Updates a self-service profile.
1138
1139 Parameters
1140 ----------
1141 id : str
1142 The id of the self-service profile to update
1143
1144 name : typing.Optional[str]
1145 The name of the self-service Profile.
1146
1147 description : typing.Optional[SelfServiceProfileDescription]
1148
1149 branding : typing.Optional[SelfServiceProfileBranding]
1150
1151 allowed_strategies : typing.Optional[typing.Sequence[SelfServiceProfileAllowedStrategyEnum]]
1152 List of IdP strategies that will be shown to users during the Self-Service Enterprise Configuration flow. Possible values: [`oidc`, `samlp`, `waad`, `google-apps`, `adfs`, `okta`, `auth0-samlp`, `okta-samlp`, `keycloak-samlp`, `pingfederate`]
1153
1154 user_attributes : typing.Optional[SelfServiceProfileUserAttributes]
1155
1156 user_attribute_profile_id : typing.Optional[str]
1157 ID of the user-attribute-profile to associate with this self-service profile.
1158
1159 request_options : typing.Optional[RequestOptions]
1160 Request-specific configuration.
1161
1162 Returns
1163 -------
1164 AsyncHttpResponse[UpdateSelfServiceProfileResponseContent]
1165 Self-service profile successfully updated.
1166 """
1167 _response = await self._client_wrapper.httpx_client.request(
1168 f"self-service-profiles/{encode_path_param(id)}",
1169 method="PATCH",
1170 json={
1171 "name": name,
1172 "description": description,
1173 "branding": convert_and_respect_annotation_metadata(
1174 object_=branding, annotation=SelfServiceProfileBranding, direction="write"
1175 ),
1176 "allowed_strategies": allowed_strategies,
1177 "user_attributes": convert_and_respect_annotation_metadata(
1178 object_=user_attributes,
1179 annotation=typing.Optional[SelfServiceProfileUserAttributes],
1180 direction="write",
1181 ),
1182 "user_attribute_profile_id": user_attribute_profile_id,
1183 },
1184 headers={
1185 "content-type": "application/json",
1186 },
1187 request_options=request_options,
1188 omit=OMIT,
1189 )
1190 try:
1191 if 200 <= _response.status_code < 300:
1192 _data = typing.cast(
1193 UpdateSelfServiceProfileResponseContent,
1194 parse_obj_as(
1195 type_=UpdateSelfServiceProfileResponseContent, # type: ignore
1196 object_=_response.json(),
1197 ),
1198 )
1199 return AsyncHttpResponse(response=_response, data=_data)
1200 if _response.status_code == 400:
1201 raise BadRequestError(
1202 headers=dict(_response.headers),
1203 body=typing.cast(
1204 typing.Any,
1205 parse_obj_as(
1206 type_=typing.Any, # type: ignore
1207 object_=_response.json(),
1208 ),
1209 ),
1210 )
1211 if _response.status_code == 401:
1212 raise UnauthorizedError(
1213 headers=dict(_response.headers),
1214 body=typing.cast(
1215 typing.Any,
1216 parse_obj_as(
1217 type_=typing.Any, # type: ignore
1218 object_=_response.json(),
1219 ),
1220 ),
1221 )
1222 if _response.status_code == 403:
1223 raise ForbiddenError(
1224 headers=dict(_response.headers),
1225 body=typing.cast(
1226 typing.Any,
1227 parse_obj_as(
1228 type_=typing.Any, # type: ignore
1229 object_=_response.json(),
1230 ),
1231 ),
1232 )
1233 if _response.status_code == 404:
1234 raise NotFoundError(
1235 headers=dict(_response.headers),
1236 body=typing.cast(
1237 typing.Any,
1238 parse_obj_as(
1239 type_=typing.Any, # type: ignore
1240 object_=_response.json(),
1241 ),
1242 ),
1243 )
1244 if _response.status_code == 429:
1245 raise TooManyRequestsError(
1246 headers=dict(_response.headers),
1247 body=typing.cast(
1248 typing.Any,
1249 parse_obj_as(
1250 type_=typing.Any, # type: ignore
1251 object_=_response.json(),
1252 ),
1253 ),
1254 )
1255 if _response.status_code == 500:
1256 raise InternalServerError(
1257 headers=dict(_response.headers),
1258 body=typing.cast(
1259 typing.Any,
1260 parse_obj_as(
1261 type_=typing.Any, # type: ignore
1262 object_=_response.json(),
1263 ),
1264 ),
1265 )
1266 _response_json = _response.json()
1267 except JSONDecodeError:
1268 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1269 except ValidationError as e:
1270 raise ParsingError(
1271 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
1272 )
1273 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)