Debian Codegraph @

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