# 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.list_user_organizations_offset_paginated_response_content import ( ListUserOrganizationsOffsetPaginatedResponseContent, ) from ...types.organization import Organization from .raw_client import AsyncRawOrganizationsClient, RawOrganizationsClient class OrganizationsClient: def __init__(self, *, client_wrapper: SyncClientWrapper): self._raw_client = RawOrganizationsClient(client_wrapper=client_wrapper) @property def with_raw_response(self) -> RawOrganizationsClient: """ Retrieves a raw implementation of this client that returns raw responses. Returns ------- RawOrganizationsClient """ 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, request_options: typing.Optional[RequestOptions] = None, ) -> SyncPager[Organization, ListUserOrganizationsOffsetPaginatedResponseContent]: """ Retrieve list of the specified user's current Organization memberships. User must be specified by user ID. For more information, review [Auth0 Organizations](https://auth0.com/docs/manage-users/organizations). Parameters ---------- id : str ID of the user to retrieve the organizations for. 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). request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- SyncPager[Organization, ListUserOrganizationsOffsetPaginatedResponseContent] Organizations successfully retrieved. Examples -------- from auth0 import Auth0 client = Auth0( token="YOUR_TOKEN", ) response = client.users.organizations.list( id="id", page=1, per_page=1, include_totals=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, request_options=request_options ) class AsyncOrganizationsClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): self._raw_client = AsyncRawOrganizationsClient(client_wrapper=client_wrapper) @property def with_raw_response(self) -> AsyncRawOrganizationsClient: """ Retrieves a raw implementation of this client that returns raw responses. Returns ------- AsyncRawOrganizationsClient """ 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, request_options: typing.Optional[RequestOptions] = None, ) -> AsyncPager[Organization, ListUserOrganizationsOffsetPaginatedResponseContent]: """ Retrieve list of the specified user's current Organization memberships. User must be specified by user ID. For more information, review [Auth0 Organizations](https://auth0.com/docs/manage-users/organizations). Parameters ---------- id : str ID of the user to retrieve the organizations for. 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). request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- AsyncPager[Organization, ListUserOrganizationsOffsetPaginatedResponseContent] Organizations successfully retrieved. Examples -------- import asyncio from auth0 import AsyncAuth0 client = AsyncAuth0( token="YOUR_TOKEN", ) async def main() -> None: response = await client.users.organizations.list( id="id", page=1, per_page=1, include_totals=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, request_options=request_options )