@@ -10,14 +10,25 @@ use serde::{Deserialize, Serialize};
1010use serde_json:: json;
1111use std:: str:: FromStr ;
1212use std:: time:: Duration ;
13+ use utoipa:: ToSchema ;
1314
1415const NODE_REQUEST_TIMEOUT : u64 = 30 ;
1516
16- #[ derive( Debug , Deserialize , Serialize ) ]
17+ #[ derive( Debug , Deserialize , Serialize , ToSchema ) ]
1718struct 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+ ) ]
2132async 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+ ) ]
5777async 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+ ) ]
91124async 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+ ) ]
111158async 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+ ) ]
252311async fn force_regroup (
253312 request : web:: Json < ForceRegroupRequest > ,
254313 app_state : Data < AppState > ,
0 commit comments