#![allow(unused_imports, clippy::too_many_arguments)]
use reqwest::Method;
use serde::{Deserialize, Serialize};
use crate::client::{Client, Request, NO_BODY, NO_QUERY};
use crate::error::Result;
use crate::generated::models;
use crate::multipart::{field_text, FilePart};
use crate::util::encode_path;
#[derive(Debug, Clone)]
pub struct SchedulerApi {
pub(crate) client: Client,
}
impl Client {
pub fn scheduler(&self) -> SchedulerApi {
SchedulerApi { client: self.clone() }
}
}
impl SchedulerApi {
pub async fn get_schedule(&self, agent_id: &str) -> Result<serde_json::Value> {
self.client
.request_json(Request {
method: Method::GET,
path: format!("/api/v1/agents/{}/schedule", encode_path(agent_id)),
query: NO_QUERY,
body: NO_BODY,
headers: Vec::new(),
idempotent: false,
})
.await
}
pub async fn remove_schedule(&self, agent_id: &str) -> Result<serde_json::Value> {
self.client
.request_json(Request {
method: Method::DELETE,
path: format!("/api/v1/agents/{}/schedule", encode_path(agent_id)),
query: NO_QUERY,
body: NO_BODY,
headers: Vec::new(),
idempotent: true,
})
.await
}
pub async fn set_schedule(&self, agent_id: &str, body: &models::SetScheduleRequest) -> Result<serde_json::Value> {
self.client
.request_json(Request {
method: Method::PUT,
path: format!("/api/v1/agents/{}/schedule", encode_path(agent_id)),
query: NO_QUERY,
body: Some(body),
headers: Vec::new(),
idempotent: true,
})
.await
}
}