manta_shared/types/api/
kernel_parameters.rs

1//! HTTP request/response bodies and CLI-built parameter structs for
2//! the kernel-parameter endpoints (`/api/v1/kernel-parameters/*`).
3//!
4//! The internal `KernelParamOperation` enum used by the server's
5//! kernel-parameter orchestration is not exposed here — it lives in
6//! `crate::service::kernel_parameters` because it carries operational
7//! logic (mutate, handles_sbps_images) rather than wire data.
8
9use serde::{Deserialize, Serialize};
10use utoipa::ToSchema;
11
12/// Which kernel-parameter mutation to perform on
13/// `POST /api/v1/kernel-parameters/apply`.
14#[derive(Debug, Clone, Copy, Serialize, Deserialize, ToSchema)]
15#[serde(rename_all = "lowercase")]
16pub enum KernelParamOp {
17  /// Merge new parameters into the existing set.
18  Add,
19  /// Replace the entire parameter set.
20  Apply,
21  /// Remove the named parameters from the existing set.
22  Delete,
23}
24
25/// Request body for `POST /api/v1/kernel-parameters/apply`.
26#[derive(Debug, Serialize, Deserialize, ToSchema)]
27pub struct ApplyKernelParametersRequest {
28  /// Hosts expression (xnames, NIDs, or hostlist notation); mutually
29  /// exclusive with `hsm_group`.
30  pub xnames_expression: Option<String>,
31  /// Target HSM group; all members are resolved to xnames.
32  pub hsm_group: Option<String>,
33  /// Which mutation to perform: add, apply (replace), or delete.
34  pub operation: KernelParamOp,
35  /// Space-separated kernel parameter `key=value` pairs.
36  pub params: String,
37  /// Only relevant for the `Add` operation.
38  #[serde(default)]
39  pub overwrite: bool,
40  /// Whether to project SBPS images (default `true`).
41  #[serde(default = "default_true")]
42  pub project_sbps: bool,
43  /// When true, return the computed changeset without applying it.
44  #[serde(default)]
45  pub dry_run: bool,
46}
47
48/// Request body for `POST /api/v1/kernel-parameters/add` (append mode).
49#[derive(Debug, Serialize, Deserialize, ToSchema)]
50pub struct AddKernelParametersRequest {
51  /// Space-separated kernel parameter `key=value` pairs to add.
52  pub params: String,
53  /// Hosts expression (xnames, NIDs, or hostlist notation); mutually
54  /// exclusive with `hsm_group`.
55  pub xnames_expression: Option<String>,
56  /// Target HSM group; all members are resolved to xnames.
57  pub hsm_group: Option<String>,
58  /// When true, overwrite parameters that already exist.
59  #[serde(default)]
60  pub overwrite: bool,
61  /// Whether to project SBPS images (default `true`).
62  #[serde(default = "default_true")]
63  pub project_sbps: bool,
64  /// When true, return the computed changeset without applying it.
65  #[serde(default)]
66  pub dry_run: bool,
67}
68
69/// Request body for `DELETE /api/v1/kernel-parameters`.
70#[derive(Debug, Serialize, Deserialize, ToSchema)]
71pub struct DeleteKernelParametersRequest {
72  /// Space-separated parameter names (or `key=value` pairs) to
73  /// remove.
74  pub params: String,
75  /// Hosts expression (xnames, NIDs, or hostlist notation); mutually
76  /// exclusive with `hsm_group`.
77  pub xnames_expression: Option<String>,
78  /// Target HSM group; all members are resolved to xnames.
79  pub hsm_group: Option<String>,
80  /// When true, return the computed changeset without applying it.
81  #[serde(default)]
82  pub dry_run: bool,
83}
84
85fn default_true() -> bool {
86  true
87}
88
89/// Typed parameters for fetching kernel boot parameters.
90pub struct GetKernelParametersParams {
91  /// Group whose members' kernel parameters should be returned.
92  pub group_name: Option<String>,
93  /// Explicit comma-separated xnames; mutually exclusive with
94  /// `group_name`.
95  pub nodes: Option<String>,
96  /// Operator default from `cli.toml`'s `parent_group_group`, used
97  /// when neither `group_name` nor `nodes` is supplied.
98  pub settings_group_name: Option<String>,
99}