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#[derive(Debug, Serialize, Deserialize, ToSchema)]
16pub struct CreatedResponse {
17 /// Always `true` on success.
18 pub created: bool,
19}
20
21/// Response for `POST /api/v1/nodes` — echoes the registered xname.
22#[derive(Debug, Serialize, Deserialize, ToSchema)]
23pub struct AddNodeResponse {
24 /// Physical location ID (xname) of the registered node.
25 pub id: String,
26}
27
28/// Response for `POST /api/v1/sessions` — names of the created CFS
29/// session and its underlying configuration.
30#[derive(Debug, Serialize, Deserialize, ToSchema)]
31pub struct CreateSessionResponse {
32 /// Name of the created CFS session.
33 pub session_name: String,
34 /// Name of the CFS configuration the session was attached to.
35 pub configuration_name: String,
36}
37
38/// Response for `POST /api/v1/ephemeral-env` — the freshly provisioned
39/// ephemeral host.
40#[derive(Debug, Serialize, Deserialize, ToSchema)]
41pub struct EphemeralEnvResponse {
42 /// Hostname of the ephemeral environment.
43 pub hostname: String,
44}
45
46/// Response for endpoints that simply confirm a backup / restore /
47/// long-running migrate operation finished. Emitted by
48/// `POST /api/v1/migrate/backup` and `POST /api/v1/migrate/restore`.
49#[derive(Debug, Serialize, Deserialize, ToSchema)]
50pub struct CompletedResponse {
51 /// Always `true` on success.
52 pub completed: bool,
53}
54
55/// One migration pair's result; mirrors
56/// `manta_server::service::migrate::NodeMigrationResult` on the wire.
57/// Embedded inside [`MigrateNodesResponse`] without importing the
58/// server-side type into the shared crate.
59#[derive(Debug, Serialize, Deserialize, ToSchema)]
60pub struct MigrateNodesPairResult {
61 /// HSM group that received the nodes.
62 pub target_hsm_name: String,
63 /// HSM group that the nodes were moved out of.
64 pub parent_hsm_name: String,
65 /// Final member list of the target group after migration.
66 pub target_members: Vec<String>,
67 /// Remaining member list of the parent group after migration.
68 pub parent_members: Vec<String>,
69}
70
71/// Response for `POST /api/v1/migrate/nodes` — moved xnames plus a
72/// per-(target,parent) result list. Dry-run uses the same shape so the
73/// CLI consumes one type regardless of mode.
74#[derive(Debug, Serialize, Deserialize, ToSchema)]
75pub struct MigrateNodesResponse {
76 /// Xnames moved (or that would have been moved, in dry-run).
77 pub xnames: Vec<String>,
78 /// Per (target, parent) pair migration result.
79 pub results: Vec<MigrateNodesPairResult>,
80}