Debian Codegraph @

src/auth0/management/organizations/members/roles/client.py

raw symbols SCIP
1 # This file was auto-generated by Fern from our API Definition.
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_member_roles_offset_paginated_response_content import (
9 ListOrganizationMemberRolesOffsetPaginatedResponseContent,
10 )
11 from ....types.role import Role
12 from .raw_client import AsyncRawRolesClient, RawRolesClient
13
14 # this is used as the default value for optional parameters
15 OMIT = typing.cast(typing.Any, ...)
16
17
18 class RolesClient:
19 def __init__(self, *, client_wrapper: SyncClientWrapper):
20 self._raw_client = RawRolesClient(client_wrapper=client_wrapper)
21
22 @property
23 def with_raw_response(self) -> RawRolesClient:
24 """
25 Retrieves a raw implementation of this client that returns raw responses.
26
27 Returns
28 -------
29 RawRolesClient
30 """
31 return self._raw_client
32
33 def list(
34 self,
35 id: str,
36 user_id: str,
37 *,
38 page: typing.Optional[int] = 0,
39 per_page: typing.Optional[int] = 50,
40 include_totals: typing.Optional[bool] = True,
41 request_options: typing.Optional[RequestOptions] = None,
42 ) -> SyncPager[Role, ListOrganizationMemberRolesOffsetPaginatedResponseContent]:
43 """
44 Retrieve detailed list of roles assigned to a given user within the context of a specific Organization.
45
46 Users can be members of multiple Organizations with unique roles assigned for each membership. This action only returns the roles associated with the specified Organization; any roles assigned to the user within other Organizations are not included.
47
48 Parameters
49 ----------
50 id : str
51 Organization identifier.
52
53 user_id : str
54 ID of the user to associate roles with.
55
56 page : typing.Optional[int]
57 Page index of the results to return. First page is 0.
58
59 per_page : typing.Optional[int]
60 Number of results per page. Defaults to 50.
61
62 include_totals : typing.Optional[bool]
63 Return results inside an object that contains the total result count (true) or as a direct array of results (false, default).
64
65 request_options : typing.Optional[RequestOptions]
66 Request-specific configuration.
67
68 Returns
69 -------
70 SyncPager[Role, ListOrganizationMemberRolesOffsetPaginatedResponseContent]
71 Roles successfully retrieved.
72
73 Examples
74 --------
75 from auth0 import Auth0
76
77 client = Auth0(
78 token="YOUR_TOKEN",
79 )
80 response = client.organizations.members.roles.list(
81 id="id",
82 user_id="user_id",
83 page=1,
84 per_page=1,
85 include_totals=True,
86 )
87 for item in response:
88 yield item
89 # alternatively, you can paginate page-by-page
90 for page in response.iter_pages():
91 yield page
92 """
93 return self._raw_client.list(
94 id, user_id, page=page, per_page=per_page, include_totals=include_totals, request_options=request_options
95 )
96
97 def assign(
98 self,
99 id: str,
100 user_id: str,
101 *,
102 roles: typing.Sequence[str],
103 request_options: typing.Optional[RequestOptions] = None,
104 ) -> None:
105 """
106 Assign one or more [roles](https://auth0.com/docs/manage-users/access-control/rbac) to a user to determine their access for a specific Organization.
107
108 Users can be members of multiple Organizations with unique roles assigned for each membership. This action assigns roles to a user only for the specified Organization. Roles cannot be assigned to a user across multiple Organizations in the same call.
109
110 Parameters
111 ----------
112 id : str
113 Organization identifier.
114
115 user_id : str
116 ID of the user to associate roles with.
117
118 roles : typing.Sequence[str]
119 List of roles IDs to associated with the user.
120
121 request_options : typing.Optional[RequestOptions]
122 Request-specific configuration.
123
124 Returns
125 -------
126 None
127
128 Examples
129 --------
130 from auth0 import Auth0
131
132 client = Auth0(
133 token="YOUR_TOKEN",
134 )
135 client.organizations.members.roles.assign(
136 id="id",
137 user_id="user_id",
138 roles=["roles"],
139 )
140 """
141 _response = self._raw_client.assign(id, user_id, roles=roles, request_options=request_options)
142 return _response.data
143
144 def delete(
145 self,
146 id: str,
147 user_id: str,
148 *,
149 roles: typing.Sequence[str],
150 request_options: typing.Optional[RequestOptions] = None,
151 ) -> None:
152 """
153 Remove one or more Organization-specific [roles](https://auth0.com/docs/manage-users/access-control/rbac) from a given user.
154
155 Users can be members of multiple Organizations with unique roles assigned for each membership. This action removes roles from a user in relation to the specified Organization. Roles assigned to the user within a different Organization cannot be managed in the same call.
156
157 Parameters
158 ----------
159 id : str
160 Organization identifier.
161
162 user_id : str
163 User ID of the organization member to remove roles from.
164
165 roles : typing.Sequence[str]
166 List of roles IDs associated with the organization member to remove.
167
168 request_options : typing.Optional[RequestOptions]
169 Request-specific configuration.
170
171 Returns
172 -------
173 None
174
175 Examples
176 --------
177 from auth0 import Auth0
178
179 client = Auth0(
180 token="YOUR_TOKEN",
181 )
182 client.organizations.members.roles.delete(
183 id="id",
184 user_id="user_id",
185 roles=["roles"],
186 )
187 """
188 _response = self._raw_client.delete(id, user_id, roles=roles, request_options=request_options)
189 return _response.data
190
191
192 class AsyncRolesClient:
193 def __init__(self, *, client_wrapper: AsyncClientWrapper):
194 self._raw_client = AsyncRawRolesClient(client_wrapper=client_wrapper)
195
196 @property
197 def with_raw_response(self) -> AsyncRawRolesClient:
198 """
199 Retrieves a raw implementation of this client that returns raw responses.
200
201 Returns
202 -------
203 AsyncRawRolesClient
204 """
205 return self._raw_client
206
207 async def list(
208 self,
209 id: str,
210 user_id: str,
211 *,
212 page: typing.Optional[int] = 0,
213 per_page: typing.Optional[int] = 50,
214 include_totals: typing.Optional[bool] = True,
215 request_options: typing.Optional[RequestOptions] = None,
216 ) -> AsyncPager[Role, ListOrganizationMemberRolesOffsetPaginatedResponseContent]:
217 """
218 Retrieve detailed list of roles assigned to a given user within the context of a specific Organization.
219
220 Users can be members of multiple Organizations with unique roles assigned for each membership. This action only returns the roles associated with the specified Organization; any roles assigned to the user within other Organizations are not included.
221
222 Parameters
223 ----------
224 id : str
225 Organization identifier.
226
227 user_id : str
228 ID of the user to associate roles with.
229
230 page : typing.Optional[int]
231 Page index of the results to return. First page is 0.
232
233 per_page : typing.Optional[int]
234 Number of results per page. Defaults to 50.
235
236 include_totals : typing.Optional[bool]
237 Return results inside an object that contains the total result count (true) or as a direct array of results (false, default).
238
239 request_options : typing.Optional[RequestOptions]
240 Request-specific configuration.
241
242 Returns
243 -------
244 AsyncPager[Role, ListOrganizationMemberRolesOffsetPaginatedResponseContent]
245 Roles successfully retrieved.
246
247 Examples
248 --------
249 import asyncio
250
251 from auth0 import AsyncAuth0
252
253 client = AsyncAuth0(
254 token="YOUR_TOKEN",
255 )
256
257
258 async def main() -> None:
259 response = await client.organizations.members.roles.list(
260 id="id",
261 user_id="user_id",
262 page=1,
263 per_page=1,
264 include_totals=True,
265 )
266 async for item in response:
267 yield item
268
269 # alternatively, you can paginate page-by-page
270 async for page in response.iter_pages():
271 yield page
272
273
274 asyncio.run(main())
275 """
276 return await self._raw_client.list(
277 id, user_id, page=page, per_page=per_page, include_totals=include_totals, request_options=request_options
278 )
279
280 async def assign(
281 self,
282 id: str,
283 user_id: str,
284 *,
285 roles: typing.Sequence[str],
286 request_options: typing.Optional[RequestOptions] = None,
287 ) -> None:
288 """
289 Assign one or more [roles](https://auth0.com/docs/manage-users/access-control/rbac) to a user to determine their access for a specific Organization.
290
291 Users can be members of multiple Organizations with unique roles assigned for each membership. This action assigns roles to a user only for the specified Organization. Roles cannot be assigned to a user across multiple Organizations in the same call.
292
293 Parameters
294 ----------
295 id : str
296 Organization identifier.
297
298 user_id : str
299 ID of the user to associate roles with.
300
301 roles : typing.Sequence[str]
302 List of roles IDs to associated with the user.
303
304 request_options : typing.Optional[RequestOptions]
305 Request-specific configuration.
306
307 Returns
308 -------
309 None
310
311 Examples
312 --------
313 import asyncio
314
315 from auth0 import AsyncAuth0
316
317 client = AsyncAuth0(
318 token="YOUR_TOKEN",
319 )
320
321
322 async def main() -> None:
323 await client.organizations.members.roles.assign(
324 id="id",
325 user_id="user_id",
326 roles=["roles"],
327 )
328
329
330 asyncio.run(main())
331 """
332 _response = await self._raw_client.assign(id, user_id, roles=roles, request_options=request_options)
333 return _response.data
334
335 async def delete(
336 self,
337 id: str,
338 user_id: str,
339 *,
340 roles: typing.Sequence[str],
341 request_options: typing.Optional[RequestOptions] = None,
342 ) -> None:
343 """
344 Remove one or more Organization-specific [roles](https://auth0.com/docs/manage-users/access-control/rbac) from a given user.
345
346 Users can be members of multiple Organizations with unique roles assigned for each membership. This action removes roles from a user in relation to the specified Organization. Roles assigned to the user within a different Organization cannot be managed in the same call.
347
348 Parameters
349 ----------
350 id : str
351 Organization identifier.
352
353 user_id : str
354 User ID of the organization member to remove roles from.
355
356 roles : typing.Sequence[str]
357 List of roles IDs associated with the organization member to remove.
358
359 request_options : typing.Optional[RequestOptions]
360 Request-specific configuration.
361
362 Returns
363 -------
364 None
365
366 Examples
367 --------
368 import asyncio
369
370 from auth0 import AsyncAuth0
371
372 client = AsyncAuth0(
373 token="YOUR_TOKEN",
374 )
375
376
377 async def main() -> None:
378 await client.organizations.members.roles.delete(
379 id="id",
380 user_id="user_id",
381 roles=["roles"],
382 )
383
384
385 asyncio.run(main())
386 """
387 _response = await self._raw_client.delete(id, user_id, roles=roles, request_options=request_options)
388 return _response.data