Add basic internal message model

This commit is contained in:
Esa Kataja
2025-02-28 12:41:32 +02:00
parent 0b4d2cfaf3
commit 7ef953e491
+19
View File
@@ -0,0 +1,19 @@
from pydantic import BaseModel, Field
from datetime import datetime
from enum import Enum
class msg_types(Enum):
info = "info"
warning = "warning"
error = "error"
class Msg(BaseModel):
msg: str = Field(..., description="Message. Required.", examples=["Hello, world!"])
type: msg_types = Field(default=msg_types.info)
timestamp: datetime = Field(
default_factory=datetime.now().astimezone,
description="Timestamp. Defaults to current time.",
examples=[datetime.now().astimezone()],
)