Spaces:
Paused
Paused
File size: 1,503 Bytes
2da7ed3 |
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 39 40 41 42 43 44 45 |
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",
"password": "therealbenjolo",
"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"]
}
}
|