
    Eoh	                         d dl Z d dlmZmZ d dlmZ d dlmZ d dlm	Z	 d dl
mZ d dlmZmZ dZd	 Z G d
 de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Zy)    N)ListOptional)Query)	validator)Field)	BaseModel)PermissionBaseRoleBasez^[a-zA-Z0-9_-]+$c                 2    t        j                  ||       d uS )N)rematch)valuepatterns     c/var/www/html/wine-match-dev/backend/winematch-backend/src/apps/role_permission/schemas/requests.pytestr      s    88GU#4//    c                       e Zd Zy)PermissionCreateRequestSchemaN__name__
__module____qualname__ r   r   r   r          r   r   c                       e Zd Zy)PermissionUpdateRequestSchemaNr   r   r   r   r   r      r   r   r   c                       e Zd ZU  ed      Zeed<    ed      Zee	   ed<    edd      Z
eee      ed<    ed      d	        Zy)
RoleCreateRequestSchemaz=Label for the role, inclusive of alphanumeric characters onlydescriptionlabel<List of permission ids that need to be mapped with this rolepermissionsNUnique IDs of the users.usersc                     d}|rCt        |      |kD  rt        d| d      |D ]!  }t        |t              rt        d| d       |S N
   zYou can provide atmost of z user ids at once'z' is not a valid user idlen
ValueErrorr   USER_UNIQUE_IDclsv	max_limititems       r   validate_usersz&RoleCreateRequestSchema.validate_users    c    	1v	! #=i[HY!Z[[ ID.1$q.F%GHHI r   )r   r   r   r   r!   str__annotations__r#   r   intr%   r   r   r3   r   r   r   r   r      sX    #bcE3c"/mnKcn!&t9S!TE8DITw r   r   c                   L    e Zd ZU  ed      Zeed<    ed      Zee	   ed<   y)RoleAssignRequestSchemazUnique ID of the user.r   user_idz6List of role ids that need to be mapped with this userrole_idsN)
r   r   r   r   r:   r5   r6   r;   r   r7   r   r   r   r9   r9   ,   s&    %=>GS>,deHd3ier   r9   c                   ~    e Zd ZU  edd      Zeee      ed<    edd      Z	eee
      ed<    ed      d        Zy)RoleUpdateRequestSchemaNr"   r   r#   r$   r%   c                     d}|rCt        |      |kD  rt        d| d      |D ]!  }t        |t              rt        d| d       |S r'   r*   r.   s       r   r3   z&RoleUpdateRequestSchema.validate_users7   r4   r   )r   r   r   r   r#   r   r   r7   r6   r%   r5   r   r3   r   r   r   r=   r=   1   sV    ',X(K$s)$  "'t9S!TE8DITw r   r=   c                   F    e Zd ZU dZee   ed<    edd      Zee	   ed<   y)RoleListFilterSchemaNsearchTzUIf true, it will show all roles including the ones that are not assigned to any user.r   show_all_roles)
r   r   r   rA   r   r5   r6   r   rB   boolr   r   r   r@   r@   C   s+     FHSM %*k&NHTN r   r@   c                   "    e Zd ZU dZee   ed<   y)PermissionListFilterSchemaNrA   )r   r   r   rA   r   r5   r6   r   r   r   rE   rE   K   s     FHSM r   rE   )r   typingr   r   fastapi.param_functionsr   pydanticr   pydantic.fieldsr   pydantic.mainr   'src.apps.role_permission.schemas.commonr	   r
   r-   r   r   r   r   r9   r=   r@   rE   r   r   r   <module>rL      s|    	 ! )  ! # L %0	N 		N 	h "fi f
h $9 ! !r   