babelforce_manager_sdk/resources/
schedules.rs1use std::sync::Arc;
2
3use crate::error::{map_task_schedule_err as map_err, ManagerError};
4use crate::gen::task_schedule::apis::configuration::Configuration;
5use crate::gen::task_schedule::apis::schedule_manager_api as api;
6use crate::gen::task_schedule::models;
7use crate::retry::{with_retry, RetryPolicy};
8
9pub struct TaskSchedulesResource {
11 pub(crate) cfg: Arc<Configuration>,
12 pub(crate) retry: RetryPolicy,
13}
14
15impl TaskSchedulesResource {
16 pub async fn list(&self) -> Result<models::TaskScheduleList, ManagerError> {
18 with_retry(&self.retry, true, || {
19 api::get_task_schedules(self.cfg.as_ref(), None, None)
20 })
21 .await
22 .map_err(map_err)
23 }
24
25 pub async fn create(&self, body: models::SubmitTaskSchedule) -> Result<(), ManagerError> {
27 with_retry(&self.retry, false, || {
28 api::submit_task_schedule(self.cfg.as_ref(), body.clone())
29 })
30 .await
31 .map_err(map_err)
32 }
33
34 pub async fn get(&self, name: &str) -> Result<models::TaskSchedule, ManagerError> {
36 with_retry(&self.retry, true, || {
37 api::get_task_schedule(self.cfg.as_ref(), name)
38 })
39 .await
40 .map_err(map_err)
41 }
42
43 pub async fn delete(&self, name: &str) -> Result<(), ManagerError> {
45 with_retry(&self.retry, false, || {
46 api::delete_schedule_task(self.cfg.as_ref(), name)
47 })
48 .await
49 .map_err(map_err)
50 }
51}