manta_server/server/handlers/
cluster.rs1use axum::{Json, extract::Query, http::StatusCode, response::IntoResponse};
4use serde::Deserialize;
5use utoipa::IntoParams;
6
7use super::{ErrorResponse, RequestCtx, SiteHeader, to_handler_error};
8use crate::service;
9
10#[derive(Deserialize, IntoParams)]
16pub struct ClusterQuery {
17 pub hsm_group: Option<String>,
20 pub status: Option<String>,
22}
23
24#[utoipa::path(get, path = "/groups/nodes", tag = "groups",
26 params(ClusterQuery, SiteHeader),
27 security(("bearerAuth" = [])),
28 responses(
29 (status = 200, description = "List of group nodes", body = serde_json::Value),
30 (status = 401, description = "Unauthorized", body = ErrorResponse),
31 (status = 500, description = "Internal error", body = ErrorResponse),
32 )
33)]
34#[tracing::instrument(skip_all)]
35pub async fn get_groups_nodes(
36 ctx: RequestCtx,
37 Query(q): Query<ClusterQuery>,
38) -> Result<impl IntoResponse, (StatusCode, Json<ErrorResponse>)> {
39 let infra = ctx.infra();
40
41 let params = service::cluster::GetClusterParams {
42 hsm_group_name: q.hsm_group,
43 settings_hsm_group_name: None,
44 status_filter: q.status,
45 };
46
47 let nodes = service::cluster::get_cluster_nodes(&infra, &ctx.token, ¶ms)
48 .await
49 .map_err(to_handler_error)?;
50
51 Ok(Json(nodes))
52}
53
54#[utoipa::path(get, path = "/clusters", tag = "clusters",
58 params(ClusterQuery, SiteHeader),
59 security(("bearerAuth" = [])),
60 responses(
61 (status = 200, description = "[DEPRECATED] use /groups/nodes — list of group nodes", body = serde_json::Value),
62 (status = 401, description = "Unauthorized", body = ErrorResponse),
63 (status = 500, description = "Internal error", body = ErrorResponse),
64 )
65)]
66#[tracing::instrument(skip_all)]
67pub async fn get_clusters_deprecated(
68 ctx: RequestCtx,
69 q: Query<ClusterQuery>,
70) -> Result<impl IntoResponse, (StatusCode, Json<ErrorResponse>)> {
71 tracing::warn!(
72 "deprecated endpoint: GET /clusters — use /groups/nodes instead"
73 );
74 get_groups_nodes(ctx, q).await
75}