# 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_user_effective_permissions_response_content import ListUserEffectivePermissionsResponseContent from ...types.user_effective_permission_response_content import UserEffectivePermissionResponseContent from .raw_client import AsyncRawEffectivePermissionsClient, RawEffectivePermissionsClient if typing.TYPE_CHECKING: from .sources.client import AsyncSourcesClient, SourcesClient class EffectivePermissionsClient: def __init__(self, *, client_wrapper: SyncClientWrapper): self._raw_client = RawEffectivePermissionsClient(client_wrapper=client_wrapper) self._client_wrapper = client_wrapper self._sources: typing.Optional[SourcesClient] = None @property def with_raw_response(self) -> RawEffectivePermissionsClient: """ Retrieves a raw implementation of this client that returns raw responses. Returns ------- RawEffectivePermissionsClient """ return self._raw_client def list( self, id: str, *, resource_server_identifier: str, from_: typing.Optional[str] = None, take: typing.Optional[int] = 50, request_options: typing.Optional[RequestOptions] = None, ) -> SyncPager[UserEffectivePermissionResponseContent, ListUserEffectivePermissionsResponseContent]: """ Returns the list of effective permissions for a user, taking into account permissions granted directly to the user, as well as those inherited through roles and group memberships. Parameters ---------- id : str ID of the user to retrieve the permissions for. resource_server_identifier : str The identifier of the resource server for which to calculate user permissions. 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[UserEffectivePermissionResponseContent, ListUserEffectivePermissionsResponseContent] User's effective permissions successfully retrieved. Examples -------- from auth0 import Auth0 client = Auth0( token="YOUR_TOKEN", ) response = client.users.effective_permissions.list( id="id", from_="from", take=1, resource_server_identifier="resource_server_identifier", ) 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, resource_server_identifier=resource_server_identifier, from_=from_, take=take, request_options=request_options, ) @property def sources(self): if self._sources is None: from .sources.client import SourcesClient # noqa: E402 self._sources = SourcesClient(client_wrapper=self._client_wrapper) return self._sources class AsyncEffectivePermissionsClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): self._raw_client = AsyncRawEffectivePermissionsClient(client_wrapper=client_wrapper) self._client_wrapper = client_wrapper self._sources: typing.Optional[AsyncSourcesClient] = None @property def with_raw_response(self) -> AsyncRawEffectivePermissionsClient: """ Retrieves a raw implementation of this client that returns raw responses. Returns ------- AsyncRawEffectivePermissionsClient """ return self._raw_client async def list( self, id: str, *, resource_server_identifier: str, from_: typing.Optional[str] = None, take: typing.Optional[int] = 50, request_options: typing.Optional[RequestOptions] = None, ) -> AsyncPager[UserEffectivePermissionResponseContent, ListUserEffectivePermissionsResponseContent]: """ Returns the list of effective permissions for a user, taking into account permissions granted directly to the user, as well as those inherited through roles and group memberships. Parameters ---------- id : str ID of the user to retrieve the permissions for. resource_server_identifier : str The identifier of the resource server for which to calculate user permissions. 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[UserEffectivePermissionResponseContent, ListUserEffectivePermissionsResponseContent] User's effective permissions successfully retrieved. Examples -------- import asyncio from auth0 import AsyncAuth0 client = AsyncAuth0( token="YOUR_TOKEN", ) async def main() -> None: response = await client.users.effective_permissions.list( id="id", from_="from", take=1, resource_server_identifier="resource_server_identifier", ) 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, resource_server_identifier=resource_server_identifier, from_=from_, take=take, request_options=request_options, ) @property def sources(self): if self._sources is None: from .sources.client import AsyncSourcesClient # noqa: E402 self._sources = AsyncSourcesClient(client_wrapper=self._client_wrapper) return self._sources