24 lines
818 B
Python
24 lines
818 B
Python
from fastapi import APIRouter
|
|
|
|
from app.schemas.common import ApiResponse
|
|
from app.services.runtime_control_service import runtime_action
|
|
from app.services.runtime_status_service import get_runtime_preflight, get_runtime_status
|
|
|
|
router = APIRouter(tags=["runtime"])
|
|
|
|
|
|
@router.get("/runtime/status", response_model=ApiResponse)
|
|
def runtime_status() -> ApiResponse:
|
|
return ApiResponse(data=get_runtime_status())
|
|
|
|
|
|
@router.get("/runtime/preflight", response_model=ApiResponse)
|
|
def runtime_preflight() -> ApiResponse:
|
|
return ApiResponse(data=get_runtime_preflight())
|
|
|
|
|
|
@router.post("/runtime/actions/{action}", response_model=ApiResponse)
|
|
def runtime_action_trigger(action: str) -> ApiResponse:
|
|
ok, message, data = runtime_action(action)
|
|
return ApiResponse(code=0 if ok else 1, message=message, data=data)
|