manta_server/server/handlers/
cluster.rs

1//! Group/cluster node-listing handlers.
2//!
3//! - `GET /api/v1/groups/nodes` → [`get_groups_nodes`] (canonical) —
4//!   wraps `service::cluster::get_cluster_nodes`.
5//! - `GET /api/v1/clusters` → [`get_clusters_deprecated`] —
6//!   deprecated alias; logs a server-side warning and forwards.
7
8use axum::{Json, extract::Query, http::StatusCode, response::IntoResponse};
9
10use super::{ErrorResponse, RequestCtx, SiteHeader, to_handler_error};
11use crate::service;
12
13// ---------------------------------------------------------------------------
14// GET /api/v1/groups/nodes
15// ---------------------------------------------------------------------------
16
17pub use manta_shared::types::api::queries::ClusterQuery;
18
19/// GET /groups/nodes — list nodes in a group with optional status filter.
20#[utoipa::path(get, path = "/groups/nodes", tag = "groups",
21  params(ClusterQuery, SiteHeader),
22  security(("bearerAuth" = [])),
23  responses(
24    (status = 200, description = "List of group nodes", body = Vec<manta_shared::types::dto::NodeDetails>),
25    (status = 401, description = "Unauthorized",         body = ErrorResponse),
26    (status = 500, description = "Internal error",       body = ErrorResponse),
27  )
28)]
29#[tracing::instrument(skip_all)]
30pub async fn get_groups_nodes(
31  ctx: RequestCtx,
32  Query(q): Query<ClusterQuery>,
33) -> Result<impl IntoResponse, (StatusCode, Json<ErrorResponse>)> {
34  let infra = ctx.infra();
35
36  let params = service::cluster::GetClusterParams {
37    group_name: q.hsm_group,
38    settings_group_name: None,
39    status_filter: q.status,
40  };
41
42  let nodes = service::cluster::get_cluster_nodes(&infra, &ctx.token, &params)
43    .await
44    .map_err(to_handler_error)?;
45
46  Ok(Json(nodes))
47}
48
49/// DEPRECATED alias for `GET /groups/nodes`. Logs a server-side warning,
50/// then delegates to the canonical handler. Old path kept for one
51/// release.
52#[utoipa::path(get, path = "/clusters", tag = "clusters",
53  params(ClusterQuery, SiteHeader),
54  security(("bearerAuth" = [])),
55  responses(
56    (status = 200, description = "[DEPRECATED] use /groups/nodes — list of group nodes", body = Vec<manta_shared::types::dto::NodeDetails>),
57    (status = 401, description = "Unauthorized",                                          body = ErrorResponse),
58    (status = 500, description = "Internal error",                                        body = ErrorResponse),
59  )
60)]
61#[tracing::instrument(skip_all)]
62pub async fn get_clusters_deprecated(
63  ctx: RequestCtx,
64  q: Query<ClusterQuery>,
65) -> Result<impl IntoResponse, (StatusCode, Json<ErrorResponse>)> {
66  tracing::warn!(
67    "deprecated endpoint: GET /clusters — use /groups/nodes instead"
68  );
69  get_groups_nodes(ctx, q).await
70}