use axum::{Json, extract::Query, http::StatusCode, response::IntoResponse};
use super::{ErrorResponse, RequestCtx, SiteHeader, to_handler_error};
use crate::service;
pub use manta_shared::types::api::queries::ClusterQuery;
#[utoipa::path(get, path = "/groups/nodes", tag = "groups",
params(ClusterQuery, SiteHeader),
security(("bearerAuth" = [])),
responses(
(status = 200, description = "List of group nodes", body = Vec<manta_shared::types::dto::NodeDetails>),
(status = 401, description = "Unauthorized", body = ErrorResponse),
(status = 500, description = "Internal error", body = ErrorResponse),
)
)]
#[tracing::instrument(skip_all)]
pub async fn get_groups_nodes(
ctx: RequestCtx,
Query(q): Query<ClusterQuery>,
) -> Result<impl IntoResponse, (StatusCode, Json<ErrorResponse>)> {
let infra = ctx.infra();
let params = service::cluster::GetClusterParams {
group_name: q.hsm_group,
settings_group_name: None,
status_filter: q.status,
};
let nodes = service::cluster::get_cluster_nodes(&infra, &ctx.token, ¶ms)
.await
.map_err(to_handler_error)?;
Ok(Json(nodes))
}
#[utoipa::path(get, path = "/clusters", tag = "clusters",
params(ClusterQuery, SiteHeader),
security(("bearerAuth" = [])),
responses(
(status = 200, description = "[DEPRECATED] use /groups/nodes — list of group nodes", body = Vec<manta_shared::types::dto::NodeDetails>),
(status = 401, description = "Unauthorized", body = ErrorResponse),
(status = 500, description = "Internal error", body = ErrorResponse),
)
)]
#[tracing::instrument(skip_all)]
pub async fn get_clusters_deprecated(
ctx: RequestCtx,
q: Query<ClusterQuery>,
) -> Result<impl IntoResponse, (StatusCode, Json<ErrorResponse>)> {
tracing::warn!(
"deprecated endpoint: GET /clusters — use /groups/nodes instead"
);
get_groups_nodes(ctx, q).await
}