summaryrefslogtreecommitdiff
path: root/makima/src/daemon/api/directive.rs
diff options
context:
space:
mode:
Diffstat (limited to 'makima/src/daemon/api/directive.rs')
-rw-r--r--makima/src/daemon/api/directive.rs54
1 files changed, 54 insertions, 0 deletions
diff --git a/makima/src/daemon/api/directive.rs b/makima/src/daemon/api/directive.rs
new file mode 100644
index 0000000..0c8115a
--- /dev/null
+++ b/makima/src/daemon/api/directive.rs
@@ -0,0 +1,54 @@
+//! Directive API methods.
+
+use serde::Serialize;
+use uuid::Uuid;
+
+use super::client::{ApiClient, ApiError};
+use super::supervisor::JsonValue;
+
+/// Request to update a directive.
+#[derive(Serialize)]
+#[serde(rename_all = "camelCase")]
+pub struct UpdateDirectiveRequest {
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub status: Option<String>,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub version: Option<i32>,
+}
+
+impl ApiClient {
+ /// Get directive status and details.
+ pub async fn directive_status(&self, directive_id: Uuid) -> Result<JsonValue, ApiError> {
+ self.get(&format!("/api/v1/directives/{}", directive_id))
+ .await
+ }
+
+ /// List chains for a directive.
+ pub async fn directive_chains(&self, directive_id: Uuid) -> Result<JsonValue, ApiError> {
+ self.get(&format!("/api/v1/directives/{}/chains", directive_id))
+ .await
+ }
+
+ /// Get a chain with its steps.
+ pub async fn directive_chain(
+ &self,
+ directive_id: Uuid,
+ chain_id: Uuid,
+ ) -> Result<JsonValue, ApiError> {
+ self.get(&format!(
+ "/api/v1/directives/{}/chains/{}",
+ directive_id, chain_id
+ ))
+ .await
+ }
+
+ /// Update a directive.
+ pub async fn directive_update(
+ &self,
+ directive_id: Uuid,
+ req: UpdateDirectiveRequest,
+ ) -> Result<JsonValue, ApiError> {
+ self.put(&format!("/api/v1/directives/{}", directive_id), &req)
+ .await
+ }
+}