18 lines
554 B
Rust

use crate::controllers::{HttpResult, LibVirtReq};
use crate::libvirt_rest_structures::VMInfo;
use actix_web::{web, HttpResponse};
/// Create a new VM
pub async fn create(client: LibVirtReq, req: web::Json<VMInfo>) -> HttpResult {
let domain = match req.0.to_domain() {
Ok(d) => d,
Err(e) => {
log::error!("Failed to extract domain info! {e}");
return Ok(HttpResponse::BadRequest().body(e.to_string()));
}
};
let id = client.update_domain(domain).await?;
Ok(HttpResponse::Ok().json(id))
}