Debian Codegraph @

src/auth0/management/connections/scim_configuration/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.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_scim_configuration_request_content import CreateScimConfigurationRequestContent
21 from ...types.create_scim_configuration_response_content import CreateScimConfigurationResponseContent
22 from ...types.get_scim_configuration_default_mapping_response_content import (
23 GetScimConfigurationDefaultMappingResponseContent,
24 )
25 from ...types.get_scim_configuration_response_content import GetScimConfigurationResponseContent
26 from ...types.list_scim_configurations_response_content import ListScimConfigurationsResponseContent
27 from ...types.scim_configuration import ScimConfiguration
28 from ...types.scim_mapping_item import ScimMappingItem
29 from ...types.update_scim_configuration_response_content import UpdateScimConfigurationResponseContent
30 from pydantic import ValidationError
31
32 # this is used as the default value for optional parameters
33 OMIT = typing.cast(typing.Any, ...)
34
35
36 class RawScimConfigurationClient:
37 def __init__(self, *, client_wrapper: SyncClientWrapper):
38 self._client_wrapper = client_wrapper
39
40 def list(
41 self,
42 *,
43 from_: typing.Optional[str] = None,
44 take: typing.Optional[int] = 50,
45 request_options: typing.Optional[RequestOptions] = None,
46 ) -> SyncPager[ScimConfiguration, ListScimConfigurationsResponseContent]:
47 """
48 Retrieve a list of SCIM configurations of a tenant.
49
50 Parameters
51 ----------
52 from_ : typing.Optional[str]
53 Optional Id from which to start selection.
54
55 take : typing.Optional[int]
56 Number of results per page. Defaults to 50.
57
58 request_options : typing.Optional[RequestOptions]
59 Request-specific configuration.
60
61 Returns
62 -------
63 SyncPager[ScimConfiguration, ListScimConfigurationsResponseContent]
64 The tenant's SCIM configurations. See <strong>Response Schema</strong> for schema.
65 """
66 _response = self._client_wrapper.httpx_client.request(
67 "connections-scim-configurations",
68 method="GET",
69 params={
70 "from": from_,
71 "take": take,
72 },
73 request_options=request_options,
74 )
75 try:
76 if 200 <= _response.status_code < 300:
77 _parsed_response = typing.cast(
78 ListScimConfigurationsResponseContent,
79 parse_obj_as(
80 type_=ListScimConfigurationsResponseContent, # type: ignore
81 object_=_response.json(),
82 ),
83 )
84 _items = _parsed_response.scim_configurations
85 _parsed_next = _parsed_response.next
86 _has_next = _parsed_next is not None and _parsed_next != ""
87 _get_next = lambda: self.list(
88 from_=_parsed_next,
89 take=take,
90 request_options=request_options,
91 )
92 return SyncPager(has_next=_has_next, items=_items, get_next=_get_next, response=_parsed_response)
93 if _response.status_code == 400:
94 raise BadRequestError(
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 if _response.status_code == 401:
105 raise UnauthorizedError(
106 headers=dict(_response.headers),
107 body=typing.cast(
108 typing.Any,
109 parse_obj_as(
110 type_=typing.Any, # type: ignore
111 object_=_response.json(),
112 ),
113 ),
114 )
115 if _response.status_code == 403:
116 raise ForbiddenError(
117 headers=dict(_response.headers),
118 body=typing.cast(
119 typing.Any,
120 parse_obj_as(
121 type_=typing.Any, # type: ignore
122 object_=_response.json(),
123 ),
124 ),
125 )
126 if _response.status_code == 429:
127 raise TooManyRequestsError(
128 headers=dict(_response.headers),
129 body=typing.cast(
130 typing.Any,
131 parse_obj_as(
132 type_=typing.Any, # type: ignore
133 object_=_response.json(),
134 ),
135 ),
136 )
137 _response_json = _response.json()
138 except JSONDecodeError:
139 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
140 except ValidationError as e:
141 raise ParsingError(
142 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
143 )
144 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
145
146 def get(
147 self, id: str, *, request_options: typing.Optional[RequestOptions] = None
148 ) -> HttpResponse[GetScimConfigurationResponseContent]:
149 """
150 Retrieves a scim configuration by its `connectionId`.
151
152 Parameters
153 ----------
154 id : str
155 The id of the connection to retrieve its SCIM configuration
156
157 request_options : typing.Optional[RequestOptions]
158 Request-specific configuration.
159
160 Returns
161 -------
162 HttpResponse[GetScimConfigurationResponseContent]
163 The connection's SCIM configuration was retrieved. See <strong>Response Schemas</strong> for schema.
164 """
165 _response = self._client_wrapper.httpx_client.request(
166 f"connections/{encode_path_param(id)}/scim-configuration",
167 method="GET",
168 request_options=request_options,
169 )
170 try:
171 if 200 <= _response.status_code < 300:
172 _data = typing.cast(
173 GetScimConfigurationResponseContent,
174 parse_obj_as(
175 type_=GetScimConfigurationResponseContent, # type: ignore
176 object_=_response.json(),
177 ),
178 )
179 return HttpResponse(response=_response, data=_data)
180 if _response.status_code == 400:
181 raise BadRequestError(
182 headers=dict(_response.headers),
183 body=typing.cast(
184 typing.Any,
185 parse_obj_as(
186 type_=typing.Any, # type: ignore
187 object_=_response.json(),
188 ),
189 ),
190 )
191 if _response.status_code == 404:
192 raise NotFoundError(
193 headers=dict(_response.headers),
194 body=typing.cast(
195 typing.Any,
196 parse_obj_as(
197 type_=typing.Any, # type: ignore
198 object_=_response.json(),
199 ),
200 ),
201 )
202 _response_json = _response.json()
203 except JSONDecodeError:
204 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
205 except ValidationError as e:
206 raise ParsingError(
207 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
208 )
209 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
210
211 def create(
212 self,
213 id: str,
214 *,
215 request: typing.Optional[CreateScimConfigurationRequestContent] = None,
216 request_options: typing.Optional[RequestOptions] = None,
217 ) -> HttpResponse[CreateScimConfigurationResponseContent]:
218 """
219 Create a scim configuration for a connection.
220
221 Parameters
222 ----------
223 id : str
224 The id of the connection to create its SCIM configuration
225
226 request : typing.Optional[CreateScimConfigurationRequestContent]
227
228 request_options : typing.Optional[RequestOptions]
229 Request-specific configuration.
230
231 Returns
232 -------
233 HttpResponse[CreateScimConfigurationResponseContent]
234 The connection's SCIM configuration was created. See <strong>Response Schemas</strong> for schema.
235 """
236 _response = self._client_wrapper.httpx_client.request(
237 f"connections/{encode_path_param(id)}/scim-configuration",
238 method="POST",
239 json=convert_and_respect_annotation_metadata(
240 object_=request, annotation=typing.Optional[CreateScimConfigurationRequestContent], direction="write"
241 ),
242 request_options=request_options,
243 omit=OMIT,
244 )
245 try:
246 if 200 <= _response.status_code < 300:
247 _data = typing.cast(
248 CreateScimConfigurationResponseContent,
249 parse_obj_as(
250 type_=CreateScimConfigurationResponseContent, # type: ignore
251 object_=_response.json(),
252 ),
253 )
254 return HttpResponse(response=_response, data=_data)
255 if _response.status_code == 400:
256 raise BadRequestError(
257 headers=dict(_response.headers),
258 body=typing.cast(
259 typing.Any,
260 parse_obj_as(
261 type_=typing.Any, # type: ignore
262 object_=_response.json(),
263 ),
264 ),
265 )
266 if _response.status_code == 404:
267 raise NotFoundError(
268 headers=dict(_response.headers),
269 body=typing.cast(
270 typing.Any,
271 parse_obj_as(
272 type_=typing.Any, # type: ignore
273 object_=_response.json(),
274 ),
275 ),
276 )
277 _response_json = _response.json()
278 except JSONDecodeError:
279 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
280 except ValidationError as e:
281 raise ParsingError(
282 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
283 )
284 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
285
286 def delete(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> HttpResponse[None]:
287 """
288 Deletes a scim configuration by its `connectionId`.
289
290 Parameters
291 ----------
292 id : str
293 The id of the connection to delete its SCIM configuration
294
295 request_options : typing.Optional[RequestOptions]
296 Request-specific configuration.
297
298 Returns
299 -------
300 HttpResponse[None]
301 """
302 _response = self._client_wrapper.httpx_client.request(
303 f"connections/{encode_path_param(id)}/scim-configuration",
304 method="DELETE",
305 request_options=request_options,
306 )
307 try:
308 if 200 <= _response.status_code < 300:
309 return HttpResponse(response=_response, data=None)
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 == 404:
322 raise NotFoundError(
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 _response_json = _response.json()
333 except JSONDecodeError:
334 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
335 except ValidationError as e:
336 raise ParsingError(
337 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
338 )
339 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
340
341 def update(
342 self,
343 id: str,
344 *,
345 user_id_attribute: str,
346 mapping: typing.Sequence[ScimMappingItem],
347 request_options: typing.Optional[RequestOptions] = None,
348 ) -> HttpResponse[UpdateScimConfigurationResponseContent]:
349 """
350 Update a scim configuration by its `connectionId`.
351
352 Parameters
353 ----------
354 id : str
355 The id of the connection to update its SCIM configuration
356
357 user_id_attribute : str
358 User ID attribute for generating unique user ids
359
360 mapping : typing.Sequence[ScimMappingItem]
361 The mapping between auth0 and SCIM
362
363 request_options : typing.Optional[RequestOptions]
364 Request-specific configuration.
365
366 Returns
367 -------
368 HttpResponse[UpdateScimConfigurationResponseContent]
369 The connection's SCIM configuration was updated. See <strong>Response Schemas</strong> for schema.
370 """
371 _response = self._client_wrapper.httpx_client.request(
372 f"connections/{encode_path_param(id)}/scim-configuration",
373 method="PATCH",
374 json={
375 "user_id_attribute": user_id_attribute,
376 "mapping": convert_and_respect_annotation_metadata(
377 object_=mapping, annotation=typing.Sequence[ScimMappingItem], direction="write"
378 ),
379 },
380 headers={
381 "content-type": "application/json",
382 },
383 request_options=request_options,
384 omit=OMIT,
385 )
386 try:
387 if 200 <= _response.status_code < 300:
388 _data = typing.cast(
389 UpdateScimConfigurationResponseContent,
390 parse_obj_as(
391 type_=UpdateScimConfigurationResponseContent, # type: ignore
392 object_=_response.json(),
393 ),
394 )
395 return HttpResponse(response=_response, data=_data)
396 if _response.status_code == 400:
397 raise BadRequestError(
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 if _response.status_code == 404:
408 raise NotFoundError(
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 _response_json = _response.json()
419 except JSONDecodeError:
420 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
421 except ValidationError as e:
422 raise ParsingError(
423 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
424 )
425 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
426
427 def get_default_mapping(
428 self, id: str, *, request_options: typing.Optional[RequestOptions] = None
429 ) -> HttpResponse[GetScimConfigurationDefaultMappingResponseContent]:
430 """
431 Retrieves a scim configuration's default mapping by its `connectionId`.
432
433 Parameters
434 ----------
435 id : str
436 The id of the connection to retrieve its default SCIM mapping
437
438 request_options : typing.Optional[RequestOptions]
439 Request-specific configuration.
440
441 Returns
442 -------
443 HttpResponse[GetScimConfigurationDefaultMappingResponseContent]
444 The connection's default SCIM mapping was retrieved. See <strong>Response Schemas</strong> for schema.
445 """
446 _response = self._client_wrapper.httpx_client.request(
447 f"connections/{encode_path_param(id)}/scim-configuration/default-mapping",
448 method="GET",
449 request_options=request_options,
450 )
451 try:
452 if 200 <= _response.status_code < 300:
453 _data = typing.cast(
454 GetScimConfigurationDefaultMappingResponseContent,
455 parse_obj_as(
456 type_=GetScimConfigurationDefaultMappingResponseContent, # type: ignore
457 object_=_response.json(),
458 ),
459 )
460 return HttpResponse(response=_response, data=_data)
461 if _response.status_code == 400:
462 raise BadRequestError(
463 headers=dict(_response.headers),
464 body=typing.cast(
465 typing.Any,
466 parse_obj_as(
467 type_=typing.Any, # type: ignore
468 object_=_response.json(),
469 ),
470 ),
471 )
472 if _response.status_code == 404:
473 raise NotFoundError(
474 headers=dict(_response.headers),
475 body=typing.cast(
476 typing.Any,
477 parse_obj_as(
478 type_=typing.Any, # type: ignore
479 object_=_response.json(),
480 ),
481 ),
482 )
483 _response_json = _response.json()
484 except JSONDecodeError:
485 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
486 except ValidationError as e:
487 raise ParsingError(
488 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
489 )
490 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
491
492
493 class AsyncRawScimConfigurationClient:
494 def __init__(self, *, client_wrapper: AsyncClientWrapper):
495 self._client_wrapper = client_wrapper
496
497 async def list(
498 self,
499 *,
500 from_: typing.Optional[str] = None,
501 take: typing.Optional[int] = 50,
502 request_options: typing.Optional[RequestOptions] = None,
503 ) -> AsyncPager[ScimConfiguration, ListScimConfigurationsResponseContent]:
504 """
505 Retrieve a list of SCIM configurations of a tenant.
506
507 Parameters
508 ----------
509 from_ : typing.Optional[str]
510 Optional Id from which to start selection.
511
512 take : typing.Optional[int]
513 Number of results per page. Defaults to 50.
514
515 request_options : typing.Optional[RequestOptions]
516 Request-specific configuration.
517
518 Returns
519 -------
520 AsyncPager[ScimConfiguration, ListScimConfigurationsResponseContent]
521 The tenant's SCIM configurations. See <strong>Response Schema</strong> for schema.
522 """
523 _response = await self._client_wrapper.httpx_client.request(
524 "connections-scim-configurations",
525 method="GET",
526 params={
527 "from": from_,
528 "take": take,
529 },
530 request_options=request_options,
531 )
532 try:
533 if 200 <= _response.status_code < 300:
534 _parsed_response = typing.cast(
535 ListScimConfigurationsResponseContent,
536 parse_obj_as(
537 type_=ListScimConfigurationsResponseContent, # type: ignore
538 object_=_response.json(),
539 ),
540 )
541 _items = _parsed_response.scim_configurations
542 _parsed_next = _parsed_response.next
543 _has_next = _parsed_next is not None and _parsed_next != ""
544
545 async def _get_next():
546 return await self.list(
547 from_=_parsed_next,
548 take=take,
549 request_options=request_options,
550 )
551
552 return AsyncPager(has_next=_has_next, items=_items, get_next=_get_next, response=_parsed_response)
553 if _response.status_code == 400:
554 raise BadRequestError(
555 headers=dict(_response.headers),
556 body=typing.cast(
557 typing.Any,
558 parse_obj_as(
559 type_=typing.Any, # type: ignore
560 object_=_response.json(),
561 ),
562 ),
563 )
564 if _response.status_code == 401:
565 raise UnauthorizedError(
566 headers=dict(_response.headers),
567 body=typing.cast(
568 typing.Any,
569 parse_obj_as(
570 type_=typing.Any, # type: ignore
571 object_=_response.json(),
572 ),
573 ),
574 )
575 if _response.status_code == 403:
576 raise ForbiddenError(
577 headers=dict(_response.headers),
578 body=typing.cast(
579 typing.Any,
580 parse_obj_as(
581 type_=typing.Any, # type: ignore
582 object_=_response.json(),
583 ),
584 ),
585 )
586 if _response.status_code == 429:
587 raise TooManyRequestsError(
588 headers=dict(_response.headers),
589 body=typing.cast(
590 typing.Any,
591 parse_obj_as(
592 type_=typing.Any, # type: ignore
593 object_=_response.json(),
594 ),
595 ),
596 )
597 _response_json = _response.json()
598 except JSONDecodeError:
599 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
600 except ValidationError as e:
601 raise ParsingError(
602 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
603 )
604 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
605
606 async def get(
607 self, id: str, *, request_options: typing.Optional[RequestOptions] = None
608 ) -> AsyncHttpResponse[GetScimConfigurationResponseContent]:
609 """
610 Retrieves a scim configuration by its `connectionId`.
611
612 Parameters
613 ----------
614 id : str
615 The id of the connection to retrieve its SCIM configuration
616
617 request_options : typing.Optional[RequestOptions]
618 Request-specific configuration.
619
620 Returns
621 -------
622 AsyncHttpResponse[GetScimConfigurationResponseContent]
623 The connection's SCIM configuration was retrieved. See <strong>Response Schemas</strong> for schema.
624 """
625 _response = await self._client_wrapper.httpx_client.request(
626 f"connections/{encode_path_param(id)}/scim-configuration",
627 method="GET",
628 request_options=request_options,
629 )
630 try:
631 if 200 <= _response.status_code < 300:
632 _data = typing.cast(
633 GetScimConfigurationResponseContent,
634 parse_obj_as(
635 type_=GetScimConfigurationResponseContent, # type: ignore
636 object_=_response.json(),
637 ),
638 )
639 return AsyncHttpResponse(response=_response, data=_data)
640 if _response.status_code == 400:
641 raise BadRequestError(
642 headers=dict(_response.headers),
643 body=typing.cast(
644 typing.Any,
645 parse_obj_as(
646 type_=typing.Any, # type: ignore
647 object_=_response.json(),
648 ),
649 ),
650 )
651 if _response.status_code == 404:
652 raise NotFoundError(
653 headers=dict(_response.headers),
654 body=typing.cast(
655 typing.Any,
656 parse_obj_as(
657 type_=typing.Any, # type: ignore
658 object_=_response.json(),
659 ),
660 ),
661 )
662 _response_json = _response.json()
663 except JSONDecodeError:
664 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
665 except ValidationError as e:
666 raise ParsingError(
667 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
668 )
669 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
670
671 async def create(
672 self,
673 id: str,
674 *,
675 request: typing.Optional[CreateScimConfigurationRequestContent] = None,
676 request_options: typing.Optional[RequestOptions] = None,
677 ) -> AsyncHttpResponse[CreateScimConfigurationResponseContent]:
678 """
679 Create a scim configuration for a connection.
680
681 Parameters
682 ----------
683 id : str
684 The id of the connection to create its SCIM configuration
685
686 request : typing.Optional[CreateScimConfigurationRequestContent]
687
688 request_options : typing.Optional[RequestOptions]
689 Request-specific configuration.
690
691 Returns
692 -------
693 AsyncHttpResponse[CreateScimConfigurationResponseContent]
694 The connection's SCIM configuration was created. See <strong>Response Schemas</strong> for schema.
695 """
696 _response = await self._client_wrapper.httpx_client.request(
697 f"connections/{encode_path_param(id)}/scim-configuration",
698 method="POST",
699 json=convert_and_respect_annotation_metadata(
700 object_=request, annotation=typing.Optional[CreateScimConfigurationRequestContent], direction="write"
701 ),
702 request_options=request_options,
703 omit=OMIT,
704 )
705 try:
706 if 200 <= _response.status_code < 300:
707 _data = typing.cast(
708 CreateScimConfigurationResponseContent,
709 parse_obj_as(
710 type_=CreateScimConfigurationResponseContent, # type: ignore
711 object_=_response.json(),
712 ),
713 )
714 return AsyncHttpResponse(response=_response, data=_data)
715 if _response.status_code == 400:
716 raise BadRequestError(
717 headers=dict(_response.headers),
718 body=typing.cast(
719 typing.Any,
720 parse_obj_as(
721 type_=typing.Any, # type: ignore
722 object_=_response.json(),
723 ),
724 ),
725 )
726 if _response.status_code == 404:
727 raise NotFoundError(
728 headers=dict(_response.headers),
729 body=typing.cast(
730 typing.Any,
731 parse_obj_as(
732 type_=typing.Any, # type: ignore
733 object_=_response.json(),
734 ),
735 ),
736 )
737 _response_json = _response.json()
738 except JSONDecodeError:
739 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
740 except ValidationError as e:
741 raise ParsingError(
742 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
743 )
744 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
745
746 async def delete(
747 self, id: str, *, request_options: typing.Optional[RequestOptions] = None
748 ) -> AsyncHttpResponse[None]:
749 """
750 Deletes a scim configuration by its `connectionId`.
751
752 Parameters
753 ----------
754 id : str
755 The id of the connection to delete its SCIM configuration
756
757 request_options : typing.Optional[RequestOptions]
758 Request-specific configuration.
759
760 Returns
761 -------
762 AsyncHttpResponse[None]
763 """
764 _response = await self._client_wrapper.httpx_client.request(
765 f"connections/{encode_path_param(id)}/scim-configuration",
766 method="DELETE",
767 request_options=request_options,
768 )
769 try:
770 if 200 <= _response.status_code < 300:
771 return AsyncHttpResponse(response=_response, data=None)
772 if _response.status_code == 400:
773 raise BadRequestError(
774 headers=dict(_response.headers),
775 body=typing.cast(
776 typing.Any,
777 parse_obj_as(
778 type_=typing.Any, # type: ignore
779 object_=_response.json(),
780 ),
781 ),
782 )
783 if _response.status_code == 404:
784 raise NotFoundError(
785 headers=dict(_response.headers),
786 body=typing.cast(
787 typing.Any,
788 parse_obj_as(
789 type_=typing.Any, # type: ignore
790 object_=_response.json(),
791 ),
792 ),
793 )
794 _response_json = _response.json()
795 except JSONDecodeError:
796 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
797 except ValidationError as e:
798 raise ParsingError(
799 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
800 )
801 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
802
803 async def update(
804 self,
805 id: str,
806 *,
807 user_id_attribute: str,
808 mapping: typing.Sequence[ScimMappingItem],
809 request_options: typing.Optional[RequestOptions] = None,
810 ) -> AsyncHttpResponse[UpdateScimConfigurationResponseContent]:
811 """
812 Update a scim configuration by its `connectionId`.
813
814 Parameters
815 ----------
816 id : str
817 The id of the connection to update its SCIM configuration
818
819 user_id_attribute : str
820 User ID attribute for generating unique user ids
821
822 mapping : typing.Sequence[ScimMappingItem]
823 The mapping between auth0 and SCIM
824
825 request_options : typing.Optional[RequestOptions]
826 Request-specific configuration.
827
828 Returns
829 -------
830 AsyncHttpResponse[UpdateScimConfigurationResponseContent]
831 The connection's SCIM configuration was updated. See <strong>Response Schemas</strong> for schema.
832 """
833 _response = await self._client_wrapper.httpx_client.request(
834 f"connections/{encode_path_param(id)}/scim-configuration",
835 method="PATCH",
836 json={
837 "user_id_attribute": user_id_attribute,
838 "mapping": convert_and_respect_annotation_metadata(
839 object_=mapping, annotation=typing.Sequence[ScimMappingItem], direction="write"
840 ),
841 },
842 headers={
843 "content-type": "application/json",
844 },
845 request_options=request_options,
846 omit=OMIT,
847 )
848 try:
849 if 200 <= _response.status_code < 300:
850 _data = typing.cast(
851 UpdateScimConfigurationResponseContent,
852 parse_obj_as(
853 type_=UpdateScimConfigurationResponseContent, # type: ignore
854 object_=_response.json(),
855 ),
856 )
857 return AsyncHttpResponse(response=_response, data=_data)
858 if _response.status_code == 400:
859 raise BadRequestError(
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 == 404:
870 raise NotFoundError(
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 _response_json = _response.json()
881 except JSONDecodeError:
882 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
883 except ValidationError as e:
884 raise ParsingError(
885 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
886 )
887 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
888
889 async def get_default_mapping(
890 self, id: str, *, request_options: typing.Optional[RequestOptions] = None
891 ) -> AsyncHttpResponse[GetScimConfigurationDefaultMappingResponseContent]:
892 """
893 Retrieves a scim configuration's default mapping by its `connectionId`.
894
895 Parameters
896 ----------
897 id : str
898 The id of the connection to retrieve its default SCIM mapping
899
900 request_options : typing.Optional[RequestOptions]
901 Request-specific configuration.
902
903 Returns
904 -------
905 AsyncHttpResponse[GetScimConfigurationDefaultMappingResponseContent]
906 The connection's default SCIM mapping was retrieved. See <strong>Response Schemas</strong> for schema.
907 """
908 _response = await self._client_wrapper.httpx_client.request(
909 f"connections/{encode_path_param(id)}/scim-configuration/default-mapping",
910 method="GET",
911 request_options=request_options,
912 )
913 try:
914 if 200 <= _response.status_code < 300:
915 _data = typing.cast(
916 GetScimConfigurationDefaultMappingResponseContent,
917 parse_obj_as(
918 type_=GetScimConfigurationDefaultMappingResponseContent, # type: ignore
919 object_=_response.json(),
920 ),
921 )
922 return AsyncHttpResponse(response=_response, data=_data)
923 if _response.status_code == 400:
924 raise BadRequestError(
925 headers=dict(_response.headers),
926 body=typing.cast(
927 typing.Any,
928 parse_obj_as(
929 type_=typing.Any, # type: ignore
930 object_=_response.json(),
931 ),
932 ),
933 )
934 if _response.status_code == 404:
935 raise NotFoundError(
936 headers=dict(_response.headers),
937 body=typing.cast(
938 typing.Any,
939 parse_obj_as(
940 type_=typing.Any, # type: ignore
941 object_=_response.json(),
942 ),
943 ),
944 )
945 _response_json = _response.json()
946 except JSONDecodeError:
947 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
948 except ValidationError as e:
949 raise ParsingError(
950 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
951 )
952 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)