1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
//! 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
}
/// Start a directive (transition from draft to planning).
pub async fn directive_start(&self, directive_id: Uuid) -> Result<JsonValue, ApiError> {
self.post_empty(&format!("/api/v1/directives/{}/start", directive_id))
.await
}
/// Trigger a manual evaluation for a step.
pub async fn directive_evaluate_step(
&self,
directive_id: Uuid,
step_id: Uuid,
) -> Result<JsonValue, ApiError> {
self.post_empty(&format!(
"/api/v1/directives/{}/steps/{}/evaluate",
directive_id, step_id
))
.await
}
/// List evaluations for a step.
pub async fn directive_evaluations(
&self,
directive_id: Uuid,
step_id: Uuid,
) -> Result<JsonValue, ApiError> {
self.get(&format!(
"/api/v1/directives/{}/steps/{}/evaluations",
directive_id, step_id
))
.await
}
}
|