Debian Codegraph @

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

raw symbols SCIP
1 # This file was auto-generated by Fern from our API Definition.
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_members_paginated_response_content import (
11 ListOrganizationMembersPaginatedResponseContent,
12 )
13 from ...types.organization_member import OrganizationMember
14 from .raw_client import AsyncRawMembersClient, RawMembersClient
15
16 if typing.TYPE_CHECKING:
17 from .effective_roles.client import AsyncEffectiveRolesClient, EffectiveRolesClient
18 from .roles.client import AsyncRolesClient, RolesClient
19 # this is used as the default value for optional parameters
20 OMIT = typing.cast(typing.Any, ...)
21
22
23 class MembersClient:
24 def __init__(self, *, client_wrapper: SyncClientWrapper):
25 self._raw_client = RawMembersClient(client_wrapper=client_wrapper)
26 self._client_wrapper = client_wrapper
27 self._effective_roles: typing.Optional[EffectiveRolesClient] = None
28 self._roles: typing.Optional[RolesClient] = None
29
30 @property
31 def with_raw_response(self) -> RawMembersClient:
32 """
33 Retrieves a raw implementation of this client that returns raw responses.
34
35 Returns
36 -------
37 RawMembersClient
38 """
39 return self._raw_client
40
41 def list(
42 self,
43 id: str,
44 *,
45 from_: typing.Optional[str] = None,
46 take: typing.Optional[int] = 50,
47 fields: typing.Optional[str] = None,
48 include_fields: typing.Optional[bool] = None,
49 request_options: typing.Optional[RequestOptions] = None,
50 ) -> SyncPager[OrganizationMember, ListOrganizationMembersPaginatedResponseContent]:
51 """
52 List organization members.
53 This endpoint is subject to eventual consistency. New users may not be immediately included in the response and deleted users may not be immediately removed from it.
54
55 - Use the `fields` parameter to optionally define the specific member details retrieved. If `fields` is left blank, all fields (except roles) are returned.
56 - Member roles are not sent by default. Use `fields=roles` to retrieve the roles assigned to each listed member. To use this parameter, you must include the `read:organization_member_roles` scope in the token.
57
58 This endpoint supports two types of pagination:
59
60 - Offset pagination
61 - Checkpoint pagination
62
63 Checkpoint pagination must be used if you need to retrieve more than 1000 organization members.
64
65 **Checkpoint Pagination**
66
67 To search by checkpoint, use the following parameters: - from: Optional id from which to start selection. - take: The total amount of entries to retrieve when using the from parameter. Defaults to 50. Note: The first time you call this endpoint using Checkpoint Pagination, you should omit the `from` parameter. If there are more results, a `next` value will be included in the response. You can use this for subsequent API calls. When `next` is no longer included in the response, this indicates there are no more pages remaining.
68
69 Parameters
70 ----------
71 id : str
72 Organization identifier.
73
74 from_ : typing.Optional[str]
75 Optional Id from which to start selection.
76
77 take : typing.Optional[int]
78 Number of results per page. Defaults to 50.
79
80 fields : typing.Optional[str]
81 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.
82
83 include_fields : typing.Optional[bool]
84 Whether specified fields are to be included (true) or excluded (false).
85
86 request_options : typing.Optional[RequestOptions]
87 Request-specific configuration.
88
89 Returns
90 -------
91 SyncPager[OrganizationMember, ListOrganizationMembersPaginatedResponseContent]
92 Members successfully retrieved.
93
94 Examples
95 --------
96 from auth0 import Auth0
97
98 client = Auth0(
99 token="YOUR_TOKEN",
100 )
101 response = client.organizations.members.list(
102 id="id",
103 from_="from",
104 take=1,
105 fields="fields",
106 include_fields=True,
107 )
108 for item in response:
109 yield item
110 # alternatively, you can paginate page-by-page
111 for page in response.iter_pages():
112 yield page
113 """
114 return self._raw_client.list(
115 id, from_=from_, take=take, fields=fields, include_fields=include_fields, request_options=request_options
116 )
117
118 def create(
119 self, id: str, *, members: typing.Sequence[str], request_options: typing.Optional[RequestOptions] = None
120 ) -> None:
121 """
122 Set one or more existing users as members of a specific [Organization](https://auth0.com/docs/manage-users/organizations).
123
124 To add a user to an Organization through this action, the user must already exist in your tenant. If a user does not yet exist, you can [invite them to create an account](https://auth0.com/docs/manage-users/organizations/configure-organizations/invite-members), manually create them through the Auth0 Dashboard, or use the Management API.
125
126 Parameters
127 ----------
128 id : str
129 Organization identifier.
130
131 members : typing.Sequence[str]
132 List of user IDs to add to the organization as members.
133
134 request_options : typing.Optional[RequestOptions]
135 Request-specific configuration.
136
137 Returns
138 -------
139 None
140
141 Examples
142 --------
143 from auth0 import Auth0
144
145 client = Auth0(
146 token="YOUR_TOKEN",
147 )
148 client.organizations.members.create(
149 id="id",
150 members=["members"],
151 )
152 """
153 _response = self._raw_client.create(id, members=members, request_options=request_options)
154 return _response.data
155
156 def delete(
157 self, id: str, *, members: typing.Sequence[str], request_options: typing.Optional[RequestOptions] = None
158 ) -> None:
159 """
160 Parameters
161 ----------
162 id : str
163 Organization identifier.
164
165 members : typing.Sequence[str]
166 List of user IDs to remove from the organization.
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.delete(
183 id="id",
184 members=["members"],
185 )
186 """
187 _response = self._raw_client.delete(id, members=members, request_options=request_options)
188 return _response.data
189
190 @property
191 def effective_roles(self):
192 if self._effective_roles is None:
193 from .effective_roles.client import EffectiveRolesClient # noqa: E402
194
195 self._effective_roles = EffectiveRolesClient(client_wrapper=self._client_wrapper)
196 return self._effective_roles
197
198 @property
199 def roles(self):
200 if self._roles is None:
201 from .roles.client import RolesClient # noqa: E402
202
203 self._roles = RolesClient(client_wrapper=self._client_wrapper)
204 return self._roles
205
206
207 class AsyncMembersClient:
208 def __init__(self, *, client_wrapper: AsyncClientWrapper):
209 self._raw_client = AsyncRawMembersClient(client_wrapper=client_wrapper)
210 self._client_wrapper = client_wrapper
211 self._effective_roles: typing.Optional[AsyncEffectiveRolesClient] = None
212 self._roles: typing.Optional[AsyncRolesClient] = None
213
214 @property
215 def with_raw_response(self) -> AsyncRawMembersClient:
216 """
217 Retrieves a raw implementation of this client that returns raw responses.
218
219 Returns
220 -------
221 AsyncRawMembersClient
222 """
223 return self._raw_client
224
225 async def list(
226 self,
227 id: str,
228 *,
229 from_: typing.Optional[str] = None,
230 take: typing.Optional[int] = 50,
231 fields: typing.Optional[str] = None,
232 include_fields: typing.Optional[bool] = None,
233 request_options: typing.Optional[RequestOptions] = None,
234 ) -> AsyncPager[OrganizationMember, ListOrganizationMembersPaginatedResponseContent]:
235 """
236 List organization members.
237 This endpoint is subject to eventual consistency. New users may not be immediately included in the response and deleted users may not be immediately removed from it.
238
239 - Use the `fields` parameter to optionally define the specific member details retrieved. If `fields` is left blank, all fields (except roles) are returned.
240 - Member roles are not sent by default. Use `fields=roles` to retrieve the roles assigned to each listed member. To use this parameter, you must include the `read:organization_member_roles` scope in the token.
241
242 This endpoint supports two types of pagination:
243
244 - Offset pagination
245 - Checkpoint pagination
246
247 Checkpoint pagination must be used if you need to retrieve more than 1000 organization members.
248
249 **Checkpoint Pagination**
250
251 To search by checkpoint, use the following parameters: - from: Optional id from which to start selection. - take: The total amount of entries to retrieve when using the from parameter. Defaults to 50. Note: The first time you call this endpoint using Checkpoint Pagination, you should omit the `from` parameter. If there are more results, a `next` value will be included in the response. You can use this for subsequent API calls. When `next` is no longer included in the response, this indicates there are no more pages remaining.
252
253 Parameters
254 ----------
255 id : str
256 Organization identifier.
257
258 from_ : typing.Optional[str]
259 Optional Id from which to start selection.
260
261 take : typing.Optional[int]
262 Number of results per page. Defaults to 50.
263
264 fields : typing.Optional[str]
265 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.
266
267 include_fields : typing.Optional[bool]
268 Whether specified fields are to be included (true) or excluded (false).
269
270 request_options : typing.Optional[RequestOptions]
271 Request-specific configuration.
272
273 Returns
274 -------
275 AsyncPager[OrganizationMember, ListOrganizationMembersPaginatedResponseContent]
276 Members successfully retrieved.
277
278 Examples
279 --------
280 import asyncio
281
282 from auth0 import AsyncAuth0
283
284 client = AsyncAuth0(
285 token="YOUR_TOKEN",
286 )
287
288
289 async def main() -> None:
290 response = await client.organizations.members.list(
291 id="id",
292 from_="from",
293 take=1,
294 fields="fields",
295 include_fields=True,
296 )
297 async for item in response:
298 yield item
299
300 # alternatively, you can paginate page-by-page
301 async for page in response.iter_pages():
302 yield page
303
304
305 asyncio.run(main())
306 """
307 return await self._raw_client.list(
308 id, from_=from_, take=take, fields=fields, include_fields=include_fields, request_options=request_options
309 )
310
311 async def create(
312 self, id: str, *, members: typing.Sequence[str], request_options: typing.Optional[RequestOptions] = None
313 ) -> None:
314 """
315 Set one or more existing users as members of a specific [Organization](https://auth0.com/docs/manage-users/organizations).
316
317 To add a user to an Organization through this action, the user must already exist in your tenant. If a user does not yet exist, you can [invite them to create an account](https://auth0.com/docs/manage-users/organizations/configure-organizations/invite-members), manually create them through the Auth0 Dashboard, or use the Management API.
318
319 Parameters
320 ----------
321 id : str
322 Organization identifier.
323
324 members : typing.Sequence[str]
325 List of user IDs to add to the organization as members.
326
327 request_options : typing.Optional[RequestOptions]
328 Request-specific configuration.
329
330 Returns
331 -------
332 None
333
334 Examples
335 --------
336 import asyncio
337
338 from auth0 import AsyncAuth0
339
340 client = AsyncAuth0(
341 token="YOUR_TOKEN",
342 )
343
344
345 async def main() -> None:
346 await client.organizations.members.create(
347 id="id",
348 members=["members"],
349 )
350
351
352 asyncio.run(main())
353 """
354 _response = await self._raw_client.create(id, members=members, request_options=request_options)
355 return _response.data
356
357 async def delete(
358 self, id: str, *, members: typing.Sequence[str], request_options: typing.Optional[RequestOptions] = None
359 ) -> None:
360 """
361 Parameters
362 ----------
363 id : str
364 Organization identifier.
365
366 members : typing.Sequence[str]
367 List of user IDs to remove from the organization.
368
369 request_options : typing.Optional[RequestOptions]
370 Request-specific configuration.
371
372 Returns
373 -------
374 None
375
376 Examples
377 --------
378 import asyncio
379
380 from auth0 import AsyncAuth0
381
382 client = AsyncAuth0(
383 token="YOUR_TOKEN",
384 )
385
386
387 async def main() -> None:
388 await client.organizations.members.delete(
389 id="id",
390 members=["members"],
391 )
392
393
394 asyncio.run(main())
395 """
396 _response = await self._raw_client.delete(id, members=members, request_options=request_options)
397 return _response.data
398
399 @property
400 def effective_roles(self):
401 if self._effective_roles is None:
402 from .effective_roles.client import AsyncEffectiveRolesClient # noqa: E402
403
404 self._effective_roles = AsyncEffectiveRolesClient(client_wrapper=self._client_wrapper)
405 return self._effective_roles
406
407 @property
408 def roles(self):
409 if self._roles is None:
410 from .roles.client import AsyncRolesClient # noqa: E402
411
412 self._roles = AsyncRolesClient(client_wrapper=self._client_wrapper)
413 return self._roles