use crate::client::EdgeQuakeClient;
use crate::error::Result;
use crate::types::operations::*;
pub struct TasksResource<'a> {
pub(crate) client: &'a EdgeQuakeClient,
}
impl<'a> TasksResource<'a> {
pub async fn list(&self) -> Result<TaskListResponse> {
self.client.get("/api/v1/tasks").await
}
pub async fn get(&self, track_id: &str) -> Result<TaskInfo> {
self.client
.get(&format!("/api/v1/tasks/{track_id}"))
.await
}
pub async fn cancel(&self, track_id: &str) -> Result<()> {
self.client
.post_no_content::<()>(
&format!("/api/v1/tasks/{track_id}/cancel"),
None,
)
.await
}
pub async fn retry(&self, track_id: &str) -> Result<serde_json::Value> {
self.client
.post::<(), serde_json::Value>(
&format!("/api/v1/tasks/{track_id}/retry"),
None,
)
.await
}
}