Debian Codegraph @

src/auth0/management/organizations/invitations/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.app_metadata import AppMetadata
9 from ...types.create_organization_invitation_response_content import CreateOrganizationInvitationResponseContent
10 from ...types.get_organization_invitation_response_content import GetOrganizationInvitationResponseContent
11 from ...types.list_organization_invitations_offset_paginated_response_content import (
12 ListOrganizationInvitationsOffsetPaginatedResponseContent,
13 )
14 from ...types.organization_invitation import OrganizationInvitation
15 from ...types.organization_invitation_invitee import OrganizationInvitationInvitee
16 from ...types.organization_invitation_inviter import OrganizationInvitationInviter
17 from ...types.user_metadata import UserMetadata
18 from .raw_client import AsyncRawInvitationsClient, RawInvitationsClient
19
20 # this is used as the default value for optional parameters
21 OMIT = typing.cast(typing.Any, ...)
22
23
24 class InvitationsClient:
25 def __init__(self, *, client_wrapper: SyncClientWrapper):
26 self._raw_client = RawInvitationsClient(client_wrapper=client_wrapper)
27
28 @property
29 def with_raw_response(self) -> RawInvitationsClient:
30 """
31 Retrieves a raw implementation of this client that returns raw responses.
32
33 Returns
34 -------
35 RawInvitationsClient
36 """
37 return self._raw_client
38
39 def list(
40 self,
41 id: str,
42 *,
43 page: typing.Optional[int] = 0,
44 per_page: typing.Optional[int] = 50,
45 include_totals: typing.Optional[bool] = True,
46 fields: typing.Optional[str] = None,
47 include_fields: typing.Optional[bool] = None,
48 sort: typing.Optional[str] = None,
49 request_options: typing.Optional[RequestOptions] = None,
50 ) -> SyncPager[OrganizationInvitation, ListOrganizationInvitationsOffsetPaginatedResponseContent]:
51 """
52 Retrieve a detailed list of invitations sent to users for a specific Organization. The list includes details such as inviter and invitee information, invitation URLs, and dates of creation and expiration. To learn more about Organization invitations, review [Invite Organization Members](https://auth0.com/docs/manage-users/organizations/configure-organizations/invite-members).
53
54 Parameters
55 ----------
56 id : str
57 Organization identifier.
58
59 page : typing.Optional[int]
60 Page index of the results to return. First page is 0.
61
62 per_page : typing.Optional[int]
63 Number of results per page. Defaults to 50.
64
65 include_totals : typing.Optional[bool]
66 When true, return results inside an object that also contains the start and limit. When false (default), a direct array of results is returned. We do not yet support returning the total invitations count.
67
68 fields : typing.Optional[str]
69 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.
70
71 include_fields : typing.Optional[bool]
72 Whether specified fields are to be included (true) or excluded (false). Defaults to true.
73
74 sort : typing.Optional[str]
75 Field to sort by. Use field:order where order is 1 for ascending and -1 for descending Defaults to created_at:-1.
76
77 request_options : typing.Optional[RequestOptions]
78 Request-specific configuration.
79
80 Returns
81 -------
82 SyncPager[OrganizationInvitation, ListOrganizationInvitationsOffsetPaginatedResponseContent]
83 Invitations successfully retrieved.
84
85 Examples
86 --------
87 from auth0 import Auth0
88
89 client = Auth0(
90 token="YOUR_TOKEN",
91 )
92 response = client.organizations.invitations.list(
93 id="id",
94 page=1,
95 per_page=1,
96 include_totals=True,
97 fields="fields",
98 include_fields=True,
99 sort="sort",
100 )
101 for item in response:
102 yield item
103 # alternatively, you can paginate page-by-page
104 for page in response.iter_pages():
105 yield page
106 """
107 return self._raw_client.list(
108 id,
109 page=page,
110 per_page=per_page,
111 include_totals=include_totals,
112 fields=fields,
113 include_fields=include_fields,
114 sort=sort,
115 request_options=request_options,
116 )
117
118 def create(
119 self,
120 id: str,
121 *,
122 inviter: OrganizationInvitationInviter,
123 invitee: OrganizationInvitationInvitee,
124 client_id: str,
125 connection_id: typing.Optional[str] = OMIT,
126 app_metadata: typing.Optional[AppMetadata] = OMIT,
127 user_metadata: typing.Optional[UserMetadata] = OMIT,
128 ttl_sec: typing.Optional[int] = OMIT,
129 roles: typing.Optional[typing.Sequence[str]] = OMIT,
130 send_invitation_email: typing.Optional[bool] = OMIT,
131 request_options: typing.Optional[RequestOptions] = None,
132 ) -> CreateOrganizationInvitationResponseContent:
133 """
134 Create a user invitation for a specific Organization. Upon creation, the listed user receives an email inviting them to join the Organization. To learn more about Organization invitations, review [Invite Organization Members](https://auth0.com/docs/manage-users/organizations/configure-organizations/invite-members).
135
136 Parameters
137 ----------
138 id : str
139 Organization identifier.
140
141 inviter : OrganizationInvitationInviter
142
143 invitee : OrganizationInvitationInvitee
144
145 client_id : str
146 Auth0 client ID. Used to resolve the application's login initiation endpoint.
147
148 connection_id : typing.Optional[str]
149 The id of the connection to force invitee to authenticate with.
150
151 app_metadata : typing.Optional[AppMetadata]
152
153 user_metadata : typing.Optional[UserMetadata]
154
155 ttl_sec : typing.Optional[int]
156 Number of seconds for which the invitation is valid before expiration. If unspecified or set to 0, this value defaults to 604800 seconds (7 days). Max value: 2592000 seconds (30 days).
157
158 roles : typing.Optional[typing.Sequence[str]]
159 List of roles IDs to associated with the user.
160
161 send_invitation_email : typing.Optional[bool]
162 Whether the user will receive an invitation email (true) or no email (false), true by default
163
164 request_options : typing.Optional[RequestOptions]
165 Request-specific configuration.
166
167 Returns
168 -------
169 CreateOrganizationInvitationResponseContent
170 Invitation successfully created.
171
172 Examples
173 --------
174 from auth0 import (
175 Auth0,
176 OrganizationInvitationInvitee,
177 OrganizationInvitationInviter,
178 )
179
180 client = Auth0(
181 token="YOUR_TOKEN",
182 )
183 client.organizations.invitations.create(
184 id="id",
185 inviter=OrganizationInvitationInviter(
186 name="name",
187 ),
188 invitee=OrganizationInvitationInvitee(
189 email="email",
190 ),
191 client_id="client_id",
192 )
193 """
194 _response = self._raw_client.create(
195 id,
196 inviter=inviter,
197 invitee=invitee,
198 client_id=client_id,
199 connection_id=connection_id,
200 app_metadata=app_metadata,
201 user_metadata=user_metadata,
202 ttl_sec=ttl_sec,
203 roles=roles,
204 send_invitation_email=send_invitation_email,
205 request_options=request_options,
206 )
207 return _response.data
208
209 def get(
210 self,
211 id: str,
212 invitation_id: str,
213 *,
214 fields: typing.Optional[str] = None,
215 include_fields: typing.Optional[bool] = None,
216 request_options: typing.Optional[RequestOptions] = None,
217 ) -> GetOrganizationInvitationResponseContent:
218 """
219 Parameters
220 ----------
221 id : str
222 Organization identifier.
223
224 invitation_id : str
225 The id of the user invitation.
226
227 fields : typing.Optional[str]
228 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.
229
230 include_fields : typing.Optional[bool]
231 Whether specified fields are to be included (true) or excluded (false). Defaults to true.
232
233 request_options : typing.Optional[RequestOptions]
234 Request-specific configuration.
235
236 Returns
237 -------
238 GetOrganizationInvitationResponseContent
239 Invitation successfully retrieved.
240
241 Examples
242 --------
243 from auth0 import Auth0
244
245 client = Auth0(
246 token="YOUR_TOKEN",
247 )
248 client.organizations.invitations.get(
249 id="id",
250 invitation_id="invitation_id",
251 fields="fields",
252 include_fields=True,
253 )
254 """
255 _response = self._raw_client.get(
256 id, invitation_id, fields=fields, include_fields=include_fields, request_options=request_options
257 )
258 return _response.data
259
260 def delete(self, id: str, invitation_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None:
261 """
262 Parameters
263 ----------
264 id : str
265 Organization identifier.
266
267 invitation_id : str
268 The id of the user invitation.
269
270 request_options : typing.Optional[RequestOptions]
271 Request-specific configuration.
272
273 Returns
274 -------
275 None
276
277 Examples
278 --------
279 from auth0 import Auth0
280
281 client = Auth0(
282 token="YOUR_TOKEN",
283 )
284 client.organizations.invitations.delete(
285 id="id",
286 invitation_id="invitation_id",
287 )
288 """
289 _response = self._raw_client.delete(id, invitation_id, request_options=request_options)
290 return _response.data
291
292
293 class AsyncInvitationsClient:
294 def __init__(self, *, client_wrapper: AsyncClientWrapper):
295 self._raw_client = AsyncRawInvitationsClient(client_wrapper=client_wrapper)
296
297 @property
298 def with_raw_response(self) -> AsyncRawInvitationsClient:
299 """
300 Retrieves a raw implementation of this client that returns raw responses.
301
302 Returns
303 -------
304 AsyncRawInvitationsClient
305 """
306 return self._raw_client
307
308 async def list(
309 self,
310 id: str,
311 *,
312 page: typing.Optional[int] = 0,
313 per_page: typing.Optional[int] = 50,
314 include_totals: typing.Optional[bool] = True,
315 fields: typing.Optional[str] = None,
316 include_fields: typing.Optional[bool] = None,
317 sort: typing.Optional[str] = None,
318 request_options: typing.Optional[RequestOptions] = None,
319 ) -> AsyncPager[OrganizationInvitation, ListOrganizationInvitationsOffsetPaginatedResponseContent]:
320 """
321 Retrieve a detailed list of invitations sent to users for a specific Organization. The list includes details such as inviter and invitee information, invitation URLs, and dates of creation and expiration. To learn more about Organization invitations, review [Invite Organization Members](https://auth0.com/docs/manage-users/organizations/configure-organizations/invite-members).
322
323 Parameters
324 ----------
325 id : str
326 Organization identifier.
327
328 page : typing.Optional[int]
329 Page index of the results to return. First page is 0.
330
331 per_page : typing.Optional[int]
332 Number of results per page. Defaults to 50.
333
334 include_totals : typing.Optional[bool]
335 When true, return results inside an object that also contains the start and limit. When false (default), a direct array of results is returned. We do not yet support returning the total invitations count.
336
337 fields : typing.Optional[str]
338 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.
339
340 include_fields : typing.Optional[bool]
341 Whether specified fields are to be included (true) or excluded (false). Defaults to true.
342
343 sort : typing.Optional[str]
344 Field to sort by. Use field:order where order is 1 for ascending and -1 for descending Defaults to created_at:-1.
345
346 request_options : typing.Optional[RequestOptions]
347 Request-specific configuration.
348
349 Returns
350 -------
351 AsyncPager[OrganizationInvitation, ListOrganizationInvitationsOffsetPaginatedResponseContent]
352 Invitations successfully retrieved.
353
354 Examples
355 --------
356 import asyncio
357
358 from auth0 import AsyncAuth0
359
360 client = AsyncAuth0(
361 token="YOUR_TOKEN",
362 )
363
364
365 async def main() -> None:
366 response = await client.organizations.invitations.list(
367 id="id",
368 page=1,
369 per_page=1,
370 include_totals=True,
371 fields="fields",
372 include_fields=True,
373 sort="sort",
374 )
375 async for item in response:
376 yield item
377
378 # alternatively, you can paginate page-by-page
379 async for page in response.iter_pages():
380 yield page
381
382
383 asyncio.run(main())
384 """
385 return await self._raw_client.list(
386 id,
387 page=page,
388 per_page=per_page,
389 include_totals=include_totals,
390 fields=fields,
391 include_fields=include_fields,
392 sort=sort,
393 request_options=request_options,
394 )
395
396 async def create(
397 self,
398 id: str,
399 *,
400 inviter: OrganizationInvitationInviter,
401 invitee: OrganizationInvitationInvitee,
402 client_id: str,
403 connection_id: typing.Optional[str] = OMIT,
404 app_metadata: typing.Optional[AppMetadata] = OMIT,
405 user_metadata: typing.Optional[UserMetadata] = OMIT,
406 ttl_sec: typing.Optional[int] = OMIT,
407 roles: typing.Optional[typing.Sequence[str]] = OMIT,
408 send_invitation_email: typing.Optional[bool] = OMIT,
409 request_options: typing.Optional[RequestOptions] = None,
410 ) -> CreateOrganizationInvitationResponseContent:
411 """
412 Create a user invitation for a specific Organization. Upon creation, the listed user receives an email inviting them to join the Organization. To learn more about Organization invitations, review [Invite Organization Members](https://auth0.com/docs/manage-users/organizations/configure-organizations/invite-members).
413
414 Parameters
415 ----------
416 id : str
417 Organization identifier.
418
419 inviter : OrganizationInvitationInviter
420
421 invitee : OrganizationInvitationInvitee
422
423 client_id : str
424 Auth0 client ID. Used to resolve the application's login initiation endpoint.
425
426 connection_id : typing.Optional[str]
427 The id of the connection to force invitee to authenticate with.
428
429 app_metadata : typing.Optional[AppMetadata]
430
431 user_metadata : typing.Optional[UserMetadata]
432
433 ttl_sec : typing.Optional[int]
434 Number of seconds for which the invitation is valid before expiration. If unspecified or set to 0, this value defaults to 604800 seconds (7 days). Max value: 2592000 seconds (30 days).
435
436 roles : typing.Optional[typing.Sequence[str]]
437 List of roles IDs to associated with the user.
438
439 send_invitation_email : typing.Optional[bool]
440 Whether the user will receive an invitation email (true) or no email (false), true by default
441
442 request_options : typing.Optional[RequestOptions]
443 Request-specific configuration.
444
445 Returns
446 -------
447 CreateOrganizationInvitationResponseContent
448 Invitation successfully created.
449
450 Examples
451 --------
452 import asyncio
453
454 from auth0 import (
455 AsyncAuth0,
456 OrganizationInvitationInvitee,
457 OrganizationInvitationInviter,
458 )
459
460 client = AsyncAuth0(
461 token="YOUR_TOKEN",
462 )
463
464
465 async def main() -> None:
466 await client.organizations.invitations.create(
467 id="id",
468 inviter=OrganizationInvitationInviter(
469 name="name",
470 ),
471 invitee=OrganizationInvitationInvitee(
472 email="email",
473 ),
474 client_id="client_id",
475 )
476
477
478 asyncio.run(main())
479 """
480 _response = await self._raw_client.create(
481 id,
482 inviter=inviter,
483 invitee=invitee,
484 client_id=client_id,
485 connection_id=connection_id,
486 app_metadata=app_metadata,
487 user_metadata=user_metadata,
488 ttl_sec=ttl_sec,
489 roles=roles,
490 send_invitation_email=send_invitation_email,
491 request_options=request_options,
492 )
493 return _response.data
494
495 async def get(
496 self,
497 id: str,
498 invitation_id: str,
499 *,
500 fields: typing.Optional[str] = None,
501 include_fields: typing.Optional[bool] = None,
502 request_options: typing.Optional[RequestOptions] = None,
503 ) -> GetOrganizationInvitationResponseContent:
504 """
505 Parameters
506 ----------
507 id : str
508 Organization identifier.
509
510 invitation_id : str
511 The id of the user invitation.
512
513 fields : typing.Optional[str]
514 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.
515
516 include_fields : typing.Optional[bool]
517 Whether specified fields are to be included (true) or excluded (false). Defaults to true.
518
519 request_options : typing.Optional[RequestOptions]
520 Request-specific configuration.
521
522 Returns
523 -------
524 GetOrganizationInvitationResponseContent
525 Invitation successfully retrieved.
526
527 Examples
528 --------
529 import asyncio
530
531 from auth0 import AsyncAuth0
532
533 client = AsyncAuth0(
534 token="YOUR_TOKEN",
535 )
536
537
538 async def main() -> None:
539 await client.organizations.invitations.get(
540 id="id",
541 invitation_id="invitation_id",
542 fields="fields",
543 include_fields=True,
544 )
545
546
547 asyncio.run(main())
548 """
549 _response = await self._raw_client.get(
550 id, invitation_id, fields=fields, include_fields=include_fields, request_options=request_options
551 )
552 return _response.data
553
554 async def delete(
555 self, id: str, invitation_id: str, *, request_options: typing.Optional[RequestOptions] = None
556 ) -> None:
557 """
558 Parameters
559 ----------
560 id : str
561 Organization identifier.
562
563 invitation_id : str
564 The id of the user invitation.
565
566 request_options : typing.Optional[RequestOptions]
567 Request-specific configuration.
568
569 Returns
570 -------
571 None
572
573 Examples
574 --------
575 import asyncio
576
577 from auth0 import AsyncAuth0
578
579 client = AsyncAuth0(
580 token="YOUR_TOKEN",
581 )
582
583
584 async def main() -> None:
585 await client.organizations.invitations.delete(
586 id="id",
587 invitation_id="invitation_id",
588 )
589
590
591 asyncio.run(main())
592 """
593 _response = await self._raw_client.delete(id, invitation_id, request_options=request_options)
594 return _response.data