# 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.get_user_groups_paginated_response_content import GetUserGroupsPaginatedResponseContent from ...types.user_groups_response_schema import UserGroupsResponseSchema from .raw_client import AsyncRawGroupsClient, RawGroupsClient class GroupsClient: def __init__(self, *, client_wrapper: SyncClientWrapper): self._raw_client = RawGroupsClient(client_wrapper=client_wrapper) @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 get( self, id: str, *, fields: typing.Optional[str] = None, include_fields: typing.Optional[bool] = None, from_: typing.Optional[str] = None, take: typing.Optional[int] = 50, request_options: typing.Optional[RequestOptions] = None, ) -> SyncPager[UserGroupsResponseSchema, GetUserGroupsPaginatedResponseContent]: """ List all groups to which this user belongs. Parameters ---------- id : str ID of the user to list groups for. fields : typing.Optional[str] A comma separated list of fields to include or exclude (depending on include_fields) from the result, empty to retrieve all fields include_fields : typing.Optional[bool] Whether specified fields are to be included (true) or excluded (false). 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[UserGroupsResponseSchema, GetUserGroupsPaginatedResponseContent] Groups successfully retrieved. Examples -------- from auth0 import Auth0 client = Auth0( token="YOUR_TOKEN", ) response = client.users.groups.get( id="id", fields="fields", include_fields=True, 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.get( id, fields=fields, include_fields=include_fields, from_=from_, take=take, request_options=request_options ) class AsyncGroupsClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): self._raw_client = AsyncRawGroupsClient(client_wrapper=client_wrapper) @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 get( self, id: str, *, fields: typing.Optional[str] = None, include_fields: typing.Optional[bool] = None, from_: typing.Optional[str] = None, take: typing.Optional[int] = 50, request_options: typing.Optional[RequestOptions] = None, ) -> AsyncPager[UserGroupsResponseSchema, GetUserGroupsPaginatedResponseContent]: """ List all groups to which this user belongs. Parameters ---------- id : str ID of the user to list groups for. fields : typing.Optional[str] A comma separated list of fields to include or exclude (depending on include_fields) from the result, empty to retrieve all fields include_fields : typing.Optional[bool] Whether specified fields are to be included (true) or excluded (false). 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[UserGroupsResponseSchema, GetUserGroupsPaginatedResponseContent] Groups successfully retrieved. Examples -------- import asyncio from auth0 import AsyncAuth0 client = AsyncAuth0( token="YOUR_TOKEN", ) async def main() -> None: response = await client.users.groups.get( id="id", fields="fields", include_fields=True, 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.get( id, fields=fields, include_fields=include_fields, from_=from_, take=take, request_options=request_options )