from typing import Annotated from pydantic import BaseModel, EmailStr, Field class Base(BaseModel): pass class PermissionOut(Base): id: int permission: str model_config = {"from_attributes": True} class PermissionIn(Base): permission: str model_config = {"from_attributes": True} class UserOut(Base): id:int=Field(..., description="Id of the user") name:str=Field(...,max_length=64, description="name of the user") last_name:str=Field(...,max_length=64, description="Last name of the user") middle_name:str = Field(..., max_length=64, description="middle name of the user") email:EmailStr = Field(...,max_length=255, description="email of the user") status:bool = Field(..., description="status of the user") permissions:list[PermissionOut] = Field(..., description="permissions of the user") model_config = {"from_attributes": True} class UserCreate(Base): name:str=Field(...,max_length=64, description="name of the user") last_name:str=Field(...,max_length=64,description="Last name of the user") middle_name:str = Field(...,max_length=64, description="middle name of the user") email:EmailStr = Field(...,max_length=255, min_length=5, description="email of the user") plain_password:str=Field(...,min_length=8, max_length=72, description="plain password of the user") permissions:list[PermissionIn] = Field(..., description="permissions of the user") class UserUpdate(Base): name:Annotated[str|None, Field(None,max_length=64, description="name of the user")] last_name:Annotated[str|None, Field(None,max_length=64,description="Last name of the user")] middle_name:Annotated[str|None, Field(None,max_length=64, description="middle name of the user")] email:Annotated[EmailStr|None, Field(None,max_length=255, min_length=5, description="email of the user")] plain_password:Annotated[str|None, Field(None,min_length=8, max_length=72, description="plain password of the user")] permissions:Annotated[list[PermissionIn]|None, Field(None, description="permissions of the user")] target_id:Annotated[int|None, Field(None, description="Id of the being updated user")] status:Annotated[bool|None, Field(None,description="status of the account")]