manta_shared/types/api/power.rs
1//! HTTP request/response bodies and CLI-built parameter structs for
2//! the power endpoints (`/api/v1/power`).
3
4use serde::{Deserialize, Serialize};
5use utoipa::ToSchema;
6
7/// Request body for `POST /api/v1/power`.
8#[derive(Debug, Serialize, Deserialize, ToSchema)]
9pub struct PowerRequest {
10 /// Power operation to perform.
11 pub action: PowerAction,
12 /// For `Nodes`: hosts expression (xnames, NIDs, or hostlist
13 /// notation). For `Cluster`: the HSM group name.
14 pub host_expression: String,
15 /// Whether `host_expression` is a node expression or a cluster
16 /// name.
17 pub target_type: PowerTargetType,
18 /// Pass `--force` to the underlying power operation (forceful
19 /// shutdown/reset).
20 #[serde(default)]
21 pub force: bool,
22}
23
24/// The power operation to apply to a list of xnames.
25#[derive(Debug, Clone, Copy, Serialize, Deserialize, ToSchema)]
26#[serde(rename_all = "lowercase")]
27pub enum PowerAction {
28 /// Power on (cold start) the listed xnames.
29 On,
30 /// Power off the listed xnames; graceful unless `force` is set.
31 Off,
32 /// Power-cycle (reset) the listed xnames; graceful unless `force`
33 /// is set.
34 Reset,
35}
36
37/// Whether the caller's `host_expression` is a hosts expression
38/// (xnames / NIDs / hostlist) or a single HSM group name whose
39/// members should be targeted.
40#[derive(Debug, Clone, Copy, Serialize, Deserialize, ToSchema)]
41#[serde(rename_all = "lowercase")]
42pub enum PowerTargetType {
43 /// `host_expression` is a hosts expression.
44 Nodes,
45 /// `host_expression` is a single HSM group name.
46 Cluster,
47}
48
49/// Typed parameters for the power-action service call.
50pub struct ApplyPowerParams {
51 /// Power operation to perform on every entry in `xnames`.
52 pub action: PowerAction,
53 /// Resolved list of xnames (already expanded from any HSM-group
54 /// or hostlist expression by the caller).
55 pub xnames: Vec<String>,
56 /// When true, perform a hard power off / reset without the
57 /// graceful shutdown path.
58 pub force: bool,
59}