Spaces:
Paused
Paused
File size: 1,052 Bytes
ddc5bbd |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
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]"
}
}
|