manta_shared/types/api/
hw_cluster.rs

1//! HTTP request/response bodies and shared types for the
2//! `POST /api/v1/hardware-clusters/{target}/*` and
3//! `DELETE /api/v1/hardware-clusters/{target}/members` endpoints.
4
5use serde::{Deserialize, Serialize};
6use utoipa::ToSchema;
7
8/// Request body for `POST /api/v1/hardware-clusters/{target}/members`.
9///
10/// Moves nodes matching `pattern` out of `parent_cluster` and into
11/// the path-level target cluster.
12#[derive(Debug, Serialize, Deserialize, ToSchema)]
13pub struct AddHwComponentRequest {
14  /// Source HSM group that donates nodes matching `pattern`.
15  pub parent_cluster: String,
16  /// Hardware component pattern used to select which nodes to move.
17  pub pattern: String,
18  /// Create the target HSM group if it does not already exist.
19  #[serde(default)]
20  pub create_hsm_group: bool,
21  /// When true, return the planned changes without modifying group
22  /// membership.
23  #[serde(default)]
24  pub dry_run: bool,
25}
26
27/// Request body for `DELETE /api/v1/hardware-clusters/{target}/members`.
28#[derive(Debug, Serialize, Deserialize, ToSchema)]
29pub struct DeleteHwComponentRequest {
30  /// Destination HSM group that receives nodes moved out of the
31  /// target cluster.
32  pub parent_cluster: String,
33  /// Hardware component pattern used to select which nodes to move
34  /// back.
35  pub pattern: String,
36  /// Delete the target HSM group if it becomes empty after the
37  /// operation.
38  #[serde(default)]
39  pub delete_hsm_group: bool,
40  /// When true, return the planned changes without modifying group
41  /// membership.
42  #[serde(default)]
43  pub dry_run: bool,
44}
45
46/// Request body for
47/// `POST /api/v1/hardware-clusters/{target}/configuration`.
48#[derive(Debug, Serialize, Deserialize, ToSchema)]
49pub struct ApplyHwConfigurationRequest {
50  /// Source (parent) HSM group supplying nodes.
51  pub parent_cluster: String,
52  /// Hardware component pattern selecting which nodes to pin/unpin.
53  pub pattern: String,
54  /// Whether to pin nodes into the target cluster or unpin them back
55  /// to the parent. Defaults to `Pin`.
56  #[serde(default)]
57  pub mode: HwClusterMode,
58  /// Create the target HSM group if absent (default `true`).
59  #[serde(default = "default_true")]
60  pub create_target_hsm_group: bool,
61  /// Delete the parent HSM group if it becomes empty (default `true`).
62  #[serde(default = "default_true")]
63  pub delete_empty_parent_hsm_group: bool,
64  /// When true, return the planned changes without modifying group
65  /// membership.
66  #[serde(default)]
67  pub dry_run: bool,
68}
69
70fn default_true() -> bool {
71  true
72}
73
74/// Whether the hw cluster operation moves nodes into the target (Pin) or
75/// releases them back (Unpin).
76#[derive(
77  Debug, Clone, Copy, PartialEq, Eq, Default, Serialize, Deserialize, ToSchema,
78)]
79#[serde(rename_all = "lowercase")]
80pub enum HwClusterMode {
81  /// Move nodes matching the hardware pattern from the parent cluster
82  /// into the target cluster.
83  #[default]
84  Pin,
85  /// Move nodes matching the hardware pattern from the target cluster
86  /// back to the parent cluster.
87  Unpin,
88}