# This file was auto-generated by Fern from our API Definition. import typing from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ...core.pagination import AsyncPager, SyncPager from ...core.request_options import RequestOptions from ...types.create_organization_all_connection_response_content import CreateOrganizationAllConnectionResponseContent from ...types.get_organization_all_connection_response_content import GetOrganizationAllConnectionResponseContent from ...types.list_organization_all_connections_offset_paginated_response_content import ( ListOrganizationAllConnectionsOffsetPaginatedResponseContent, ) from ...types.organization_access_level_enum import OrganizationAccessLevelEnum from ...types.organization_access_level_enum_with_null import OrganizationAccessLevelEnumWithNull from ...types.organization_all_connection_post import OrganizationAllConnectionPost from ...types.update_organization_all_connection_response_content import UpdateOrganizationAllConnectionResponseContent from .raw_client import AsyncRawConnectionsClient, RawConnectionsClient # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) class ConnectionsClient: def __init__(self, *, client_wrapper: SyncClientWrapper): self._raw_client = RawConnectionsClient(client_wrapper=client_wrapper) @property def with_raw_response(self) -> RawConnectionsClient: """ Retrieves a raw implementation of this client that returns raw responses. Returns ------- RawConnectionsClient """ return self._raw_client def list( self, id: str, *, page: typing.Optional[int] = 0, per_page: typing.Optional[int] = 50, include_totals: typing.Optional[bool] = True, is_enabled: typing.Optional[bool] = None, request_options: typing.Optional[RequestOptions] = None, ) -> SyncPager[OrganizationAllConnectionPost, ListOrganizationAllConnectionsOffsetPaginatedResponseContent]: """ Parameters ---------- id : str Organization identifier. page : typing.Optional[int] Page index of the results to return. First page is 0. per_page : typing.Optional[int] Number of results per page. Defaults to 50. include_totals : typing.Optional[bool] Return results inside an object that contains the total result count (true) or as a direct array of results (false, default). is_enabled : typing.Optional[bool] Filter connections by enabled status. request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- SyncPager[OrganizationAllConnectionPost, ListOrganizationAllConnectionsOffsetPaginatedResponseContent] Connections successfully retrieved. Examples -------- from auth0 import Auth0 client = Auth0( token="YOUR_TOKEN", ) response = client.organizations.connections.list( id="id", page=1, per_page=1, include_totals=True, is_enabled=True, ) for item in response: yield item # alternatively, you can paginate page-by-page for page in response.iter_pages(): yield page """ return self._raw_client.list( id, page=page, per_page=per_page, include_totals=include_totals, is_enabled=is_enabled, request_options=request_options, ) def create( self, id: str, *, connection_id: str, organization_connection_name: typing.Optional[str] = OMIT, assign_membership_on_login: typing.Optional[bool] = OMIT, show_as_button: typing.Optional[bool] = OMIT, is_signup_enabled: typing.Optional[bool] = OMIT, organization_access_level: typing.Optional[OrganizationAccessLevelEnum] = OMIT, is_enabled: typing.Optional[bool] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> CreateOrganizationAllConnectionResponseContent: """ Parameters ---------- id : str Organization identifier. connection_id : str Connection identifier. organization_connection_name : typing.Optional[str] Name of the connection in the scope of this organization. assign_membership_on_login : typing.Optional[bool] 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. show_as_button : typing.Optional[bool] Determines whether a connection should be displayed on this organization’s login prompt. Only applicable for enterprise connections. Default: true. is_signup_enabled : typing.Optional[bool] Determines whether organization signup should be enabled for this organization connection. Only applicable for database connections. Default: false. organization_access_level : typing.Optional[OrganizationAccessLevelEnum] is_enabled : typing.Optional[bool] Whether the connection is enabled for the organization. request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- CreateOrganizationAllConnectionResponseContent Connection successfully created. Examples -------- from auth0 import Auth0 client = Auth0( token="YOUR_TOKEN", ) client.organizations.connections.create( id="id", connection_id="connection_id", ) """ _response = self._raw_client.create( id, connection_id=connection_id, organization_connection_name=organization_connection_name, assign_membership_on_login=assign_membership_on_login, show_as_button=show_as_button, is_signup_enabled=is_signup_enabled, organization_access_level=organization_access_level, is_enabled=is_enabled, request_options=request_options, ) return _response.data def get( self, id: str, connection_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> GetOrganizationAllConnectionResponseContent: """ Parameters ---------- id : str Organization identifier. connection_id : str Connection identifier. request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- GetOrganizationAllConnectionResponseContent Connection successfully retrieved. Examples -------- from auth0 import Auth0 client = Auth0( token="YOUR_TOKEN", ) client.organizations.connections.get( id="id", connection_id="connection_id", ) """ _response = self._raw_client.get(id, connection_id, request_options=request_options) return _response.data def delete(self, id: str, connection_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None: """ Parameters ---------- id : str Organization identifier. connection_id : str Connection identifier. request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- None Examples -------- from auth0 import Auth0 client = Auth0( token="YOUR_TOKEN", ) client.organizations.connections.delete( id="id", connection_id="connection_id", ) """ _response = self._raw_client.delete(id, connection_id, request_options=request_options) return _response.data def update( self, id: str, connection_id: str, *, organization_connection_name: typing.Optional[str] = OMIT, assign_membership_on_login: typing.Optional[bool] = OMIT, show_as_button: typing.Optional[bool] = OMIT, is_signup_enabled: typing.Optional[bool] = OMIT, organization_access_level: typing.Optional[OrganizationAccessLevelEnumWithNull] = OMIT, is_enabled: typing.Optional[bool] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> UpdateOrganizationAllConnectionResponseContent: """ Parameters ---------- id : str Organization identifier. connection_id : str Connection identifier. organization_connection_name : typing.Optional[str] Name of the connection in the scope of this organization. assign_membership_on_login : typing.Optional[bool] 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. show_as_button : typing.Optional[bool] Determines whether a connection should be displayed on this organization’s login prompt. Only applicable for enterprise connections. Default: true. is_signup_enabled : typing.Optional[bool] Determines whether organization signup should be enabled for this organization connection. Only applicable for database connections. Default: false. organization_access_level : typing.Optional[OrganizationAccessLevelEnumWithNull] is_enabled : typing.Optional[bool] Whether the connection is enabled for the organization. request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- UpdateOrganizationAllConnectionResponseContent Connection successfully updated. Examples -------- from auth0 import Auth0 client = Auth0( token="YOUR_TOKEN", ) client.organizations.connections.update( id="id", connection_id="connection_id", ) """ _response = self._raw_client.update( id, connection_id, organization_connection_name=organization_connection_name, assign_membership_on_login=assign_membership_on_login, show_as_button=show_as_button, is_signup_enabled=is_signup_enabled, organization_access_level=organization_access_level, is_enabled=is_enabled, request_options=request_options, ) return _response.data class AsyncConnectionsClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): self._raw_client = AsyncRawConnectionsClient(client_wrapper=client_wrapper) @property def with_raw_response(self) -> AsyncRawConnectionsClient: """ Retrieves a raw implementation of this client that returns raw responses. Returns ------- AsyncRawConnectionsClient """ return self._raw_client async def list( self, id: str, *, page: typing.Optional[int] = 0, per_page: typing.Optional[int] = 50, include_totals: typing.Optional[bool] = True, is_enabled: typing.Optional[bool] = None, request_options: typing.Optional[RequestOptions] = None, ) -> AsyncPager[OrganizationAllConnectionPost, ListOrganizationAllConnectionsOffsetPaginatedResponseContent]: """ Parameters ---------- id : str Organization identifier. page : typing.Optional[int] Page index of the results to return. First page is 0. per_page : typing.Optional[int] Number of results per page. Defaults to 50. include_totals : typing.Optional[bool] Return results inside an object that contains the total result count (true) or as a direct array of results (false, default). is_enabled : typing.Optional[bool] Filter connections by enabled status. request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- AsyncPager[OrganizationAllConnectionPost, ListOrganizationAllConnectionsOffsetPaginatedResponseContent] Connections successfully retrieved. Examples -------- import asyncio from auth0 import AsyncAuth0 client = AsyncAuth0( token="YOUR_TOKEN", ) async def main() -> None: response = await client.organizations.connections.list( id="id", page=1, per_page=1, include_totals=True, is_enabled=True, ) async for item in response: yield item # alternatively, you can paginate page-by-page async for page in response.iter_pages(): yield page asyncio.run(main()) """ return await self._raw_client.list( id, page=page, per_page=per_page, include_totals=include_totals, is_enabled=is_enabled, request_options=request_options, ) async def create( self, id: str, *, connection_id: str, organization_connection_name: typing.Optional[str] = OMIT, assign_membership_on_login: typing.Optional[bool] = OMIT, show_as_button: typing.Optional[bool] = OMIT, is_signup_enabled: typing.Optional[bool] = OMIT, organization_access_level: typing.Optional[OrganizationAccessLevelEnum] = OMIT, is_enabled: typing.Optional[bool] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> CreateOrganizationAllConnectionResponseContent: """ Parameters ---------- id : str Organization identifier. connection_id : str Connection identifier. organization_connection_name : typing.Optional[str] Name of the connection in the scope of this organization. assign_membership_on_login : typing.Optional[bool] 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. show_as_button : typing.Optional[bool] Determines whether a connection should be displayed on this organization’s login prompt. Only applicable for enterprise connections. Default: true. is_signup_enabled : typing.Optional[bool] Determines whether organization signup should be enabled for this organization connection. Only applicable for database connections. Default: false. organization_access_level : typing.Optional[OrganizationAccessLevelEnum] is_enabled : typing.Optional[bool] Whether the connection is enabled for the organization. request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- CreateOrganizationAllConnectionResponseContent Connection successfully created. Examples -------- import asyncio from auth0 import AsyncAuth0 client = AsyncAuth0( token="YOUR_TOKEN", ) async def main() -> None: await client.organizations.connections.create( id="id", connection_id="connection_id", ) asyncio.run(main()) """ _response = await self._raw_client.create( id, connection_id=connection_id, organization_connection_name=organization_connection_name, assign_membership_on_login=assign_membership_on_login, show_as_button=show_as_button, is_signup_enabled=is_signup_enabled, organization_access_level=organization_access_level, is_enabled=is_enabled, request_options=request_options, ) return _response.data async def get( self, id: str, connection_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> GetOrganizationAllConnectionResponseContent: """ Parameters ---------- id : str Organization identifier. connection_id : str Connection identifier. request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- GetOrganizationAllConnectionResponseContent Connection successfully retrieved. Examples -------- import asyncio from auth0 import AsyncAuth0 client = AsyncAuth0( token="YOUR_TOKEN", ) async def main() -> None: await client.organizations.connections.get( id="id", connection_id="connection_id", ) asyncio.run(main()) """ _response = await self._raw_client.get(id, connection_id, request_options=request_options) return _response.data async def delete( self, id: str, connection_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> None: """ Parameters ---------- id : str Organization identifier. connection_id : str Connection identifier. request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- None Examples -------- import asyncio from auth0 import AsyncAuth0 client = AsyncAuth0( token="YOUR_TOKEN", ) async def main() -> None: await client.organizations.connections.delete( id="id", connection_id="connection_id", ) asyncio.run(main()) """ _response = await self._raw_client.delete(id, connection_id, request_options=request_options) return _response.data async def update( self, id: str, connection_id: str, *, organization_connection_name: typing.Optional[str] = OMIT, assign_membership_on_login: typing.Optional[bool] = OMIT, show_as_button: typing.Optional[bool] = OMIT, is_signup_enabled: typing.Optional[bool] = OMIT, organization_access_level: typing.Optional[OrganizationAccessLevelEnumWithNull] = OMIT, is_enabled: typing.Optional[bool] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> UpdateOrganizationAllConnectionResponseContent: """ Parameters ---------- id : str Organization identifier. connection_id : str Connection identifier. organization_connection_name : typing.Optional[str] Name of the connection in the scope of this organization. assign_membership_on_login : typing.Optional[bool] 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. show_as_button : typing.Optional[bool] Determines whether a connection should be displayed on this organization’s login prompt. Only applicable for enterprise connections. Default: true. is_signup_enabled : typing.Optional[bool] Determines whether organization signup should be enabled for this organization connection. Only applicable for database connections. Default: false. organization_access_level : typing.Optional[OrganizationAccessLevelEnumWithNull] is_enabled : typing.Optional[bool] Whether the connection is enabled for the organization. request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- UpdateOrganizationAllConnectionResponseContent Connection successfully updated. Examples -------- import asyncio from auth0 import AsyncAuth0 client = AsyncAuth0( token="YOUR_TOKEN", ) async def main() -> None: await client.organizations.connections.update( id="id", connection_id="connection_id", ) asyncio.run(main()) """ _response = await self._raw_client.update( id, connection_id, organization_connection_name=organization_connection_name, assign_membership_on_login=assign_membership_on_login, show_as_button=show_as_button, is_signup_enabled=is_signup_enabled, organization_access_level=organization_access_level, is_enabled=is_enabled, request_options=request_options, ) return _response.data