manta_shared/types/api/
template.rs

1//! HTTP request/response bodies and CLI-built parameter structs for
2//! the BOS session template endpoints (`/api/v1/templates`,
3//! `/api/v1/templates/{name}/sessions`).
4
5use serde::{Deserialize, Serialize};
6use utoipa::ToSchema;
7
8/// BOS session operation to run against the template's node list.
9#[derive(Debug, Clone, Copy, Serialize, Deserialize, ToSchema)]
10#[serde(rename_all = "lowercase")]
11pub enum BosOperation {
12  /// Boot nodes that are currently off.
13  Boot,
14  /// Reboot (power-cycle) nodes.
15  Reboot,
16  /// Shut down nodes.
17  Shutdown,
18}
19
20impl BosOperation {
21  /// Wire-level string form expected by the backend (`"boot"` /
22  /// `"reboot"` / `"shutdown"`).
23  pub fn as_str(&self) -> &'static str {
24    match self {
25      Self::Boot => "boot",
26      Self::Reboot => "reboot",
27      Self::Shutdown => "shutdown",
28    }
29  }
30}
31
32/// Request body for `POST /api/v1/templates/{name}/sessions`.
33#[derive(Debug, Serialize, Deserialize, ToSchema)]
34pub struct PostTemplateSessionRequest {
35  /// BOS operation to run (boot, reboot, or shutdown).
36  pub operation: BosOperation,
37  /// Ansible limit expression restricting which template nodes are
38  /// targeted.
39  pub limit: String,
40  /// Optional explicit name for the BOS session; auto-generated when
41  /// absent.
42  pub session_name: Option<String>,
43  /// When true, include nodes marked as disabled.
44  #[serde(default)]
45  pub include_disabled: bool,
46  /// When true, validate the session parameters without creating a
47  /// BOS session.
48  #[serde(default)]
49  pub dry_run: bool,
50}
51
52/// Typed parameters for fetching BOS session templates.
53pub struct GetTemplateParams {
54  /// Exact template name.
55  pub name: Option<String>,
56  /// Group whose associated templates should be returned.
57  pub group_name: Option<String>,
58  /// Operator default from `cli.toml`'s `hsm_group`, used
59  /// as a fallback for `group_name`.
60  pub settings_group_name: Option<String>,
61  /// Cap on the number of templates returned (most recent first).
62  pub limit: Option<u8>,
63}
64
65/// Parameters for applying a BOS session template.
66pub struct ApplyTemplateParams {
67  /// Optional explicit name for the created BOS session;
68  /// auto-generated when absent.
69  pub bos_session_name: Option<String>,
70  /// Name of an existing BOS session template to instantiate.
71  pub bos_sessiontemplate_name: String,
72  /// Operation to perform: `"boot"`, `"reboot"`, or `"shutdown"`.
73  pub bos_session_operation: String,
74  /// Ansible-style limit expression scoping which template nodes
75  /// are targeted (xnames, NIDs, groups, or roles).
76  pub limit: String,
77  /// When true, include nodes marked as disabled in the hardware
78  /// state manager.
79  pub include_disabled: bool,
80}