manta_shared/types/api/responses.rs
1//! Lightweight response shapes for handlers that return ad-hoc JSON
2//! maps such as `{ "created": true }` or `{ "id": "..." }`.
3//!
4//! Defined here so the OpenAPI spec carries a real type instead of
5//! the catch-all `serde_json::Value`. Each struct matches the literal
6//! JSON the handler emits today via `serde_json::json!({ ... })`.
7
8use serde::{Deserialize, Serialize};
9use utoipa::ToSchema;
10
11/// Response for endpoints that simply confirm a write happened.
12///
13/// Emitted by `POST /api/v1/redfish-endpoints`,
14/// `POST /api/v1/boot-parameters`, and `POST /api/v1/groups`.
15///
16/// # Wire shape
17///
18/// ```json
19/// { "created": true }
20/// ```
21#[derive(Debug, Serialize, Deserialize, ToSchema)]
22pub struct CreatedResponse {
23 /// Always `true` on success.
24 pub created: bool,
25}
26
27/// Response for `POST /api/v1/nodes` — echoes the registered xname.
28///
29/// Paired with [`super::node::AddNodeRequest`].
30///
31/// # Wire shape
32///
33/// ```json
34/// { "id": "x3000c0s1b0n0" }
35/// ```
36#[derive(Debug, Serialize, Deserialize, ToSchema)]
37pub struct AddNodeResponse {
38 /// Physical location ID (xname) of the registered node.
39 pub id: String,
40}
41
42/// Response for `POST /api/v1/sessions` — names of the created CFS
43/// session and its underlying configuration.
44///
45/// Paired with [`super::session::CreateSessionRequest`]. When the
46/// caller did not supply `cfs_conf_sess_name`, the server-generated
47/// name is echoed back here.
48#[derive(Debug, Serialize, Deserialize, ToSchema)]
49pub struct CreateSessionResponse {
50 /// Name of the created CFS session.
51 pub session_name: String,
52 /// Name of the CFS configuration the session was attached to.
53 pub configuration_name: String,
54}
55
56/// Response for `POST /api/v1/ephemeral-env` — the freshly provisioned
57/// ephemeral host.
58#[derive(Debug, Serialize, Deserialize, ToSchema)]
59pub struct EphemeralEnvResponse {
60 /// Hostname of the ephemeral environment.
61 pub hostname: String,
62}
63
64/// Response for endpoints that simply confirm a backup / restore /
65/// long-running migrate operation finished. Emitted by
66/// `POST /api/v1/migrate/backup` and `POST /api/v1/migrate/restore`.
67///
68/// # Wire shape
69///
70/// ```json
71/// { "completed": true }
72/// ```
73#[derive(Debug, Serialize, Deserialize, ToSchema)]
74pub struct CompletedResponse {
75 /// Always `true` on success.
76 pub completed: bool,
77}
78
79/// One migration pair's result; mirrors
80/// `manta_server::service::migrate::NodeMigrationResult` on the wire.
81/// Embedded inside [`MigrateNodesResponse`] without importing the
82/// server-side type into the shared crate.
83#[derive(Debug, Serialize, Deserialize, ToSchema)]
84pub struct MigrateNodesPairResult {
85 /// HSM group that received the nodes.
86 pub target_hsm_name: String,
87 /// HSM group that the nodes were moved out of.
88 pub parent_hsm_name: String,
89 /// Final member list of the target group after migration.
90 pub target_members: Vec<String>,
91 /// Remaining member list of the parent group after migration.
92 pub parent_members: Vec<String>,
93}
94
95/// Response for `POST /api/v1/migrate/nodes` — moved xnames plus a
96/// per-(target,parent) result list. Dry-run uses the same shape so the
97/// CLI consumes one type regardless of mode.
98///
99/// Paired with [`super::migrate::MigrateNodesRequest`]. The `results`
100/// array runs in lockstep with the request's `target_hsm_names` /
101/// `parent_hsm_names` pairs.
102#[derive(Debug, Serialize, Deserialize, ToSchema)]
103pub struct MigrateNodesResponse {
104 /// Xnames moved (or that would have been moved, in dry-run).
105 pub xnames: Vec<String>,
106 /// Per (target, parent) pair migration result.
107 pub results: Vec<MigrateNodesPairResult>,
108}