Implement routes to start VMs of a group
This commit is contained in:
30
remote_backend/src/controllers/group_controller.rs
Normal file
30
remote_backend/src/controllers/group_controller.rs
Normal file
@@ -0,0 +1,30 @@
|
||||
use crate::controllers::HttpResult;
|
||||
use crate::virtweb_client;
|
||||
use crate::virtweb_client::{GroupID, VMUuid};
|
||||
use actix_web::{web, HttpResponse};
|
||||
|
||||
#[derive(serde::Deserialize)]
|
||||
pub struct GroupIDInPath {
|
||||
gid: GroupID,
|
||||
}
|
||||
|
||||
#[derive(serde::Deserialize)]
|
||||
pub struct VMIDInQuery {
|
||||
vm_id: Option<VMUuid>,
|
||||
}
|
||||
|
||||
/// Get the state of one or all VM
|
||||
pub async fn vm_state(
|
||||
path: web::Path<GroupIDInPath>,
|
||||
query: web::Query<VMIDInQuery>,
|
||||
) -> HttpResult {
|
||||
Ok(HttpResponse::Ok().json(virtweb_client::group_vm_state(&path.gid, query.vm_id).await?))
|
||||
}
|
||||
|
||||
/// Start one or all VM
|
||||
pub async fn vm_start(
|
||||
path: web::Path<GroupIDInPath>,
|
||||
query: web::Query<VMIDInQuery>,
|
||||
) -> HttpResult {
|
||||
Ok(HttpResponse::Ok().json(virtweb_client::group_vm_start(&path.gid, query.vm_id).await?))
|
||||
}
|
||||
Reference in New Issue
Block a user