Can delete a pending device
This commit is contained in:
@ -1,7 +1,8 @@
|
||||
use crate::devices::device::DeviceId;
|
||||
use crate::energy::energy_actor;
|
||||
use crate::server::custom_error::HttpResult;
|
||||
use crate::server::WebEnergyActor;
|
||||
use actix_web::HttpResponse;
|
||||
use actix_web::{web, HttpResponse};
|
||||
|
||||
/// Get the list of pending (not accepted yet) devices
|
||||
pub async fn list_pending(actor: WebEnergyActor) -> HttpResult {
|
||||
@ -26,3 +27,17 @@ pub async fn list_validated(actor: WebEnergyActor) -> HttpResult {
|
||||
|
||||
Ok(HttpResponse::Ok().json(list))
|
||||
}
|
||||
|
||||
#[derive(serde::Deserialize)]
|
||||
pub struct DeviceInPath {
|
||||
id: DeviceId,
|
||||
}
|
||||
|
||||
/// Delete a device
|
||||
pub async fn delete_device(actor: WebEnergyActor, id: web::Path<DeviceInPath>) -> HttpResult {
|
||||
actor
|
||||
.send(energy_actor::DeleteDevice(id.id.clone()))
|
||||
.await??;
|
||||
|
||||
Ok(HttpResponse::Accepted().finish())
|
||||
}
|
||||
|
Reference in New Issue
Block a user