Can update and delete networks

This commit is contained in:
2023-10-31 12:03:37 +01:00
parent 2025416607
commit 9a99e0b54e
4 changed files with 48 additions and 0 deletions

View File

@ -40,3 +40,23 @@ pub async fn get_single(client: LibVirtReq, req: web::Path<NetworkID>) -> HttpRe
Ok(HttpResponse::Ok().json(network))
}
/// Update the information about a single network
pub async fn update(
client: LibVirtReq,
path: web::Path<NetworkID>,
body: web::Json<NetworkInfo>,
) -> HttpResult {
let mut network = body.0.to_virt_network()?;
network.uuid = Some(path.uid);
client.update_network(network).await?;
Ok(HttpResponse::Ok().json("Network updated"))
}
/// Delete a network
pub async fn delete(client: LibVirtReq, path: web::Path<NetworkID>) -> HttpResult {
client.delete_network(path.uid).await?;
Ok(HttpResponse::Ok().json("Network deleted"))
}