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
|
|
@ -6,17 +6,18 @@ from typing import Any
|
|||
|
||||
from fastapi import APIRouter, Body, Depends
|
||||
|
||||
from app.automations.api.schemas import RunDispatched
|
||||
from app.automations.services import AutomationService, get_automation_service
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
|
||||
@router.post("/automations/{automation_id}/run")
|
||||
@router.post("/automations/{automation_id}/run", response_model=RunDispatched)
|
||||
async def run_automation_now(
|
||||
automation_id: int,
|
||||
payload: dict[str, Any] | None = Body(default=None),
|
||||
service: AutomationService = Depends(get_automation_service),
|
||||
) -> dict[str, Any]:
|
||||
) -> RunDispatched:
|
||||
"""Fire a manual run."""
|
||||
run = await service.run_now(automation_id=automation_id, payload=payload)
|
||||
return {"run_id": run.id, "status": run.status.value}
|
||||
return RunDispatched(run_id=run.id, status=run.status)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue