Skip to main content

romm_api/endpoints/
tasks.rs

1//! Task runner endpoints (listing, running, and status).
2
3use serde_json::Value;
4
5use super::Endpoint;
6
7/// `GET /api/tasks` — list runnable tasks grouped by type.
8#[derive(Debug, Default, Clone)]
9pub struct ListTasks;
10
11impl Endpoint for ListTasks {
12    type Output = Value;
13
14    fn method(&self) -> &'static str {
15        "GET"
16    }
17
18    fn path(&self) -> String {
19        "/api/tasks".into()
20    }
21}
22
23/// `POST /api/tasks/run` — run all tasks.
24#[derive(Debug, Default, Clone)]
25pub struct RunAllTasks;
26
27impl Endpoint for RunAllTasks {
28    type Output = Value;
29
30    fn method(&self) -> &'static str {
31        "POST"
32    }
33
34    fn path(&self) -> String {
35        "/api/tasks/run".into()
36    }
37}
38
39/// `GET /api/tasks/status` — queue snapshot.
40#[derive(Debug, Default, Clone)]
41pub struct GetTasksStatus;
42
43impl Endpoint for GetTasksStatus {
44    type Output = Value;
45
46    fn method(&self) -> &'static str {
47        "GET"
48    }
49
50    fn path(&self) -> String {
51        "/api/tasks/status".into()
52    }
53}