From 4f55566694d0d1462afeac110f550eed36a62c13 Mon Sep 17 00:00:00 2001 From: damocles Date: Fri, 31 Jul 2026 23:03:14 +0200 Subject: [PATCH] hive-c0re: wire the newly-annotated routes into the OpenApiRouter --- hive-c0re/src/dashboard/mod.rs | 208 ++++++++++----------------------- 1 file changed, 62 insertions(+), 146 deletions(-) diff --git a/hive-c0re/src/dashboard/mod.rs b/hive-c0re/src/dashboard/mod.rs index ae315088..7aaa8229 100644 --- a/hive-c0re/src/dashboard/mod.rs +++ b/hive-c0re/src/dashboard/mod.rs @@ -10,7 +10,7 @@ use axum::{ Router, http::StatusCode, response::{IntoResponse, Response}, - routing::{get, post}, + routing::get, }; use utoipa::OpenApi; use utoipa_axum::{router::OpenApiRouter, routes}; @@ -120,156 +120,16 @@ pub async fn serve( ) -> Result<()> { // API-only: the gateway static-serves the dashboard dist and proxies // non-static requests here (see hive-gateway.nix). Unmatched paths 404. - // The four `#[utoipa::path]`-annotated routes are registered further - // down via `OpenApiRouter` instead of the plain `.route(...)` calls - // below — see the `router`/`api` split at the end of this fn. + // Every `#[utoipa::path]`-annotated route is registered further down + // via `OpenApiRouter` instead of a plain `.route(...)` call here — see + // the `router`/`api` split below. What's left in this plain chain is + // exactly the SSE/streaming endpoints utoipa can't model (see the + // `ApiDoc` doc comment) plus anything not yet annotated. let app = Router::new() - .route("/api/state", get(state_snapshot::api_state)) - .route("/api/state-file", get(state_files::get_state_file)) - .route( - "/api/matrix-accounts", - get(matrix_accounts::get_matrix_accounts), - ) - .route("/api/extra-forges", get(extra_forges::get_extra_forges)) - .route( - "/api/extra-forge-account", - post(extra_forges::post_extra_forge_account), - ) - .route("/api/operator-inbox", get(misc_api::api_operator_inbox)) - .route("/api/stats-hive", get(misc_api::api_stats_hive)) - .route( - "/api/container-resources", - get(misc_api::api_container_resources), - ) - .route("/api/audit-log", get(misc_api::api_audit_log)) - .route("/api/build-logs", get(build_logs::get_build_logs_all)) - .route( - "/api/build-log/{node_id}", - get(build_logs::get_build_log_for_node), - ) - .route( - "/api/build-log/{node_id}/raw", - get(build_logs::get_build_log_raw_for_node), - ) - .route( - "/api/build-logs/{agent}", - get(build_logs::get_build_logs_agent), - ) - .route( - "/api/build-logs/id/{id}", - get(build_logs::get_build_log_full), - ) .route( "/api/build-logs/id/{id}/stream", get(build_logs::get_build_log_stream), ) - .route( - "/api/build-logs/id/{id}/raw", - get(build_logs::get_build_log_raw), - ) - .route( - "/api/agent/{name}/mark-all-read", - post(misc_api::post_mark_all_read), - ) - .route("/api/topology/set-parent", post(topology::post_set_parent)) - .route( - "/api/topology/set-parent-bulk", - post(topology::post_set_parent_bulk), - ) - .route("/api/tool-groups", get(permissions::get_tool_groups)) - .route( - "/api/tool-groups/{agent}", - post(permissions::post_tool_groups), - ) - .route("/api/capabilities", get(permissions::get_capabilities)) - .route( - "/api/capabilities/{agent}", - post(permissions::post_capabilities), - ) - .route("/api/permissions", post(permissions::post_permissions)) - .route( - "/api/permissions/stale", - get(permissions::get_stale_permissions), - ) - .route( - "/api/permissions/{agent}", - axum::routing::delete(permissions::delete_agent_permissions), - ) - .route( - "/api/schedules", - get(schedules::api_schedules).post(schedules::post_schedule_new), - ) - .route( - "/api/schedules/{id}", - axum::routing::patch(schedules::patch_schedule), - ) - .route( - "/api/schedules/{id}/cancel", - post(schedules::post_schedule_cancel), - ) - .route( - "/api/schedules/{id}/pause", - post(schedules::post_schedule_pause), - ) - .route( - "/api/schedules/{id}/resume", - post(schedules::post_schedule_resume), - ) - .route( - "/api/schedules/{id}/fire-now", - post(schedules::post_schedule_fire_now), - ) - .route( - "/api/rebuild-queue/{id}/cancel", - post(schedules::post_rebuild_queue_cancel), - ) - .route("/webhook/knowledge", post(webhook::post_webhook_knowledge)) - .route("/webhook/config-pr", post(webhook::post_webhook_config_pr)) - // Backend routes — the frontend calls these `/api/` paths. The - // transitional bare top-level aliases were removed once the - // frontend migrated. `/webhook/*` keeps its own prefix - // (forge-driven, not the SPA). - .route("/api/approve/{id}", post(approvals::post_approve)) - .route("/api/deny/{id}", post(approvals::post_deny)) - .route("/api/destroy/{name}", post(lifecycle_ops::post_destroy)) - .route("/api/kill/{name}", post(lifecycle_ops::post_kill)) - .route("/api/restart/{name}", post(lifecycle_ops::post_restart)) - .route("/api/start/{name}", post(lifecycle_ops::post_start)) - .route("/api/rebuild/{name}", post(lifecycle_ops::post_rebuild)) - .route("/api/pause/{name}", post(lifecycle_ops::post_pause)) - .route("/api/resume/{name}", post(lifecycle_ops::post_resume)) - .route( - "/api/resource-limits/{name}", - post(lifecycle_ops::post_resource_limits), - ) - .route("/api/update-all", post(lifecycle_ops::post_update_all)) - .route( - "/api/infra-container/{name}/{action}", - post(infra_containers::post_infra_container), - ) - .route( - "/api/answer-question/{id}", - post(questions::post_answer_question), - ) - .route( - "/api/cancel-question/{id}", - post(questions::post_cancel_question), - ) - .route( - "/api/purge-tombstone/{name}", - post(tombstones::post_purge_tombstone), - ) - .route( - "/api/matrix-account-login", - post(matrix_accounts::post_matrix_account_login), - ) - .route( - "/api/github-account", - post(matrix_accounts::post_github_account).get(matrix_accounts::get_github_account), - ) - .route("/api/request-spawn", post(misc_api::post_request_spawn)) - .route("/api/op-send", post(misc_api::post_op_send)) - .route("/api/meta-update", post(meta_inputs::post_meta_update)) .route( "/api/dashboard/stream", get(state_snapshot::dashboard_stream), @@ -287,6 +147,62 @@ pub async fn serve( health::get_health_ready, journal::get_journal, journal::get_journal_host, + state_snapshot::api_state, + state_files::get_state_file, + matrix_accounts::get_matrix_accounts, + matrix_accounts::post_matrix_account_login, + matrix_accounts::post_github_account, + matrix_accounts::get_github_account, + extra_forges::get_extra_forges, + extra_forges::post_extra_forge_account, + misc_api::api_operator_inbox, + misc_api::api_stats_hive, + misc_api::api_container_resources, + misc_api::api_audit_log, + misc_api::post_mark_all_read, + misc_api::post_request_spawn, + misc_api::post_op_send, + build_logs::get_build_logs_all, + build_logs::get_build_log_for_node, + build_logs::get_build_log_raw_for_node, + build_logs::get_build_logs_agent, + build_logs::get_build_log_full, + build_logs::get_build_log_raw, + topology::post_set_parent, + topology::post_set_parent_bulk, + permissions::get_tool_groups, + permissions::post_tool_groups, + permissions::get_capabilities, + permissions::post_capabilities, + permissions::post_permissions, + permissions::get_stale_permissions, + permissions::delete_agent_permissions, + schedules::api_schedules, + schedules::post_schedule_new, + schedules::patch_schedule, + schedules::post_schedule_cancel, + schedules::post_schedule_pause, + schedules::post_schedule_resume, + schedules::post_schedule_fire_now, + schedules::post_rebuild_queue_cancel, + webhook::post_webhook_knowledge, + webhook::post_webhook_config_pr, + approvals::post_approve, + approvals::post_deny, + lifecycle_ops::post_destroy, + lifecycle_ops::post_kill, + lifecycle_ops::post_restart, + lifecycle_ops::post_start, + lifecycle_ops::post_rebuild, + lifecycle_ops::post_pause, + lifecycle_ops::post_resume, + lifecycle_ops::post_resource_limits, + lifecycle_ops::post_update_all, + infra_containers::post_infra_container, + questions::post_answer_question, + questions::post_cancel_question, + tombstones::post_purge_tombstone, + meta_inputs::post_meta_update, )) .merge(app.into()) .split_for_parts();