manta_server/server/handlers/
cluster.rs

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