Debian Codegraph @

src/auth0/management/users/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.app_metadata import AppMetadata
11 from ..types.create_user_response_content import CreateUserResponseContent
12 from ..types.get_user_response_content import GetUserResponseContent
13 from ..types.list_users_offset_paginated_response_content import ListUsersOffsetPaginatedResponseContent
14 from ..types.regenerate_users_recovery_code_response_content import RegenerateUsersRecoveryCodeResponseContent
15 from ..types.search_engine_versions_enum import SearchEngineVersionsEnum
16 from ..types.update_user_response_content import UpdateUserResponseContent
17 from ..types.user_metadata import UserMetadata
18 from ..types.user_response_schema import UserResponseSchema
19 from .raw_client import AsyncRawUsersClient, RawUsersClient
20
21 if typing.TYPE_CHECKING:
22 from .authentication_methods.client import AsyncAuthenticationMethodsClient, AuthenticationMethodsClient
23 from .authenticators.client import AsyncAuthenticatorsClient, AuthenticatorsClient
24 from .connected_accounts.client import AsyncConnectedAccountsClient, ConnectedAccountsClient
25 from .effective_permissions.client import AsyncEffectivePermissionsClient, EffectivePermissionsClient
26 from .effective_roles.client import AsyncEffectiveRolesClient, EffectiveRolesClient
27 from .enrollments.client import AsyncEnrollmentsClient, EnrollmentsClient
28 from .groups.client import AsyncGroupsClient, GroupsClient
29 from .identities.client import AsyncIdentitiesClient, IdentitiesClient
30 from .logs.client import AsyncLogsClient, LogsClient
31 from .multifactor.client import AsyncMultifactorClient, MultifactorClient
32 from .organizations.client import AsyncOrganizationsClient, OrganizationsClient
33 from .permissions.client import AsyncPermissionsClient, PermissionsClient
34 from .refresh_token.client import AsyncRefreshTokenClient, RefreshTokenClient
35 from .risk_assessments.client import AsyncRiskAssessmentsClient, RiskAssessmentsClient
36 from .roles.client import AsyncRolesClient, RolesClient
37 from .sessions.client import AsyncSessionsClient, SessionsClient
38 # this is used as the default value for optional parameters
39 OMIT = typing.cast(typing.Any, ...)
40
41
42 class UsersClient:
43 def __init__(self, *, client_wrapper: SyncClientWrapper):
44 self._raw_client = RawUsersClient(client_wrapper=client_wrapper)
45 self._client_wrapper = client_wrapper
46 self._authentication_methods: typing.Optional[AuthenticationMethodsClient] = None
47 self._authenticators: typing.Optional[AuthenticatorsClient] = None
48 self._connected_accounts: typing.Optional[ConnectedAccountsClient] = None
49 self._effective_permissions: typing.Optional[EffectivePermissionsClient] = None
50 self._effective_roles: typing.Optional[EffectiveRolesClient] = None
51 self._enrollments: typing.Optional[EnrollmentsClient] = None
52 self._groups: typing.Optional[GroupsClient] = None
53 self._identities: typing.Optional[IdentitiesClient] = None
54 self._logs: typing.Optional[LogsClient] = None
55 self._multifactor: typing.Optional[MultifactorClient] = None
56 self._organizations: typing.Optional[OrganizationsClient] = None
57 self._permissions: typing.Optional[PermissionsClient] = None
58 self._risk_assessments: typing.Optional[RiskAssessmentsClient] = None
59 self._roles: typing.Optional[RolesClient] = None
60 self._refresh_token: typing.Optional[RefreshTokenClient] = None
61 self._sessions: typing.Optional[SessionsClient] = None
62
63 @property
64 def with_raw_response(self) -> RawUsersClient:
65 """
66 Retrieves a raw implementation of this client that returns raw responses.
67
68 Returns
69 -------
70 RawUsersClient
71 """
72 return self._raw_client
73
74 def list(
75 self,
76 *,
77 page: typing.Optional[int] = 0,
78 per_page: typing.Optional[int] = 50,
79 include_totals: typing.Optional[bool] = True,
80 sort: typing.Optional[str] = None,
81 connection: typing.Optional[str] = None,
82 fields: typing.Optional[str] = None,
83 include_fields: typing.Optional[bool] = None,
84 q: typing.Optional[str] = None,
85 search_engine: typing.Optional[SearchEngineVersionsEnum] = None,
86 primary_order: typing.Optional[bool] = None,
87 request_options: typing.Optional[RequestOptions] = None,
88 ) -> SyncPager[UserResponseSchema, ListUsersOffsetPaginatedResponseContent]:
89 """
90 Retrieve details of users. It is possible to:
91
92 - Specify a search criteria for users
93 - Sort the users to be returned
94 - Select the fields to be returned
95 - Specify the number of users to retrieve per page and the page index
96
97
98
99 The `q` query parameter can be used to get users that match the specified criteria [using query string syntax.](https://auth0.com/docs/users/search/v3/query-syntax)
100
101 [Learn more about searching for users.](https://auth0.com/docs/users/search/v3)
102
103 Read about [best practices](https://auth0.com/docs/users/search/best-practices) when working with the API endpoints for retrieving users.
104
105
106
107 Auth0 limits the number of users you can return. If you exceed this threshold, please redefine your search, use the [export job](https://auth0.com/docs/api/management/v2#!/Jobs/post_users_exports), or the [User Import / Export](https://auth0.com/docs/extensions/user-import-export) extension.
108
109 Parameters
110 ----------
111 page : typing.Optional[int]
112 Page index of the results to return. First page is 0.
113
114 per_page : typing.Optional[int]
115 Number of results per page.
116
117 include_totals : typing.Optional[bool]
118 Return results inside an object that contains the total result count (true) or as a direct array of results (false, default).
119
120 sort : typing.Optional[str]
121 Field to sort by. Use <code>field:order</code> where order is <code>1</code> for ascending and <code>-1</code> for descending. e.g. <code>created_at:1</code>
122
123 connection : typing.Optional[str]
124 Connection filter. Only applies when using <code>search_engine=v1</code>. To filter by connection with <code>search_engine=v2|v3</code>, use <code>q=identities.connection:"connection_name"</code>
125
126 fields : typing.Optional[str]
127 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.
128
129 include_fields : typing.Optional[bool]
130 Whether specified fields are to be included (true) or excluded (false).
131
132 q : typing.Optional[str]
133 Query in <a target='_new' href ='https://lucene.apache.org/core/2_9_4/queryparsersyntax.html'>Lucene query string syntax</a>. Some query types cannot be used on metadata fields, for details see <a href='https://auth0.com/docs/users/search/v3/query-syntax#searchable-fields'>Searchable Fields</a>.
134
135 search_engine : typing.Optional[SearchEngineVersionsEnum]
136 The version of the search engine
137
138 primary_order : typing.Optional[bool]
139 If true (default), results are returned in a deterministic order. If false, results may be returned in a non-deterministic order, which can enhance performance for complex queries targeting a small number of users. Set to false only when consistent ordering and pagination is not required.
140
141 request_options : typing.Optional[RequestOptions]
142 Request-specific configuration.
143
144 Returns
145 -------
146 SyncPager[UserResponseSchema, ListUsersOffsetPaginatedResponseContent]
147 Users successfully retrieved.
148
149 Examples
150 --------
151 from auth0 import Auth0
152
153 client = Auth0(
154 token="YOUR_TOKEN",
155 )
156 response = client.users.list(
157 page=1,
158 per_page=1,
159 include_totals=True,
160 sort="sort",
161 connection="connection",
162 fields="fields",
163 include_fields=True,
164 q="q",
165 search_engine="v1",
166 primary_order=True,
167 )
168 for item in response:
169 yield item
170 # alternatively, you can paginate page-by-page
171 for page in response.iter_pages():
172 yield page
173 """
174 return self._raw_client.list(
175 page=page,
176 per_page=per_page,
177 include_totals=include_totals,
178 sort=sort,
179 connection=connection,
180 fields=fields,
181 include_fields=include_fields,
182 q=q,
183 search_engine=search_engine,
184 primary_order=primary_order,
185 request_options=request_options,
186 )
187
188 def create(
189 self,
190 *,
191 connection: str,
192 email: typing.Optional[str] = OMIT,
193 phone_number: typing.Optional[str] = OMIT,
194 user_metadata: typing.Optional[UserMetadata] = OMIT,
195 blocked: typing.Optional[bool] = OMIT,
196 email_verified: typing.Optional[bool] = OMIT,
197 phone_verified: typing.Optional[bool] = OMIT,
198 app_metadata: typing.Optional[AppMetadata] = OMIT,
199 given_name: typing.Optional[str] = OMIT,
200 family_name: typing.Optional[str] = OMIT,
201 name: typing.Optional[str] = OMIT,
202 nickname: typing.Optional[str] = OMIT,
203 picture: typing.Optional[str] = OMIT,
204 user_id: typing.Optional[str] = OMIT,
205 password: typing.Optional[str] = OMIT,
206 verify_email: typing.Optional[bool] = OMIT,
207 username: typing.Optional[str] = OMIT,
208 request_options: typing.Optional[RequestOptions] = None,
209 ) -> CreateUserResponseContent:
210 """
211 Create a new user for a given [database](https://auth0.com/docs/connections/database) or [passwordless](https://auth0.com/docs/connections/passwordless) connection.
212
213 Note: `connection` is required but other parameters such as `email` and `password` are dependent upon the type of connection.
214
215 Parameters
216 ----------
217 connection : str
218 Name of the connection this user should be created in.
219
220 email : typing.Optional[str]
221 The user's email.
222
223 phone_number : typing.Optional[str]
224 The user's phone number (following the E.164 recommendation).
225
226 user_metadata : typing.Optional[UserMetadata]
227
228 blocked : typing.Optional[bool]
229 Whether this user was blocked by an administrator (true) or not (false).
230
231 email_verified : typing.Optional[bool]
232 Whether this email address is verified (true) or unverified (false). User will receive a verification email after creation if `email_verified` is false or not specified
233
234 phone_verified : typing.Optional[bool]
235 Whether this phone number has been verified (true) or not (false).
236
237 app_metadata : typing.Optional[AppMetadata]
238
239 given_name : typing.Optional[str]
240 The user's given name(s).
241
242 family_name : typing.Optional[str]
243 The user's family name(s).
244
245 name : typing.Optional[str]
246 The user's full name.
247
248 nickname : typing.Optional[str]
249 The user's nickname.
250
251 picture : typing.Optional[str]
252 A URI pointing to the user's picture.
253
254 user_id : typing.Optional[str]
255 The external user's id provided by the identity provider.
256
257 password : typing.Optional[str]
258 Initial password for this user. Only valid for auth0 connection strategy.
259
260 verify_email : typing.Optional[bool]
261 Whether the user will receive a verification email after creation (true) or no email (false). Overrides behavior of `email_verified` parameter.
262
263 username : typing.Optional[str]
264 The user's username. Only valid if the connection requires a username.
265
266 request_options : typing.Optional[RequestOptions]
267 Request-specific configuration.
268
269 Returns
270 -------
271 CreateUserResponseContent
272 User successfully created.
273
274 Examples
275 --------
276 from auth0 import Auth0
277
278 client = Auth0(
279 token="YOUR_TOKEN",
280 )
281 client.users.create(
282 connection="connection",
283 )
284 """
285 _response = self._raw_client.create(
286 connection=connection,
287 email=email,
288 phone_number=phone_number,
289 user_metadata=user_metadata,
290 blocked=blocked,
291 email_verified=email_verified,
292 phone_verified=phone_verified,
293 app_metadata=app_metadata,
294 given_name=given_name,
295 family_name=family_name,
296 name=name,
297 nickname=nickname,
298 picture=picture,
299 user_id=user_id,
300 password=password,
301 verify_email=verify_email,
302 username=username,
303 request_options=request_options,
304 )
305 return _response.data
306
307 def list_users_by_email(
308 self,
309 *,
310 email: str,
311 fields: typing.Optional[str] = None,
312 include_fields: typing.Optional[bool] = None,
313 request_options: typing.Optional[RequestOptions] = None,
314 ) -> typing.List[UserResponseSchema]:
315 """
316 Find users by email. If Auth0 is the identity provider (idP), the email address associated with a user is saved in lower case, regardless of how you initially provided it.
317
318 For example, if you register a user as [email protected], Auth0 saves the user's email as [email protected].
319
320 Therefore, when using this endpoint, make sure that you are searching for users via email addresses using the correct case.
321
322 Parameters
323 ----------
324 email : str
325 Email address to search for (case-sensitive).
326
327 fields : typing.Optional[str]
328 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.
329
330 include_fields : typing.Optional[bool]
331 Whether specified fields are to be included (true) or excluded (false). Defaults to true.
332
333 request_options : typing.Optional[RequestOptions]
334 Request-specific configuration.
335
336 Returns
337 -------
338 typing.List[UserResponseSchema]
339 Users successfully searched.
340
341 Examples
342 --------
343 from auth0 import Auth0
344
345 client = Auth0(
346 token="YOUR_TOKEN",
347 )
348 client.users.list_users_by_email(
349 fields="fields",
350 include_fields=True,
351 email="email",
352 )
353 """
354 _response = self._raw_client.list_users_by_email(
355 email=email, fields=fields, include_fields=include_fields, request_options=request_options
356 )
357 return _response.data
358
359 def get(
360 self,
361 id: str,
362 *,
363 fields: typing.Optional[str] = None,
364 include_fields: typing.Optional[bool] = None,
365 request_options: typing.Optional[RequestOptions] = None,
366 ) -> GetUserResponseContent:
367 """
368 Retrieve user details. A list of fields to include or exclude may also be specified. For more information, see [Retrieve Users with the Get Users Endpoint](https://auth0.com/docs/manage-users/user-search/retrieve-users-with-get-users-endpoint).
369
370 Parameters
371 ----------
372 id : str
373 ID of the user to retrieve.
374
375 fields : typing.Optional[str]
376 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.
377
378 include_fields : typing.Optional[bool]
379 Whether specified fields are to be included (true) or excluded (false).
380
381 request_options : typing.Optional[RequestOptions]
382 Request-specific configuration.
383
384 Returns
385 -------
386 GetUserResponseContent
387 User successfully retrieved.
388
389 Examples
390 --------
391 from auth0 import Auth0
392
393 client = Auth0(
394 token="YOUR_TOKEN",
395 )
396 client.users.get(
397 id="id",
398 fields="fields",
399 include_fields=True,
400 )
401 """
402 _response = self._raw_client.get(
403 id, fields=fields, include_fields=include_fields, request_options=request_options
404 )
405 return _response.data
406
407 def delete(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None:
408 """
409 Delete a user by user ID. This action cannot be undone. For Auth0 Dashboard instructions, see [Delete Users](https://auth0.com/docs/manage-users/user-accounts/delete-users).
410
411 Parameters
412 ----------
413 id : str
414 ID of the user to delete.
415
416 request_options : typing.Optional[RequestOptions]
417 Request-specific configuration.
418
419 Returns
420 -------
421 None
422
423 Examples
424 --------
425 from auth0 import Auth0
426
427 client = Auth0(
428 token="YOUR_TOKEN",
429 )
430 client.users.delete(
431 id="id",
432 )
433 """
434 _response = self._raw_client.delete(id, request_options=request_options)
435 return _response.data
436
437 def update(
438 self,
439 id: str,
440 *,
441 blocked: typing.Optional[bool] = OMIT,
442 email_verified: typing.Optional[bool] = OMIT,
443 email: typing.Optional[str] = OMIT,
444 phone_number: typing.Optional[str] = OMIT,
445 phone_verified: typing.Optional[bool] = OMIT,
446 user_metadata: typing.Optional[UserMetadata] = OMIT,
447 app_metadata: typing.Optional[AppMetadata] = OMIT,
448 given_name: typing.Optional[str] = OMIT,
449 family_name: typing.Optional[str] = OMIT,
450 name: typing.Optional[str] = OMIT,
451 nickname: typing.Optional[str] = OMIT,
452 picture: typing.Optional[str] = OMIT,
453 verify_email: typing.Optional[bool] = OMIT,
454 verify_phone_number: typing.Optional[bool] = OMIT,
455 password: typing.Optional[str] = OMIT,
456 connection: typing.Optional[str] = OMIT,
457 client_id: typing.Optional[str] = OMIT,
458 username: typing.Optional[str] = OMIT,
459 request_options: typing.Optional[RequestOptions] = None,
460 ) -> UpdateUserResponseContent:
461 """
462 Update a user.
463
464 These are the attributes that can be updated at the root level:
465
466 - app_metadata
467 - blocked
468 - email
469 - email_verified
470 - family_name
471 - given_name
472 - name
473 - nickname
474 - password
475 - phone_number
476 - phone_verified
477 - picture
478 - username
479 - user_metadata
480 - verify_email
481
482 Some considerations:
483
484 - The properties of the new object will replace the old ones.
485 - The metadata fields are an exception to this rule (`user_metadata` and `app_metadata`). These properties are merged instead of being replaced but be careful, the merge only occurs on the first level.
486 - If you are updating `email`, `email_verified`, `phone_number`, `phone_verified`, `username` or `password` of a secondary identity, you need to specify the `connection` property too.
487 - If you are updating `email` or `phone_number` you can specify, optionally, the `client_id` property.
488 - Updating `email_verified` is not supported for enterprise and passwordless sms connections.
489 - Updating the `blocked` to `false` does not affect the user's blocked state from an excessive amount of incorrectly provided credentials. Use the "Unblock a user" endpoint from the "User Blocks" API to change the user's state.
490 - Supported attributes can be unset by supplying `null` as the value.
491
492 **Updating a field (non-metadata property)**
493
494 To mark the email address of a user as verified, the body to send should be:
495
496 ```json
497 { "email_verified": true }
498 ```
499
500 **Updating a user metadata root property**
501
502 Let's assume that our test user has the following `user_metadata`:
503
504 ```json
505 { "user_metadata" : { "profileCode": 1479 } }
506 ```
507
508 To add the field `addresses` the body to send should be:
509
510 ```json
511 { "user_metadata" : { "addresses": {"work_address": "100 Industrial Way"} }}
512 ```
513
514 The modified object ends up with the following `user_metadata` property:
515
516 ```json
517 {
518 "user_metadata": {
519 "profileCode": 1479,
520 "addresses": { "work_address": "100 Industrial Way" }
521 }
522 }
523 ```
524
525 **Updating an inner user metadata property**
526
527 If there's existing user metadata to which we want to add `"home_address": "742 Evergreen Terrace"` (using the `addresses` property) we should send the whole `addresses` object. Since this is a first-level object, the object will be merged in, but its own properties will not be. The body to send should be:
528
529 ```json
530 {
531 "user_metadata": {
532 "addresses": {
533 "work_address": "100 Industrial Way",
534 "home_address": "742 Evergreen Terrace"
535 }
536 }
537 }
538 ```
539
540 The modified object ends up with the following `user_metadata` property:
541
542 ```json
543 {
544 "user_metadata": {
545 "profileCode": 1479,
546 "addresses": {
547 "work_address": "100 Industrial Way",
548 "home_address": "742 Evergreen Terrace"
549 }
550 }
551 }
552 ```
553
554 Parameters
555 ----------
556 id : str
557 ID of the user to update.
558
559 blocked : typing.Optional[bool]
560 Whether this user was blocked by an administrator (true) or not (false).
561
562 email_verified : typing.Optional[bool]
563 Whether this email address is verified (true) or unverified (false). If set to false the user will not receive a verification email unless `verify_email` is set to true.
564
565 email : typing.Optional[str]
566 Email address of this user.
567
568 phone_number : typing.Optional[str]
569 The user's phone number (following the E.164 recommendation).
570
571 phone_verified : typing.Optional[bool]
572 Whether this phone number has been verified (true) or not (false).
573
574 user_metadata : typing.Optional[UserMetadata]
575 User metadata to which this user has read/write access.
576
577 app_metadata : typing.Optional[AppMetadata]
578 User metadata to which this user has read-only access.
579
580 given_name : typing.Optional[str]
581 Given name/first name/forename of this user.
582
583 family_name : typing.Optional[str]
584 Family name/last name/surname of this user.
585
586 name : typing.Optional[str]
587 Name of this user.
588
589 nickname : typing.Optional[str]
590 Preferred nickname or alias of this user.
591
592 picture : typing.Optional[str]
593 URL to picture, photo, or avatar of this user.
594
595 verify_email : typing.Optional[bool]
596 Whether this user will receive a verification email after creation (true) or no email (false). Overrides behavior of `email_verified` parameter.
597
598 verify_phone_number : typing.Optional[bool]
599 Whether this user will receive a text after changing the phone number (true) or no text (false). Only valid when changing phone number for SMS connections.
600
601 password : typing.Optional[str]
602 New password for this user. Only valid for database connections.
603
604 connection : typing.Optional[str]
605 Name of the connection to target for this user update.
606
607 client_id : typing.Optional[str]
608 Auth0 client ID. Only valid when updating email address.
609
610 username : typing.Optional[str]
611 The user's username. Only valid if the connection requires a username.
612
613 request_options : typing.Optional[RequestOptions]
614 Request-specific configuration.
615
616 Returns
617 -------
618 UpdateUserResponseContent
619 User successfully updated.
620
621 Examples
622 --------
623 from auth0 import Auth0
624
625 client = Auth0(
626 token="YOUR_TOKEN",
627 )
628 client.users.update(
629 id="id",
630 )
631 """
632 _response = self._raw_client.update(
633 id,
634 blocked=blocked,
635 email_verified=email_verified,
636 email=email,
637 phone_number=phone_number,
638 phone_verified=phone_verified,
639 user_metadata=user_metadata,
640 app_metadata=app_metadata,
641 given_name=given_name,
642 family_name=family_name,
643 name=name,
644 nickname=nickname,
645 picture=picture,
646 verify_email=verify_email,
647 verify_phone_number=verify_phone_number,
648 password=password,
649 connection=connection,
650 client_id=client_id,
651 username=username,
652 request_options=request_options,
653 )
654 return _response.data
655
656 def regenerate_recovery_code(
657 self, id: str, *, request_options: typing.Optional[RequestOptions] = None
658 ) -> RegenerateUsersRecoveryCodeResponseContent:
659 """
660 Remove an existing multi-factor authentication (MFA) [recovery code](https://auth0.com/docs/secure/multi-factor-authentication/reset-user-mfa) and generate a new one. If a user cannot access the original device or account used for MFA enrollment, they can use a recovery code to authenticate.
661
662 Parameters
663 ----------
664 id : str
665 ID of the user to regenerate a multi-factor authentication recovery code for.
666
667 request_options : typing.Optional[RequestOptions]
668 Request-specific configuration.
669
670 Returns
671 -------
672 RegenerateUsersRecoveryCodeResponseContent
673 New recovery code successfully generated.
674
675 Examples
676 --------
677 from auth0 import Auth0
678
679 client = Auth0(
680 token="YOUR_TOKEN",
681 )
682 client.users.regenerate_recovery_code(
683 id="id",
684 )
685 """
686 _response = self._raw_client.regenerate_recovery_code(id, request_options=request_options)
687 return _response.data
688
689 def revoke_access(
690 self,
691 id: str,
692 *,
693 session_id: typing.Optional[str] = OMIT,
694 preserve_refresh_tokens: typing.Optional[bool] = OMIT,
695 request_options: typing.Optional[RequestOptions] = None,
696 ) -> None:
697 """
698 Revokes selected resources related to a user (sessions, refresh tokens, ...).
699
700 Parameters
701 ----------
702 id : str
703 ID of the user.
704
705 session_id : typing.Optional[str]
706 ID of the session to revoke.
707
708 preserve_refresh_tokens : typing.Optional[bool]
709 Whether to preserve the refresh tokens associated with the session.
710
711 request_options : typing.Optional[RequestOptions]
712 Request-specific configuration.
713
714 Returns
715 -------
716 None
717
718 Examples
719 --------
720 from auth0 import Auth0
721
722 client = Auth0(
723 token="YOUR_TOKEN",
724 )
725 client.users.revoke_access(
726 id="id",
727 )
728 """
729 _response = self._raw_client.revoke_access(
730 id, session_id=session_id, preserve_refresh_tokens=preserve_refresh_tokens, request_options=request_options
731 )
732 return _response.data
733
734 @property
735 def authentication_methods(self):
736 if self._authentication_methods is None:
737 from .authentication_methods.client import AuthenticationMethodsClient # noqa: E402
738
739 self._authentication_methods = AuthenticationMethodsClient(client_wrapper=self._client_wrapper)
740 return self._authentication_methods
741
742 @property
743 def authenticators(self):
744 if self._authenticators is None:
745 from .authenticators.client import AuthenticatorsClient # noqa: E402
746
747 self._authenticators = AuthenticatorsClient(client_wrapper=self._client_wrapper)
748 return self._authenticators
749
750 @property
751 def connected_accounts(self):
752 if self._connected_accounts is None:
753 from .connected_accounts.client import ConnectedAccountsClient # noqa: E402
754
755 self._connected_accounts = ConnectedAccountsClient(client_wrapper=self._client_wrapper)
756 return self._connected_accounts
757
758 @property
759 def effective_permissions(self):
760 if self._effective_permissions is None:
761 from .effective_permissions.client import EffectivePermissionsClient # noqa: E402
762
763 self._effective_permissions = EffectivePermissionsClient(client_wrapper=self._client_wrapper)
764 return self._effective_permissions
765
766 @property
767 def effective_roles(self):
768 if self._effective_roles is None:
769 from .effective_roles.client import EffectiveRolesClient # noqa: E402
770
771 self._effective_roles = EffectiveRolesClient(client_wrapper=self._client_wrapper)
772 return self._effective_roles
773
774 @property
775 def enrollments(self):
776 if self._enrollments is None:
777 from .enrollments.client import EnrollmentsClient # noqa: E402
778
779 self._enrollments = EnrollmentsClient(client_wrapper=self._client_wrapper)
780 return self._enrollments
781
782 @property
783 def groups(self):
784 if self._groups is None:
785 from .groups.client import GroupsClient # noqa: E402
786
787 self._groups = GroupsClient(client_wrapper=self._client_wrapper)
788 return self._groups
789
790 @property
791 def identities(self):
792 if self._identities is None:
793 from .identities.client import IdentitiesClient # noqa: E402
794
795 self._identities = IdentitiesClient(client_wrapper=self._client_wrapper)
796 return self._identities
797
798 @property
799 def logs(self):
800 if self._logs is None:
801 from .logs.client import LogsClient # noqa: E402
802
803 self._logs = LogsClient(client_wrapper=self._client_wrapper)
804 return self._logs
805
806 @property
807 def multifactor(self):
808 if self._multifactor is None:
809 from .multifactor.client import MultifactorClient # noqa: E402
810
811 self._multifactor = MultifactorClient(client_wrapper=self._client_wrapper)
812 return self._multifactor
813
814 @property
815 def organizations(self):
816 if self._organizations is None:
817 from .organizations.client import OrganizationsClient # noqa: E402
818
819 self._organizations = OrganizationsClient(client_wrapper=self._client_wrapper)
820 return self._organizations
821
822 @property
823 def permissions(self):
824 if self._permissions is None:
825 from .permissions.client import PermissionsClient # noqa: E402
826
827 self._permissions = PermissionsClient(client_wrapper=self._client_wrapper)
828 return self._permissions
829
830 @property
831 def risk_assessments(self):
832 if self._risk_assessments is None:
833 from .risk_assessments.client import RiskAssessmentsClient # noqa: E402
834
835 self._risk_assessments = RiskAssessmentsClient(client_wrapper=self._client_wrapper)
836 return self._risk_assessments
837
838 @property
839 def roles(self):
840 if self._roles is None:
841 from .roles.client import RolesClient # noqa: E402
842
843 self._roles = RolesClient(client_wrapper=self._client_wrapper)
844 return self._roles
845
846 @property
847 def refresh_token(self):
848 if self._refresh_token is None:
849 from .refresh_token.client import RefreshTokenClient # noqa: E402
850
851 self._refresh_token = RefreshTokenClient(client_wrapper=self._client_wrapper)
852 return self._refresh_token
853
854 @property
855 def sessions(self):
856 if self._sessions is None:
857 from .sessions.client import SessionsClient # noqa: E402
858
859 self._sessions = SessionsClient(client_wrapper=self._client_wrapper)
860 return self._sessions
861
862
863 class AsyncUsersClient:
864 def __init__(self, *, client_wrapper: AsyncClientWrapper):
865 self._raw_client = AsyncRawUsersClient(client_wrapper=client_wrapper)
866 self._client_wrapper = client_wrapper
867 self._authentication_methods: typing.Optional[AsyncAuthenticationMethodsClient] = None
868 self._authenticators: typing.Optional[AsyncAuthenticatorsClient] = None
869 self._connected_accounts: typing.Optional[AsyncConnectedAccountsClient] = None
870 self._effective_permissions: typing.Optional[AsyncEffectivePermissionsClient] = None
871 self._effective_roles: typing.Optional[AsyncEffectiveRolesClient] = None
872 self._enrollments: typing.Optional[AsyncEnrollmentsClient] = None
873 self._groups: typing.Optional[AsyncGroupsClient] = None
874 self._identities: typing.Optional[AsyncIdentitiesClient] = None
875 self._logs: typing.Optional[AsyncLogsClient] = None
876 self._multifactor: typing.Optional[AsyncMultifactorClient] = None
877 self._organizations: typing.Optional[AsyncOrganizationsClient] = None
878 self._permissions: typing.Optional[AsyncPermissionsClient] = None
879 self._risk_assessments: typing.Optional[AsyncRiskAssessmentsClient] = None
880 self._roles: typing.Optional[AsyncRolesClient] = None
881 self._refresh_token: typing.Optional[AsyncRefreshTokenClient] = None
882 self._sessions: typing.Optional[AsyncSessionsClient] = None
883
884 @property
885 def with_raw_response(self) -> AsyncRawUsersClient:
886 """
887 Retrieves a raw implementation of this client that returns raw responses.
888
889 Returns
890 -------
891 AsyncRawUsersClient
892 """
893 return self._raw_client
894
895 async def list(
896 self,
897 *,
898 page: typing.Optional[int] = 0,
899 per_page: typing.Optional[int] = 50,
900 include_totals: typing.Optional[bool] = True,
901 sort: typing.Optional[str] = None,
902 connection: typing.Optional[str] = None,
903 fields: typing.Optional[str] = None,
904 include_fields: typing.Optional[bool] = None,
905 q: typing.Optional[str] = None,
906 search_engine: typing.Optional[SearchEngineVersionsEnum] = None,
907 primary_order: typing.Optional[bool] = None,
908 request_options: typing.Optional[RequestOptions] = None,
909 ) -> AsyncPager[UserResponseSchema, ListUsersOffsetPaginatedResponseContent]:
910 """
911 Retrieve details of users. It is possible to:
912
913 - Specify a search criteria for users
914 - Sort the users to be returned
915 - Select the fields to be returned
916 - Specify the number of users to retrieve per page and the page index
917
918
919
920 The `q` query parameter can be used to get users that match the specified criteria [using query string syntax.](https://auth0.com/docs/users/search/v3/query-syntax)
921
922 [Learn more about searching for users.](https://auth0.com/docs/users/search/v3)
923
924 Read about [best practices](https://auth0.com/docs/users/search/best-practices) when working with the API endpoints for retrieving users.
925
926
927
928 Auth0 limits the number of users you can return. If you exceed this threshold, please redefine your search, use the [export job](https://auth0.com/docs/api/management/v2#!/Jobs/post_users_exports), or the [User Import / Export](https://auth0.com/docs/extensions/user-import-export) extension.
929
930 Parameters
931 ----------
932 page : typing.Optional[int]
933 Page index of the results to return. First page is 0.
934
935 per_page : typing.Optional[int]
936 Number of results per page.
937
938 include_totals : typing.Optional[bool]
939 Return results inside an object that contains the total result count (true) or as a direct array of results (false, default).
940
941 sort : typing.Optional[str]
942 Field to sort by. Use <code>field:order</code> where order is <code>1</code> for ascending and <code>-1</code> for descending. e.g. <code>created_at:1</code>
943
944 connection : typing.Optional[str]
945 Connection filter. Only applies when using <code>search_engine=v1</code>. To filter by connection with <code>search_engine=v2|v3</code>, use <code>q=identities.connection:"connection_name"</code>
946
947 fields : typing.Optional[str]
948 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.
949
950 include_fields : typing.Optional[bool]
951 Whether specified fields are to be included (true) or excluded (false).
952
953 q : typing.Optional[str]
954 Query in <a target='_new' href ='https://lucene.apache.org/core/2_9_4/queryparsersyntax.html'>Lucene query string syntax</a>. Some query types cannot be used on metadata fields, for details see <a href='https://auth0.com/docs/users/search/v3/query-syntax#searchable-fields'>Searchable Fields</a>.
955
956 search_engine : typing.Optional[SearchEngineVersionsEnum]
957 The version of the search engine
958
959 primary_order : typing.Optional[bool]
960 If true (default), results are returned in a deterministic order. If false, results may be returned in a non-deterministic order, which can enhance performance for complex queries targeting a small number of users. Set to false only when consistent ordering and pagination is not required.
961
962 request_options : typing.Optional[RequestOptions]
963 Request-specific configuration.
964
965 Returns
966 -------
967 AsyncPager[UserResponseSchema, ListUsersOffsetPaginatedResponseContent]
968 Users successfully retrieved.
969
970 Examples
971 --------
972 import asyncio
973
974 from auth0 import AsyncAuth0
975
976 client = AsyncAuth0(
977 token="YOUR_TOKEN",
978 )
979
980
981 async def main() -> None:
982 response = await client.users.list(
983 page=1,
984 per_page=1,
985 include_totals=True,
986 sort="sort",
987 connection="connection",
988 fields="fields",
989 include_fields=True,
990 q="q",
991 search_engine="v1",
992 primary_order=True,
993 )
994 async for item in response:
995 yield item
996
997 # alternatively, you can paginate page-by-page
998 async for page in response.iter_pages():
999 yield page
1000
1001
1002 asyncio.run(main())
1003 """
1004 return await self._raw_client.list(
1005 page=page,
1006 per_page=per_page,
1007 include_totals=include_totals,
1008 sort=sort,
1009 connection=connection,
1010 fields=fields,
1011 include_fields=include_fields,
1012 q=q,
1013 search_engine=search_engine,
1014 primary_order=primary_order,
1015 request_options=request_options,
1016 )
1017
1018 async def create(
1019 self,
1020 *,
1021 connection: str,
1022 email: typing.Optional[str] = OMIT,
1023 phone_number: typing.Optional[str] = OMIT,
1024 user_metadata: typing.Optional[UserMetadata] = OMIT,
1025 blocked: typing.Optional[bool] = OMIT,
1026 email_verified: typing.Optional[bool] = OMIT,
1027 phone_verified: typing.Optional[bool] = OMIT,
1028 app_metadata: typing.Optional[AppMetadata] = OMIT,
1029 given_name: typing.Optional[str] = OMIT,
1030 family_name: typing.Optional[str] = OMIT,
1031 name: typing.Optional[str] = OMIT,
1032 nickname: typing.Optional[str] = OMIT,
1033 picture: typing.Optional[str] = OMIT,
1034 user_id: typing.Optional[str] = OMIT,
1035 password: typing.Optional[str] = OMIT,
1036 verify_email: typing.Optional[bool] = OMIT,
1037 username: typing.Optional[str] = OMIT,
1038 request_options: typing.Optional[RequestOptions] = None,
1039 ) -> CreateUserResponseContent:
1040 """
1041 Create a new user for a given [database](https://auth0.com/docs/connections/database) or [passwordless](https://auth0.com/docs/connections/passwordless) connection.
1042
1043 Note: `connection` is required but other parameters such as `email` and `password` are dependent upon the type of connection.
1044
1045 Parameters
1046 ----------
1047 connection : str
1048 Name of the connection this user should be created in.
1049
1050 email : typing.Optional[str]
1051 The user's email.
1052
1053 phone_number : typing.Optional[str]
1054 The user's phone number (following the E.164 recommendation).
1055
1056 user_metadata : typing.Optional[UserMetadata]
1057
1058 blocked : typing.Optional[bool]
1059 Whether this user was blocked by an administrator (true) or not (false).
1060
1061 email_verified : typing.Optional[bool]
1062 Whether this email address is verified (true) or unverified (false). User will receive a verification email after creation if `email_verified` is false or not specified
1063
1064 phone_verified : typing.Optional[bool]
1065 Whether this phone number has been verified (true) or not (false).
1066
1067 app_metadata : typing.Optional[AppMetadata]
1068
1069 given_name : typing.Optional[str]
1070 The user's given name(s).
1071
1072 family_name : typing.Optional[str]
1073 The user's family name(s).
1074
1075 name : typing.Optional[str]
1076 The user's full name.
1077
1078 nickname : typing.Optional[str]
1079 The user's nickname.
1080
1081 picture : typing.Optional[str]
1082 A URI pointing to the user's picture.
1083
1084 user_id : typing.Optional[str]
1085 The external user's id provided by the identity provider.
1086
1087 password : typing.Optional[str]
1088 Initial password for this user. Only valid for auth0 connection strategy.
1089
1090 verify_email : typing.Optional[bool]
1091 Whether the user will receive a verification email after creation (true) or no email (false). Overrides behavior of `email_verified` parameter.
1092
1093 username : typing.Optional[str]
1094 The user's username. Only valid if the connection requires a username.
1095
1096 request_options : typing.Optional[RequestOptions]
1097 Request-specific configuration.
1098
1099 Returns
1100 -------
1101 CreateUserResponseContent
1102 User successfully created.
1103
1104 Examples
1105 --------
1106 import asyncio
1107
1108 from auth0 import AsyncAuth0
1109
1110 client = AsyncAuth0(
1111 token="YOUR_TOKEN",
1112 )
1113
1114
1115 async def main() -> None:
1116 await client.users.create(
1117 connection="connection",
1118 )
1119
1120
1121 asyncio.run(main())
1122 """
1123 _response = await self._raw_client.create(
1124 connection=connection,
1125 email=email,
1126 phone_number=phone_number,
1127 user_metadata=user_metadata,
1128 blocked=blocked,
1129 email_verified=email_verified,
1130 phone_verified=phone_verified,
1131 app_metadata=app_metadata,
1132 given_name=given_name,
1133 family_name=family_name,
1134 name=name,
1135 nickname=nickname,
1136 picture=picture,
1137 user_id=user_id,
1138 password=password,
1139 verify_email=verify_email,
1140 username=username,
1141 request_options=request_options,
1142 )
1143 return _response.data
1144
1145 async def list_users_by_email(
1146 self,
1147 *,
1148 email: str,
1149 fields: typing.Optional[str] = None,
1150 include_fields: typing.Optional[bool] = None,
1151 request_options: typing.Optional[RequestOptions] = None,
1152 ) -> typing.List[UserResponseSchema]:
1153 """
1154 Find users by email. If Auth0 is the identity provider (idP), the email address associated with a user is saved in lower case, regardless of how you initially provided it.
1155
1156 For example, if you register a user as [email protected], Auth0 saves the user's email as [email protected].
1157
1158 Therefore, when using this endpoint, make sure that you are searching for users via email addresses using the correct case.
1159
1160 Parameters
1161 ----------
1162 email : str
1163 Email address to search for (case-sensitive).
1164
1165 fields : typing.Optional[str]
1166 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.
1167
1168 include_fields : typing.Optional[bool]
1169 Whether specified fields are to be included (true) or excluded (false). Defaults to true.
1170
1171 request_options : typing.Optional[RequestOptions]
1172 Request-specific configuration.
1173
1174 Returns
1175 -------
1176 typing.List[UserResponseSchema]
1177 Users successfully searched.
1178
1179 Examples
1180 --------
1181 import asyncio
1182
1183 from auth0 import AsyncAuth0
1184
1185 client = AsyncAuth0(
1186 token="YOUR_TOKEN",
1187 )
1188
1189
1190 async def main() -> None:
1191 await client.users.list_users_by_email(
1192 fields="fields",
1193 include_fields=True,
1194 email="email",
1195 )
1196
1197
1198 asyncio.run(main())
1199 """
1200 _response = await self._raw_client.list_users_by_email(
1201 email=email, fields=fields, include_fields=include_fields, request_options=request_options
1202 )
1203 return _response.data
1204
1205 async def get(
1206 self,
1207 id: str,
1208 *,
1209 fields: typing.Optional[str] = None,
1210 include_fields: typing.Optional[bool] = None,
1211 request_options: typing.Optional[RequestOptions] = None,
1212 ) -> GetUserResponseContent:
1213 """
1214 Retrieve user details. A list of fields to include or exclude may also be specified. For more information, see [Retrieve Users with the Get Users Endpoint](https://auth0.com/docs/manage-users/user-search/retrieve-users-with-get-users-endpoint).
1215
1216 Parameters
1217 ----------
1218 id : str
1219 ID of the user to retrieve.
1220
1221 fields : typing.Optional[str]
1222 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.
1223
1224 include_fields : typing.Optional[bool]
1225 Whether specified fields are to be included (true) or excluded (false).
1226
1227 request_options : typing.Optional[RequestOptions]
1228 Request-specific configuration.
1229
1230 Returns
1231 -------
1232 GetUserResponseContent
1233 User successfully retrieved.
1234
1235 Examples
1236 --------
1237 import asyncio
1238
1239 from auth0 import AsyncAuth0
1240
1241 client = AsyncAuth0(
1242 token="YOUR_TOKEN",
1243 )
1244
1245
1246 async def main() -> None:
1247 await client.users.get(
1248 id="id",
1249 fields="fields",
1250 include_fields=True,
1251 )
1252
1253
1254 asyncio.run(main())
1255 """
1256 _response = await self._raw_client.get(
1257 id, fields=fields, include_fields=include_fields, request_options=request_options
1258 )
1259 return _response.data
1260
1261 async def delete(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None:
1262 """
1263 Delete a user by user ID. This action cannot be undone. For Auth0 Dashboard instructions, see [Delete Users](https://auth0.com/docs/manage-users/user-accounts/delete-users).
1264
1265 Parameters
1266 ----------
1267 id : str
1268 ID of the user to delete.
1269
1270 request_options : typing.Optional[RequestOptions]
1271 Request-specific configuration.
1272
1273 Returns
1274 -------
1275 None
1276
1277 Examples
1278 --------
1279 import asyncio
1280
1281 from auth0 import AsyncAuth0
1282
1283 client = AsyncAuth0(
1284 token="YOUR_TOKEN",
1285 )
1286
1287
1288 async def main() -> None:
1289 await client.users.delete(
1290 id="id",
1291 )
1292
1293
1294 asyncio.run(main())
1295 """
1296 _response = await self._raw_client.delete(id, request_options=request_options)
1297 return _response.data
1298
1299 async def update(
1300 self,
1301 id: str,
1302 *,
1303 blocked: typing.Optional[bool] = OMIT,
1304 email_verified: typing.Optional[bool] = OMIT,
1305 email: typing.Optional[str] = OMIT,
1306 phone_number: typing.Optional[str] = OMIT,
1307 phone_verified: typing.Optional[bool] = OMIT,
1308 user_metadata: typing.Optional[UserMetadata] = OMIT,
1309 app_metadata: typing.Optional[AppMetadata] = OMIT,
1310 given_name: typing.Optional[str] = OMIT,
1311 family_name: typing.Optional[str] = OMIT,
1312 name: typing.Optional[str] = OMIT,
1313 nickname: typing.Optional[str] = OMIT,
1314 picture: typing.Optional[str] = OMIT,
1315 verify_email: typing.Optional[bool] = OMIT,
1316 verify_phone_number: typing.Optional[bool] = OMIT,
1317 password: typing.Optional[str] = OMIT,
1318 connection: typing.Optional[str] = OMIT,
1319 client_id: typing.Optional[str] = OMIT,
1320 username: typing.Optional[str] = OMIT,
1321 request_options: typing.Optional[RequestOptions] = None,
1322 ) -> UpdateUserResponseContent:
1323 """
1324 Update a user.
1325
1326 These are the attributes that can be updated at the root level:
1327
1328 - app_metadata
1329 - blocked
1330 - email
1331 - email_verified
1332 - family_name
1333 - given_name
1334 - name
1335 - nickname
1336 - password
1337 - phone_number
1338 - phone_verified
1339 - picture
1340 - username
1341 - user_metadata
1342 - verify_email
1343
1344 Some considerations:
1345
1346 - The properties of the new object will replace the old ones.
1347 - The metadata fields are an exception to this rule (`user_metadata` and `app_metadata`). These properties are merged instead of being replaced but be careful, the merge only occurs on the first level.
1348 - If you are updating `email`, `email_verified`, `phone_number`, `phone_verified`, `username` or `password` of a secondary identity, you need to specify the `connection` property too.
1349 - If you are updating `email` or `phone_number` you can specify, optionally, the `client_id` property.
1350 - Updating `email_verified` is not supported for enterprise and passwordless sms connections.
1351 - Updating the `blocked` to `false` does not affect the user's blocked state from an excessive amount of incorrectly provided credentials. Use the "Unblock a user" endpoint from the "User Blocks" API to change the user's state.
1352 - Supported attributes can be unset by supplying `null` as the value.
1353
1354 **Updating a field (non-metadata property)**
1355
1356 To mark the email address of a user as verified, the body to send should be:
1357
1358 ```json
1359 { "email_verified": true }
1360 ```
1361
1362 **Updating a user metadata root property**
1363
1364 Let's assume that our test user has the following `user_metadata`:
1365
1366 ```json
1367 { "user_metadata" : { "profileCode": 1479 } }
1368 ```
1369
1370 To add the field `addresses` the body to send should be:
1371
1372 ```json
1373 { "user_metadata" : { "addresses": {"work_address": "100 Industrial Way"} }}
1374 ```
1375
1376 The modified object ends up with the following `user_metadata` property:
1377
1378 ```json
1379 {
1380 "user_metadata": {
1381 "profileCode": 1479,
1382 "addresses": { "work_address": "100 Industrial Way" }
1383 }
1384 }
1385 ```
1386
1387 **Updating an inner user metadata property**
1388
1389 If there's existing user metadata to which we want to add `"home_address": "742 Evergreen Terrace"` (using the `addresses` property) we should send the whole `addresses` object. Since this is a first-level object, the object will be merged in, but its own properties will not be. The body to send should be:
1390
1391 ```json
1392 {
1393 "user_metadata": {
1394 "addresses": {
1395 "work_address": "100 Industrial Way",
1396 "home_address": "742 Evergreen Terrace"
1397 }
1398 }
1399 }
1400 ```
1401
1402 The modified object ends up with the following `user_metadata` property:
1403
1404 ```json
1405 {
1406 "user_metadata": {
1407 "profileCode": 1479,
1408 "addresses": {
1409 "work_address": "100 Industrial Way",
1410 "home_address": "742 Evergreen Terrace"
1411 }
1412 }
1413 }
1414 ```
1415
1416 Parameters
1417 ----------
1418 id : str
1419 ID of the user to update.
1420
1421 blocked : typing.Optional[bool]
1422 Whether this user was blocked by an administrator (true) or not (false).
1423
1424 email_verified : typing.Optional[bool]
1425 Whether this email address is verified (true) or unverified (false). If set to false the user will not receive a verification email unless `verify_email` is set to true.
1426
1427 email : typing.Optional[str]
1428 Email address of this user.
1429
1430 phone_number : typing.Optional[str]
1431 The user's phone number (following the E.164 recommendation).
1432
1433 phone_verified : typing.Optional[bool]
1434 Whether this phone number has been verified (true) or not (false).
1435
1436 user_metadata : typing.Optional[UserMetadata]
1437 User metadata to which this user has read/write access.
1438
1439 app_metadata : typing.Optional[AppMetadata]
1440 User metadata to which this user has read-only access.
1441
1442 given_name : typing.Optional[str]
1443 Given name/first name/forename of this user.
1444
1445 family_name : typing.Optional[str]
1446 Family name/last name/surname of this user.
1447
1448 name : typing.Optional[str]
1449 Name of this user.
1450
1451 nickname : typing.Optional[str]
1452 Preferred nickname or alias of this user.
1453
1454 picture : typing.Optional[str]
1455 URL to picture, photo, or avatar of this user.
1456
1457 verify_email : typing.Optional[bool]
1458 Whether this user will receive a verification email after creation (true) or no email (false). Overrides behavior of `email_verified` parameter.
1459
1460 verify_phone_number : typing.Optional[bool]
1461 Whether this user will receive a text after changing the phone number (true) or no text (false). Only valid when changing phone number for SMS connections.
1462
1463 password : typing.Optional[str]
1464 New password for this user. Only valid for database connections.
1465
1466 connection : typing.Optional[str]
1467 Name of the connection to target for this user update.
1468
1469 client_id : typing.Optional[str]
1470 Auth0 client ID. Only valid when updating email address.
1471
1472 username : typing.Optional[str]
1473 The user's username. Only valid if the connection requires a username.
1474
1475 request_options : typing.Optional[RequestOptions]
1476 Request-specific configuration.
1477
1478 Returns
1479 -------
1480 UpdateUserResponseContent
1481 User successfully updated.
1482
1483 Examples
1484 --------
1485 import asyncio
1486
1487 from auth0 import AsyncAuth0
1488
1489 client = AsyncAuth0(
1490 token="YOUR_TOKEN",
1491 )
1492
1493
1494 async def main() -> None:
1495 await client.users.update(
1496 id="id",
1497 )
1498
1499
1500 asyncio.run(main())
1501 """
1502 _response = await self._raw_client.update(
1503 id,
1504 blocked=blocked,
1505 email_verified=email_verified,
1506 email=email,
1507 phone_number=phone_number,
1508 phone_verified=phone_verified,
1509 user_metadata=user_metadata,
1510 app_metadata=app_metadata,
1511 given_name=given_name,
1512 family_name=family_name,
1513 name=name,
1514 nickname=nickname,
1515 picture=picture,
1516 verify_email=verify_email,
1517 verify_phone_number=verify_phone_number,
1518 password=password,
1519 connection=connection,
1520 client_id=client_id,
1521 username=username,
1522 request_options=request_options,
1523 )
1524 return _response.data
1525
1526 async def regenerate_recovery_code(
1527 self, id: str, *, request_options: typing.Optional[RequestOptions] = None
1528 ) -> RegenerateUsersRecoveryCodeResponseContent:
1529 """
1530 Remove an existing multi-factor authentication (MFA) [recovery code](https://auth0.com/docs/secure/multi-factor-authentication/reset-user-mfa) and generate a new one. If a user cannot access the original device or account used for MFA enrollment, they can use a recovery code to authenticate.
1531
1532 Parameters
1533 ----------
1534 id : str
1535 ID of the user to regenerate a multi-factor authentication recovery code for.
1536
1537 request_options : typing.Optional[RequestOptions]
1538 Request-specific configuration.
1539
1540 Returns
1541 -------
1542 RegenerateUsersRecoveryCodeResponseContent
1543 New recovery code successfully generated.
1544
1545 Examples
1546 --------
1547 import asyncio
1548
1549 from auth0 import AsyncAuth0
1550
1551 client = AsyncAuth0(
1552 token="YOUR_TOKEN",
1553 )
1554
1555
1556 async def main() -> None:
1557 await client.users.regenerate_recovery_code(
1558 id="id",
1559 )
1560
1561
1562 asyncio.run(main())
1563 """
1564 _response = await self._raw_client.regenerate_recovery_code(id, request_options=request_options)
1565 return _response.data
1566
1567 async def revoke_access(
1568 self,
1569 id: str,
1570 *,
1571 session_id: typing.Optional[str] = OMIT,
1572 preserve_refresh_tokens: typing.Optional[bool] = OMIT,
1573 request_options: typing.Optional[RequestOptions] = None,
1574 ) -> None:
1575 """
1576 Revokes selected resources related to a user (sessions, refresh tokens, ...).
1577
1578 Parameters
1579 ----------
1580 id : str
1581 ID of the user.
1582
1583 session_id : typing.Optional[str]
1584 ID of the session to revoke.
1585
1586 preserve_refresh_tokens : typing.Optional[bool]
1587 Whether to preserve the refresh tokens associated with the session.
1588
1589 request_options : typing.Optional[RequestOptions]
1590 Request-specific configuration.
1591
1592 Returns
1593 -------
1594 None
1595
1596 Examples
1597 --------
1598 import asyncio
1599
1600 from auth0 import AsyncAuth0
1601
1602 client = AsyncAuth0(
1603 token="YOUR_TOKEN",
1604 )
1605
1606
1607 async def main() -> None:
1608 await client.users.revoke_access(
1609 id="id",
1610 )
1611
1612
1613 asyncio.run(main())
1614 """
1615 _response = await self._raw_client.revoke_access(
1616 id, session_id=session_id, preserve_refresh_tokens=preserve_refresh_tokens, request_options=request_options
1617 )
1618 return _response.data
1619
1620 @property
1621 def authentication_methods(self):
1622 if self._authentication_methods is None:
1623 from .authentication_methods.client import AsyncAuthenticationMethodsClient # noqa: E402
1624
1625 self._authentication_methods = AsyncAuthenticationMethodsClient(client_wrapper=self._client_wrapper)
1626 return self._authentication_methods
1627
1628 @property
1629 def authenticators(self):
1630 if self._authenticators is None:
1631 from .authenticators.client import AsyncAuthenticatorsClient # noqa: E402
1632
1633 self._authenticators = AsyncAuthenticatorsClient(client_wrapper=self._client_wrapper)
1634 return self._authenticators
1635
1636 @property
1637 def connected_accounts(self):
1638 if self._connected_accounts is None:
1639 from .connected_accounts.client import AsyncConnectedAccountsClient # noqa: E402
1640
1641 self._connected_accounts = AsyncConnectedAccountsClient(client_wrapper=self._client_wrapper)
1642 return self._connected_accounts
1643
1644 @property
1645 def effective_permissions(self):
1646 if self._effective_permissions is None:
1647 from .effective_permissions.client import AsyncEffectivePermissionsClient # noqa: E402
1648
1649 self._effective_permissions = AsyncEffectivePermissionsClient(client_wrapper=self._client_wrapper)
1650 return self._effective_permissions
1651
1652 @property
1653 def effective_roles(self):
1654 if self._effective_roles is None:
1655 from .effective_roles.client import AsyncEffectiveRolesClient # noqa: E402
1656
1657 self._effective_roles = AsyncEffectiveRolesClient(client_wrapper=self._client_wrapper)
1658 return self._effective_roles
1659
1660 @property
1661 def enrollments(self):
1662 if self._enrollments is None:
1663 from .enrollments.client import AsyncEnrollmentsClient # noqa: E402
1664
1665 self._enrollments = AsyncEnrollmentsClient(client_wrapper=self._client_wrapper)
1666 return self._enrollments
1667
1668 @property
1669 def groups(self):
1670 if self._groups is None:
1671 from .groups.client import AsyncGroupsClient # noqa: E402
1672
1673 self._groups = AsyncGroupsClient(client_wrapper=self._client_wrapper)
1674 return self._groups
1675
1676 @property
1677 def identities(self):
1678 if self._identities is None:
1679 from .identities.client import AsyncIdentitiesClient # noqa: E402
1680
1681 self._identities = AsyncIdentitiesClient(client_wrapper=self._client_wrapper)
1682 return self._identities
1683
1684 @property
1685 def logs(self):
1686 if self._logs is None:
1687 from .logs.client import AsyncLogsClient # noqa: E402
1688
1689 self._logs = AsyncLogsClient(client_wrapper=self._client_wrapper)
1690 return self._logs
1691
1692 @property
1693 def multifactor(self):
1694 if self._multifactor is None:
1695 from .multifactor.client import AsyncMultifactorClient # noqa: E402
1696
1697 self._multifactor = AsyncMultifactorClient(client_wrapper=self._client_wrapper)
1698 return self._multifactor
1699
1700 @property
1701 def organizations(self):
1702 if self._organizations is None:
1703 from .organizations.client import AsyncOrganizationsClient # noqa: E402
1704
1705 self._organizations = AsyncOrganizationsClient(client_wrapper=self._client_wrapper)
1706 return self._organizations
1707
1708 @property
1709 def permissions(self):
1710 if self._permissions is None:
1711 from .permissions.client import AsyncPermissionsClient # noqa: E402
1712
1713 self._permissions = AsyncPermissionsClient(client_wrapper=self._client_wrapper)
1714 return self._permissions
1715
1716 @property
1717 def risk_assessments(self):
1718 if self._risk_assessments is None:
1719 from .risk_assessments.client import AsyncRiskAssessmentsClient # noqa: E402
1720
1721 self._risk_assessments = AsyncRiskAssessmentsClient(client_wrapper=self._client_wrapper)
1722 return self._risk_assessments
1723
1724 @property
1725 def roles(self):
1726 if self._roles is None:
1727 from .roles.client import AsyncRolesClient # noqa: E402
1728
1729 self._roles = AsyncRolesClient(client_wrapper=self._client_wrapper)
1730 return self._roles
1731
1732 @property
1733 def refresh_token(self):
1734 if self._refresh_token is None:
1735 from .refresh_token.client import AsyncRefreshTokenClient # noqa: E402
1736
1737 self._refresh_token = AsyncRefreshTokenClient(client_wrapper=self._client_wrapper)
1738 return self._refresh_token
1739
1740 @property
1741 def sessions(self):
1742 if self._sessions is None:
1743 from .sessions.client import AsyncSessionsClient # noqa: E402
1744
1745 self._sessions = AsyncSessionsClient(client_wrapper=self._client_wrapper)
1746 return self._sessions