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

View file

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

View file

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

View file

@ -1,8 +1,10 @@
use crate::db::errors::DatabaseError; use std::ops::DerefMut;
use crate::db::models::*;
use sqlx::pool::PoolConnection; use sqlx::pool::PoolConnection;
use sqlx::Sqlite; use sqlx::Sqlite;
use std::ops::DerefMut;
use crate::db::errors::DatabaseError;
use crate::db::models::*;
pub async fn create_tag( pub async fn create_tag(
conn: &mut PoolConnection<Sqlite>, 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 actix_web::{delete, get, post, put, web, HttpResponse, Responder};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use sqlx::pool::PoolConnection; use sqlx::pool::PoolConnection;
use sqlx::{Pool, Sqlite}; 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::models::{Periods, Schedule};
use crate::db::schedules::*; use crate::db::schedules::*;
use crate::db::tag::get_tag; use crate::db::tag::get_tag;

View file

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

View file

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

View file

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