| 1 |
|
| 2 |
|
| 3 |
import typing |
| 4 |
|
| 5 |
from ....core.client_wrapper import AsyncClientWrapper, SyncClientWrapper |
| 6 |
from ....core.pagination import AsyncPager, SyncPager |
| 7 |
from ....core.request_options import RequestOptions |
| 8 |
from ....types.list_organization_role_members_response_content import ListOrganizationRoleMembersResponseContent |
| 9 |
from ....types.role_member import RoleMember |
| 10 |
from .raw_client import AsyncRawMembersClient, RawMembersClient |
| 11 |
|
| 12 |
|
| 13 |
class MembersClient: |
| 14 |
def __init__(self, *, client_wrapper: SyncClientWrapper): |
| 15 |
self._raw_client = RawMembersClient(client_wrapper=client_wrapper) |
| 16 |
|
| 17 |
@property |
| 18 |
def with_raw_response(self) -> RawMembersClient: |
| 19 |
""" |
| 20 |
Retrieves a raw implementation of this client that returns raw responses. |
| 21 |
|
| 22 |
Returns |
| 23 |
------- |
| 24 |
RawMembersClient |
| 25 |
""" |
| 26 |
return self._raw_client |
| 27 |
|
| 28 |
def list( |
| 29 |
self, |
| 30 |
id: str, |
| 31 |
role_id: str, |
| 32 |
*, |
| 33 |
from_: typing.Optional[str] = None, |
| 34 |
take: typing.Optional[int] = 50, |
| 35 |
fields: typing.Optional[str] = None, |
| 36 |
include_fields: typing.Optional[bool] = True, |
| 37 |
request_options: typing.Optional[RequestOptions] = None, |
| 38 |
) -> SyncPager[RoleMember, ListOrganizationRoleMembersResponseContent]: |
| 39 |
""" |
| 40 |
List the organization members assigned a specific role within the context of an organization. |
| 41 |
|
| 42 |
Parameters |
| 43 |
---------- |
| 44 |
id : str |
| 45 |
ID of the organization. |
| 46 |
|
| 47 |
role_id : str |
| 48 |
ID of the role to retrieve the assigned members for. |
| 49 |
|
| 50 |
from_ : typing.Optional[str] |
| 51 |
Optional Id from which to start selection. |
| 52 |
|
| 53 |
take : typing.Optional[int] |
| 54 |
Number of results per page. Defaults to 50. Values above the maximum permitted size are capped. |
| 55 |
|
| 56 |
fields : typing.Optional[str] |
| 57 |
Comma-separated list of fields to include or exclude (based on value provided for include_fields) in the result. Leave empty to retrieve all fields. |
| 58 |
|
| 59 |
include_fields : typing.Optional[bool] |
| 60 |
Whether specified fields are to be included (true) or excluded (false). Defaults to true. |
| 61 |
|
| 62 |
request_options : typing.Optional[RequestOptions] |
| 63 |
Request-specific configuration. |
| 64 |
|
| 65 |
Returns |
| 66 |
------- |
| 67 |
SyncPager[RoleMember, ListOrganizationRoleMembersResponseContent] |
| 68 |
Role members successfully retrieved. |
| 69 |
|
| 70 |
Examples |
| 71 |
-------- |
| 72 |
from auth0 import Auth0 |
| 73 |
|
| 74 |
client = Auth0( |
| 75 |
token="YOUR_TOKEN", |
| 76 |
) |
| 77 |
response = client.organizations.roles.members.list( |
| 78 |
id="id", |
| 79 |
role_id="role_id", |
| 80 |
from_="from", |
| 81 |
take=1, |
| 82 |
fields="fields", |
| 83 |
include_fields=True, |
| 84 |
) |
| 85 |
for item in response: |
| 86 |
yield item |
| 87 |
# alternatively, you can paginate page-by-page |
| 88 |
for page in response.iter_pages(): |
| 89 |
yield page |
| 90 |
""" |
| 91 |
return self._raw_client.list( |
| 92 |
id, |
| 93 |
role_id, |
| 94 |
from_=from_, |
| 95 |
take=take, |
| 96 |
fields=fields, |
| 97 |
include_fields=include_fields, |
| 98 |
request_options=request_options, |
| 99 |
) |
| 100 |
|
| 101 |
|
| 102 |
class AsyncMembersClient: |
| 103 |
def __init__(self, *, client_wrapper: AsyncClientWrapper): |
| 104 |
self._raw_client = AsyncRawMembersClient(client_wrapper=client_wrapper) |
| 105 |
|
| 106 |
@property |
| 107 |
def with_raw_response(self) -> AsyncRawMembersClient: |
| 108 |
""" |
| 109 |
Retrieves a raw implementation of this client that returns raw responses. |
| 110 |
|
| 111 |
Returns |
| 112 |
------- |
| 113 |
AsyncRawMembersClient |
| 114 |
""" |
| 115 |
return self._raw_client |
| 116 |
|
| 117 |
async def list( |
| 118 |
self, |
| 119 |
id: str, |
| 120 |
role_id: str, |
| 121 |
*, |
| 122 |
from_: typing.Optional[str] = None, |
| 123 |
take: typing.Optional[int] = 50, |
| 124 |
fields: typing.Optional[str] = None, |
| 125 |
include_fields: typing.Optional[bool] = True, |
| 126 |
request_options: typing.Optional[RequestOptions] = None, |
| 127 |
) -> AsyncPager[RoleMember, ListOrganizationRoleMembersResponseContent]: |
| 128 |
""" |
| 129 |
List the organization members assigned a specific role within the context of an organization. |
| 130 |
|
| 131 |
Parameters |
| 132 |
---------- |
| 133 |
id : str |
| 134 |
ID of the organization. |
| 135 |
|
| 136 |
role_id : str |
| 137 |
ID of the role to retrieve the assigned members for. |
| 138 |
|
| 139 |
from_ : typing.Optional[str] |
| 140 |
Optional Id from which to start selection. |
| 141 |
|
| 142 |
take : typing.Optional[int] |
| 143 |
Number of results per page. Defaults to 50. Values above the maximum permitted size are capped. |
| 144 |
|
| 145 |
fields : typing.Optional[str] |
| 146 |
Comma-separated list of fields to include or exclude (based on value provided for include_fields) in the result. Leave empty to retrieve all fields. |
| 147 |
|
| 148 |
include_fields : typing.Optional[bool] |
| 149 |
Whether specified fields are to be included (true) or excluded (false). Defaults to true. |
| 150 |
|
| 151 |
request_options : typing.Optional[RequestOptions] |
| 152 |
Request-specific configuration. |
| 153 |
|
| 154 |
Returns |
| 155 |
------- |
| 156 |
AsyncPager[RoleMember, ListOrganizationRoleMembersResponseContent] |
| 157 |
Role members successfully retrieved. |
| 158 |
|
| 159 |
Examples |
| 160 |
-------- |
| 161 |
import asyncio |
| 162 |
|
| 163 |
from auth0 import AsyncAuth0 |
| 164 |
|
| 165 |
client = AsyncAuth0( |
| 166 |
token="YOUR_TOKEN", |
| 167 |
) |
| 168 |
|
| 169 |
|
| 170 |
async def main() -> None: |
| 171 |
response = await client.organizations.roles.members.list( |
| 172 |
id="id", |
| 173 |
role_id="role_id", |
| 174 |
from_="from", |
| 175 |
take=1, |
| 176 |
fields="fields", |
| 177 |
include_fields=True, |
| 178 |
) |
| 179 |
async for item in response: |
| 180 |
yield item |
| 181 |
|
| 182 |
# alternatively, you can paginate page-by-page |
| 183 |
async for page in response.iter_pages(): |
| 184 |
yield page |
| 185 |
|
| 186 |
|
| 187 |
asyncio.run(main()) |
| 188 |
""" |
| 189 |
return await self._raw_client.list( |
| 190 |
id, |
| 191 |
role_id, |
| 192 |
from_=from_, |
| 193 |
take=take, |
| 194 |
fields=fields, |
| 195 |
include_fields=include_fields, |
| 196 |
request_options=request_options, |
| 197 |
) |