use url::Url;
use uuid::Uuid;
pub mod client;
pub mod types;
#[derive(Clone, Debug)]
pub struct DmsPaths {
base: Url,
}
impl DmsPaths {
pub fn new(base: Url) -> Self {
Self { base }
}
pub fn tasks(&self) -> Url {
self.base.join("tasks").expect("join /tasks")
}
pub fn tasks_with_capability(&self, capability: &str) -> Url {
let mut url = self.tasks();
{
let mut qp = url.query_pairs_mut();
qp.append_pair("capability", capability);
}
url
}
pub fn heartbeat(&self, task_id: Uuid) -> Url {
self.base
.join(&format!("tasks/{}/heartbeat", task_id))
.expect("join heartbeat")
}
pub fn complete(&self, task_id: Uuid) -> Url {
self.base
.join(&format!("tasks/{}/complete", task_id))
.expect("join complete")
}
pub fn fail(&self, task_id: Uuid) -> Url {
self.base
.join(&format!("tasks/{}/fail", task_id))
.expect("join fail")
}
}