0.1.1
This commit is contained in:
52
src/models/pydantic_models/model.py
Normal file
52
src/models/pydantic_models/model.py
Normal file
@@ -0,0 +1,52 @@
|
||||
from typing import Annotated
|
||||
from pydantic import BaseModel, EmailStr, Field
|
||||
from uuid import UUID
|
||||
|
||||
|
||||
class Base(BaseModel):
|
||||
pass
|
||||
|
||||
class UserCreate(Base):
|
||||
|
||||
first_name:Annotated[str, Field(..., max_length=64,description="first name of the user")]
|
||||
last_name:Annotated[str, Field(...,max_length=64, description="last name of the user")]
|
||||
middle_name:Annotated[str, Field(...,max_length=64, description="middle name of the user")]
|
||||
email:Annotated[EmailStr, Field(...,min_length=5, max_length=255, description="email of the user")]
|
||||
plain_password:Annotated[str, Field(...,min_length=8,max_length=72, description="plain password of the user")]
|
||||
status:Annotated[bool, Field(..., description="status of the user")]
|
||||
permissions:Annotated[list[str], Field(..., description="permissions of the user")]
|
||||
permission_groups:Annotated[list[str], Field(..., description="permissions groups of the user")]
|
||||
|
||||
class UserOut(Base):
|
||||
|
||||
id:Annotated[UUID, Field(..., description="Id of the user")]
|
||||
first_name:Annotated[str, Field(..., max_length=64,description="first name of the user")]
|
||||
last_name:Annotated[str, Field(..., max_length=64,description="last name of the user")]
|
||||
middle_name:Annotated[str, Field(..., max_length=64, description="middle name of the user")]
|
||||
email:Annotated[EmailStr, Field(...,min_length=5, max_length=255, description="email of the user")]
|
||||
status:Annotated[bool, Field(..., description="status of the user")]
|
||||
permissions:Annotated[list[str], Field(..., description="permissions of the user")]
|
||||
permission_groups:Annotated[list[str], Field(..., description="permissions groups of the user")]
|
||||
|
||||
model_config = {"from_attributes": True}
|
||||
|
||||
class UserUpdate(Base):
|
||||
|
||||
first_name:Annotated[str|None, Field(None, max_length=64, description="first 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, min_length=5, max_length=255, description="email of the user")]
|
||||
status:Annotated[bool|None, Field(None, description="status of the user")]
|
||||
permissions:Annotated[list[str]|None, Field(None, description="permissions of the user")]
|
||||
permission_groups:Annotated[list[str]|None, Field(None, description="permissions groups of the user")]
|
||||
|
||||
class Permissions(Base):
|
||||
id:int
|
||||
permission_name:Annotated[str, Field(..., max_length=30, description="permission name")]
|
||||
|
||||
model_config = {"from_attributes": True}
|
||||
|
||||
class PermissionsOut(Base):
|
||||
permission_name:Annotated[str, Field(..., max_length=30, description="permission name")]
|
||||
|
||||
model_config = {"from_attributes": True}
|
||||
Reference in New Issue
Block a user