# This file was auto-generated by Fern from our API Definition. from __future__ import annotations import typing from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ...core.pagination import AsyncPager, SyncPager from ...core.request_options import RequestOptions from ...types.list_organization_members_paginated_response_content import ( ListOrganizationMembersPaginatedResponseContent, ) from ...types.organization_member import OrganizationMember from .raw_client import AsyncRawMembersClient, RawMembersClient if typing.TYPE_CHECKING: from .effective_roles.client import AsyncEffectiveRolesClient, EffectiveRolesClient from .roles.client import AsyncRolesClient, RolesClient # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) class MembersClient: def __init__(self, *, client_wrapper: SyncClientWrapper): self._raw_client = RawMembersClient(client_wrapper=client_wrapper) self._client_wrapper = client_wrapper self._effective_roles: typing.Optional[EffectiveRolesClient] = None self._roles: typing.Optional[RolesClient] = None @property def with_raw_response(self) -> RawMembersClient: """ Retrieves a raw implementation of this client that returns raw responses. Returns ------- RawMembersClient """ return self._raw_client def list( self, id: str, *, from_: typing.Optional[str] = None, take: typing.Optional[int] = 50, fields: typing.Optional[str] = None, include_fields: typing.Optional[bool] = None, request_options: typing.Optional[RequestOptions] = None, ) -> SyncPager[OrganizationMember, ListOrganizationMembersPaginatedResponseContent]: """ List organization members. This endpoint is subject to eventual consistency. New users may not be immediately included in the response and deleted users may not be immediately removed from it. - Use the `fields` parameter to optionally define the specific member details retrieved. If `fields` is left blank, all fields (except roles) are returned. - Member roles are not sent by default. Use `fields=roles` to retrieve the roles assigned to each listed member. To use this parameter, you must include the `read:organization_member_roles` scope in the token. This endpoint supports two types of pagination: - Offset pagination - Checkpoint pagination Checkpoint pagination must be used if you need to retrieve more than 1000 organization members. **Checkpoint Pagination** To search by checkpoint, use the following parameters: - from: Optional id from which to start selection. - take: The total amount of entries to retrieve when using the from parameter. Defaults to 50. Note: The first time you call this endpoint using Checkpoint Pagination, you should omit the `from` parameter. If there are more results, a `next` value will be included in the response. You can use this for subsequent API calls. When `next` is no longer included in the response, this indicates there are no more pages remaining. Parameters ---------- id : str Organization identifier. from_ : typing.Optional[str] Optional Id from which to start selection. take : typing.Optional[int] Number of results per page. Defaults to 50. fields : typing.Optional[str] Comma-separated list of fields to include or exclude (based on value provided for include_fields) in the result. Leave empty to retrieve all fields. include_fields : typing.Optional[bool] Whether specified fields are to be included (true) or excluded (false). request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- SyncPager[OrganizationMember, ListOrganizationMembersPaginatedResponseContent] Members successfully retrieved. Examples -------- from auth0 import Auth0 client = Auth0( token="YOUR_TOKEN", ) response = client.organizations.members.list( id="id", from_="from", take=1, fields="fields", include_fields=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, from_=from_, take=take, fields=fields, include_fields=include_fields, request_options=request_options ) def create( self, id: str, *, members: typing.Sequence[str], request_options: typing.Optional[RequestOptions] = None ) -> None: """ Set one or more existing users as members of a specific [Organization](https://auth0.com/docs/manage-users/organizations). To add a user to an Organization through this action, the user must already exist in your tenant. If a user does not yet exist, you can [invite them to create an account](https://auth0.com/docs/manage-users/organizations/configure-organizations/invite-members), manually create them through the Auth0 Dashboard, or use the Management API. Parameters ---------- id : str Organization identifier. members : typing.Sequence[str] List of user IDs to add to the organization as members. request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- None Examples -------- from auth0 import Auth0 client = Auth0( token="YOUR_TOKEN", ) client.organizations.members.create( id="id", members=["members"], ) """ _response = self._raw_client.create(id, members=members, request_options=request_options) return _response.data def delete( self, id: str, *, members: typing.Sequence[str], request_options: typing.Optional[RequestOptions] = None ) -> None: """ Parameters ---------- id : str Organization identifier. members : typing.Sequence[str] List of user IDs to remove from the organization. request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- None Examples -------- from auth0 import Auth0 client = Auth0( token="YOUR_TOKEN", ) client.organizations.members.delete( id="id", members=["members"], ) """ _response = self._raw_client.delete(id, members=members, request_options=request_options) return _response.data @property def effective_roles(self): if self._effective_roles is None: from .effective_roles.client import EffectiveRolesClient # noqa: E402 self._effective_roles = EffectiveRolesClient(client_wrapper=self._client_wrapper) return self._effective_roles @property def roles(self): if self._roles is None: from .roles.client import RolesClient # noqa: E402 self._roles = RolesClient(client_wrapper=self._client_wrapper) return self._roles class AsyncMembersClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): self._raw_client = AsyncRawMembersClient(client_wrapper=client_wrapper) self._client_wrapper = client_wrapper self._effective_roles: typing.Optional[AsyncEffectiveRolesClient] = None self._roles: typing.Optional[AsyncRolesClient] = None @property def with_raw_response(self) -> AsyncRawMembersClient: """ Retrieves a raw implementation of this client that returns raw responses. Returns ------- AsyncRawMembersClient """ return self._raw_client async def list( self, id: str, *, from_: typing.Optional[str] = None, take: typing.Optional[int] = 50, fields: typing.Optional[str] = None, include_fields: typing.Optional[bool] = None, request_options: typing.Optional[RequestOptions] = None, ) -> AsyncPager[OrganizationMember, ListOrganizationMembersPaginatedResponseContent]: """ List organization members. This endpoint is subject to eventual consistency. New users may not be immediately included in the response and deleted users may not be immediately removed from it. - Use the `fields` parameter to optionally define the specific member details retrieved. If `fields` is left blank, all fields (except roles) are returned. - Member roles are not sent by default. Use `fields=roles` to retrieve the roles assigned to each listed member. To use this parameter, you must include the `read:organization_member_roles` scope in the token. This endpoint supports two types of pagination: - Offset pagination - Checkpoint pagination Checkpoint pagination must be used if you need to retrieve more than 1000 organization members. **Checkpoint Pagination** To search by checkpoint, use the following parameters: - from: Optional id from which to start selection. - take: The total amount of entries to retrieve when using the from parameter. Defaults to 50. Note: The first time you call this endpoint using Checkpoint Pagination, you should omit the `from` parameter. If there are more results, a `next` value will be included in the response. You can use this for subsequent API calls. When `next` is no longer included in the response, this indicates there are no more pages remaining. Parameters ---------- id : str Organization identifier. from_ : typing.Optional[str] Optional Id from which to start selection. take : typing.Optional[int] Number of results per page. Defaults to 50. fields : typing.Optional[str] Comma-separated list of fields to include or exclude (based on value provided for include_fields) in the result. Leave empty to retrieve all fields. include_fields : typing.Optional[bool] Whether specified fields are to be included (true) or excluded (false). request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- AsyncPager[OrganizationMember, ListOrganizationMembersPaginatedResponseContent] Members successfully retrieved. Examples -------- import asyncio from auth0 import AsyncAuth0 client = AsyncAuth0( token="YOUR_TOKEN", ) async def main() -> None: response = await client.organizations.members.list( id="id", from_="from", take=1, fields="fields", include_fields=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, from_=from_, take=take, fields=fields, include_fields=include_fields, request_options=request_options ) async def create( self, id: str, *, members: typing.Sequence[str], request_options: typing.Optional[RequestOptions] = None ) -> None: """ Set one or more existing users as members of a specific [Organization](https://auth0.com/docs/manage-users/organizations). To add a user to an Organization through this action, the user must already exist in your tenant. If a user does not yet exist, you can [invite them to create an account](https://auth0.com/docs/manage-users/organizations/configure-organizations/invite-members), manually create them through the Auth0 Dashboard, or use the Management API. Parameters ---------- id : str Organization identifier. members : typing.Sequence[str] List of user IDs to add to the organization as members. 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.members.create( id="id", members=["members"], ) asyncio.run(main()) """ _response = await self._raw_client.create(id, members=members, request_options=request_options) return _response.data async def delete( self, id: str, *, members: typing.Sequence[str], request_options: typing.Optional[RequestOptions] = None ) -> None: """ Parameters ---------- id : str Organization identifier. members : typing.Sequence[str] List of user IDs to remove from the organization. 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.members.delete( id="id", members=["members"], ) asyncio.run(main()) """ _response = await self._raw_client.delete(id, members=members, request_options=request_options) return _response.data @property def effective_roles(self): if self._effective_roles is None: from .effective_roles.client import AsyncEffectiveRolesClient # noqa: E402 self._effective_roles = AsyncEffectiveRolesClient(client_wrapper=self._client_wrapper) return self._effective_roles @property def roles(self): if self._roles is None: from .roles.client import AsyncRolesClient # noqa: E402 self._roles = AsyncRolesClient(client_wrapper=self._client_wrapper) return self._roles