# 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.group import Group from ...types.list_organization_groups_response_content import ListOrganizationGroupsResponseContent from .raw_client import AsyncRawGroupsClient, RawGroupsClient if typing.TYPE_CHECKING: from .roles.client import AsyncRolesClient, RolesClient class GroupsClient: def __init__(self, *, client_wrapper: SyncClientWrapper): self._raw_client = RawGroupsClient(client_wrapper=client_wrapper) self._client_wrapper = client_wrapper self._roles: typing.Optional[RolesClient] = None @property def with_raw_response(self) -> RawGroupsClient: """ Retrieves a raw implementation of this client that returns raw responses. Returns ------- RawGroupsClient """ return self._raw_client def list( self, organization_id: str, *, from_: typing.Optional[str] = None, take: typing.Optional[int] = 50, request_options: typing.Optional[RequestOptions] = None, ) -> SyncPager[Group, ListOrganizationGroupsResponseContent]: """ Lists the groups that are assigned to the specified organization. Parameters ---------- organization_id : str ID of the organization from_ : typing.Optional[str] Optional Id from which to start selection. take : typing.Optional[int] Number of results per page. Defaults to 50. request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- SyncPager[Group, ListOrganizationGroupsResponseContent] Organization groups successfully retrieved. Examples -------- from auth0 import Auth0 client = Auth0( token="YOUR_TOKEN", ) response = client.organizations.groups.list( organization_id="organization_id", from_="from", take=1, ) 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(organization_id, from_=from_, take=take, request_options=request_options) @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 AsyncGroupsClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): self._raw_client = AsyncRawGroupsClient(client_wrapper=client_wrapper) self._client_wrapper = client_wrapper self._roles: typing.Optional[AsyncRolesClient] = None @property def with_raw_response(self) -> AsyncRawGroupsClient: """ Retrieves a raw implementation of this client that returns raw responses. Returns ------- AsyncRawGroupsClient """ return self._raw_client async def list( self, organization_id: str, *, from_: typing.Optional[str] = None, take: typing.Optional[int] = 50, request_options: typing.Optional[RequestOptions] = None, ) -> AsyncPager[Group, ListOrganizationGroupsResponseContent]: """ Lists the groups that are assigned to the specified organization. Parameters ---------- organization_id : str ID of the organization from_ : typing.Optional[str] Optional Id from which to start selection. take : typing.Optional[int] Number of results per page. Defaults to 50. request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- AsyncPager[Group, ListOrganizationGroupsResponseContent] Organization groups successfully retrieved. Examples -------- import asyncio from auth0 import AsyncAuth0 client = AsyncAuth0( token="YOUR_TOKEN", ) async def main() -> None: response = await client.organizations.groups.list( organization_id="organization_id", from_="from", take=1, ) 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(organization_id, from_=from_, take=take, request_options=request_options) @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