Initial solution: add models.py

This commit is contained in:
2026-06-10 09:57:03 +00:00
parent fedd46e98b
commit 0cc43ea669
+27
View File
@@ -0,0 +1,27 @@
from __future__ import annotations
from typing import Annotated, Literal, Union
from pydantic import BaseModel, Field
class HttpOkEvent(BaseModel):
kind: Literal["ok"] = Field("ok", description="Discriminator for OK events")
status: Literal[200] = Field(200, description="HTTP status code for success")
path: str = Field(..., description="Requested path")
duration_ms: int = Field(..., description="Duration of the request in milliseconds")
class HttpErrorEvent(BaseModel):
kind: Literal["error"] = Field("error", description="Discriminator for error events")
status: int = Field(..., description="HTTP status code for error (4xx/5xx)")
path: str = Field(..., description="Requested path")
error_message: str = Field(..., description="Error message returned by the server")
ApiEvent = Annotated[
Union[HttpOkEvent, HttpErrorEvent],
Field(discriminator="kind")
]
__all__ = ["HttpOkEvent", "HttpErrorEvent", "ApiEvent"]