@@ -12,6 +12,9 @@ use axum::{
12
12
#[ cfg( feature = "http-api" ) ]
13
13
use std:: sync:: Arc ;
14
14
15
+ #[ cfg( feature = "http-api" ) ]
16
+ use utoipa;
17
+
15
18
#[ cfg( feature = "http-api" ) ]
16
19
use super :: traits:: RuntimeApiProvider ;
17
20
@@ -23,6 +26,16 @@ use crate::types::AgentId;
23
26
24
27
/// Workflow execution endpoint handler
25
28
#[ cfg( feature = "http-api" ) ]
29
+ #[ utoipa:: path(
30
+ post,
31
+ path = "/api/v1/workflows/execute" ,
32
+ request_body = WorkflowExecutionRequest ,
33
+ responses(
34
+ ( status = 200 , description = "Workflow executed successfully" , body = serde_json:: Value ) ,
35
+ ( status = 500 , description = "Internal server error" , body = ErrorResponse )
36
+ ) ,
37
+ tag = "workflows"
38
+ ) ]
26
39
pub async fn execute_workflow (
27
40
State ( provider) : State < Arc < dyn RuntimeApiProvider > > ,
28
41
Json ( request) : Json < WorkflowExecutionRequest > ,
@@ -42,6 +55,18 @@ pub async fn execute_workflow(
42
55
43
56
/// Agent status endpoint handler
44
57
#[ cfg( feature = "http-api" ) ]
58
+ #[ utoipa:: path(
59
+ get,
60
+ path = "/api/v1/agents/{id}/status" ,
61
+ params(
62
+ ( "id" = AgentId , Path , description = "Agent identifier" )
63
+ ) ,
64
+ responses(
65
+ ( status = 200 , description = "Agent status retrieved successfully" , body = AgentStatusResponse ) ,
66
+ ( status = 404 , description = "Agent not found" , body = ErrorResponse )
67
+ ) ,
68
+ tag = "agents"
69
+ ) ]
45
70
pub async fn get_agent_status (
46
71
State ( provider) : State < Arc < dyn RuntimeApiProvider > > ,
47
72
Path ( agent_id) : Path < AgentId > ,
@@ -61,6 +86,15 @@ pub async fn get_agent_status(
61
86
62
87
/// List agents endpoint handler
63
88
#[ cfg( feature = "http-api" ) ]
89
+ #[ utoipa:: path(
90
+ get,
91
+ path = "/api/v1/agents" ,
92
+ responses(
93
+ ( status = 200 , description = "Agents listed successfully" , body = Vec <String >) ,
94
+ ( status = 500 , description = "Internal server error" , body = ErrorResponse )
95
+ ) ,
96
+ tag = "agents"
97
+ ) ]
64
98
pub async fn list_agents (
65
99
State ( provider) : State < Arc < dyn RuntimeApiProvider > > ,
66
100
) -> Result < Json < Vec < String > > , ( StatusCode , Json < ErrorResponse > ) > {
@@ -82,6 +116,15 @@ pub async fn list_agents(
82
116
83
117
/// System metrics endpoint handler
84
118
#[ cfg( feature = "http-api" ) ]
119
+ #[ utoipa:: path(
120
+ get,
121
+ path = "/api/v1/metrics" ,
122
+ responses(
123
+ ( status = 200 , description = "Metrics retrieved successfully" , body = serde_json:: Value ) ,
124
+ ( status = 500 , description = "Internal server error" , body = ErrorResponse )
125
+ ) ,
126
+ tag = "system"
127
+ ) ]
85
128
pub async fn get_metrics (
86
129
State ( provider) : State < Arc < dyn RuntimeApiProvider > > ,
87
130
) -> Result < Json < serde_json:: Value > , ( StatusCode , Json < ErrorResponse > ) > {
@@ -100,6 +143,16 @@ pub async fn get_metrics(
100
143
101
144
/// Create agent endpoint handler
102
145
#[ cfg( feature = "http-api" ) ]
146
+ #[ utoipa:: path(
147
+ post,
148
+ path = "/api/v1/agents" ,
149
+ request_body = CreateAgentRequest ,
150
+ responses(
151
+ ( status = 200 , description = "Agent created successfully" , body = CreateAgentResponse ) ,
152
+ ( status = 500 , description = "Internal server error" , body = ErrorResponse )
153
+ ) ,
154
+ tag = "agents"
155
+ ) ]
103
156
pub async fn create_agent (
104
157
State ( provider) : State < Arc < dyn RuntimeApiProvider > > ,
105
158
Json ( request) : Json < CreateAgentRequest > ,
@@ -119,6 +172,19 @@ pub async fn create_agent(
119
172
120
173
/// Update agent endpoint handler
121
174
#[ cfg( feature = "http-api" ) ]
175
+ #[ utoipa:: path(
176
+ put,
177
+ path = "/api/v1/agents/{id}" ,
178
+ params(
179
+ ( "id" = AgentId , Path , description = "Agent identifier" )
180
+ ) ,
181
+ request_body = UpdateAgentRequest ,
182
+ responses(
183
+ ( status = 200 , description = "Agent updated successfully" , body = UpdateAgentResponse ) ,
184
+ ( status = 500 , description = "Internal server error" , body = ErrorResponse )
185
+ ) ,
186
+ tag = "agents"
187
+ ) ]
122
188
pub async fn update_agent (
123
189
State ( provider) : State < Arc < dyn RuntimeApiProvider > > ,
124
190
Path ( agent_id) : Path < AgentId > ,
@@ -139,6 +205,18 @@ pub async fn update_agent(
139
205
140
206
/// Delete agent endpoint handler
141
207
#[ cfg( feature = "http-api" ) ]
208
+ #[ utoipa:: path(
209
+ delete,
210
+ path = "/api/v1/agents/{id}" ,
211
+ params(
212
+ ( "id" = AgentId , Path , description = "Agent identifier" )
213
+ ) ,
214
+ responses(
215
+ ( status = 200 , description = "Agent deleted successfully" , body = DeleteAgentResponse ) ,
216
+ ( status = 500 , description = "Internal server error" , body = ErrorResponse )
217
+ ) ,
218
+ tag = "agents"
219
+ ) ]
142
220
pub async fn delete_agent (
143
221
State ( provider) : State < Arc < dyn RuntimeApiProvider > > ,
144
222
Path ( agent_id) : Path < AgentId > ,
@@ -158,6 +236,19 @@ pub async fn delete_agent(
158
236
159
237
/// Execute agent endpoint handler
160
238
#[ cfg( feature = "http-api" ) ]
239
+ #[ utoipa:: path(
240
+ post,
241
+ path = "/api/v1/agents/{id}/execute" ,
242
+ params(
243
+ ( "id" = AgentId , Path , description = "Agent identifier" )
244
+ ) ,
245
+ request_body = ExecuteAgentRequest ,
246
+ responses(
247
+ ( status = 200 , description = "Agent executed successfully" , body = ExecuteAgentResponse ) ,
248
+ ( status = 500 , description = "Internal server error" , body = ErrorResponse )
249
+ ) ,
250
+ tag = "agents"
251
+ ) ]
161
252
pub async fn execute_agent (
162
253
State ( provider) : State < Arc < dyn RuntimeApiProvider > > ,
163
254
Path ( agent_id) : Path < AgentId > ,
@@ -178,6 +269,18 @@ pub async fn execute_agent(
178
269
179
270
/// Get agent execution history endpoint handler
180
271
#[ cfg( feature = "http-api" ) ]
272
+ #[ utoipa:: path(
273
+ get,
274
+ path = "/api/v1/agents/{id}/history" ,
275
+ params(
276
+ ( "id" = AgentId , Path , description = "Agent identifier" )
277
+ ) ,
278
+ responses(
279
+ ( status = 200 , description = "Agent history retrieved successfully" , body = GetAgentHistoryResponse ) ,
280
+ ( status = 500 , description = "Internal server error" , body = ErrorResponse )
281
+ ) ,
282
+ tag = "agents"
283
+ ) ]
181
284
pub async fn get_agent_history (
182
285
State ( provider) : State < Arc < dyn RuntimeApiProvider > > ,
183
286
Path ( agent_id) : Path < AgentId > ,
0 commit comments