Reformat code

This commit is contained in:
Tobias Reisinger 2023-11-21 14:58:01 +01:00
parent 271b24b70d
commit a17a9868fa
8 changed files with 40 additions and 33 deletions

View file

@ -26,7 +26,7 @@ paths:
responses:
'200':
description: OK
headers: {}
headers: { }
content:
application/json:
schema:
@ -53,7 +53,7 @@ paths:
schema:
$ref: '#/components/schemas/schedule'
description: The "id" field will be set by the server.
parameters: []
parameters: [ ]
'/api/v1/schedules/{schedule_id}':
parameters:
- schema:
@ -80,7 +80,7 @@ paths:
application/json:
schema:
type: object
properties: {}
properties: { }
operationId: get-schedules-schedule_id
description: Return a single schedule by id.
put:
@ -100,14 +100,14 @@ paths:
application/json:
schema:
type: object
properties: {}
properties: { }
'404':
description: Not Found
content:
application/json:
schema:
type: object
properties: {}
properties: { }
operationId: put-schedules-schedule_id
requestBody:
content:
@ -126,7 +126,7 @@ paths:
items:
$ref: '#/components/schemas/tag'
description: ''
parameters: []
parameters: [ ]
description: Overwrite the properties for a single schedule. Overwriting periods on "on" or "off" will fail.
delete:
summary: delete single schedule
@ -172,7 +172,7 @@ paths:
responses:
'200':
description: OK
headers: {}
headers: { }
content:
application/json:
schema:
@ -181,7 +181,7 @@ paths:
$ref: '#/components/schemas/relay'
operationId: get-relays
description: Return a list with all relays.
parameters: []
parameters: [ ]
'/api/v1/relays/tag/{tag}':
parameters:
- schema:
@ -218,7 +218,7 @@ paths:
$ref: '#/components/schemas/controller'
operationId: get-controllers
description: Return all controllers.
parameters: []
parameters: [ ]
/api/v1/controllers/discover:
put:
summary: discover controllers
@ -235,7 +235,7 @@ paths:
$ref: '#/components/schemas/controller'
operationId: put-controllers-discover
description: Start a discovery process to find controllers in the network. This operations needs multiple seconds to complete.
parameters: []
parameters: [ ]
'/api/v1/controllers/{controller_id}':
parameters:
- schema:
@ -261,14 +261,14 @@ paths:
application/json:
schema:
type: object
properties: {}
properties: { }
operationId: get-controllers-controller_id
requestBody:
content:
application/json:
schema:
type: object
properties: {}
properties: { }
description: ''
description: Return a single controller by id. When no controller with the id is found 404 will be returned.
put:
@ -288,14 +288,14 @@ paths:
application/json:
schema:
type: object
properties: {}
properties: { }
'404':
description: Not Found
content:
application/json:
schema:
type: object
properties: {}
properties: { }
operationId: put-controllers-controller_id
requestBody:
content:
@ -335,7 +335,7 @@ paths:
responses:
'200':
description: OK
headers: {}
headers: { }
content:
application/json:
schema:
@ -348,7 +348,7 @@ paths:
application/json:
schema:
type: array
items: {}
items: { }
operationId: get-controllers-controller_id-relays
description: Returns all relays for a single controller.
'/api/v1/controllers/{controller_id}/relays/{relay_num}':
@ -381,7 +381,7 @@ paths:
application/json:
schema:
type: object
properties: {}
properties: { }
operationId: get-controllers-controller_id-relays-relay_num
description: 'Return a single relay by number for a controller by id. When the relay or controller is not found, 404 will be returned.'
put:
@ -402,14 +402,14 @@ paths:
application/json:
schema:
type: object
properties: {}
properties: { }
'404':
description: Not Found
content:
application/json:
schema:
type: object
properties: {}
properties: { }
operationId: put-controllers-controller_id-relays-relay_num
requestBody:
content:
@ -454,7 +454,7 @@ paths:
$ref: '#/components/schemas/tag'
operationId: get-tags
description: Returns a list of tags.
parameters: []
parameters: [ ]
post:
summary: add new tag
operationId: post-api-v1-tags
@ -568,7 +568,7 @@ paths:
description: |-
WEBSOCKET
This websocket will send all relays with the most recent status every 10 seconds.
parameters: []
parameters: [ ]
/api/v1/macros:
get:
summary: get all macros
@ -723,7 +723,7 @@ paths:
items:
$ref: '#/components/schemas/schedule'
description: Create a list of schedules
parameters: []
parameters: [ ]
components:
schemas:
controller:

View file

@ -1,4 +1,3 @@
use crate::db::models::Periods;
use chrono::{NaiveTime, Timelike};
use serde::{Deserialize, Serialize};
use sqlx::database::HasArguments;
@ -7,6 +6,8 @@ use sqlx::error::BoxDynError;
use sqlx::sqlite::{SqliteTypeInfo, SqliteValueRef};
use sqlx::{Decode, Encode, Sqlite, Type};
use crate::db::models::Periods;
#[derive(Debug, Serialize, Deserialize, PartialEq, Clone)]
pub struct Period {
#[serde(with = "period_format")]

View file

@ -1,6 +1,6 @@
use crate::db::model_utils::Period;
use serde::{Deserialize, Serialize};
use crate::db::model_utils::Period;
use crate::types::EmgauwaUid;
#[derive(Debug, Serialize)]

View file

@ -1,8 +1,10 @@
use crate::db::errors::DatabaseError;
use crate::db::models::*;
use std::ops::DerefMut;
use sqlx::pool::PoolConnection;
use sqlx::Sqlite;
use std::ops::DerefMut;
use crate::db::errors::DatabaseError;
use crate::db::models::*;
pub async fn create_tag(
conn: &mut PoolConnection<Sqlite>,

View file

@ -1,11 +1,12 @@
use crate::db::errors::DatabaseError;
use std::borrow::Borrow;
use std::convert::TryFrom;
use actix_web::{delete, get, post, put, web, HttpResponse, Responder};
use serde::{Deserialize, Serialize};
use sqlx::pool::PoolConnection;
use sqlx::{Pool, Sqlite};
use std::borrow::Borrow;
use std::convert::TryFrom;
use crate::db::errors::DatabaseError;
use crate::db::models::{Periods, Schedule};
use crate::db::schedules::*;
use crate::db::tag::get_tag;

View file

@ -1,10 +1,11 @@
extern crate dotenv;
use std::str::FromStr;
use actix_web::middleware::TrailingSlash;
use actix_web::{middleware, web, App, HttpServer};
use log::{trace, LevelFilter};
use simple_logger::SimpleLogger;
use std::str::FromStr;
mod db;
mod handlers;

View file

@ -1,7 +1,8 @@
use std::sync::RwLock;
use config::Config;
use lazy_static::lazy_static;
use serde_derive::Deserialize;
use std::sync::RwLock;
#[derive(Clone, Debug, Deserialize)]
#[serde(default)]

View file

@ -2,7 +2,6 @@ use std::convert::TryFrom;
use std::fmt::{Debug, Formatter};
use std::str::FromStr;
use crate::types::EmgauwaUid;
use serde::{Serialize, Serializer};
use sqlx::database::HasArguments;
use sqlx::encode::IsNull;
@ -11,6 +10,8 @@ use sqlx::sqlite::{SqliteTypeInfo, SqliteValueRef};
use sqlx::{Decode, Encode, Sqlite, Type};
use uuid::Uuid;
use crate::types::EmgauwaUid;
impl EmgauwaUid {
const OFF_STR: &'static str = "off";
const ON_STR: &'static str = "on";