zart_api/lib.rs
1//! Zart HTTP API — optional Axum server for external interaction with durable executions.
2//!
3//! Route prefixes are configurable at startup (default: `/api/v1` and `/zart/admin/v1`).
4//! Set `ZART_API_PREFIX` / `ZART_ADMIN_PREFIX` env vars or use the builder methods
5//! [`ApiServer::with_api_prefix`] / [`ApiServer::with_admin_prefix`].
6//!
7//! # Endpoints (default prefixes)
8//!
9//! ```text
10//! GET /api/v1/executions — List executions
11//! POST /api/v1/executions — Start a new execution
12//! GET /api/v1/executions/:execution_id — Get execution status
13//! POST /api/v1/executions/:execution_id/cancel — Cancel an execution
14//! GET /api/v1/executions/:execution_id/wait — Long-poll until completion
15//! GET /api/v1/stats — Aggregate execution counts by status
16//! POST /api/v1/events/:execution_id/:event_name — Deliver an event
17//! GET /healthz — Liveness probe (always at root)
18//! GET /readyz — Readiness probe (always at root)
19//! GET /metrics — Prometheus metrics (always at root)
20//!
21//! GET /zart/admin/v1/executions/:id/detail — Full execution detail with steps & attempts
22//! POST /zart/admin/v1/executions/:id/retry-step — Retry a dead step
23//! POST /zart/admin/v1/executions/:id/restart — Restart an execution
24//! POST /zart/admin/v1/executions/:id/rerun — Selective step rerun
25//! GET /zart/admin/v1/executions/:id/runs — List runs for an execution
26//! POST /zart/admin/v1/pause — Create a pause rule
27//! GET /zart/admin/v1/pause — List pause rules
28//! POST /zart/admin/v1/pause/:rule_id — Resume (soft-delete) a pause rule
29//! DELETE /zart/admin/v1/pause/:rule_id — Delete a pause rule
30//! ```
31//!
32//! # Usage
33//!
34//! ```rust,no_run
35//! use zart_api::ApiServer;
36//! use zart::{DurableRegistry, DurableScheduler, into_durable_api};
37//! use std::sync::Arc;
38//!
39//! # async fn example() {
40//! // let scheduler = Arc::new(/* PostgresScheduler */);
41//! // let durable = into_durable_api(DurableScheduler::new(scheduler));
42//! // ApiServer::new("0.0.0.0:8080", durable).serve().await.unwrap();
43//! # }
44//! ```
45
46pub mod admin_routes;
47pub mod models;
48#[cfg(feature = "openapi")]
49pub mod openapi;
50pub mod routes;
51pub mod server;
52pub mod state;
53
54pub use admin_routes::admin_router;
55pub use server::ApiServer;
56pub use state::{AdminState, AppState};
57
58#[cfg(feature = "openapi")]
59pub use openapi::{ZartApiDoc, build_openapi};