36 lines
711 B
Python
36 lines
711 B
Python
"""Settings schemas."""
|
|
|
|
from pydantic import BaseModel
|
|
from typing import Optional, Any
|
|
from datetime import datetime
|
|
|
|
|
|
class SettingBase(BaseModel):
|
|
"""Base setting schema."""
|
|
key: str
|
|
value: Any
|
|
|
|
|
|
class SettingUpdate(BaseModel):
|
|
"""Schema for updating a setting."""
|
|
value: Any
|
|
|
|
|
|
class Setting(BaseModel):
|
|
"""Setting schema for responses."""
|
|
key: str
|
|
value: Any
|
|
updated_at: datetime
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
@classmethod
|
|
def from_orm(cls, obj):
|
|
"""Custom from_orm to handle value extraction."""
|
|
return cls(
|
|
key=obj.key,
|
|
value=obj.get_value(),
|
|
updated_at=obj.updated_at
|
|
)
|