Debian Codegraph @

src/auth0/management/connections/directory_provisioning/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.not_found_error import NotFoundError
19 from ...errors.too_many_requests_error import TooManyRequestsError
20 from ...errors.unauthorized_error import UnauthorizedError
21 from ...types.create_directory_provisioning_request_content import CreateDirectoryProvisioningRequestContent
22 from ...types.create_directory_provisioning_response_content import CreateDirectoryProvisioningResponseContent
23 from ...types.directory_provisioning import DirectoryProvisioning
24 from ...types.get_directory_provisioning_default_mapping_response_content import (
25 GetDirectoryProvisioningDefaultMappingResponseContent,
26 )
27 from ...types.get_directory_provisioning_response_content import GetDirectoryProvisioningResponseContent
28 from ...types.list_directory_provisionings_response_content import ListDirectoryProvisioningsResponseContent
29 from ...types.list_synchronized_groups_response_content import ListSynchronizedGroupsResponseContent
30 from ...types.synchronized_group_payload import SynchronizedGroupPayload
31 from ...types.update_directory_provisioning_request_content import UpdateDirectoryProvisioningRequestContent
32 from ...types.update_directory_provisioning_response_content import UpdateDirectoryProvisioningResponseContent
33 from pydantic import ValidationError
34
35 # this is used as the default value for optional parameters
36 OMIT = typing.cast(typing.Any, ...)
37
38
39 class RawDirectoryProvisioningClient:
40 def __init__(self, *, client_wrapper: SyncClientWrapper):
41 self._client_wrapper = client_wrapper
42
43 def list(
44 self,
45 *,
46 from_: typing.Optional[str] = None,
47 take: typing.Optional[int] = 50,
48 request_options: typing.Optional[RequestOptions] = None,
49 ) -> SyncPager[DirectoryProvisioning, ListDirectoryProvisioningsResponseContent]:
50 """
51 Retrieve a list of directory provisioning configurations of a tenant.
52
53 Parameters
54 ----------
55 from_ : typing.Optional[str]
56 Optional Id from which to start selection.
57
58 take : typing.Optional[int]
59 Number of results per page. Defaults to 50.
60
61 request_options : typing.Optional[RequestOptions]
62 Request-specific configuration.
63
64 Returns
65 -------
66 SyncPager[DirectoryProvisioning, ListDirectoryProvisioningsResponseContent]
67 The tenant's directory provisioning configuration. See <strong>Response Schemas</strong> for schema.
68 """
69 _response = self._client_wrapper.httpx_client.request(
70 "connections-directory-provisionings",
71 method="GET",
72 params={
73 "from": from_,
74 "take": take,
75 },
76 request_options=request_options,
77 )
78 try:
79 if 200 <= _response.status_code < 300:
80 _parsed_response = typing.cast(
81 ListDirectoryProvisioningsResponseContent,
82 parse_obj_as(
83 type_=ListDirectoryProvisioningsResponseContent, # type: ignore
84 object_=_response.json(),
85 ),
86 )
87 _items = _parsed_response.directory_provisionings
88 _parsed_next = _parsed_response.next
89 _has_next = _parsed_next is not None and _parsed_next != ""
90 _get_next = lambda: self.list(
91 from_=_parsed_next,
92 take=take,
93 request_options=request_options,
94 )
95 return SyncPager(has_next=_has_next, items=_items, get_next=_get_next, response=_parsed_response)
96 if _response.status_code == 400:
97 raise BadRequestError(
98 headers=dict(_response.headers),
99 body=typing.cast(
100 typing.Any,
101 parse_obj_as(
102 type_=typing.Any, # type: ignore
103 object_=_response.json(),
104 ),
105 ),
106 )
107 if _response.status_code == 401:
108 raise UnauthorizedError(
109 headers=dict(_response.headers),
110 body=typing.cast(
111 typing.Any,
112 parse_obj_as(
113 type_=typing.Any, # type: ignore
114 object_=_response.json(),
115 ),
116 ),
117 )
118 if _response.status_code == 403:
119 raise ForbiddenError(
120 headers=dict(_response.headers),
121 body=typing.cast(
122 typing.Any,
123 parse_obj_as(
124 type_=typing.Any, # type: ignore
125 object_=_response.json(),
126 ),
127 ),
128 )
129 if _response.status_code == 429:
130 raise TooManyRequestsError(
131 headers=dict(_response.headers),
132 body=typing.cast(
133 typing.Any,
134 parse_obj_as(
135 type_=typing.Any, # type: ignore
136 object_=_response.json(),
137 ),
138 ),
139 )
140 _response_json = _response.json()
141 except JSONDecodeError:
142 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
143 except ValidationError as e:
144 raise ParsingError(
145 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
146 )
147 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
148
149 def get(
150 self, id: str, *, request_options: typing.Optional[RequestOptions] = None
151 ) -> HttpResponse[GetDirectoryProvisioningResponseContent]:
152 """
153 Retrieve the directory provisioning configuration of a connection.
154
155 Parameters
156 ----------
157 id : str
158 The id of the connection to retrieve its directory provisioning configuration
159
160 request_options : typing.Optional[RequestOptions]
161 Request-specific configuration.
162
163 Returns
164 -------
165 HttpResponse[GetDirectoryProvisioningResponseContent]
166 The connection's directory provisioning configuration. See <strong>Response Schemas</strong> for schema.
167 """
168 _response = self._client_wrapper.httpx_client.request(
169 f"connections/{encode_path_param(id)}/directory-provisioning",
170 method="GET",
171 request_options=request_options,
172 )
173 try:
174 if 200 <= _response.status_code < 300:
175 _data = typing.cast(
176 GetDirectoryProvisioningResponseContent,
177 parse_obj_as(
178 type_=GetDirectoryProvisioningResponseContent, # type: ignore
179 object_=_response.json(),
180 ),
181 )
182 return HttpResponse(response=_response, data=_data)
183 if _response.status_code == 400:
184 raise BadRequestError(
185 headers=dict(_response.headers),
186 body=typing.cast(
187 typing.Any,
188 parse_obj_as(
189 type_=typing.Any, # type: ignore
190 object_=_response.json(),
191 ),
192 ),
193 )
194 if _response.status_code == 401:
195 raise UnauthorizedError(
196 headers=dict(_response.headers),
197 body=typing.cast(
198 typing.Any,
199 parse_obj_as(
200 type_=typing.Any, # type: ignore
201 object_=_response.json(),
202 ),
203 ),
204 )
205 if _response.status_code == 403:
206 raise ForbiddenError(
207 headers=dict(_response.headers),
208 body=typing.cast(
209 typing.Any,
210 parse_obj_as(
211 type_=typing.Any, # type: ignore
212 object_=_response.json(),
213 ),
214 ),
215 )
216 if _response.status_code == 404:
217 raise NotFoundError(
218 headers=dict(_response.headers),
219 body=typing.cast(
220 typing.Any,
221 parse_obj_as(
222 type_=typing.Any, # type: ignore
223 object_=_response.json(),
224 ),
225 ),
226 )
227 if _response.status_code == 429:
228 raise TooManyRequestsError(
229 headers=dict(_response.headers),
230 body=typing.cast(
231 typing.Any,
232 parse_obj_as(
233 type_=typing.Any, # type: ignore
234 object_=_response.json(),
235 ),
236 ),
237 )
238 _response_json = _response.json()
239 except JSONDecodeError:
240 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
241 except ValidationError as e:
242 raise ParsingError(
243 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
244 )
245 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
246
247 def create(
248 self,
249 id: str,
250 *,
251 request: typing.Optional[CreateDirectoryProvisioningRequestContent] = None,
252 request_options: typing.Optional[RequestOptions] = None,
253 ) -> HttpResponse[CreateDirectoryProvisioningResponseContent]:
254 """
255 Create a directory provisioning configuration for a connection.
256
257 Parameters
258 ----------
259 id : str
260 The id of the connection to create its directory provisioning configuration
261
262 request : typing.Optional[CreateDirectoryProvisioningRequestContent]
263
264 request_options : typing.Optional[RequestOptions]
265 Request-specific configuration.
266
267 Returns
268 -------
269 HttpResponse[CreateDirectoryProvisioningResponseContent]
270 The connection's directory provisioning configuration was created. See <strong>Response Schemas</strong> for schema.
271 """
272 _response = self._client_wrapper.httpx_client.request(
273 f"connections/{encode_path_param(id)}/directory-provisioning",
274 method="POST",
275 json=convert_and_respect_annotation_metadata(
276 object_=request,
277 annotation=typing.Optional[CreateDirectoryProvisioningRequestContent],
278 direction="write",
279 ),
280 request_options=request_options,
281 omit=OMIT,
282 )
283 try:
284 if 200 <= _response.status_code < 300:
285 _data = typing.cast(
286 CreateDirectoryProvisioningResponseContent,
287 parse_obj_as(
288 type_=CreateDirectoryProvisioningResponseContent, # type: ignore
289 object_=_response.json(),
290 ),
291 )
292 return HttpResponse(response=_response, data=_data)
293 if _response.status_code == 400:
294 raise BadRequestError(
295 headers=dict(_response.headers),
296 body=typing.cast(
297 typing.Any,
298 parse_obj_as(
299 type_=typing.Any, # type: ignore
300 object_=_response.json(),
301 ),
302 ),
303 )
304 if _response.status_code == 401:
305 raise UnauthorizedError(
306 headers=dict(_response.headers),
307 body=typing.cast(
308 typing.Any,
309 parse_obj_as(
310 type_=typing.Any, # type: ignore
311 object_=_response.json(),
312 ),
313 ),
314 )
315 if _response.status_code == 403:
316 raise ForbiddenError(
317 headers=dict(_response.headers),
318 body=typing.cast(
319 typing.Any,
320 parse_obj_as(
321 type_=typing.Any, # type: ignore
322 object_=_response.json(),
323 ),
324 ),
325 )
326 if _response.status_code == 404:
327 raise NotFoundError(
328 headers=dict(_response.headers),
329 body=typing.cast(
330 typing.Any,
331 parse_obj_as(
332 type_=typing.Any, # type: ignore
333 object_=_response.json(),
334 ),
335 ),
336 )
337 if _response.status_code == 409:
338 raise ConflictError(
339 headers=dict(_response.headers),
340 body=typing.cast(
341 typing.Any,
342 parse_obj_as(
343 type_=typing.Any, # type: ignore
344 object_=_response.json(),
345 ),
346 ),
347 )
348 if _response.status_code == 429:
349 raise TooManyRequestsError(
350 headers=dict(_response.headers),
351 body=typing.cast(
352 typing.Any,
353 parse_obj_as(
354 type_=typing.Any, # type: ignore
355 object_=_response.json(),
356 ),
357 ),
358 )
359 _response_json = _response.json()
360 except JSONDecodeError:
361 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
362 except ValidationError as e:
363 raise ParsingError(
364 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
365 )
366 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
367
368 def delete(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> HttpResponse[None]:
369 """
370 Delete the directory provisioning configuration of a connection.
371
372 Parameters
373 ----------
374 id : str
375 The id of the connection to delete its directory provisioning configuration
376
377 request_options : typing.Optional[RequestOptions]
378 Request-specific configuration.
379
380 Returns
381 -------
382 HttpResponse[None]
383 """
384 _response = self._client_wrapper.httpx_client.request(
385 f"connections/{encode_path_param(id)}/directory-provisioning",
386 method="DELETE",
387 request_options=request_options,
388 )
389 try:
390 if 200 <= _response.status_code < 300:
391 return HttpResponse(response=_response, data=None)
392 if _response.status_code == 400:
393 raise BadRequestError(
394 headers=dict(_response.headers),
395 body=typing.cast(
396 typing.Any,
397 parse_obj_as(
398 type_=typing.Any, # type: ignore
399 object_=_response.json(),
400 ),
401 ),
402 )
403 if _response.status_code == 401:
404 raise UnauthorizedError(
405 headers=dict(_response.headers),
406 body=typing.cast(
407 typing.Any,
408 parse_obj_as(
409 type_=typing.Any, # type: ignore
410 object_=_response.json(),
411 ),
412 ),
413 )
414 if _response.status_code == 403:
415 raise ForbiddenError(
416 headers=dict(_response.headers),
417 body=typing.cast(
418 typing.Any,
419 parse_obj_as(
420 type_=typing.Any, # type: ignore
421 object_=_response.json(),
422 ),
423 ),
424 )
425 if _response.status_code == 404:
426 raise NotFoundError(
427 headers=dict(_response.headers),
428 body=typing.cast(
429 typing.Any,
430 parse_obj_as(
431 type_=typing.Any, # type: ignore
432 object_=_response.json(),
433 ),
434 ),
435 )
436 if _response.status_code == 429:
437 raise TooManyRequestsError(
438 headers=dict(_response.headers),
439 body=typing.cast(
440 typing.Any,
441 parse_obj_as(
442 type_=typing.Any, # type: ignore
443 object_=_response.json(),
444 ),
445 ),
446 )
447 _response_json = _response.json()
448 except JSONDecodeError:
449 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
450 except ValidationError as e:
451 raise ParsingError(
452 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
453 )
454 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
455
456 def update(
457 self,
458 id: str,
459 *,
460 request: typing.Optional[UpdateDirectoryProvisioningRequestContent] = None,
461 request_options: typing.Optional[RequestOptions] = None,
462 ) -> HttpResponse[UpdateDirectoryProvisioningResponseContent]:
463 """
464 Update the directory provisioning configuration of a connection.
465
466 Parameters
467 ----------
468 id : str
469 The id of the connection to create its directory provisioning configuration
470
471 request : typing.Optional[UpdateDirectoryProvisioningRequestContent]
472
473 request_options : typing.Optional[RequestOptions]
474 Request-specific configuration.
475
476 Returns
477 -------
478 HttpResponse[UpdateDirectoryProvisioningResponseContent]
479 The connection's directory provisioning configuration was updated. See <strong>Response Schemas</strong> for schema.
480 """
481 _response = self._client_wrapper.httpx_client.request(
482 f"connections/{encode_path_param(id)}/directory-provisioning",
483 method="PATCH",
484 json=convert_and_respect_annotation_metadata(
485 object_=request,
486 annotation=typing.Optional[UpdateDirectoryProvisioningRequestContent],
487 direction="write",
488 ),
489 request_options=request_options,
490 omit=OMIT,
491 )
492 try:
493 if 200 <= _response.status_code < 300:
494 _data = typing.cast(
495 UpdateDirectoryProvisioningResponseContent,
496 parse_obj_as(
497 type_=UpdateDirectoryProvisioningResponseContent, # type: ignore
498 object_=_response.json(),
499 ),
500 )
501 return HttpResponse(response=_response, data=_data)
502 if _response.status_code == 400:
503 raise BadRequestError(
504 headers=dict(_response.headers),
505 body=typing.cast(
506 typing.Any,
507 parse_obj_as(
508 type_=typing.Any, # type: ignore
509 object_=_response.json(),
510 ),
511 ),
512 )
513 if _response.status_code == 401:
514 raise UnauthorizedError(
515 headers=dict(_response.headers),
516 body=typing.cast(
517 typing.Any,
518 parse_obj_as(
519 type_=typing.Any, # type: ignore
520 object_=_response.json(),
521 ),
522 ),
523 )
524 if _response.status_code == 403:
525 raise ForbiddenError(
526 headers=dict(_response.headers),
527 body=typing.cast(
528 typing.Any,
529 parse_obj_as(
530 type_=typing.Any, # type: ignore
531 object_=_response.json(),
532 ),
533 ),
534 )
535 if _response.status_code == 404:
536 raise NotFoundError(
537 headers=dict(_response.headers),
538 body=typing.cast(
539 typing.Any,
540 parse_obj_as(
541 type_=typing.Any, # type: ignore
542 object_=_response.json(),
543 ),
544 ),
545 )
546 if _response.status_code == 429:
547 raise TooManyRequestsError(
548 headers=dict(_response.headers),
549 body=typing.cast(
550 typing.Any,
551 parse_obj_as(
552 type_=typing.Any, # type: ignore
553 object_=_response.json(),
554 ),
555 ),
556 )
557 _response_json = _response.json()
558 except JSONDecodeError:
559 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
560 except ValidationError as e:
561 raise ParsingError(
562 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
563 )
564 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
565
566 def get_default_mapping(
567 self, id: str, *, request_options: typing.Optional[RequestOptions] = None
568 ) -> HttpResponse[GetDirectoryProvisioningDefaultMappingResponseContent]:
569 """
570 Retrieve the directory provisioning default attribute mapping of a connection.
571
572 Parameters
573 ----------
574 id : str
575 The id of the connection to retrieve its directory provisioning configuration
576
577 request_options : typing.Optional[RequestOptions]
578 Request-specific configuration.
579
580 Returns
581 -------
582 HttpResponse[GetDirectoryProvisioningDefaultMappingResponseContent]
583 The connection's directory provisioning default mapping. See <strong>Response Schemas</strong> for schema.
584 """
585 _response = self._client_wrapper.httpx_client.request(
586 f"connections/{encode_path_param(id)}/directory-provisioning/default-mapping",
587 method="GET",
588 request_options=request_options,
589 )
590 try:
591 if 200 <= _response.status_code < 300:
592 _data = typing.cast(
593 GetDirectoryProvisioningDefaultMappingResponseContent,
594 parse_obj_as(
595 type_=GetDirectoryProvisioningDefaultMappingResponseContent, # type: ignore
596 object_=_response.json(),
597 ),
598 )
599 return HttpResponse(response=_response, data=_data)
600 if _response.status_code == 400:
601 raise BadRequestError(
602 headers=dict(_response.headers),
603 body=typing.cast(
604 typing.Any,
605 parse_obj_as(
606 type_=typing.Any, # type: ignore
607 object_=_response.json(),
608 ),
609 ),
610 )
611 if _response.status_code == 401:
612 raise UnauthorizedError(
613 headers=dict(_response.headers),
614 body=typing.cast(
615 typing.Any,
616 parse_obj_as(
617 type_=typing.Any, # type: ignore
618 object_=_response.json(),
619 ),
620 ),
621 )
622 if _response.status_code == 403:
623 raise ForbiddenError(
624 headers=dict(_response.headers),
625 body=typing.cast(
626 typing.Any,
627 parse_obj_as(
628 type_=typing.Any, # type: ignore
629 object_=_response.json(),
630 ),
631 ),
632 )
633 if _response.status_code == 404:
634 raise NotFoundError(
635 headers=dict(_response.headers),
636 body=typing.cast(
637 typing.Any,
638 parse_obj_as(
639 type_=typing.Any, # type: ignore
640 object_=_response.json(),
641 ),
642 ),
643 )
644 if _response.status_code == 429:
645 raise TooManyRequestsError(
646 headers=dict(_response.headers),
647 body=typing.cast(
648 typing.Any,
649 parse_obj_as(
650 type_=typing.Any, # type: ignore
651 object_=_response.json(),
652 ),
653 ),
654 )
655 _response_json = _response.json()
656 except JSONDecodeError:
657 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
658 except ValidationError as e:
659 raise ParsingError(
660 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
661 )
662 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
663
664 def list_synchronized_groups(
665 self,
666 id: str,
667 *,
668 from_: typing.Optional[str] = None,
669 take: typing.Optional[int] = 50,
670 request_options: typing.Optional[RequestOptions] = None,
671 ) -> SyncPager[SynchronizedGroupPayload, ListSynchronizedGroupsResponseContent]:
672 """
673 Retrieve the configured synchronized groups for a connection directory provisioning configuration.
674
675 Parameters
676 ----------
677 id : str
678 The id of the connection to list synchronized groups for.
679
680 from_ : typing.Optional[str]
681 Optional Id from which to start selection.
682
683 take : typing.Optional[int]
684 Number of results per page. Defaults to 50.
685
686 request_options : typing.Optional[RequestOptions]
687 Request-specific configuration.
688
689 Returns
690 -------
691 SyncPager[SynchronizedGroupPayload, ListSynchronizedGroupsResponseContent]
692 The connection's synchronized groups. See <strong>Response Schemas</strong> for schema.
693 """
694 _response = self._client_wrapper.httpx_client.request(
695 f"connections/{encode_path_param(id)}/directory-provisioning/synchronized-groups",
696 method="GET",
697 params={
698 "from": from_,
699 "take": take,
700 },
701 request_options=request_options,
702 )
703 try:
704 if 200 <= _response.status_code < 300:
705 _parsed_response = typing.cast(
706 ListSynchronizedGroupsResponseContent,
707 parse_obj_as(
708 type_=ListSynchronizedGroupsResponseContent, # type: ignore
709 object_=_response.json(),
710 ),
711 )
712 _items = _parsed_response.groups
713 _parsed_next = _parsed_response.next
714 _has_next = _parsed_next is not None and _parsed_next != ""
715 _get_next = lambda: self.list_synchronized_groups(
716 id,
717 from_=_parsed_next,
718 take=take,
719 request_options=request_options,
720 )
721 return SyncPager(has_next=_has_next, items=_items, get_next=_get_next, response=_parsed_response)
722 if _response.status_code == 400:
723 raise BadRequestError(
724 headers=dict(_response.headers),
725 body=typing.cast(
726 typing.Any,
727 parse_obj_as(
728 type_=typing.Any, # type: ignore
729 object_=_response.json(),
730 ),
731 ),
732 )
733 if _response.status_code == 401:
734 raise UnauthorizedError(
735 headers=dict(_response.headers),
736 body=typing.cast(
737 typing.Any,
738 parse_obj_as(
739 type_=typing.Any, # type: ignore
740 object_=_response.json(),
741 ),
742 ),
743 )
744 if _response.status_code == 403:
745 raise ForbiddenError(
746 headers=dict(_response.headers),
747 body=typing.cast(
748 typing.Any,
749 parse_obj_as(
750 type_=typing.Any, # type: ignore
751 object_=_response.json(),
752 ),
753 ),
754 )
755 if _response.status_code == 404:
756 raise NotFoundError(
757 headers=dict(_response.headers),
758 body=typing.cast(
759 typing.Any,
760 parse_obj_as(
761 type_=typing.Any, # type: ignore
762 object_=_response.json(),
763 ),
764 ),
765 )
766 if _response.status_code == 429:
767 raise TooManyRequestsError(
768 headers=dict(_response.headers),
769 body=typing.cast(
770 typing.Any,
771 parse_obj_as(
772 type_=typing.Any, # type: ignore
773 object_=_response.json(),
774 ),
775 ),
776 )
777 _response_json = _response.json()
778 except JSONDecodeError:
779 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
780 except ValidationError as e:
781 raise ParsingError(
782 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
783 )
784 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
785
786 def set(
787 self,
788 id: str,
789 *,
790 groups: typing.Sequence[SynchronizedGroupPayload],
791 request_options: typing.Optional[RequestOptions] = None,
792 ) -> HttpResponse[None]:
793 """
794 Create or replace the selected groups for a connection directory provisioning configuration.
795
796 Parameters
797 ----------
798 id : str
799 The id of the connection to create or replace synchronized groups for
800
801 groups : typing.Sequence[SynchronizedGroupPayload]
802 Array of Google Workspace Directory group objects to synchronize.
803
804 request_options : typing.Optional[RequestOptions]
805 Request-specific configuration.
806
807 Returns
808 -------
809 HttpResponse[None]
810 """
811 _response = self._client_wrapper.httpx_client.request(
812 f"connections/{encode_path_param(id)}/directory-provisioning/synchronized-groups",
813 method="PUT",
814 json={
815 "groups": convert_and_respect_annotation_metadata(
816 object_=groups, annotation=typing.Sequence[SynchronizedGroupPayload], direction="write"
817 ),
818 },
819 headers={
820 "content-type": "application/json",
821 },
822 request_options=request_options,
823 omit=OMIT,
824 )
825 try:
826 if 200 <= _response.status_code < 300:
827 return HttpResponse(response=_response, data=None)
828 if _response.status_code == 400:
829 raise BadRequestError(
830 headers=dict(_response.headers),
831 body=typing.cast(
832 typing.Any,
833 parse_obj_as(
834 type_=typing.Any, # type: ignore
835 object_=_response.json(),
836 ),
837 ),
838 )
839 if _response.status_code == 401:
840 raise UnauthorizedError(
841 headers=dict(_response.headers),
842 body=typing.cast(
843 typing.Any,
844 parse_obj_as(
845 type_=typing.Any, # type: ignore
846 object_=_response.json(),
847 ),
848 ),
849 )
850 if _response.status_code == 403:
851 raise ForbiddenError(
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 == 404:
862 raise NotFoundError(
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 == 409:
873 raise ConflictError(
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 == 429:
884 raise TooManyRequestsError(
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 _response_json = _response.json()
895 except JSONDecodeError:
896 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
897 except ValidationError as e:
898 raise ParsingError(
899 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
900 )
901 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
902
903
904 class AsyncRawDirectoryProvisioningClient:
905 def __init__(self, *, client_wrapper: AsyncClientWrapper):
906 self._client_wrapper = client_wrapper
907
908 async def list(
909 self,
910 *,
911 from_: typing.Optional[str] = None,
912 take: typing.Optional[int] = 50,
913 request_options: typing.Optional[RequestOptions] = None,
914 ) -> AsyncPager[DirectoryProvisioning, ListDirectoryProvisioningsResponseContent]:
915 """
916 Retrieve a list of directory provisioning configurations of a tenant.
917
918 Parameters
919 ----------
920 from_ : typing.Optional[str]
921 Optional Id from which to start selection.
922
923 take : typing.Optional[int]
924 Number of results per page. Defaults to 50.
925
926 request_options : typing.Optional[RequestOptions]
927 Request-specific configuration.
928
929 Returns
930 -------
931 AsyncPager[DirectoryProvisioning, ListDirectoryProvisioningsResponseContent]
932 The tenant's directory provisioning configuration. See <strong>Response Schemas</strong> for schema.
933 """
934 _response = await self._client_wrapper.httpx_client.request(
935 "connections-directory-provisionings",
936 method="GET",
937 params={
938 "from": from_,
939 "take": take,
940 },
941 request_options=request_options,
942 )
943 try:
944 if 200 <= _response.status_code < 300:
945 _parsed_response = typing.cast(
946 ListDirectoryProvisioningsResponseContent,
947 parse_obj_as(
948 type_=ListDirectoryProvisioningsResponseContent, # type: ignore
949 object_=_response.json(),
950 ),
951 )
952 _items = _parsed_response.directory_provisionings
953 _parsed_next = _parsed_response.next
954 _has_next = _parsed_next is not None and _parsed_next != ""
955
956 async def _get_next():
957 return await self.list(
958 from_=_parsed_next,
959 take=take,
960 request_options=request_options,
961 )
962
963 return AsyncPager(has_next=_has_next, items=_items, get_next=_get_next, response=_parsed_response)
964 if _response.status_code == 400:
965 raise BadRequestError(
966 headers=dict(_response.headers),
967 body=typing.cast(
968 typing.Any,
969 parse_obj_as(
970 type_=typing.Any, # type: ignore
971 object_=_response.json(),
972 ),
973 ),
974 )
975 if _response.status_code == 401:
976 raise UnauthorizedError(
977 headers=dict(_response.headers),
978 body=typing.cast(
979 typing.Any,
980 parse_obj_as(
981 type_=typing.Any, # type: ignore
982 object_=_response.json(),
983 ),
984 ),
985 )
986 if _response.status_code == 403:
987 raise ForbiddenError(
988 headers=dict(_response.headers),
989 body=typing.cast(
990 typing.Any,
991 parse_obj_as(
992 type_=typing.Any, # type: ignore
993 object_=_response.json(),
994 ),
995 ),
996 )
997 if _response.status_code == 429:
998 raise TooManyRequestsError(
999 headers=dict(_response.headers),
1000 body=typing.cast(
1001 typing.Any,
1002 parse_obj_as(
1003 type_=typing.Any, # type: ignore
1004 object_=_response.json(),
1005 ),
1006 ),
1007 )
1008 _response_json = _response.json()
1009 except JSONDecodeError:
1010 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1011 except ValidationError as e:
1012 raise ParsingError(
1013 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
1014 )
1015 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
1016
1017 async def get(
1018 self, id: str, *, request_options: typing.Optional[RequestOptions] = None
1019 ) -> AsyncHttpResponse[GetDirectoryProvisioningResponseContent]:
1020 """
1021 Retrieve the directory provisioning configuration of a connection.
1022
1023 Parameters
1024 ----------
1025 id : str
1026 The id of the connection to retrieve its directory provisioning configuration
1027
1028 request_options : typing.Optional[RequestOptions]
1029 Request-specific configuration.
1030
1031 Returns
1032 -------
1033 AsyncHttpResponse[GetDirectoryProvisioningResponseContent]
1034 The connection's directory provisioning configuration. See <strong>Response Schemas</strong> for schema.
1035 """
1036 _response = await self._client_wrapper.httpx_client.request(
1037 f"connections/{encode_path_param(id)}/directory-provisioning",
1038 method="GET",
1039 request_options=request_options,
1040 )
1041 try:
1042 if 200 <= _response.status_code < 300:
1043 _data = typing.cast(
1044 GetDirectoryProvisioningResponseContent,
1045 parse_obj_as(
1046 type_=GetDirectoryProvisioningResponseContent, # type: ignore
1047 object_=_response.json(),
1048 ),
1049 )
1050 return AsyncHttpResponse(response=_response, data=_data)
1051 if _response.status_code == 400:
1052 raise BadRequestError(
1053 headers=dict(_response.headers),
1054 body=typing.cast(
1055 typing.Any,
1056 parse_obj_as(
1057 type_=typing.Any, # type: ignore
1058 object_=_response.json(),
1059 ),
1060 ),
1061 )
1062 if _response.status_code == 401:
1063 raise UnauthorizedError(
1064 headers=dict(_response.headers),
1065 body=typing.cast(
1066 typing.Any,
1067 parse_obj_as(
1068 type_=typing.Any, # type: ignore
1069 object_=_response.json(),
1070 ),
1071 ),
1072 )
1073 if _response.status_code == 403:
1074 raise ForbiddenError(
1075 headers=dict(_response.headers),
1076 body=typing.cast(
1077 typing.Any,
1078 parse_obj_as(
1079 type_=typing.Any, # type: ignore
1080 object_=_response.json(),
1081 ),
1082 ),
1083 )
1084 if _response.status_code == 404:
1085 raise NotFoundError(
1086 headers=dict(_response.headers),
1087 body=typing.cast(
1088 typing.Any,
1089 parse_obj_as(
1090 type_=typing.Any, # type: ignore
1091 object_=_response.json(),
1092 ),
1093 ),
1094 )
1095 if _response.status_code == 429:
1096 raise TooManyRequestsError(
1097 headers=dict(_response.headers),
1098 body=typing.cast(
1099 typing.Any,
1100 parse_obj_as(
1101 type_=typing.Any, # type: ignore
1102 object_=_response.json(),
1103 ),
1104 ),
1105 )
1106 _response_json = _response.json()
1107 except JSONDecodeError:
1108 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1109 except ValidationError as e:
1110 raise ParsingError(
1111 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
1112 )
1113 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
1114
1115 async def create(
1116 self,
1117 id: str,
1118 *,
1119 request: typing.Optional[CreateDirectoryProvisioningRequestContent] = None,
1120 request_options: typing.Optional[RequestOptions] = None,
1121 ) -> AsyncHttpResponse[CreateDirectoryProvisioningResponseContent]:
1122 """
1123 Create a directory provisioning configuration for a connection.
1124
1125 Parameters
1126 ----------
1127 id : str
1128 The id of the connection to create its directory provisioning configuration
1129
1130 request : typing.Optional[CreateDirectoryProvisioningRequestContent]
1131
1132 request_options : typing.Optional[RequestOptions]
1133 Request-specific configuration.
1134
1135 Returns
1136 -------
1137 AsyncHttpResponse[CreateDirectoryProvisioningResponseContent]
1138 The connection's directory provisioning configuration was created. See <strong>Response Schemas</strong> for schema.
1139 """
1140 _response = await self._client_wrapper.httpx_client.request(
1141 f"connections/{encode_path_param(id)}/directory-provisioning",
1142 method="POST",
1143 json=convert_and_respect_annotation_metadata(
1144 object_=request,
1145 annotation=typing.Optional[CreateDirectoryProvisioningRequestContent],
1146 direction="write",
1147 ),
1148 request_options=request_options,
1149 omit=OMIT,
1150 )
1151 try:
1152 if 200 <= _response.status_code < 300:
1153 _data = typing.cast(
1154 CreateDirectoryProvisioningResponseContent,
1155 parse_obj_as(
1156 type_=CreateDirectoryProvisioningResponseContent, # type: ignore
1157 object_=_response.json(),
1158 ),
1159 )
1160 return AsyncHttpResponse(response=_response, data=_data)
1161 if _response.status_code == 400:
1162 raise BadRequestError(
1163 headers=dict(_response.headers),
1164 body=typing.cast(
1165 typing.Any,
1166 parse_obj_as(
1167 type_=typing.Any, # type: ignore
1168 object_=_response.json(),
1169 ),
1170 ),
1171 )
1172 if _response.status_code == 401:
1173 raise UnauthorizedError(
1174 headers=dict(_response.headers),
1175 body=typing.cast(
1176 typing.Any,
1177 parse_obj_as(
1178 type_=typing.Any, # type: ignore
1179 object_=_response.json(),
1180 ),
1181 ),
1182 )
1183 if _response.status_code == 403:
1184 raise ForbiddenError(
1185 headers=dict(_response.headers),
1186 body=typing.cast(
1187 typing.Any,
1188 parse_obj_as(
1189 type_=typing.Any, # type: ignore
1190 object_=_response.json(),
1191 ),
1192 ),
1193 )
1194 if _response.status_code == 404:
1195 raise NotFoundError(
1196 headers=dict(_response.headers),
1197 body=typing.cast(
1198 typing.Any,
1199 parse_obj_as(
1200 type_=typing.Any, # type: ignore
1201 object_=_response.json(),
1202 ),
1203 ),
1204 )
1205 if _response.status_code == 409:
1206 raise ConflictError(
1207 headers=dict(_response.headers),
1208 body=typing.cast(
1209 typing.Any,
1210 parse_obj_as(
1211 type_=typing.Any, # type: ignore
1212 object_=_response.json(),
1213 ),
1214 ),
1215 )
1216 if _response.status_code == 429:
1217 raise TooManyRequestsError(
1218 headers=dict(_response.headers),
1219 body=typing.cast(
1220 typing.Any,
1221 parse_obj_as(
1222 type_=typing.Any, # type: ignore
1223 object_=_response.json(),
1224 ),
1225 ),
1226 )
1227 _response_json = _response.json()
1228 except JSONDecodeError:
1229 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1230 except ValidationError as e:
1231 raise ParsingError(
1232 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
1233 )
1234 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
1235
1236 async def delete(
1237 self, id: str, *, request_options: typing.Optional[RequestOptions] = None
1238 ) -> AsyncHttpResponse[None]:
1239 """
1240 Delete the directory provisioning configuration of a connection.
1241
1242 Parameters
1243 ----------
1244 id : str
1245 The id of the connection to delete its directory provisioning configuration
1246
1247 request_options : typing.Optional[RequestOptions]
1248 Request-specific configuration.
1249
1250 Returns
1251 -------
1252 AsyncHttpResponse[None]
1253 """
1254 _response = await self._client_wrapper.httpx_client.request(
1255 f"connections/{encode_path_param(id)}/directory-provisioning",
1256 method="DELETE",
1257 request_options=request_options,
1258 )
1259 try:
1260 if 200 <= _response.status_code < 300:
1261 return AsyncHttpResponse(response=_response, data=None)
1262 if _response.status_code == 400:
1263 raise BadRequestError(
1264 headers=dict(_response.headers),
1265 body=typing.cast(
1266 typing.Any,
1267 parse_obj_as(
1268 type_=typing.Any, # type: ignore
1269 object_=_response.json(),
1270 ),
1271 ),
1272 )
1273 if _response.status_code == 401:
1274 raise UnauthorizedError(
1275 headers=dict(_response.headers),
1276 body=typing.cast(
1277 typing.Any,
1278 parse_obj_as(
1279 type_=typing.Any, # type: ignore
1280 object_=_response.json(),
1281 ),
1282 ),
1283 )
1284 if _response.status_code == 403:
1285 raise ForbiddenError(
1286 headers=dict(_response.headers),
1287 body=typing.cast(
1288 typing.Any,
1289 parse_obj_as(
1290 type_=typing.Any, # type: ignore
1291 object_=_response.json(),
1292 ),
1293 ),
1294 )
1295 if _response.status_code == 404:
1296 raise NotFoundError(
1297 headers=dict(_response.headers),
1298 body=typing.cast(
1299 typing.Any,
1300 parse_obj_as(
1301 type_=typing.Any, # type: ignore
1302 object_=_response.json(),
1303 ),
1304 ),
1305 )
1306 if _response.status_code == 429:
1307 raise TooManyRequestsError(
1308 headers=dict(_response.headers),
1309 body=typing.cast(
1310 typing.Any,
1311 parse_obj_as(
1312 type_=typing.Any, # type: ignore
1313 object_=_response.json(),
1314 ),
1315 ),
1316 )
1317 _response_json = _response.json()
1318 except JSONDecodeError:
1319 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1320 except ValidationError as e:
1321 raise ParsingError(
1322 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
1323 )
1324 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
1325
1326 async def update(
1327 self,
1328 id: str,
1329 *,
1330 request: typing.Optional[UpdateDirectoryProvisioningRequestContent] = None,
1331 request_options: typing.Optional[RequestOptions] = None,
1332 ) -> AsyncHttpResponse[UpdateDirectoryProvisioningResponseContent]:
1333 """
1334 Update the directory provisioning configuration of a connection.
1335
1336 Parameters
1337 ----------
1338 id : str
1339 The id of the connection to create its directory provisioning configuration
1340
1341 request : typing.Optional[UpdateDirectoryProvisioningRequestContent]
1342
1343 request_options : typing.Optional[RequestOptions]
1344 Request-specific configuration.
1345
1346 Returns
1347 -------
1348 AsyncHttpResponse[UpdateDirectoryProvisioningResponseContent]
1349 The connection's directory provisioning configuration was updated. See <strong>Response Schemas</strong> for schema.
1350 """
1351 _response = await self._client_wrapper.httpx_client.request(
1352 f"connections/{encode_path_param(id)}/directory-provisioning",
1353 method="PATCH",
1354 json=convert_and_respect_annotation_metadata(
1355 object_=request,
1356 annotation=typing.Optional[UpdateDirectoryProvisioningRequestContent],
1357 direction="write",
1358 ),
1359 request_options=request_options,
1360 omit=OMIT,
1361 )
1362 try:
1363 if 200 <= _response.status_code < 300:
1364 _data = typing.cast(
1365 UpdateDirectoryProvisioningResponseContent,
1366 parse_obj_as(
1367 type_=UpdateDirectoryProvisioningResponseContent, # type: ignore
1368 object_=_response.json(),
1369 ),
1370 )
1371 return AsyncHttpResponse(response=_response, data=_data)
1372 if _response.status_code == 400:
1373 raise BadRequestError(
1374 headers=dict(_response.headers),
1375 body=typing.cast(
1376 typing.Any,
1377 parse_obj_as(
1378 type_=typing.Any, # type: ignore
1379 object_=_response.json(),
1380 ),
1381 ),
1382 )
1383 if _response.status_code == 401:
1384 raise UnauthorizedError(
1385 headers=dict(_response.headers),
1386 body=typing.cast(
1387 typing.Any,
1388 parse_obj_as(
1389 type_=typing.Any, # type: ignore
1390 object_=_response.json(),
1391 ),
1392 ),
1393 )
1394 if _response.status_code == 403:
1395 raise ForbiddenError(
1396 headers=dict(_response.headers),
1397 body=typing.cast(
1398 typing.Any,
1399 parse_obj_as(
1400 type_=typing.Any, # type: ignore
1401 object_=_response.json(),
1402 ),
1403 ),
1404 )
1405 if _response.status_code == 404:
1406 raise NotFoundError(
1407 headers=dict(_response.headers),
1408 body=typing.cast(
1409 typing.Any,
1410 parse_obj_as(
1411 type_=typing.Any, # type: ignore
1412 object_=_response.json(),
1413 ),
1414 ),
1415 )
1416 if _response.status_code == 429:
1417 raise TooManyRequestsError(
1418 headers=dict(_response.headers),
1419 body=typing.cast(
1420 typing.Any,
1421 parse_obj_as(
1422 type_=typing.Any, # type: ignore
1423 object_=_response.json(),
1424 ),
1425 ),
1426 )
1427 _response_json = _response.json()
1428 except JSONDecodeError:
1429 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1430 except ValidationError as e:
1431 raise ParsingError(
1432 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
1433 )
1434 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
1435
1436 async def get_default_mapping(
1437 self, id: str, *, request_options: typing.Optional[RequestOptions] = None
1438 ) -> AsyncHttpResponse[GetDirectoryProvisioningDefaultMappingResponseContent]:
1439 """
1440 Retrieve the directory provisioning default attribute mapping of a connection.
1441
1442 Parameters
1443 ----------
1444 id : str
1445 The id of the connection to retrieve its directory provisioning configuration
1446
1447 request_options : typing.Optional[RequestOptions]
1448 Request-specific configuration.
1449
1450 Returns
1451 -------
1452 AsyncHttpResponse[GetDirectoryProvisioningDefaultMappingResponseContent]
1453 The connection's directory provisioning default mapping. See <strong>Response Schemas</strong> for schema.
1454 """
1455 _response = await self._client_wrapper.httpx_client.request(
1456 f"connections/{encode_path_param(id)}/directory-provisioning/default-mapping",
1457 method="GET",
1458 request_options=request_options,
1459 )
1460 try:
1461 if 200 <= _response.status_code < 300:
1462 _data = typing.cast(
1463 GetDirectoryProvisioningDefaultMappingResponseContent,
1464 parse_obj_as(
1465 type_=GetDirectoryProvisioningDefaultMappingResponseContent, # type: ignore
1466 object_=_response.json(),
1467 ),
1468 )
1469 return AsyncHttpResponse(response=_response, data=_data)
1470 if _response.status_code == 400:
1471 raise BadRequestError(
1472 headers=dict(_response.headers),
1473 body=typing.cast(
1474 typing.Any,
1475 parse_obj_as(
1476 type_=typing.Any, # type: ignore
1477 object_=_response.json(),
1478 ),
1479 ),
1480 )
1481 if _response.status_code == 401:
1482 raise UnauthorizedError(
1483 headers=dict(_response.headers),
1484 body=typing.cast(
1485 typing.Any,
1486 parse_obj_as(
1487 type_=typing.Any, # type: ignore
1488 object_=_response.json(),
1489 ),
1490 ),
1491 )
1492 if _response.status_code == 403:
1493 raise ForbiddenError(
1494 headers=dict(_response.headers),
1495 body=typing.cast(
1496 typing.Any,
1497 parse_obj_as(
1498 type_=typing.Any, # type: ignore
1499 object_=_response.json(),
1500 ),
1501 ),
1502 )
1503 if _response.status_code == 404:
1504 raise NotFoundError(
1505 headers=dict(_response.headers),
1506 body=typing.cast(
1507 typing.Any,
1508 parse_obj_as(
1509 type_=typing.Any, # type: ignore
1510 object_=_response.json(),
1511 ),
1512 ),
1513 )
1514 if _response.status_code == 429:
1515 raise TooManyRequestsError(
1516 headers=dict(_response.headers),
1517 body=typing.cast(
1518 typing.Any,
1519 parse_obj_as(
1520 type_=typing.Any, # type: ignore
1521 object_=_response.json(),
1522 ),
1523 ),
1524 )
1525 _response_json = _response.json()
1526 except JSONDecodeError:
1527 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1528 except ValidationError as e:
1529 raise ParsingError(
1530 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
1531 )
1532 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
1533
1534 async def list_synchronized_groups(
1535 self,
1536 id: str,
1537 *,
1538 from_: typing.Optional[str] = None,
1539 take: typing.Optional[int] = 50,
1540 request_options: typing.Optional[RequestOptions] = None,
1541 ) -> AsyncPager[SynchronizedGroupPayload, ListSynchronizedGroupsResponseContent]:
1542 """
1543 Retrieve the configured synchronized groups for a connection directory provisioning configuration.
1544
1545 Parameters
1546 ----------
1547 id : str
1548 The id of the connection to list synchronized groups for.
1549
1550 from_ : typing.Optional[str]
1551 Optional Id from which to start selection.
1552
1553 take : typing.Optional[int]
1554 Number of results per page. Defaults to 50.
1555
1556 request_options : typing.Optional[RequestOptions]
1557 Request-specific configuration.
1558
1559 Returns
1560 -------
1561 AsyncPager[SynchronizedGroupPayload, ListSynchronizedGroupsResponseContent]
1562 The connection's synchronized groups. See <strong>Response Schemas</strong> for schema.
1563 """
1564 _response = await self._client_wrapper.httpx_client.request(
1565 f"connections/{encode_path_param(id)}/directory-provisioning/synchronized-groups",
1566 method="GET",
1567 params={
1568 "from": from_,
1569 "take": take,
1570 },
1571 request_options=request_options,
1572 )
1573 try:
1574 if 200 <= _response.status_code < 300:
1575 _parsed_response = typing.cast(
1576 ListSynchronizedGroupsResponseContent,
1577 parse_obj_as(
1578 type_=ListSynchronizedGroupsResponseContent, # type: ignore
1579 object_=_response.json(),
1580 ),
1581 )
1582 _items = _parsed_response.groups
1583 _parsed_next = _parsed_response.next
1584 _has_next = _parsed_next is not None and _parsed_next != ""
1585
1586 async def _get_next():
1587 return await self.list_synchronized_groups(
1588 id,
1589 from_=_parsed_next,
1590 take=take,
1591 request_options=request_options,
1592 )
1593
1594 return AsyncPager(has_next=_has_next, items=_items, get_next=_get_next, response=_parsed_response)
1595 if _response.status_code == 400:
1596 raise BadRequestError(
1597 headers=dict(_response.headers),
1598 body=typing.cast(
1599 typing.Any,
1600 parse_obj_as(
1601 type_=typing.Any, # type: ignore
1602 object_=_response.json(),
1603 ),
1604 ),
1605 )
1606 if _response.status_code == 401:
1607 raise UnauthorizedError(
1608 headers=dict(_response.headers),
1609 body=typing.cast(
1610 typing.Any,
1611 parse_obj_as(
1612 type_=typing.Any, # type: ignore
1613 object_=_response.json(),
1614 ),
1615 ),
1616 )
1617 if _response.status_code == 403:
1618 raise ForbiddenError(
1619 headers=dict(_response.headers),
1620 body=typing.cast(
1621 typing.Any,
1622 parse_obj_as(
1623 type_=typing.Any, # type: ignore
1624 object_=_response.json(),
1625 ),
1626 ),
1627 )
1628 if _response.status_code == 404:
1629 raise NotFoundError(
1630 headers=dict(_response.headers),
1631 body=typing.cast(
1632 typing.Any,
1633 parse_obj_as(
1634 type_=typing.Any, # type: ignore
1635 object_=_response.json(),
1636 ),
1637 ),
1638 )
1639 if _response.status_code == 429:
1640 raise TooManyRequestsError(
1641 headers=dict(_response.headers),
1642 body=typing.cast(
1643 typing.Any,
1644 parse_obj_as(
1645 type_=typing.Any, # type: ignore
1646 object_=_response.json(),
1647 ),
1648 ),
1649 )
1650 _response_json = _response.json()
1651 except JSONDecodeError:
1652 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1653 except ValidationError as e:
1654 raise ParsingError(
1655 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
1656 )
1657 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
1658
1659 async def set(
1660 self,
1661 id: str,
1662 *,
1663 groups: typing.Sequence[SynchronizedGroupPayload],
1664 request_options: typing.Optional[RequestOptions] = None,
1665 ) -> AsyncHttpResponse[None]:
1666 """
1667 Create or replace the selected groups for a connection directory provisioning configuration.
1668
1669 Parameters
1670 ----------
1671 id : str
1672 The id of the connection to create or replace synchronized groups for
1673
1674 groups : typing.Sequence[SynchronizedGroupPayload]
1675 Array of Google Workspace Directory group objects to synchronize.
1676
1677 request_options : typing.Optional[RequestOptions]
1678 Request-specific configuration.
1679
1680 Returns
1681 -------
1682 AsyncHttpResponse[None]
1683 """
1684 _response = await self._client_wrapper.httpx_client.request(
1685 f"connections/{encode_path_param(id)}/directory-provisioning/synchronized-groups",
1686 method="PUT",
1687 json={
1688 "groups": convert_and_respect_annotation_metadata(
1689 object_=groups, annotation=typing.Sequence[SynchronizedGroupPayload], direction="write"
1690 ),
1691 },
1692 headers={
1693 "content-type": "application/json",
1694 },
1695 request_options=request_options,
1696 omit=OMIT,
1697 )
1698 try:
1699 if 200 <= _response.status_code < 300:
1700 return AsyncHttpResponse(response=_response, data=None)
1701 if _response.status_code == 400:
1702 raise BadRequestError(
1703 headers=dict(_response.headers),
1704 body=typing.cast(
1705 typing.Any,
1706 parse_obj_as(
1707 type_=typing.Any, # type: ignore
1708 object_=_response.json(),
1709 ),
1710 ),
1711 )
1712 if _response.status_code == 401:
1713 raise UnauthorizedError(
1714 headers=dict(_response.headers),
1715 body=typing.cast(
1716 typing.Any,
1717 parse_obj_as(
1718 type_=typing.Any, # type: ignore
1719 object_=_response.json(),
1720 ),
1721 ),
1722 )
1723 if _response.status_code == 403:
1724 raise ForbiddenError(
1725 headers=dict(_response.headers),
1726 body=typing.cast(
1727 typing.Any,
1728 parse_obj_as(
1729 type_=typing.Any, # type: ignore
1730 object_=_response.json(),
1731 ),
1732 ),
1733 )
1734 if _response.status_code == 404:
1735 raise NotFoundError(
1736 headers=dict(_response.headers),
1737 body=typing.cast(
1738 typing.Any,
1739 parse_obj_as(
1740 type_=typing.Any, # type: ignore
1741 object_=_response.json(),
1742 ),
1743 ),
1744 )
1745 if _response.status_code == 409:
1746 raise ConflictError(
1747 headers=dict(_response.headers),
1748 body=typing.cast(
1749 typing.Any,
1750 parse_obj_as(
1751 type_=typing.Any, # type: ignore
1752 object_=_response.json(),
1753 ),
1754 ),
1755 )
1756 if _response.status_code == 429:
1757 raise TooManyRequestsError(
1758 headers=dict(_response.headers),
1759 body=typing.cast(
1760 typing.Any,
1761 parse_obj_as(
1762 type_=typing.Any, # type: ignore
1763 object_=_response.json(),
1764 ),
1765 ),
1766 )
1767 _response_json = _response.json()
1768 except JSONDecodeError:
1769 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1770 except ValidationError as e:
1771 raise ParsingError(
1772 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
1773 )
1774 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)