mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-29 19:35:20 +02:00
automations(api): API request/response schemas
This commit is contained in:
parent
dd6bc30f98
commit
84d99f19a2
5 changed files with 189 additions and 3 deletions
50
surfsense_backend/app/automations/api/schemas/run.py
Normal file
50
surfsense_backend/app/automations/api/schemas/run.py
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
"""Response schemas for run sub-resources and run dispatch."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import datetime
|
||||
from typing import Any
|
||||
|
||||
from pydantic import BaseModel, ConfigDict
|
||||
|
||||
from app.automations.persistence.enums.run_status import RunStatus
|
||||
|
||||
|
||||
class RunSummary(BaseModel):
|
||||
"""Lightweight run view for list endpoints."""
|
||||
|
||||
model_config = ConfigDict(from_attributes=True)
|
||||
|
||||
id: int
|
||||
automation_id: int
|
||||
trigger_id: int | None = None
|
||||
status: RunStatus
|
||||
started_at: datetime | None = None
|
||||
finished_at: datetime | None = None
|
||||
created_at: datetime
|
||||
|
||||
|
||||
class RunDetail(RunSummary):
|
||||
"""Full run view including snapshot, results and artifacts."""
|
||||
|
||||
definition_snapshot: dict[str, Any]
|
||||
trigger_payload: dict[str, Any] | None = None
|
||||
resolved_inputs: dict[str, Any]
|
||||
step_results: list[dict[str, Any]]
|
||||
output: dict[str, Any] | None = None
|
||||
artifacts: list[dict[str, Any]]
|
||||
error: dict[str, Any] | None = None
|
||||
|
||||
|
||||
class RunList(BaseModel):
|
||||
"""Paginated list of runs."""
|
||||
|
||||
items: list[RunSummary]
|
||||
total: int
|
||||
|
||||
|
||||
class RunDispatched(BaseModel):
|
||||
"""Response of a successful run dispatch."""
|
||||
|
||||
run_id: int
|
||||
status: RunStatus
|
||||
Loading…
Add table
Add a link
Reference in a new issue