From 2d0f1ba57269bc4024ec182ef4ad465f5ab947a5 Mon Sep 17 00:00:00 2001 From: demo-bot Date: Sun, 9 Aug 2026 15:52:18 +0000 Subject: [PATCH] decomposer: generate deliverable files for Define the service contract and project architecture for the FastAPI endpoint monitoring service.; Implement the typed monitor CRUD API and concurrency-safe in-memory state according to the service design.; Implement secure on-demand endpoint checks with status updates, latency measurement, robust error handling, and redacted structured logs.; Add operational API endpoints and environment-driven runtime configuration to the monitoring service.; Create automated tests for the monitoring service.; Package the service with Docker and developer documentation.; Validate the complete project. --- src/endpoint_monitor/models.py | 54 ++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 src/endpoint_monitor/models.py diff --git a/src/endpoint_monitor/models.py b/src/endpoint_monitor/models.py new file mode 100644 index 0000000..757c955 --- /dev/null +++ b/src/endpoint_monitor/models.py @@ -0,0 +1,54 @@ +from datetime import datetime +from enum import Enum +from uuid import UUID + +from pydantic import AnyHttpUrl, BaseModel, ConfigDict, Field + + +class MonitorStatus(str, Enum): + UNKNOWN = "unknown" + UP = "up" + DOWN = "down" + ERROR = "error" + + +class MonitorCreate(BaseModel): + name: str = Field(min_length=1, max_length=100, pattern=r".*\S.*") + url: AnyHttpUrl + + +class MonitorUpdate(BaseModel): + name: str | None = Field(default=None, min_length=1, max_length=100, pattern=r".*\S.*") + url: AnyHttpUrl | None = None + + +class CheckResult(BaseModel): + status: MonitorStatus + checked_at: datetime + latency_ms: float = Field(ge=0) + http_status: int | None = None + final_url: str | None = None + detail: str | None = Field(default=None, max_length=300) + + +class Monitor(BaseModel): + model_config = ConfigDict(from_attributes=True) + + id: UUID + name: str + url: AnyHttpUrl + created_at: datetime + updated_at: datetime + revision: int + status: MonitorStatus = MonitorStatus.UNKNOWN + last_check: CheckResult | None = None + + +class StatusView(BaseModel): + id: UUID + status: MonitorStatus + last_check: CheckResult | None + + +class Health(BaseModel): + status: str