feat(api): the OpenAPI description covers health, workspace and support routes (#1006)
CI / Check (push) Skipped
CI / Detect Changes (pull_request) Skipped
CI / Deploy Agent (pull_request) Skipped
CI / Deploy Dashboard (pull_request) Skipped
CI / Deploy Docs (pull_request) Skipped
CI / Deploy MCP (pull_request) Skipped
CI / Agent integration (pull_request) Successful in 4m47s
CI / Check (pull_request) Successful in 21m22s
CI / Check (push) Skipped
CI / Detect Changes (pull_request) Skipped
CI / Deploy Agent (pull_request) Skipped
CI / Deploy Dashboard (pull_request) Skipped
CI / Deploy Docs (pull_request) Skipped
CI / Deploy MCP (pull_request) Skipped
CI / Agent integration (pull_request) Successful in 4m47s
CI / Check (pull_request) Successful in 21m22s
The 8 paths are described from their handlers: the public health check (tag "Health", no bearer requirement), access, overview stats, projects, metering usage and the git source (tag "Workspace"), and support's tenant list and session (tag "Support"). undescribed_routes.txt drops to 31 paths. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Q9inRcu428A2iNjDHPEAT9
This commit is contained in:
1 parent
126345aa9d
commit
20714bf923
7 files changed
+112
-41
No files matched your search
@@ -17,8 +17,20 @@ fn may_view(tenant: &TenantCtx) -> bool {
|
||||
tenant.0.staff.is_some() || tenant.0.is_admin()
|
||||
}
|
||||
|
||||
/// The source without secrets, plus the webhook URL; `data: null` when the
|
||||
/// workspace has none.
|
||||
/// The workspace's managed git source, without secrets.
|
||||
///
|
||||
/// Plus the webhook URL; `data: null` when the workspace has none. For
|
||||
/// administrators (IT_ADMIN, OWNER) and support.
|
||||
#[utoipa::path(
|
||||
get,
|
||||
path = "/api/v1/git-source",
|
||||
tag = "Workspace",
|
||||
responses(
|
||||
(status = 200, description = "The source, or null"),
|
||||
(status = 403, description = "Not an administrator or support"),
|
||||
(status = 401, description = "No valid bearer token"),
|
||||
)
|
||||
)]
|
||||
pub async fn get_git_source(
|
||||
axum::extract::Extension(agent): AgentExt,
|
||||
tenant: TenantCtx,
|
||||
|
||||
@@ -5,9 +5,21 @@ use super::dto::*;
|
||||
use compliance_core::models::ScanRun;
|
||||
use compliance_core::tenant_ctx::TenantCtx;
|
||||
|
||||
/// `GET /api/v1/access`: reached only when the authentication, entitlement
|
||||
/// and role layers let the caller through; they answer the refusals (a
|
||||
/// blocked member gets 403 `MEMBER_BLOCKED`).
|
||||
/// Whether the caller may use Prüfwerk at all.
|
||||
///
|
||||
/// Reached only when the authentication, entitlement and role layers let the
|
||||
/// caller through; they answer the refusals (a blocked member gets 403
|
||||
/// `MEMBER_BLOCKED`).
|
||||
#[utoipa::path(
|
||||
get,
|
||||
path = "/api/v1/access",
|
||||
tag = "Workspace",
|
||||
responses(
|
||||
(status = 200, description = "The caller may use Prüfwerk"),
|
||||
(status = 403, description = "Not entitled, or a blocked member"),
|
||||
(status = 401, description = "No valid bearer token"),
|
||||
)
|
||||
)]
|
||||
#[tracing::instrument(skip_all)]
|
||||
pub async fn access() -> Json<serde_json::Value> {
|
||||
Json(serde_json::json!({ "access": true }))
|
||||
@@ -16,10 +28,21 @@ pub async fn access() -> Json<serde_json::Value> {
|
||||
/// How long the health check waits for MongoDB before it reports it down.
|
||||
const DB_PING_TIMEOUT: std::time::Duration = std::time::Duration::from_secs(2);
|
||||
|
||||
/// `GET /api/v1/health`: 200 `{"status":"ok"}` when MongoDB answers a ping,
|
||||
/// 503 `{"status":"degraded","mongo":"unreachable"}` when it does not, so a
|
||||
/// load balancer and the container health check stop sending traffic to an
|
||||
/// Whether the agent can serve: MongoDB answers a ping.
|
||||
///
|
||||
/// 200 `{"status":"ok"}` when MongoDB answers, 503
|
||||
/// `{"status":"degraded","mongo":"unreachable"}` when it does not, so a load
|
||||
/// balancer and the container health check stop sending traffic to an
|
||||
/// instance that cannot serve it (#60). Public, untraced, no tenant.
|
||||
#[utoipa::path(
|
||||
get,
|
||||
path = "/api/v1/health",
|
||||
tag = "Health",
|
||||
responses(
|
||||
(status = 200, description = "MongoDB answers"),
|
||||
(status = 503, description = "MongoDB is unreachable"),
|
||||
)
|
||||
)]
|
||||
#[tracing::instrument(skip_all)]
|
||||
pub async fn health(
|
||||
axum::extract::Extension(agent): AgentExt,
|
||||
@@ -93,6 +116,16 @@ pub(crate) async fn open_findings_by_severity(
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// The counts the overview page shows for the tenant.
|
||||
#[utoipa::path(
|
||||
get,
|
||||
path = "/api/v1/stats/overview",
|
||||
tag = "Workspace",
|
||||
responses(
|
||||
(status = 200, description = "The counts"),
|
||||
(status = 401, description = "No valid bearer token"),
|
||||
)
|
||||
)]
|
||||
#[tracing::instrument(skip_all)]
|
||||
pub async fn stats_overview(
|
||||
axum::extract::Extension(agent): AgentExt,
|
||||
|
||||
@@ -27,12 +27,23 @@ struct UsageView {
|
||||
prueftag_cap: Option<u32>,
|
||||
}
|
||||
|
||||
/// GET /api/v1/metering/usage — the tenant's Prüfungen, Prüftage and extra
|
||||
/// targets this month (Europe/Berlin), with the plan's limits.
|
||||
/// The tenant's usage this month, with the plan's limits.
|
||||
///
|
||||
/// Prüfungen, Prüftage and extra targets this month (Europe/Berlin).
|
||||
///
|
||||
/// # Errors
|
||||
///
|
||||
/// `500` when the counters cannot be read.
|
||||
#[utoipa::path(
|
||||
get,
|
||||
path = "/api/v1/metering/usage",
|
||||
tag = "Workspace",
|
||||
responses(
|
||||
(status = 200, description = "The usage"),
|
||||
(status = 500, description = "The counters cannot be read"),
|
||||
(status = 401, description = "No valid bearer token"),
|
||||
)
|
||||
)]
|
||||
pub async fn get_usage(
|
||||
Extension(agent): AgentExt,
|
||||
tenant: TenantCtx,
|
||||
|
||||
@@ -106,8 +106,17 @@ pub fn projects_changed_entry(
|
||||
)
|
||||
}
|
||||
|
||||
/// GET /api/v1/projects — the tenant's projects, for choosing and showing
|
||||
/// them in the dashboard.
|
||||
/// The tenant's projects, for choosing and showing them in the dashboard.
|
||||
#[utoipa::path(
|
||||
get,
|
||||
path = "/api/v1/projects",
|
||||
tag = "Workspace",
|
||||
responses(
|
||||
(status = 200, description = "The projects"),
|
||||
(status = 503, description = "The registry cannot be asked"),
|
||||
(status = 401, description = "No valid bearer token"),
|
||||
)
|
||||
)]
|
||||
#[tracing::instrument(skip_all)]
|
||||
pub async fn list_projects(
|
||||
Extension(agent): AgentExt,
|
||||
|
||||
@@ -41,8 +41,20 @@ fn picker_order(mut tenants: Vec<SupportTenant>) -> Vec<SupportTenant> {
|
||||
tenants
|
||||
}
|
||||
|
||||
/// GET /api/v1/support/tenants — every tenant, for support to choose from.
|
||||
/// Every tenant, for Breakpilot support to choose from.
|
||||
///
|
||||
/// 403 for anyone but support; 503 without a registry.
|
||||
#[utoipa::path(
|
||||
get,
|
||||
path = "/api/v1/support/tenants",
|
||||
tag = "Support",
|
||||
responses(
|
||||
(status = 200, description = "The tenants"),
|
||||
(status = 403, description = "Not support"),
|
||||
(status = 503, description = "No registry"),
|
||||
(status = 401, description = "No valid bearer token"),
|
||||
)
|
||||
)]
|
||||
#[tracing::instrument(skip_all)]
|
||||
pub async fn list_tenants(
|
||||
Extension(agent): AgentExt,
|
||||
@@ -60,9 +72,20 @@ pub async fn list_tenants(
|
||||
Ok(Json(serde_json::json!({ "data": tenants })))
|
||||
}
|
||||
|
||||
/// POST /api/v1/support/session — open the tenant named in the header. The
|
||||
/// middleware has confirmed it with the registry and records the opening in
|
||||
/// the audit log; this answers what was opened. 403 for anyone but support.
|
||||
/// Open the tenant named in the `X-Pruefwerk-Tenant` header for support.
|
||||
///
|
||||
/// The middleware has confirmed it with the registry and records the opening
|
||||
/// in the audit log; this answers what was opened. 403 for anyone but support.
|
||||
#[utoipa::path(
|
||||
post,
|
||||
path = "/api/v1/support/session",
|
||||
tag = "Support",
|
||||
responses(
|
||||
(status = 200, description = "The opened tenant"),
|
||||
(status = 403, description = "Not support"),
|
||||
(status = 401, description = "No valid bearer token"),
|
||||
)
|
||||
)]
|
||||
#[tracing::instrument(skip_all)]
|
||||
pub async fn open_session(tenant: TenantCtx) -> Result<Json<serde_json::Value>, StatusCode> {
|
||||
if tenant.0.staff.is_none() {
|
||||
|
||||
@@ -40,30 +40,21 @@ pub fn build_router() -> Router {
|
||||
|
||||
fn described_routes() -> OpenApiRouter {
|
||||
OpenApiRouter::with_openapi(openapi::ApiDoc::openapi())
|
||||
.route("/api/v1/health", get(handlers::health))
|
||||
.routes(routes!(handlers::health))
|
||||
.routes(routes!(handlers::oscal::assess_target))
|
||||
.route("/api/v1/stats/overview", get(handlers::stats_overview))
|
||||
.routes(routes!(handlers::stats_overview))
|
||||
// The tenant's projects (owned by the registry), for assigning targets.
|
||||
.route("/api/v1/projects", get(handlers::projects::list_projects))
|
||||
.route("/api/v1/metering/usage", get(handlers::metering::get_usage))
|
||||
.routes(routes!(handlers::projects::list_projects))
|
||||
.routes(routes!(handlers::metering::get_usage))
|
||||
// Whether the caller may use Prüfwerk at all: answered by the
|
||||
// authentication and entitlement layers in front of it (a blocked
|
||||
// member gets 403 MEMBER_BLOCKED), for the dashboard's sign-in check.
|
||||
.route("/api/v1/access", get(handlers::health::access))
|
||||
.routes(routes!(handlers::health::access))
|
||||
// The managed git source, read-only (IT admin and support).
|
||||
.route(
|
||||
"/api/v1/git-source",
|
||||
get(handlers::git_source::get_git_source),
|
||||
)
|
||||
.routes(routes!(handlers::git_source::get_git_source))
|
||||
// BreakPilot support access: choose and open a customer's tenant.
|
||||
.route(
|
||||
"/api/v1/support/tenants",
|
||||
get(handlers::support::list_tenants),
|
||||
)
|
||||
.route(
|
||||
"/api/v1/support/session",
|
||||
post(handlers::support::open_session),
|
||||
)
|
||||
.routes(routes!(handlers::support::list_tenants))
|
||||
.routes(routes!(handlers::support::open_session))
|
||||
// Unified onboarding targets (#131).
|
||||
.routes(routes!(
|
||||
handlers::onboarding::list_targets,
|
||||
|
||||
@@ -3,14 +3,6 @@
|
||||
# `.route("...")` in routes.rs is missing here, or when a line here names no
|
||||
# such route, so the list only ever shrinks. Describe a route with
|
||||
# `#[utoipa::path]` and `.routes(routes!(...))`, then delete its line.
|
||||
/api/v1/health
|
||||
/api/v1/stats/overview
|
||||
/api/v1/projects
|
||||
/api/v1/metering/usage
|
||||
/api/v1/access
|
||||
/api/v1/git-source
|
||||
/api/v1/support/tenants
|
||||
/api/v1/support/session
|
||||
/api/v1/inbox
|
||||
/api/v1/inbox/decide
|
||||
/api/v1/inbox/undo
|
||||
|
||||
Reference in new issue
Block a user