Skip to main content

edgequake_sdk/resources/
tasks.rs

1//! Tasks resource.
2
3use crate::client::EdgeQuakeClient;
4use crate::error::Result;
5use crate::types::operations::*;
6
7pub struct TasksResource<'a> {
8    pub(crate) client: &'a EdgeQuakeClient,
9}
10
11impl<'a> TasksResource<'a> {
12    /// `GET /api/v1/tasks`
13    pub async fn list(&self) -> Result<TaskListResponse> {
14        self.client.get("/api/v1/tasks").await
15    }
16
17    /// `GET /api/v1/tasks/{track_id}`
18    pub async fn get(&self, track_id: &str) -> Result<TaskInfo> {
19        self.client
20            .get(&format!("/api/v1/tasks/{track_id}"))
21            .await
22    }
23
24    /// `POST /api/v1/tasks/{track_id}/cancel`
25    pub async fn cancel(&self, track_id: &str) -> Result<()> {
26        self.client
27            .post_no_content::<()>(
28                &format!("/api/v1/tasks/{track_id}/cancel"),
29                None,
30            )
31            .await
32    }
33
34    /// `POST /api/v1/tasks/{track_id}/retry` — Retry a failed task.
35    pub async fn retry(&self, track_id: &str) -> Result<serde_json::Value> {
36        self.client
37            .post::<(), serde_json::Value>(
38                &format!("/api/v1/tasks/{track_id}/retry"),
39                None,
40            )
41            .await
42    }
43}