@@ -32,6 +32,7 @@ def create(
3232 invite_url : Optional [str ] = None ,
3333 additional_login_ids : Optional [List [str ]] = None ,
3434 sso_app_ids : Optional [List [str ]] = None ,
35+ status : Optional [str ] = None ,
3536 ) -> dict :
3637 """
3738 Create a new user. Users can have any number of optional fields, including email, phone number and authorization.
@@ -48,6 +49,7 @@ def create(
4849 picture (str): Optional url for user picture
4950 custom_attributes (dict): Optional, set the different custom attributes values of the keys that were previously configured in Descope console app
5051 sso_app_ids (List[str]): Optional, list of SSO applications IDs to be associated with the user.
52+ status (str): Optional status field. Can be one of: "enabled", "disabled", "invited", "expired".
5153
5254 Return value (dict):
5355 Return dict in the format
@@ -57,6 +59,7 @@ def create(
5759 Raise:
5860 AuthException: raised if create operation fails
5961 """
62+ UserBase ._validate_status (status )
6063 role_names = [] if role_names is None else role_names
6164 user_tenants = [] if user_tenants is None else user_tenants
6265
@@ -83,6 +86,7 @@ def create(
8386 None ,
8487 additional_login_ids ,
8588 sso_app_ids ,
89+ status = status ,
8690 ),
8791 )
8892 return response .json ()
@@ -389,17 +393,7 @@ def patch(
389393 Raise:
390394 AuthException: raised if patch operation fails
391395 """
392- if status is not None and status not in [
393- "enabled" ,
394- "disabled" ,
395- "invited" ,
396- "expired" ,
397- ]:
398- raise AuthException (
399- 400 ,
400- ERROR_TYPE_INVALID_ARGUMENT ,
401- f"Invalid status value: { status } . Must be one of: enabled, disabled, invited, expired" ,
402- )
396+ UserBase ._validate_status (status )
403397 response = self ._http .patch (
404398 MgmtV1 .user_patch_path ,
405399 body = UserBase ._compose_patch_body (
@@ -445,19 +439,8 @@ def patch_batch(
445439 Raise:
446440 AuthException: raised if patch batch operation fails
447441 """
448- # Validate status fields for all users
449442 for user in users :
450- if user .status is not None and user .status not in [
451- "enabled" ,
452- "disabled" ,
453- "invited" ,
454- "expired" ,
455- ]:
456- raise AuthException (
457- 400 ,
458- ERROR_TYPE_INVALID_ARGUMENT ,
459- f"Invalid status value: { user .status } for user { user .login_id } . Must be one of: enabled, disabled, invited, expired" ,
460- )
443+ UserBase ._validate_status (user .status , user .login_id )
461444
462445 response = self ._http .patch (
463446 MgmtV1 .user_patch_batch_path ,
0 commit comments