Spaces:
Paused
Paused
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) | |
class Config: | |
populate_by_name = True | |
json_schema_extra = { | |
"example": { | |
"user_id": "65ede65b6d246e52aaba9d4f", | |
"name": "benjolo", | |
"email": "[email protected]" | |
} | |
} | |
'''Class for updating user records''' | |
class UpdateUser(BaseModel): | |
user_id: Optional[str] = None | |
name: Optional[str] = None | |
email: Optional[EmailStr] = None | |
class Config: | |
populate_by_name = True | |
json_schema_extra = { | |
"example": { | |
"email": "[email protected]" | |
} | |
} | |