Skip to content
This repository was archived by the owner on Jan 27, 2026. It is now read-only.

Commit d6ed167

Browse files
authored
feat(orchestrator): swagger docs (#531)
* setup orchestrator swagger docs via `/docs`
1 parent c9b2257 commit d6ed167

17 files changed

Lines changed: 524 additions & 41 deletions

File tree

Cargo.lock

Lines changed: 164 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/orchestrator/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ serde_json = { workspace = true }
2828
shared = { workspace = true }
2929
tokio = { workspace = true }
3030
url = { workspace = true }
31+
utoipa = { version = "5.3.0", features = ["actix_extras", "chrono", "uuid"] }
32+
utoipa-swagger-ui = { version = "9.0.2", features = ["actix-web", "debug-embed", "reqwest", "vendored"] }
3133
uuid = { workspace = true }
3234
iroh = { workspace = true }
3335
rand_v8 = { workspace = true }

crates/orchestrator/src/api/routes/groups.rs

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,25 @@ use serde::{Deserialize, Serialize};
1010
use serde_json::json;
1111
use std::str::FromStr;
1212
use std::time::Duration;
13+
use utoipa::ToSchema;
1314

1415
const NODE_REQUEST_TIMEOUT: u64 = 30;
1516

16-
#[derive(Debug, Deserialize, Serialize)]
17+
#[derive(Debug, Deserialize, Serialize, ToSchema)]
1718
struct ForceRegroupRequest {
1819
configuration_name: String,
1920
}
2021

22+
#[utoipa::path(
23+
get,
24+
path = "/groups",
25+
responses(
26+
(status = 200, description = "List of all groups retrieved successfully"),
27+
(status = 503, description = "Node groups plugin is not enabled"),
28+
(status = 500, description = "Internal server error")
29+
),
30+
tag = "groups"
31+
)]
2132
async fn get_groups(app_state: Data<AppState>) -> HttpResponse {
2233
if let Some(node_groups_plugin) = &app_state.node_groups_plugin {
2334
match node_groups_plugin.get_all_groups().await {
@@ -54,6 +65,15 @@ async fn get_groups(app_state: Data<AppState>) -> HttpResponse {
5465
}
5566
}
5667

68+
#[utoipa::path(
69+
get,
70+
path = "/groups/configs",
71+
responses(
72+
(status = 200, description = "List of all configurations retrieved successfully"),
73+
(status = 503, description = "Node groups plugin is not enabled")
74+
),
75+
tag = "groups"
76+
)]
5777
async fn get_configurations(app_state: Data<AppState>) -> HttpResponse {
5878
if let Some(node_groups_plugin) = &app_state.node_groups_plugin {
5979
let all_configs = node_groups_plugin.get_all_configuration_templates();
@@ -88,6 +108,19 @@ async fn get_configurations(app_state: Data<AppState>) -> HttpResponse {
88108
}
89109
}
90110

111+
#[utoipa::path(
112+
delete,
113+
path = "/groups/{group_id}",
114+
params(
115+
("group_id" = String, Path, description = "Group ID to delete")
116+
),
117+
responses(
118+
(status = 200, description = "Group deleted successfully"),
119+
(status = 503, description = "Node groups plugin is not enabled"),
120+
(status = 500, description = "Internal server error")
121+
),
122+
tag = "groups"
123+
)]
91124
async fn delete_group(group_id: web::Path<String>, app_state: Data<AppState>) -> HttpResponse {
92125
if let Some(node_groups_plugin) = &app_state.node_groups_plugin {
93126
match node_groups_plugin.dissolve_group(&group_id).await {
@@ -108,6 +141,20 @@ async fn delete_group(group_id: web::Path<String>, app_state: Data<AppState>) ->
108141
}
109142
}
110143

144+
#[utoipa::path(
145+
get,
146+
path = "/groups/{group_id}/logs",
147+
params(
148+
("group_id" = String, Path, description = "Group ID to get logs for")
149+
),
150+
responses(
151+
(status = 200, description = "Group logs retrieved successfully"),
152+
(status = 404, description = "Group not found"),
153+
(status = 503, description = "Node groups plugin is not enabled"),
154+
(status = 500, description = "Internal server error")
155+
),
156+
tag = "groups"
157+
)]
111158
async fn get_group_logs(group_id: web::Path<String>, app_state: Data<AppState>) -> HttpResponse {
112159
if let Some(node_groups_plugin) = &app_state.node_groups_plugin {
113160
match node_groups_plugin.get_group_by_id(&group_id).await {
@@ -249,6 +296,18 @@ async fn fetch_node_logs_p2p(
249296
}
250297
}
251298

299+
#[utoipa::path(
300+
post,
301+
path = "/groups/force-regroup",
302+
request_body = ForceRegroupRequest,
303+
responses(
304+
(status = 200, description = "Force regroup initiated successfully"),
305+
(status = 404, description = "Configuration not found"),
306+
(status = 503, description = "Node groups plugin is not enabled"),
307+
(status = 500, description = "Internal server error")
308+
),
309+
tag = "groups"
310+
)]
252311
async fn force_regroup(
253312
request: web::Json<ForceRegroupRequest>,
254313
app_state: Data<AppState>,

0 commit comments

Comments
 (0)