Debian Codegraph @

src/auth0/management/organizations/enabled_connections/raw_client.py

raw symbols SCIP
1 # This file was auto-generated by Fern from our API Definition.
2
3 import typing
4 from json.decoder import JSONDecodeError
5
6 from ...core.api_error import ApiError
7 from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
8 from ...core.http_response import AsyncHttpResponse, HttpResponse
9 from ...core.jsonable_encoder import encode_path_param
10 from ...core.pagination import AsyncPager, SyncPager
11 from ...core.parse_error import ParsingError
12 from ...core.pydantic_utilities import parse_obj_as
13 from ...core.request_options import RequestOptions
14 from ...errors.bad_request_error import BadRequestError
15 from ...errors.forbidden_error import ForbiddenError
16 from ...errors.not_found_error import NotFoundError
17 from ...errors.too_many_requests_error import TooManyRequestsError
18 from ...errors.unauthorized_error import UnauthorizedError
19 from ...types.add_organization_connection_response_content import AddOrganizationConnectionResponseContent
20 from ...types.get_organization_connection_response_content import GetOrganizationConnectionResponseContent
21 from ...types.list_organization_connections_offset_paginated_response_content import (
22 ListOrganizationConnectionsOffsetPaginatedResponseContent,
23 )
24 from ...types.organization_connection import OrganizationConnection
25 from ...types.update_organization_connection_response_content import UpdateOrganizationConnectionResponseContent
26 from pydantic import ValidationError
27
28 # this is used as the default value for optional parameters
29 OMIT = typing.cast(typing.Any, ...)
30
31
32 class RawEnabledConnectionsClient:
33 def __init__(self, *, client_wrapper: SyncClientWrapper):
34 self._client_wrapper = client_wrapper
35
36 def list(
37 self,
38 id: str,
39 *,
40 page: typing.Optional[int] = 0,
41 per_page: typing.Optional[int] = 50,
42 include_totals: typing.Optional[bool] = True,
43 request_options: typing.Optional[RequestOptions] = None,
44 ) -> SyncPager[OrganizationConnection, ListOrganizationConnectionsOffsetPaginatedResponseContent]:
45 """
46 Retrieve details about a specific connection currently enabled for an Organization. Information returned includes details such as connection ID, name, strategy, and whether the connection automatically grants membership upon login.
47
48 Parameters
49 ----------
50 id : str
51 Organization identifier.
52
53 page : typing.Optional[int]
54 Page index of the results to return. First page is 0.
55
56 per_page : typing.Optional[int]
57 Number of results per page. Defaults to 50.
58
59 include_totals : typing.Optional[bool]
60 Return results inside an object that contains the total result count (true) or as a direct array of results (false, default).
61
62 request_options : typing.Optional[RequestOptions]
63 Request-specific configuration.
64
65 Returns
66 -------
67 SyncPager[OrganizationConnection, ListOrganizationConnectionsOffsetPaginatedResponseContent]
68 Connections successfully retrieved.
69 """
70 page = page if page is not None else 0
71
72 _response = self._client_wrapper.httpx_client.request(
73 f"organizations/{encode_path_param(id)}/enabled_connections",
74 method="GET",
75 params={
76 "page": page,
77 "per_page": per_page,
78 "include_totals": include_totals,
79 },
80 request_options=request_options,
81 )
82 try:
83 if 200 <= _response.status_code < 300:
84 _parsed_response = typing.cast(
85 ListOrganizationConnectionsOffsetPaginatedResponseContent,
86 parse_obj_as(
87 type_=ListOrganizationConnectionsOffsetPaginatedResponseContent, # type: ignore
88 object_=_response.json(),
89 ),
90 )
91 _items = _parsed_response.enabled_connections
92 _has_next = len(_items or []) > 0
93 _get_next = lambda: self.list(
94 id,
95 page=page + 1,
96 per_page=per_page,
97 include_totals=include_totals,
98 request_options=request_options,
99 )
100 return SyncPager(has_next=_has_next, items=_items, get_next=_get_next, response=_parsed_response)
101 if _response.status_code == 400:
102 raise BadRequestError(
103 headers=dict(_response.headers),
104 body=typing.cast(
105 typing.Any,
106 parse_obj_as(
107 type_=typing.Any, # type: ignore
108 object_=_response.json(),
109 ),
110 ),
111 )
112 if _response.status_code == 401:
113 raise UnauthorizedError(
114 headers=dict(_response.headers),
115 body=typing.cast(
116 typing.Any,
117 parse_obj_as(
118 type_=typing.Any, # type: ignore
119 object_=_response.json(),
120 ),
121 ),
122 )
123 if _response.status_code == 403:
124 raise ForbiddenError(
125 headers=dict(_response.headers),
126 body=typing.cast(
127 typing.Any,
128 parse_obj_as(
129 type_=typing.Any, # type: ignore
130 object_=_response.json(),
131 ),
132 ),
133 )
134 if _response.status_code == 404:
135 raise NotFoundError(
136 headers=dict(_response.headers),
137 body=typing.cast(
138 typing.Any,
139 parse_obj_as(
140 type_=typing.Any, # type: ignore
141 object_=_response.json(),
142 ),
143 ),
144 )
145 if _response.status_code == 429:
146 raise TooManyRequestsError(
147 headers=dict(_response.headers),
148 body=typing.cast(
149 typing.Any,
150 parse_obj_as(
151 type_=typing.Any, # type: ignore
152 object_=_response.json(),
153 ),
154 ),
155 )
156 _response_json = _response.json()
157 except JSONDecodeError:
158 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
159 except ValidationError as e:
160 raise ParsingError(
161 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
162 )
163 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
164
165 def add(
166 self,
167 id: str,
168 *,
169 connection_id: str,
170 assign_membership_on_login: typing.Optional[bool] = OMIT,
171 is_signup_enabled: typing.Optional[bool] = OMIT,
172 show_as_button: typing.Optional[bool] = OMIT,
173 request_options: typing.Optional[RequestOptions] = None,
174 ) -> HttpResponse[AddOrganizationConnectionResponseContent]:
175 """
176 Enable a specific connection for a given Organization. To enable a connection, it must already exist within your tenant; connections cannot be created through this action.
177
178 [Connections](https://auth0.com/docs/authenticate/identity-providers) represent the relationship between Auth0 and a source of users. Available types of connections include database, enterprise, and social.
179
180 Parameters
181 ----------
182 id : str
183 Organization identifier.
184
185 connection_id : str
186 Single connection ID to add to the organization.
187
188 assign_membership_on_login : typing.Optional[bool]
189 When true, all users that log in with this connection will be automatically granted membership in the organization. When false, users must be granted membership in the organization before logging in with this connection.
190
191 is_signup_enabled : typing.Optional[bool]
192 Determines whether organization signup should be enabled for this organization connection. Only applicable for database connections. Default: false.
193
194 show_as_button : typing.Optional[bool]
195 Determines whether a connection should be displayed on this organization’s login prompt. Only applicable for enterprise connections. Default: true.
196
197 request_options : typing.Optional[RequestOptions]
198 Request-specific configuration.
199
200 Returns
201 -------
202 HttpResponse[AddOrganizationConnectionResponseContent]
203 Organization connection successfully added.
204 """
205 _response = self._client_wrapper.httpx_client.request(
206 f"organizations/{encode_path_param(id)}/enabled_connections",
207 method="POST",
208 json={
209 "connection_id": connection_id,
210 "assign_membership_on_login": assign_membership_on_login,
211 "is_signup_enabled": is_signup_enabled,
212 "show_as_button": show_as_button,
213 },
214 headers={
215 "content-type": "application/json",
216 },
217 request_options=request_options,
218 omit=OMIT,
219 )
220 try:
221 if 200 <= _response.status_code < 300:
222 _data = typing.cast(
223 AddOrganizationConnectionResponseContent,
224 parse_obj_as(
225 type_=AddOrganizationConnectionResponseContent, # type: ignore
226 object_=_response.json(),
227 ),
228 )
229 return HttpResponse(response=_response, data=_data)
230 if _response.status_code == 400:
231 raise BadRequestError(
232 headers=dict(_response.headers),
233 body=typing.cast(
234 typing.Any,
235 parse_obj_as(
236 type_=typing.Any, # type: ignore
237 object_=_response.json(),
238 ),
239 ),
240 )
241 if _response.status_code == 401:
242 raise UnauthorizedError(
243 headers=dict(_response.headers),
244 body=typing.cast(
245 typing.Any,
246 parse_obj_as(
247 type_=typing.Any, # type: ignore
248 object_=_response.json(),
249 ),
250 ),
251 )
252 if _response.status_code == 403:
253 raise ForbiddenError(
254 headers=dict(_response.headers),
255 body=typing.cast(
256 typing.Any,
257 parse_obj_as(
258 type_=typing.Any, # type: ignore
259 object_=_response.json(),
260 ),
261 ),
262 )
263 if _response.status_code == 404:
264 raise NotFoundError(
265 headers=dict(_response.headers),
266 body=typing.cast(
267 typing.Any,
268 parse_obj_as(
269 type_=typing.Any, # type: ignore
270 object_=_response.json(),
271 ),
272 ),
273 )
274 if _response.status_code == 429:
275 raise TooManyRequestsError(
276 headers=dict(_response.headers),
277 body=typing.cast(
278 typing.Any,
279 parse_obj_as(
280 type_=typing.Any, # type: ignore
281 object_=_response.json(),
282 ),
283 ),
284 )
285 _response_json = _response.json()
286 except JSONDecodeError:
287 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
288 except ValidationError as e:
289 raise ParsingError(
290 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
291 )
292 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
293
294 def get(
295 self, id: str, connection_id: str, *, request_options: typing.Optional[RequestOptions] = None
296 ) -> HttpResponse[GetOrganizationConnectionResponseContent]:
297 """
298 Retrieve details about a specific connection currently enabled for an Organization. Information returned includes details such as connection ID, name, strategy, and whether the connection automatically grants membership upon login.
299
300 Parameters
301 ----------
302 id : str
303 Organization identifier.
304
305 connection_id : str
306 Connection identifier.
307
308 request_options : typing.Optional[RequestOptions]
309 Request-specific configuration.
310
311 Returns
312 -------
313 HttpResponse[GetOrganizationConnectionResponseContent]
314 Connection successfully retrieved.
315 """
316 _response = self._client_wrapper.httpx_client.request(
317 f"organizations/{encode_path_param(id)}/enabled_connections/{encode_path_param(connection_id)}",
318 method="GET",
319 request_options=request_options,
320 )
321 try:
322 if 200 <= _response.status_code < 300:
323 _data = typing.cast(
324 GetOrganizationConnectionResponseContent,
325 parse_obj_as(
326 type_=GetOrganizationConnectionResponseContent, # type: ignore
327 object_=_response.json(),
328 ),
329 )
330 return HttpResponse(response=_response, data=_data)
331 if _response.status_code == 401:
332 raise UnauthorizedError(
333 headers=dict(_response.headers),
334 body=typing.cast(
335 typing.Any,
336 parse_obj_as(
337 type_=typing.Any, # type: ignore
338 object_=_response.json(),
339 ),
340 ),
341 )
342 if _response.status_code == 403:
343 raise ForbiddenError(
344 headers=dict(_response.headers),
345 body=typing.cast(
346 typing.Any,
347 parse_obj_as(
348 type_=typing.Any, # type: ignore
349 object_=_response.json(),
350 ),
351 ),
352 )
353 if _response.status_code == 404:
354 raise NotFoundError(
355 headers=dict(_response.headers),
356 body=typing.cast(
357 typing.Any,
358 parse_obj_as(
359 type_=typing.Any, # type: ignore
360 object_=_response.json(),
361 ),
362 ),
363 )
364 if _response.status_code == 429:
365 raise TooManyRequestsError(
366 headers=dict(_response.headers),
367 body=typing.cast(
368 typing.Any,
369 parse_obj_as(
370 type_=typing.Any, # type: ignore
371 object_=_response.json(),
372 ),
373 ),
374 )
375 _response_json = _response.json()
376 except JSONDecodeError:
377 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
378 except ValidationError as e:
379 raise ParsingError(
380 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
381 )
382 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
383
384 def delete(
385 self, id: str, connection_id: str, *, request_options: typing.Optional[RequestOptions] = None
386 ) -> HttpResponse[None]:
387 """
388 Disable a specific connection for an Organization. Once disabled, Organization members can no longer use that connection to authenticate.
389
390 **Note**: This action does not remove the connection from your tenant.
391
392 Parameters
393 ----------
394 id : str
395 Organization identifier.
396
397 connection_id : str
398 Connection identifier.
399
400 request_options : typing.Optional[RequestOptions]
401 Request-specific configuration.
402
403 Returns
404 -------
405 HttpResponse[None]
406 """
407 _response = self._client_wrapper.httpx_client.request(
408 f"organizations/{encode_path_param(id)}/enabled_connections/{encode_path_param(connection_id)}",
409 method="DELETE",
410 request_options=request_options,
411 )
412 try:
413 if 200 <= _response.status_code < 300:
414 return HttpResponse(response=_response, data=None)
415 if _response.status_code == 400:
416 raise BadRequestError(
417 headers=dict(_response.headers),
418 body=typing.cast(
419 typing.Any,
420 parse_obj_as(
421 type_=typing.Any, # type: ignore
422 object_=_response.json(),
423 ),
424 ),
425 )
426 if _response.status_code == 401:
427 raise UnauthorizedError(
428 headers=dict(_response.headers),
429 body=typing.cast(
430 typing.Any,
431 parse_obj_as(
432 type_=typing.Any, # type: ignore
433 object_=_response.json(),
434 ),
435 ),
436 )
437 if _response.status_code == 403:
438 raise ForbiddenError(
439 headers=dict(_response.headers),
440 body=typing.cast(
441 typing.Any,
442 parse_obj_as(
443 type_=typing.Any, # type: ignore
444 object_=_response.json(),
445 ),
446 ),
447 )
448 if _response.status_code == 404:
449 raise NotFoundError(
450 headers=dict(_response.headers),
451 body=typing.cast(
452 typing.Any,
453 parse_obj_as(
454 type_=typing.Any, # type: ignore
455 object_=_response.json(),
456 ),
457 ),
458 )
459 if _response.status_code == 429:
460 raise TooManyRequestsError(
461 headers=dict(_response.headers),
462 body=typing.cast(
463 typing.Any,
464 parse_obj_as(
465 type_=typing.Any, # type: ignore
466 object_=_response.json(),
467 ),
468 ),
469 )
470 _response_json = _response.json()
471 except JSONDecodeError:
472 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
473 except ValidationError as e:
474 raise ParsingError(
475 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
476 )
477 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
478
479 def update(
480 self,
481 id: str,
482 connection_id: str,
483 *,
484 assign_membership_on_login: typing.Optional[bool] = OMIT,
485 is_signup_enabled: typing.Optional[bool] = OMIT,
486 show_as_button: typing.Optional[bool] = OMIT,
487 request_options: typing.Optional[RequestOptions] = None,
488 ) -> HttpResponse[UpdateOrganizationConnectionResponseContent]:
489 """
490 Modify the details of a specific connection currently enabled for an Organization.
491
492 Parameters
493 ----------
494 id : str
495 Organization identifier.
496
497 connection_id : str
498 Connection identifier.
499
500 assign_membership_on_login : typing.Optional[bool]
501 When true, all users that log in with this connection will be automatically granted membership in the organization. When false, users must be granted membership in the organization before logging in with this connection.
502
503 is_signup_enabled : typing.Optional[bool]
504 Determines whether organization signup should be enabled for this organization connection. Only applicable for database connections. Default: false.
505
506 show_as_button : typing.Optional[bool]
507 Determines whether a connection should be displayed on this organization’s login prompt. Only applicable for enterprise connections. Default: true.
508
509 request_options : typing.Optional[RequestOptions]
510 Request-specific configuration.
511
512 Returns
513 -------
514 HttpResponse[UpdateOrganizationConnectionResponseContent]
515 Organization connection successfully updated.
516 """
517 _response = self._client_wrapper.httpx_client.request(
518 f"organizations/{encode_path_param(id)}/enabled_connections/{encode_path_param(connection_id)}",
519 method="PATCH",
520 json={
521 "assign_membership_on_login": assign_membership_on_login,
522 "is_signup_enabled": is_signup_enabled,
523 "show_as_button": show_as_button,
524 },
525 headers={
526 "content-type": "application/json",
527 },
528 request_options=request_options,
529 omit=OMIT,
530 )
531 try:
532 if 200 <= _response.status_code < 300:
533 _data = typing.cast(
534 UpdateOrganizationConnectionResponseContent,
535 parse_obj_as(
536 type_=UpdateOrganizationConnectionResponseContent, # type: ignore
537 object_=_response.json(),
538 ),
539 )
540 return HttpResponse(response=_response, data=_data)
541 if _response.status_code == 400:
542 raise BadRequestError(
543 headers=dict(_response.headers),
544 body=typing.cast(
545 typing.Any,
546 parse_obj_as(
547 type_=typing.Any, # type: ignore
548 object_=_response.json(),
549 ),
550 ),
551 )
552 if _response.status_code == 401:
553 raise UnauthorizedError(
554 headers=dict(_response.headers),
555 body=typing.cast(
556 typing.Any,
557 parse_obj_as(
558 type_=typing.Any, # type: ignore
559 object_=_response.json(),
560 ),
561 ),
562 )
563 if _response.status_code == 403:
564 raise ForbiddenError(
565 headers=dict(_response.headers),
566 body=typing.cast(
567 typing.Any,
568 parse_obj_as(
569 type_=typing.Any, # type: ignore
570 object_=_response.json(),
571 ),
572 ),
573 )
574 if _response.status_code == 404:
575 raise NotFoundError(
576 headers=dict(_response.headers),
577 body=typing.cast(
578 typing.Any,
579 parse_obj_as(
580 type_=typing.Any, # type: ignore
581 object_=_response.json(),
582 ),
583 ),
584 )
585 if _response.status_code == 429:
586 raise TooManyRequestsError(
587 headers=dict(_response.headers),
588 body=typing.cast(
589 typing.Any,
590 parse_obj_as(
591 type_=typing.Any, # type: ignore
592 object_=_response.json(),
593 ),
594 ),
595 )
596 _response_json = _response.json()
597 except JSONDecodeError:
598 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
599 except ValidationError as e:
600 raise ParsingError(
601 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
602 )
603 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
604
605
606 class AsyncRawEnabledConnectionsClient:
607 def __init__(self, *, client_wrapper: AsyncClientWrapper):
608 self._client_wrapper = client_wrapper
609
610 async def list(
611 self,
612 id: str,
613 *,
614 page: typing.Optional[int] = 0,
615 per_page: typing.Optional[int] = 50,
616 include_totals: typing.Optional[bool] = True,
617 request_options: typing.Optional[RequestOptions] = None,
618 ) -> AsyncPager[OrganizationConnection, ListOrganizationConnectionsOffsetPaginatedResponseContent]:
619 """
620 Retrieve details about a specific connection currently enabled for an Organization. Information returned includes details such as connection ID, name, strategy, and whether the connection automatically grants membership upon login.
621
622 Parameters
623 ----------
624 id : str
625 Organization identifier.
626
627 page : typing.Optional[int]
628 Page index of the results to return. First page is 0.
629
630 per_page : typing.Optional[int]
631 Number of results per page. Defaults to 50.
632
633 include_totals : typing.Optional[bool]
634 Return results inside an object that contains the total result count (true) or as a direct array of results (false, default).
635
636 request_options : typing.Optional[RequestOptions]
637 Request-specific configuration.
638
639 Returns
640 -------
641 AsyncPager[OrganizationConnection, ListOrganizationConnectionsOffsetPaginatedResponseContent]
642 Connections successfully retrieved.
643 """
644 page = page if page is not None else 0
645
646 _response = await self._client_wrapper.httpx_client.request(
647 f"organizations/{encode_path_param(id)}/enabled_connections",
648 method="GET",
649 params={
650 "page": page,
651 "per_page": per_page,
652 "include_totals": include_totals,
653 },
654 request_options=request_options,
655 )
656 try:
657 if 200 <= _response.status_code < 300:
658 _parsed_response = typing.cast(
659 ListOrganizationConnectionsOffsetPaginatedResponseContent,
660 parse_obj_as(
661 type_=ListOrganizationConnectionsOffsetPaginatedResponseContent, # type: ignore
662 object_=_response.json(),
663 ),
664 )
665 _items = _parsed_response.enabled_connections
666 _has_next = len(_items or []) > 0
667
668 async def _get_next():
669 return await self.list(
670 id,
671 page=page + 1,
672 per_page=per_page,
673 include_totals=include_totals,
674 request_options=request_options,
675 )
676
677 return AsyncPager(has_next=_has_next, items=_items, get_next=_get_next, response=_parsed_response)
678 if _response.status_code == 400:
679 raise BadRequestError(
680 headers=dict(_response.headers),
681 body=typing.cast(
682 typing.Any,
683 parse_obj_as(
684 type_=typing.Any, # type: ignore
685 object_=_response.json(),
686 ),
687 ),
688 )
689 if _response.status_code == 401:
690 raise UnauthorizedError(
691 headers=dict(_response.headers),
692 body=typing.cast(
693 typing.Any,
694 parse_obj_as(
695 type_=typing.Any, # type: ignore
696 object_=_response.json(),
697 ),
698 ),
699 )
700 if _response.status_code == 403:
701 raise ForbiddenError(
702 headers=dict(_response.headers),
703 body=typing.cast(
704 typing.Any,
705 parse_obj_as(
706 type_=typing.Any, # type: ignore
707 object_=_response.json(),
708 ),
709 ),
710 )
711 if _response.status_code == 404:
712 raise NotFoundError(
713 headers=dict(_response.headers),
714 body=typing.cast(
715 typing.Any,
716 parse_obj_as(
717 type_=typing.Any, # type: ignore
718 object_=_response.json(),
719 ),
720 ),
721 )
722 if _response.status_code == 429:
723 raise TooManyRequestsError(
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 _response_json = _response.json()
734 except JSONDecodeError:
735 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
736 except ValidationError as e:
737 raise ParsingError(
738 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
739 )
740 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
741
742 async def add(
743 self,
744 id: str,
745 *,
746 connection_id: str,
747 assign_membership_on_login: typing.Optional[bool] = OMIT,
748 is_signup_enabled: typing.Optional[bool] = OMIT,
749 show_as_button: typing.Optional[bool] = OMIT,
750 request_options: typing.Optional[RequestOptions] = None,
751 ) -> AsyncHttpResponse[AddOrganizationConnectionResponseContent]:
752 """
753 Enable a specific connection for a given Organization. To enable a connection, it must already exist within your tenant; connections cannot be created through this action.
754
755 [Connections](https://auth0.com/docs/authenticate/identity-providers) represent the relationship between Auth0 and a source of users. Available types of connections include database, enterprise, and social.
756
757 Parameters
758 ----------
759 id : str
760 Organization identifier.
761
762 connection_id : str
763 Single connection ID to add to the organization.
764
765 assign_membership_on_login : typing.Optional[bool]
766 When true, all users that log in with this connection will be automatically granted membership in the organization. When false, users must be granted membership in the organization before logging in with this connection.
767
768 is_signup_enabled : typing.Optional[bool]
769 Determines whether organization signup should be enabled for this organization connection. Only applicable for database connections. Default: false.
770
771 show_as_button : typing.Optional[bool]
772 Determines whether a connection should be displayed on this organization’s login prompt. Only applicable for enterprise connections. Default: true.
773
774 request_options : typing.Optional[RequestOptions]
775 Request-specific configuration.
776
777 Returns
778 -------
779 AsyncHttpResponse[AddOrganizationConnectionResponseContent]
780 Organization connection successfully added.
781 """
782 _response = await self._client_wrapper.httpx_client.request(
783 f"organizations/{encode_path_param(id)}/enabled_connections",
784 method="POST",
785 json={
786 "connection_id": connection_id,
787 "assign_membership_on_login": assign_membership_on_login,
788 "is_signup_enabled": is_signup_enabled,
789 "show_as_button": show_as_button,
790 },
791 headers={
792 "content-type": "application/json",
793 },
794 request_options=request_options,
795 omit=OMIT,
796 )
797 try:
798 if 200 <= _response.status_code < 300:
799 _data = typing.cast(
800 AddOrganizationConnectionResponseContent,
801 parse_obj_as(
802 type_=AddOrganizationConnectionResponseContent, # type: ignore
803 object_=_response.json(),
804 ),
805 )
806 return AsyncHttpResponse(response=_response, data=_data)
807 if _response.status_code == 400:
808 raise BadRequestError(
809 headers=dict(_response.headers),
810 body=typing.cast(
811 typing.Any,
812 parse_obj_as(
813 type_=typing.Any, # type: ignore
814 object_=_response.json(),
815 ),
816 ),
817 )
818 if _response.status_code == 401:
819 raise UnauthorizedError(
820 headers=dict(_response.headers),
821 body=typing.cast(
822 typing.Any,
823 parse_obj_as(
824 type_=typing.Any, # type: ignore
825 object_=_response.json(),
826 ),
827 ),
828 )
829 if _response.status_code == 403:
830 raise ForbiddenError(
831 headers=dict(_response.headers),
832 body=typing.cast(
833 typing.Any,
834 parse_obj_as(
835 type_=typing.Any, # type: ignore
836 object_=_response.json(),
837 ),
838 ),
839 )
840 if _response.status_code == 404:
841 raise NotFoundError(
842 headers=dict(_response.headers),
843 body=typing.cast(
844 typing.Any,
845 parse_obj_as(
846 type_=typing.Any, # type: ignore
847 object_=_response.json(),
848 ),
849 ),
850 )
851 if _response.status_code == 429:
852 raise TooManyRequestsError(
853 headers=dict(_response.headers),
854 body=typing.cast(
855 typing.Any,
856 parse_obj_as(
857 type_=typing.Any, # type: ignore
858 object_=_response.json(),
859 ),
860 ),
861 )
862 _response_json = _response.json()
863 except JSONDecodeError:
864 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
865 except ValidationError as e:
866 raise ParsingError(
867 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
868 )
869 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
870
871 async def get(
872 self, id: str, connection_id: str, *, request_options: typing.Optional[RequestOptions] = None
873 ) -> AsyncHttpResponse[GetOrganizationConnectionResponseContent]:
874 """
875 Retrieve details about a specific connection currently enabled for an Organization. Information returned includes details such as connection ID, name, strategy, and whether the connection automatically grants membership upon login.
876
877 Parameters
878 ----------
879 id : str
880 Organization identifier.
881
882 connection_id : str
883 Connection identifier.
884
885 request_options : typing.Optional[RequestOptions]
886 Request-specific configuration.
887
888 Returns
889 -------
890 AsyncHttpResponse[GetOrganizationConnectionResponseContent]
891 Connection successfully retrieved.
892 """
893 _response = await self._client_wrapper.httpx_client.request(
894 f"organizations/{encode_path_param(id)}/enabled_connections/{encode_path_param(connection_id)}",
895 method="GET",
896 request_options=request_options,
897 )
898 try:
899 if 200 <= _response.status_code < 300:
900 _data = typing.cast(
901 GetOrganizationConnectionResponseContent,
902 parse_obj_as(
903 type_=GetOrganizationConnectionResponseContent, # type: ignore
904 object_=_response.json(),
905 ),
906 )
907 return AsyncHttpResponse(response=_response, data=_data)
908 if _response.status_code == 401:
909 raise UnauthorizedError(
910 headers=dict(_response.headers),
911 body=typing.cast(
912 typing.Any,
913 parse_obj_as(
914 type_=typing.Any, # type: ignore
915 object_=_response.json(),
916 ),
917 ),
918 )
919 if _response.status_code == 403:
920 raise ForbiddenError(
921 headers=dict(_response.headers),
922 body=typing.cast(
923 typing.Any,
924 parse_obj_as(
925 type_=typing.Any, # type: ignore
926 object_=_response.json(),
927 ),
928 ),
929 )
930 if _response.status_code == 404:
931 raise NotFoundError(
932 headers=dict(_response.headers),
933 body=typing.cast(
934 typing.Any,
935 parse_obj_as(
936 type_=typing.Any, # type: ignore
937 object_=_response.json(),
938 ),
939 ),
940 )
941 if _response.status_code == 429:
942 raise TooManyRequestsError(
943 headers=dict(_response.headers),
944 body=typing.cast(
945 typing.Any,
946 parse_obj_as(
947 type_=typing.Any, # type: ignore
948 object_=_response.json(),
949 ),
950 ),
951 )
952 _response_json = _response.json()
953 except JSONDecodeError:
954 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
955 except ValidationError as e:
956 raise ParsingError(
957 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
958 )
959 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
960
961 async def delete(
962 self, id: str, connection_id: str, *, request_options: typing.Optional[RequestOptions] = None
963 ) -> AsyncHttpResponse[None]:
964 """
965 Disable a specific connection for an Organization. Once disabled, Organization members can no longer use that connection to authenticate.
966
967 **Note**: This action does not remove the connection from your tenant.
968
969 Parameters
970 ----------
971 id : str
972 Organization identifier.
973
974 connection_id : str
975 Connection identifier.
976
977 request_options : typing.Optional[RequestOptions]
978 Request-specific configuration.
979
980 Returns
981 -------
982 AsyncHttpResponse[None]
983 """
984 _response = await self._client_wrapper.httpx_client.request(
985 f"organizations/{encode_path_param(id)}/enabled_connections/{encode_path_param(connection_id)}",
986 method="DELETE",
987 request_options=request_options,
988 )
989 try:
990 if 200 <= _response.status_code < 300:
991 return AsyncHttpResponse(response=_response, data=None)
992 if _response.status_code == 400:
993 raise BadRequestError(
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 == 401:
1004 raise UnauthorizedError(
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 == 403:
1015 raise ForbiddenError(
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 if _response.status_code == 404:
1026 raise NotFoundError(
1027 headers=dict(_response.headers),
1028 body=typing.cast(
1029 typing.Any,
1030 parse_obj_as(
1031 type_=typing.Any, # type: ignore
1032 object_=_response.json(),
1033 ),
1034 ),
1035 )
1036 if _response.status_code == 429:
1037 raise TooManyRequestsError(
1038 headers=dict(_response.headers),
1039 body=typing.cast(
1040 typing.Any,
1041 parse_obj_as(
1042 type_=typing.Any, # type: ignore
1043 object_=_response.json(),
1044 ),
1045 ),
1046 )
1047 _response_json = _response.json()
1048 except JSONDecodeError:
1049 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1050 except ValidationError as e:
1051 raise ParsingError(
1052 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
1053 )
1054 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
1055
1056 async def update(
1057 self,
1058 id: str,
1059 connection_id: str,
1060 *,
1061 assign_membership_on_login: typing.Optional[bool] = OMIT,
1062 is_signup_enabled: typing.Optional[bool] = OMIT,
1063 show_as_button: typing.Optional[bool] = OMIT,
1064 request_options: typing.Optional[RequestOptions] = None,
1065 ) -> AsyncHttpResponse[UpdateOrganizationConnectionResponseContent]:
1066 """
1067 Modify the details of a specific connection currently enabled for an Organization.
1068
1069 Parameters
1070 ----------
1071 id : str
1072 Organization identifier.
1073
1074 connection_id : str
1075 Connection identifier.
1076
1077 assign_membership_on_login : typing.Optional[bool]
1078 When true, all users that log in with this connection will be automatically granted membership in the organization. When false, users must be granted membership in the organization before logging in with this connection.
1079
1080 is_signup_enabled : typing.Optional[bool]
1081 Determines whether organization signup should be enabled for this organization connection. Only applicable for database connections. Default: false.
1082
1083 show_as_button : typing.Optional[bool]
1084 Determines whether a connection should be displayed on this organization’s login prompt. Only applicable for enterprise connections. Default: true.
1085
1086 request_options : typing.Optional[RequestOptions]
1087 Request-specific configuration.
1088
1089 Returns
1090 -------
1091 AsyncHttpResponse[UpdateOrganizationConnectionResponseContent]
1092 Organization connection successfully updated.
1093 """
1094 _response = await self._client_wrapper.httpx_client.request(
1095 f"organizations/{encode_path_param(id)}/enabled_connections/{encode_path_param(connection_id)}",
1096 method="PATCH",
1097 json={
1098 "assign_membership_on_login": assign_membership_on_login,
1099 "is_signup_enabled": is_signup_enabled,
1100 "show_as_button": show_as_button,
1101 },
1102 headers={
1103 "content-type": "application/json",
1104 },
1105 request_options=request_options,
1106 omit=OMIT,
1107 )
1108 try:
1109 if 200 <= _response.status_code < 300:
1110 _data = typing.cast(
1111 UpdateOrganizationConnectionResponseContent,
1112 parse_obj_as(
1113 type_=UpdateOrganizationConnectionResponseContent, # type: ignore
1114 object_=_response.json(),
1115 ),
1116 )
1117 return AsyncHttpResponse(response=_response, data=_data)
1118 if _response.status_code == 400:
1119 raise BadRequestError(
1120 headers=dict(_response.headers),
1121 body=typing.cast(
1122 typing.Any,
1123 parse_obj_as(
1124 type_=typing.Any, # type: ignore
1125 object_=_response.json(),
1126 ),
1127 ),
1128 )
1129 if _response.status_code == 401:
1130 raise UnauthorizedError(
1131 headers=dict(_response.headers),
1132 body=typing.cast(
1133 typing.Any,
1134 parse_obj_as(
1135 type_=typing.Any, # type: ignore
1136 object_=_response.json(),
1137 ),
1138 ),
1139 )
1140 if _response.status_code == 403:
1141 raise ForbiddenError(
1142 headers=dict(_response.headers),
1143 body=typing.cast(
1144 typing.Any,
1145 parse_obj_as(
1146 type_=typing.Any, # type: ignore
1147 object_=_response.json(),
1148 ),
1149 ),
1150 )
1151 if _response.status_code == 404:
1152 raise NotFoundError(
1153 headers=dict(_response.headers),
1154 body=typing.cast(
1155 typing.Any,
1156 parse_obj_as(
1157 type_=typing.Any, # type: ignore
1158 object_=_response.json(),
1159 ),
1160 ),
1161 )
1162 if _response.status_code == 429:
1163 raise TooManyRequestsError(
1164 headers=dict(_response.headers),
1165 body=typing.cast(
1166 typing.Any,
1167 parse_obj_as(
1168 type_=typing.Any, # type: ignore
1169 object_=_response.json(),
1170 ),
1171 ),
1172 )
1173 _response_json = _response.json()
1174 except JSONDecodeError:
1175 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
1176 except ValidationError as e:
1177 raise ParsingError(
1178 status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
1179 )
1180 raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)