llmrix-rust-sdk 1.0.0

Official Rust SDK for the llmrix AI Agent Platform API
Documentation
use std::sync::Arc;
use crate::{error::Result, model::*, transport::*};

/// Operations on the Cron Tasks API. Obtain via [`LlmrixClient::cron`].
pub struct CronResource {
    pub(crate) t: Arc<Transport>,
}

impl CronResource {
    /// Return all cron tasks.
    pub async fn list(&self) -> Result<Vec<CronTask>> {
        self.t.get_unwrap(&path_cron_tasks(), "tasks").await
    }

    /// Create a new cron task.
    pub async fn create(&self, req: CronCreateRequest) -> Result<CronTask> {
        self.t.post(&path_cron_tasks(), &req).await
    }

    /// Retrieve a single cron task by its UUID.
    pub async fn get(&self, task_id: &str) -> Result<CronTask> {
        self.t.get(&path_cron_task(task_id)).await
    }

    /// Update a cron task's properties.
    pub async fn update(&self, task_id: &str, req: CronUpdateRequest) -> Result<CronTask> {
        self.t.put(&path_cron_task(task_id), &req).await
    }

    /// Pause an active cron task.
    pub async fn pause(&self, task_id: &str) -> Result<CronTask> {
        self.t.post(&path_cron_pause(task_id), &serde_json::Value::Object(Default::default())).await
    }

    /// Resume a paused cron task.
    pub async fn resume(&self, task_id: &str) -> Result<CronTask> {
        self.t.post(&path_cron_resume(task_id), &serde_json::Value::Object(Default::default())).await
    }

    /// Permanently delete a cron task.
    pub async fn delete(&self, task_id: &str) -> Result<()> {
        self.t.delete(&path_cron_task(task_id)).await
    }
}