mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-29 19:35:20 +02:00
move automations api into vertical slice with service layer
This commit is contained in:
parent
d84240a630
commit
dd6bc30f98
6 changed files with 107 additions and 57 deletions
12
surfsense_backend/app/automations/api/__init__.py
Normal file
12
surfsense_backend/app/automations/api/__init__.py
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
"""HTTP layer for the automations feature."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from fastapi import APIRouter
|
||||
|
||||
from .automation import router as automation_router
|
||||
|
||||
router = APIRouter()
|
||||
router.include_router(automation_router)
|
||||
|
||||
__all__ = ["router"]
|
||||
22
surfsense_backend/app/automations/api/automation.py
Normal file
22
surfsense_backend/app/automations/api/automation.py
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
"""Routes for the ``Automation`` resource."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
from fastapi import APIRouter, Body, Depends
|
||||
|
||||
from app.automations.services import AutomationService, get_automation_service
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
|
||||
@router.post("/automations/{automation_id}/run")
|
||||
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]:
|
||||
"""Fire a manual run."""
|
||||
run = await service.run_now(automation_id=automation_id, payload=payload)
|
||||
return {"run_id": run.id, "status": run.status.value}
|
||||
Loading…
Add table
Add a link
Reference in a new issue