import uuid from typing import List, Optional from pydantic import BaseModel, Field, SecretStr, PrivateAttr from pydantic.networks import EmailStr '''Class for user model used to relate users to past calls''' class User(BaseModel): _id: uuid.UUID = PrivateAttr(default_factory=uuid.uuid4) # private attr not included in http calls user_id: str name: str email: EmailStr = Field(unique=True, index=True) # password: SecretStr call_ids: Optional[List[str]] = None class Config: populate_by_name = True json_schema_extra = { "example": { "user_id": "65ede65b6d246e52aaba9d4f", "name": "benjolo", "email": "benjolounchained@gmail.com", "call_ids": ["65e205ced1be3a22854ff300", "65df8c3eba9c7c2ed1b20e85"] } } '''Class for updating user records''' class UpdateUser(BaseModel): user_id: Optional[str] = None name: Optional[str] = None email: Optional[EmailStr] = None ''' To decode use -> SecretStr("abc").get_secret_value()''' # password: Optional[SecretStr] call_ids: Optional[List[str]] = None class Config: populate_by_name = True json_schema_extra = { "example": { "email": "benjolounchained21@gmail.com", "call_ids": ["65e205ced1be3a22854ff300", "65df8c3eba9c7c2ed1b20e85", "65eef930e9abd3b1e3506906"] } }