Skip to main content

manta_shared/types/wire/
template.rs

1//! Wire types for `POST /api/v1/templates/{name}/sessions` (create a
2//! BOS session from a BOS session template).
3
4use serde::{Deserialize, Serialize};
5use utoipa::ToSchema;
6
7/// BOS session operation to run against the template's node list.
8#[derive(Debug, Clone, Copy, Serialize, Deserialize, ToSchema)]
9#[serde(rename_all = "lowercase")]
10pub enum BosOperation {
11  /// Boot nodes that are currently off.
12  Boot,
13  /// Reboot (power-cycle) nodes.
14  Reboot,
15  /// Shut down nodes.
16  Shutdown,
17}
18
19impl BosOperation {
20  /// Wire-level string form expected by the backend (`"boot"` /
21  /// `"reboot"` / `"shutdown"`).
22  pub fn as_str(&self) -> &'static str {
23    match self {
24      Self::Boot => "boot",
25      Self::Reboot => "reboot",
26      Self::Shutdown => "shutdown",
27    }
28  }
29}
30
31/// Request body for `POST /api/v1/templates/{name}/sessions`.
32#[derive(Debug, Serialize, Deserialize, ToSchema)]
33pub struct PostTemplateSessionRequest {
34  /// BOS operation to run (boot, reboot, or shutdown).
35  pub operation: BosOperation,
36  /// Ansible limit expression restricting which template nodes are
37  /// targeted.
38  pub limit: String,
39  /// Optional explicit name for the BOS session; auto-generated when
40  /// absent.
41  pub session_name: Option<String>,
42  /// When true, include nodes marked as disabled.
43  #[serde(default)]
44  pub include_disabled: bool,
45  /// When true, validate the session parameters without creating a
46  /// BOS session.
47  #[serde(default)]
48  pub dry_run: bool,
49}