Add REST route to get networks list

This commit is contained in:
2023-10-31 10:51:13 +01:00
parent f2237d4f2f
commit 2741faa95b
7 changed files with 125 additions and 2 deletions

View File

@ -21,3 +21,15 @@ pub async fn create(client: LibVirtReq, req: web::Json<NetworkInfo>) -> HttpResu
Ok(HttpResponse::Ok().json(NetworkID { id }))
}
/// Get the list of networks
pub async fn list(client: LibVirtReq) -> HttpResult {
let networks = client
.get_full_networks_list()
.await?
.into_iter()
.map(|n| NetworkInfo::from_xml(n).unwrap())
.collect::<Vec<_>>();
Ok(HttpResponse::Ok().json(networks))
}