summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main.rs4
-rw-r--r--src/routes/device.rs10
-rw-r--r--src/routes/start.rs8
3 files changed, 11 insertions, 11 deletions
diff --git a/src/main.rs b/src/main.rs
index 779385f..8af8c63 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -41,9 +41,9 @@ mod wol;
41 ), 41 ),
42 components( 42 components(
43 schemas( 43 schemas(
44 start::Payload, 44 start::SPayload,
45 start::Response, 45 start::Response,
46 device::Payload, 46 device::DPayload,
47 storage::DeviceSchema, 47 storage::DeviceSchema,
48 ) 48 )
49 ), 49 ),
diff --git a/src/routes/device.rs b/src/routes/device.rs
index b6bd9d0..49361f2 100644
--- a/src/routes/device.rs
+++ b/src/routes/device.rs
@@ -32,7 +32,7 @@ pub async fn get(Path(id): Path<String>) -> Result<Json<Value>, Error> {
32} 32}
33 33
34#[derive(Deserialize, ToSchema)] 34#[derive(Deserialize, ToSchema)]
35pub struct Payload { 35pub struct DPayload {
36 id: String, 36 id: String,
37 mac: String, 37 mac: String,
38 broadcast_addr: String, 38 broadcast_addr: String,
@@ -42,14 +42,14 @@ pub struct Payload {
42#[utoipa::path( 42#[utoipa::path(
43 put, 43 put,
44 path = "/device", 44 path = "/device",
45 request_body = Payload, 45 request_body = DPayload,
46 responses( 46 responses(
47 (status = 200, description = "add device to storage", body = [DeviceSchema]) 47 (status = 200, description = "add device to storage", body = [DeviceSchema])
48 ), 48 ),
49 security((), ("api_key" = [])) 49 security((), ("api_key" = []))
50)] 50)]
51pub async fn put( 51pub async fn put(
52 Json(payload): Json<Payload>, 52 Json(payload): Json<DPayload>,
53) -> Result<Json<Value>, Error> { 53) -> Result<Json<Value>, Error> {
54 info!( 54 info!(
55 "add device {} ({}, {}, {})", 55 "add device {} ({}, {}, {})",
@@ -73,14 +73,14 @@ pub async fn put(
73#[utoipa::path( 73#[utoipa::path(
74 post, 74 post,
75 path = "/device", 75 path = "/device",
76 request_body = Payload, 76 request_body = DPayload,
77 responses( 77 responses(
78 (status = 200, description = "update device in storage", body = [DeviceSchema]) 78 (status = 200, description = "update device in storage", body = [DeviceSchema])
79 ), 79 ),
80 security((), ("api_key" = [])) 80 security((), ("api_key" = []))
81)] 81)]
82pub async fn post( 82pub async fn post(
83 Json(payload): Json<Payload>, 83 Json(payload): Json<DPayload>,
84) -> Result<Json<Value>, Error> { 84) -> Result<Json<Value>, Error> {
85 info!( 85 info!(
86 "edit device {} ({}, {}, {})", 86 "edit device {} ({}, {}, {})",
diff --git a/src/routes/start.rs b/src/routes/start.rs
index 6907193..ae2b384 100644
--- a/src/routes/start.rs
+++ b/src/routes/start.rs
@@ -14,7 +14,7 @@ use uuid::Uuid;
14#[utoipa::path( 14#[utoipa::path(
15 post, 15 post,
16 path = "/start/{id}", 16 path = "/start/{id}",
17 request_body = Option<Payload>, 17 request_body = Option<SPayload>,
18 responses( 18 responses(
19 (status = 200, description = "start the device with the given id", body = [Response]) 19 (status = 200, description = "start the device with the given id", body = [Response])
20 ), 20 ),
@@ -26,7 +26,7 @@ use uuid::Uuid;
26pub async fn post( 26pub async fn post(
27 State(state): State<Arc<crate::AppState>>, 27 State(state): State<Arc<crate::AppState>>,
28 Path(id): Path<String>, 28 Path(id): Path<String>,
29 payload: Option<Json<Payload>>, 29 payload: Option<Json<SPayload>>,
30) -> Result<Json<Value>, Error> { 30) -> Result<Json<Value>, Error> {
31 send_wol(state, &id, payload) 31 send_wol(state, &id, payload)
32} 32}
@@ -52,7 +52,7 @@ pub async fn get(
52fn send_wol( 52fn send_wol(
53 state: Arc<crate::AppState>, 53 state: Arc<crate::AppState>,
54 id: &str, 54 id: &str,
55 payload: Option<Json<Payload>>, 55 payload: Option<Json<SPayload>>,
56) -> Result<Json<Value>, Error> { 56) -> Result<Json<Value>, Error> {
57 info!("start request for {id}"); 57 info!("start request for {id}");
58 let device = Device::read(id)?; 58 let device = Device::read(id)?;
@@ -134,7 +134,7 @@ fn get_eta(times: Option<Vec<i64>>) -> i64 {
134} 134}
135 135
136#[derive(Deserialize, ToSchema)] 136#[derive(Deserialize, ToSchema)]
137pub struct Payload { 137pub struct SPayload {
138 ping: Option<bool>, 138 ping: Option<bool>,
139} 139}
140 140