feat: connect alpine agents to admin api

This commit is contained in:
a.tolmachev
2026-03-30 01:31:07 +03:00
parent 85395b10f8
commit e8a4a1138b
9 changed files with 807 additions and 220 deletions
+31 -1
View File
@@ -7,7 +7,7 @@ use serde_json::{Value, json};
use crate::{
error::ApiError,
service::{AgentBindingPayload, AgentPayload, PublishPayload},
service::{AgentBindingPayload, AgentPayload, PublishPayload, UpdateAgentPayload},
state::AppState,
};
@@ -66,6 +66,36 @@ pub async fn get_agent(
Ok(Json(json!(agent)))
}
pub async fn update_agent(
Path(path): Path<WorkspaceAgentPath>,
State(state): State<AppState>,
Json(payload): Json<UpdateAgentPayload>,
) -> Result<Json<Value>, ApiError> {
let updated = state
.service
.update_agent(
&path.workspace_id.as_str().into(),
&path.agent_id.as_str().into(),
payload,
)
.await?;
Ok(Json(json!(updated)))
}
pub async fn delete_agent(
Path(path): Path<WorkspaceAgentPath>,
State(state): State<AppState>,
) -> Result<Json<Value>, ApiError> {
let deleted = state
.service
.delete_agent(
&path.workspace_id.as_str().into(),
&path.agent_id.as_str().into(),
)
.await?;
Ok(Json(json!(deleted)))
}
pub async fn get_agent_version(
Path(path): Path<WorkspaceAgentVersionPath>,
State(state): State<AppState>,