manta_server/server/handlers/
analysis.rs

1//! Cross-resource analyses.
2//!
3//! Surfaces the image-centric "link graph" computed by
4//! [`crate::service::analysis`] over the four CFS/BOS/IMS resource
5//! lists the caller can see. Exposes:
6//!
7//! - `GET /api/v1/analysis/images` — one row per IMS image, joined
8//!   against CFS configurations, CFS sessions, and BOS session
9//!   templates. The row carries `safe_to_delete` and orphan hints
10//!   the CLI uses for cascading-delete preview.
11
12use axum::{Json, http::StatusCode, response::IntoResponse};
13
14use super::{ErrorResponse, RequestCtx, SiteHeader, to_handler_error};
15use crate::service;
16use manta_shared::types::api::analysis::BackendSummary;
17
18/// GET /analysis/images — image-centric flat projection of every CFS
19/// configuration, CFS session, BOS session template, and IMS image
20/// visible to the caller. One row per IMS image; see
21/// [`BackendSummary`] for column semantics.
22#[utoipa::path(get, path = "/analysis/images", tag = "analysis",
23  params(SiteHeader),
24  security(("bearerAuth" = [])),
25  responses(
26    (status = 200, description = "Image-analysis rows",   body = Vec<BackendSummary>),
27    (status = 401, description = "Unauthorized",          body = ErrorResponse),
28    (status = 500, description = "Internal error",        body = ErrorResponse),
29  )
30)]
31#[tracing::instrument(skip_all)]
32pub async fn get_image_analysis(
33  ctx: RequestCtx,
34) -> Result<impl IntoResponse, (StatusCode, Json<ErrorResponse>)> {
35  let infra = ctx.infra();
36  let rows = service::analysis::get_image_analysis(&infra, &ctx.token)
37    .await
38    .map_err(to_handler_error)?;
39  Ok((StatusCode::OK, Json(rows)))
40}