| 1 |
|
| 2 |
|
| 3 |
from __future__ import annotations |
| 4 |
|
| 5 |
import typing |
| 6 |
|
| 7 |
from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper |
| 8 |
from ...core.pagination import AsyncPager, SyncPager |
| 9 |
from ...core.request_options import RequestOptions |
| 10 |
from ...types.list_user_effective_roles_response_content import ListUserEffectiveRolesResponseContent |
| 11 |
from ...types.user_effective_role import UserEffectiveRole |
| 12 |
from .raw_client import AsyncRawEffectiveRolesClient, RawEffectiveRolesClient |
| 13 |
|
| 14 |
if typing.TYPE_CHECKING: |
| 15 |
from .sources.client import AsyncSourcesClient, SourcesClient |
| 16 |
|
| 17 |
|
| 18 |
class EffectiveRolesClient: |
| 19 |
def __init__(self, *, client_wrapper: SyncClientWrapper): |
| 20 |
self._raw_client = RawEffectiveRolesClient(client_wrapper=client_wrapper) |
| 21 |
self._client_wrapper = client_wrapper |
| 22 |
self._sources: typing.Optional[SourcesClient] = None |
| 23 |
|
| 24 |
@property |
| 25 |
def with_raw_response(self) -> RawEffectiveRolesClient: |
| 26 |
""" |
| 27 |
Retrieves a raw implementation of this client that returns raw responses. |
| 28 |
|
| 29 |
Returns |
| 30 |
------- |
| 31 |
RawEffectiveRolesClient |
| 32 |
""" |
| 33 |
return self._raw_client |
| 34 |
|
| 35 |
def list( |
| 36 |
self, |
| 37 |
id: str, |
| 38 |
*, |
| 39 |
from_: typing.Optional[str] = None, |
| 40 |
take: typing.Optional[int] = 50, |
| 41 |
request_options: typing.Optional[RequestOptions] = None, |
| 42 |
) -> SyncPager[UserEffectiveRole, ListUserEffectiveRolesResponseContent]: |
| 43 |
""" |
| 44 |
Retrieve detailed list of effective roles for a user, including roles assigned directly and through group memberships. |
| 45 |
|
| 46 |
Parameters |
| 47 |
---------- |
| 48 |
id : str |
| 49 |
ID of the user to list effective roles for. |
| 50 |
|
| 51 |
from_ : typing.Optional[str] |
| 52 |
Optional Id from which to start selection. |
| 53 |
|
| 54 |
take : typing.Optional[int] |
| 55 |
Number of results per page. Defaults to 50. |
| 56 |
|
| 57 |
request_options : typing.Optional[RequestOptions] |
| 58 |
Request-specific configuration. |
| 59 |
|
| 60 |
Returns |
| 61 |
------- |
| 62 |
SyncPager[UserEffectiveRole, ListUserEffectiveRolesResponseContent] |
| 63 |
User's effective roles successfully retrieved. |
| 64 |
|
| 65 |
Examples |
| 66 |
-------- |
| 67 |
from auth0 import Auth0 |
| 68 |
|
| 69 |
client = Auth0( |
| 70 |
token="YOUR_TOKEN", |
| 71 |
) |
| 72 |
response = client.users.effective_roles.list( |
| 73 |
id="id", |
| 74 |
from_="from", |
| 75 |
take=1, |
| 76 |
) |
| 77 |
for item in response: |
| 78 |
yield item |
| 79 |
# alternatively, you can paginate page-by-page |
| 80 |
for page in response.iter_pages(): |
| 81 |
yield page |
| 82 |
""" |
| 83 |
return self._raw_client.list(id, from_=from_, take=take, request_options=request_options) |
| 84 |
|
| 85 |
@property |
| 86 |
def sources(self): |
| 87 |
if self._sources is None: |
| 88 |
from .sources.client import SourcesClient |
| 89 |
|
| 90 |
self._sources = SourcesClient(client_wrapper=self._client_wrapper) |
| 91 |
return self._sources |
| 92 |
|
| 93 |
|
| 94 |
class AsyncEffectiveRolesClient: |
| 95 |
def __init__(self, *, client_wrapper: AsyncClientWrapper): |
| 96 |
self._raw_client = AsyncRawEffectiveRolesClient(client_wrapper=client_wrapper) |
| 97 |
self._client_wrapper = client_wrapper |
| 98 |
self._sources: typing.Optional[AsyncSourcesClient] = None |
| 99 |
|
| 100 |
@property |
| 101 |
def with_raw_response(self) -> AsyncRawEffectiveRolesClient: |
| 102 |
""" |
| 103 |
Retrieves a raw implementation of this client that returns raw responses. |
| 104 |
|
| 105 |
Returns |
| 106 |
------- |
| 107 |
AsyncRawEffectiveRolesClient |
| 108 |
""" |
| 109 |
return self._raw_client |
| 110 |
|
| 111 |
async def list( |
| 112 |
self, |
| 113 |
id: str, |
| 114 |
*, |
| 115 |
from_: typing.Optional[str] = None, |
| 116 |
take: typing.Optional[int] = 50, |
| 117 |
request_options: typing.Optional[RequestOptions] = None, |
| 118 |
) -> AsyncPager[UserEffectiveRole, ListUserEffectiveRolesResponseContent]: |
| 119 |
""" |
| 120 |
Retrieve detailed list of effective roles for a user, including roles assigned directly and through group memberships. |
| 121 |
|
| 122 |
Parameters |
| 123 |
---------- |
| 124 |
id : str |
| 125 |
ID of the user to list effective roles for. |
| 126 |
|
| 127 |
from_ : typing.Optional[str] |
| 128 |
Optional Id from which to start selection. |
| 129 |
|
| 130 |
take : typing.Optional[int] |
| 131 |
Number of results per page. Defaults to 50. |
| 132 |
|
| 133 |
request_options : typing.Optional[RequestOptions] |
| 134 |
Request-specific configuration. |
| 135 |
|
| 136 |
Returns |
| 137 |
------- |
| 138 |
AsyncPager[UserEffectiveRole, ListUserEffectiveRolesResponseContent] |
| 139 |
User's effective roles successfully retrieved. |
| 140 |
|
| 141 |
Examples |
| 142 |
-------- |
| 143 |
import asyncio |
| 144 |
|
| 145 |
from auth0 import AsyncAuth0 |
| 146 |
|
| 147 |
client = AsyncAuth0( |
| 148 |
token="YOUR_TOKEN", |
| 149 |
) |
| 150 |
|
| 151 |
|
| 152 |
async def main() -> None: |
| 153 |
response = await client.users.effective_roles.list( |
| 154 |
id="id", |
| 155 |
from_="from", |
| 156 |
take=1, |
| 157 |
) |
| 158 |
async for item in response: |
| 159 |
yield item |
| 160 |
|
| 161 |
# alternatively, you can paginate page-by-page |
| 162 |
async for page in response.iter_pages(): |
| 163 |
yield page |
| 164 |
|
| 165 |
|
| 166 |
asyncio.run(main()) |
| 167 |
""" |
| 168 |
return await self._raw_client.list(id, from_=from_, take=take, request_options=request_options) |
| 169 |
|
| 170 |
@property |
| 171 |
def sources(self): |
| 172 |
if self._sources is None: |
| 173 |
from .sources.client import AsyncSourcesClient |
| 174 |
|
| 175 |
self._sources = AsyncSourcesClient(client_wrapper=self._client_wrapper) |
| 176 |
return self._sources |