Skip to main content

manta_shared/types/api/
group.rs

1//! HTTP request/response bodies and CLI-built parameter structs for
2//! the HSM group endpoints (`/api/v1/groups`,
3//! `/api/v1/groups/{name}/members`).
4
5use serde::{Deserialize, Serialize};
6use utoipa::ToSchema;
7
8/// Request body for `POST /api/v1/groups/{name}/members`.
9#[derive(Debug, Serialize, Deserialize, ToSchema)]
10pub struct AddNodesToGroupRequest {
11  /// Hostlist expression (xnames, NIDs, or hostlist notation)
12  /// identifying the new member set for the group.
13  pub hosts_expression: String,
14}
15
16/// Response body for `POST /api/v1/groups/{name}/members`.
17///
18/// The `removed` field name is retained for wire stability; its value
19/// is the final, sorted membership of the group after the update —
20/// **not** a list of removed nodes.
21#[derive(Debug, Serialize, Deserialize, ToSchema)]
22pub struct AddNodesToGroupResponse {
23  /// Xnames that were added to the group as part of this request.
24  pub added: Vec<String>,
25  /// Final, sorted membership of the group after the update.
26  pub final_members: Vec<String>,
27  /// Deprecated alias for [`Self::final_members`]. Carries the same
28  /// value so existing clients reading `removed` keep working for one
29  /// release; new clients should read `final_members`. Scheduled for
30  /// removal in the next major bump — at which point the
31  /// `#[serde(alias = "removed")]` on `final_members` keeps inbound
32  /// compatibility for anyone POSTing back the old name.
33  #[serde(default)]
34  pub removed: Vec<String>,
35}
36
37/// Request body for `DELETE /api/v1/groups/{name}/members`.
38#[derive(Debug, Serialize, Deserialize, ToSchema)]
39pub struct DeleteGroupMembersRequest {
40  /// Hosts expression (xnames, NIDs, or hostlist notation)
41  /// identifying nodes to remove.
42  pub xnames_expression: String,
43  /// When true, validate the request without modifying group
44  /// membership.
45  #[serde(default)]
46  pub dry_run: bool,
47}
48
49/// Typed parameters for fetching HSM groups.
50#[derive(Debug)]
51pub struct GetGroupParams {
52  /// Exact group name to fetch; returns all groups when `None`.
53  pub group_name: Option<String>,
54  /// Operator default from `~/.config/manta/cli.toml`'s
55  /// `group_name`; used to scope results when `group_name` is
56  /// absent but a configured default exists.
57  pub settings_group_name: Option<String>,
58}