| 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_permissions_response_content import ListUserEffectivePermissionsResponseContent |
| 11 |
from ...types.user_effective_permission_response_content import UserEffectivePermissionResponseContent |
| 12 |
from .raw_client import AsyncRawEffectivePermissionsClient, RawEffectivePermissionsClient |
| 13 |
|
| 14 |
if typing.TYPE_CHECKING: |
| 15 |
from .sources.client import AsyncSourcesClient, SourcesClient |
| 16 |
|
| 17 |
|
| 18 |
class EffectivePermissionsClient: |
| 19 |
def __init__(self, *, client_wrapper: SyncClientWrapper): |
| 20 |
self._raw_client = RawEffectivePermissionsClient(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) -> RawEffectivePermissionsClient: |
| 26 |
""" |
| 27 |
Retrieves a raw implementation of this client that returns raw responses. |
| 28 |
|
| 29 |
Returns |
| 30 |
------- |
| 31 |
RawEffectivePermissionsClient |
| 32 |
""" |
| 33 |
return self._raw_client |
| 34 |
|
| 35 |
def list( |
| 36 |
self, |
| 37 |
id: str, |
| 38 |
*, |
| 39 |
resource_server_identifier: str, |
| 40 |
from_: typing.Optional[str] = None, |
| 41 |
take: typing.Optional[int] = 50, |
| 42 |
request_options: typing.Optional[RequestOptions] = None, |
| 43 |
) -> SyncPager[UserEffectivePermissionResponseContent, ListUserEffectivePermissionsResponseContent]: |
| 44 |
""" |
| 45 |
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. |
| 46 |
|
| 47 |
Parameters |
| 48 |
---------- |
| 49 |
id : str |
| 50 |
ID of the user to retrieve the permissions for. |
| 51 |
|
| 52 |
resource_server_identifier : str |
| 53 |
The identifier of the resource server for which to calculate user permissions. |
| 54 |
|
| 55 |
from_ : typing.Optional[str] |
| 56 |
Optional Id from which to start selection. |
| 57 |
|
| 58 |
take : typing.Optional[int] |
| 59 |
Number of results per page. Defaults to 50. |
| 60 |
|
| 61 |
request_options : typing.Optional[RequestOptions] |
| 62 |
Request-specific configuration. |
| 63 |
|
| 64 |
Returns |
| 65 |
------- |
| 66 |
SyncPager[UserEffectivePermissionResponseContent, ListUserEffectivePermissionsResponseContent] |
| 67 |
User's effective permissions successfully retrieved. |
| 68 |
|
| 69 |
Examples |
| 70 |
-------- |
| 71 |
from auth0 import Auth0 |
| 72 |
|
| 73 |
client = Auth0( |
| 74 |
token="YOUR_TOKEN", |
| 75 |
) |
| 76 |
response = client.users.effective_permissions.list( |
| 77 |
id="id", |
| 78 |
from_="from", |
| 79 |
take=1, |
| 80 |
resource_server_identifier="resource_server_identifier", |
| 81 |
) |
| 82 |
for item in response: |
| 83 |
yield item |
| 84 |
# alternatively, you can paginate page-by-page |
| 85 |
for page in response.iter_pages(): |
| 86 |
yield page |
| 87 |
""" |
| 88 |
return self._raw_client.list( |
| 89 |
id, |
| 90 |
resource_server_identifier=resource_server_identifier, |
| 91 |
from_=from_, |
| 92 |
take=take, |
| 93 |
request_options=request_options, |
| 94 |
) |
| 95 |
|
| 96 |
@property |
| 97 |
def sources(self): |
| 98 |
if self._sources is None: |
| 99 |
from .sources.client import SourcesClient |
| 100 |
|
| 101 |
self._sources = SourcesClient(client_wrapper=self._client_wrapper) |
| 102 |
return self._sources |
| 103 |
|
| 104 |
|
| 105 |
class AsyncEffectivePermissionsClient: |
| 106 |
def __init__(self, *, client_wrapper: AsyncClientWrapper): |
| 107 |
self._raw_client = AsyncRawEffectivePermissionsClient(client_wrapper=client_wrapper) |
| 108 |
self._client_wrapper = client_wrapper |
| 109 |
self._sources: typing.Optional[AsyncSourcesClient] = None |
| 110 |
|
| 111 |
@property |
| 112 |
def with_raw_response(self) -> AsyncRawEffectivePermissionsClient: |
| 113 |
""" |
| 114 |
Retrieves a raw implementation of this client that returns raw responses. |
| 115 |
|
| 116 |
Returns |
| 117 |
------- |
| 118 |
AsyncRawEffectivePermissionsClient |
| 119 |
""" |
| 120 |
return self._raw_client |
| 121 |
|
| 122 |
async def list( |
| 123 |
self, |
| 124 |
id: str, |
| 125 |
*, |
| 126 |
resource_server_identifier: str, |
| 127 |
from_: typing.Optional[str] = None, |
| 128 |
take: typing.Optional[int] = 50, |
| 129 |
request_options: typing.Optional[RequestOptions] = None, |
| 130 |
) -> AsyncPager[UserEffectivePermissionResponseContent, ListUserEffectivePermissionsResponseContent]: |
| 131 |
""" |
| 132 |
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. |
| 133 |
|
| 134 |
Parameters |
| 135 |
---------- |
| 136 |
id : str |
| 137 |
ID of the user to retrieve the permissions for. |
| 138 |
|
| 139 |
resource_server_identifier : str |
| 140 |
The identifier of the resource server for which to calculate user permissions. |
| 141 |
|
| 142 |
from_ : typing.Optional[str] |
| 143 |
Optional Id from which to start selection. |
| 144 |
|
| 145 |
take : typing.Optional[int] |
| 146 |
Number of results per page. Defaults to 50. |
| 147 |
|
| 148 |
request_options : typing.Optional[RequestOptions] |
| 149 |
Request-specific configuration. |
| 150 |
|
| 151 |
Returns |
| 152 |
------- |
| 153 |
AsyncPager[UserEffectivePermissionResponseContent, ListUserEffectivePermissionsResponseContent] |
| 154 |
User's effective permissions successfully retrieved. |
| 155 |
|
| 156 |
Examples |
| 157 |
-------- |
| 158 |
import asyncio |
| 159 |
|
| 160 |
from auth0 import AsyncAuth0 |
| 161 |
|
| 162 |
client = AsyncAuth0( |
| 163 |
token="YOUR_TOKEN", |
| 164 |
) |
| 165 |
|
| 166 |
|
| 167 |
async def main() -> None: |
| 168 |
response = await client.users.effective_permissions.list( |
| 169 |
id="id", |
| 170 |
from_="from", |
| 171 |
take=1, |
| 172 |
resource_server_identifier="resource_server_identifier", |
| 173 |
) |
| 174 |
async for item in response: |
| 175 |
yield item |
| 176 |
|
| 177 |
# alternatively, you can paginate page-by-page |
| 178 |
async for page in response.iter_pages(): |
| 179 |
yield page |
| 180 |
|
| 181 |
|
| 182 |
asyncio.run(main()) |
| 183 |
""" |
| 184 |
return await self._raw_client.list( |
| 185 |
id, |
| 186 |
resource_server_identifier=resource_server_identifier, |
| 187 |
from_=from_, |
| 188 |
take=take, |
| 189 |
request_options=request_options, |
| 190 |
) |
| 191 |
|
| 192 |
@property |
| 193 |
def sources(self): |
| 194 |
if self._sources is None: |
| 195 |
from .sources.client import AsyncSourcesClient |
| 196 |
|
| 197 |
self._sources = AsyncSourcesClient(client_wrapper=self._client_wrapper) |
| 198 |
return self._sources |