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