tsk-170: Added the rest of the documentation
This commit is contained in:
+36
-33
@@ -1,5 +1,5 @@
|
||||
// TODO: Separate queue and coverart endpoints
|
||||
#[derive(Debug, Default, serde::Deserialize, serde::Serialize)]
|
||||
#[derive(Debug, Default, serde::Deserialize, serde::Serialize, utoipa::ToSchema)]
|
||||
pub struct CoverArtQueue {
|
||||
pub id: uuid::Uuid,
|
||||
pub song_queue_id: uuid::Uuid,
|
||||
@@ -575,17 +575,19 @@ pub mod endpoint {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
/// Endpoint to fetch cover art details
|
||||
#[utoipa::path(
|
||||
post,
|
||||
get,
|
||||
path = super::super::endpoints::QUEUECOVERART,
|
||||
params(super::request::fetch_coverart_no_data::Params),
|
||||
params(
|
||||
("id" = uuid::Uuid, Path, description = "Queued cover art Id"),
|
||||
("song_queue_id" = uuid::Uuid, Path, description = "Queued song Id")
|
||||
),
|
||||
responses(
|
||||
(status = 200, description = "Queued song linked", body = super::response::fetch_coverart_no_data::Response),
|
||||
(status = 400, description = "Linkage failed", body = super::response::fetch_coverart_no_data::Response)
|
||||
)
|
||||
)]
|
||||
*/
|
||||
pub async fn fetch_coverart_no_data(
|
||||
axum::Extension(pool): axum::Extension<sqlx::PgPool>,
|
||||
axum::extract::Query(params): axum::extract::Query<
|
||||
@@ -635,7 +637,7 @@ pub mod endpoint {
|
||||
|
||||
/// Endpoint to fetch the queued cover art data
|
||||
#[utoipa::path(
|
||||
post,
|
||||
get,
|
||||
path = super::super::endpoints::QUEUECOVERARTDATA,
|
||||
params(("id" = uuid::Uuid, Path, description = "Queued cover art Id")),
|
||||
responses(
|
||||
@@ -671,17 +673,18 @@ pub mod endpoint {
|
||||
}
|
||||
}
|
||||
|
||||
/// Endpoint to create cover art
|
||||
#[utoipa::path(
|
||||
post,
|
||||
path = "/api/v2/song/queue/link",
|
||||
path = super::super::endpoints::CREATECOVERART,
|
||||
request_body(
|
||||
content = super::request::link_user_id::Request,
|
||||
description = "User Id and queued song id",
|
||||
content = super::request::create_coverart::Request,
|
||||
description = "Data required to create cover art",
|
||||
content_type = "application/json"
|
||||
),
|
||||
responses(
|
||||
(status = 200, description = "Queued song linked", body = super::response::link_user_id::Response),
|
||||
(status = 400, description = "Linkage failed", body = super::response::link_user_id::Response)
|
||||
(status = 200, description = "Cover art created", body = super::response::create_coverart::Response),
|
||||
(status = 400, description = "Failure in creating cover art", body = super::response::create_coverart::Response)
|
||||
)
|
||||
)]
|
||||
pub async fn create_coverart(
|
||||
@@ -744,17 +747,19 @@ pub mod endpoint {
|
||||
}
|
||||
}
|
||||
|
||||
/// Endpoint to wipe data from the cover art queue
|
||||
#[utoipa::path(
|
||||
post,
|
||||
path = "/api/v2/song/queue/link",
|
||||
patch,
|
||||
path = super::super::endpoints::QUEUECOVERARTDATAWIPE,
|
||||
request_body(
|
||||
content = super::request::link_user_id::Request,
|
||||
description = "User Id and queued song id",
|
||||
content = super::request::wipe_data_from_coverart_queue::Request,
|
||||
description = "Data required to wipe the data from the cover art queue",
|
||||
content_type = "application/json"
|
||||
),
|
||||
responses(
|
||||
(status = 200, description = "Queued song linked", body = super::response::link_user_id::Response),
|
||||
(status = 400, description = "Linkage failed", body = super::response::link_user_id::Response)
|
||||
(status = 200, description = "Data wiped from cover art queue", body = super::response::wipe_data_from_coverart_queue::Response),
|
||||
(status = 400, description = "Error wiping the data", body = super::response::wipe_data_from_coverart_queue::Response),
|
||||
(status = 404, description = "Cover art not found", body = super::response::wipe_data_from_coverart_queue::Response)
|
||||
)
|
||||
)]
|
||||
pub async fn wipe_data_from_coverart_queue(
|
||||
@@ -786,17 +791,16 @@ pub mod endpoint {
|
||||
}
|
||||
}
|
||||
|
||||
/// Endpoint to get cover art with criteria
|
||||
#[utoipa::path(
|
||||
post,
|
||||
path = "/api/v2/song/queue/link",
|
||||
request_body(
|
||||
content = super::request::link_user_id::Request,
|
||||
description = "User Id and queued song id",
|
||||
content_type = "application/json"
|
||||
get,
|
||||
path = super::super::endpoints::GETCOVERART,
|
||||
params(
|
||||
("id" = uuid::Uuid, Path, description = "Cover art Id")
|
||||
),
|
||||
responses(
|
||||
(status = 200, description = "Queued song linked", body = super::response::link_user_id::Response),
|
||||
(status = 400, description = "Linkage failed", body = super::response::link_user_id::Response)
|
||||
(status = 200, description = "Cover art retrieved", body = super::response::get_coverart::Response),
|
||||
(status = 400, description = "Error retrieving cover art", body = super::response::get_coverart::Response)
|
||||
)
|
||||
)]
|
||||
pub async fn get_coverart(
|
||||
@@ -827,17 +831,16 @@ pub mod endpoint {
|
||||
}
|
||||
}
|
||||
|
||||
/// Endpoint to download cover art
|
||||
#[utoipa::path(
|
||||
post,
|
||||
path = "/api/v2/song/queue/link",
|
||||
request_body(
|
||||
content = super::request::link_user_id::Request,
|
||||
description = "User Id and queued song id",
|
||||
content_type = "application/json"
|
||||
get,
|
||||
path = super::super::endpoints::DOWNLOADCOVERART,
|
||||
params(
|
||||
("id" = uuid::Uuid, Path, description = "Cover art Id")
|
||||
),
|
||||
responses(
|
||||
(status = 200, description = "Queued song linked", body = super::response::link_user_id::Response),
|
||||
(status = 400, description = "Linkage failed", body = super::response::link_user_id::Response)
|
||||
(status = 200, description = "Cover art downloading", body = Vec<u8>),
|
||||
(status = 404, description = "Cover art not found", body = Vec<u8>)
|
||||
)
|
||||
)]
|
||||
pub async fn download_coverart(
|
||||
|
||||
+27
-21
@@ -1,10 +1,9 @@
|
||||
// TODO: Explicitly make this module target queueing a song's metadata
|
||||
pub mod request {
|
||||
|
||||
pub mod queue_metadata {
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Debug, Default, Deserialize, Serialize, sqlx::FromRow)]
|
||||
#[derive(Debug, Default, Deserialize, Serialize, sqlx::FromRow, utoipa::ToSchema)]
|
||||
pub struct Request {
|
||||
pub song_queue_id: uuid::Uuid,
|
||||
pub album: String,
|
||||
@@ -43,7 +42,13 @@ pub mod request {
|
||||
|
||||
pub mod fetch_metadata {
|
||||
#[derive(
|
||||
Debug, Default, serde::Deserialize, serde::Serialize, sqlx::FromRow, sqlx::Decode,
|
||||
Debug,
|
||||
Default,
|
||||
serde::Deserialize,
|
||||
serde::Serialize,
|
||||
sqlx::FromRow,
|
||||
sqlx::Decode,
|
||||
utoipa::ToSchema,
|
||||
)]
|
||||
pub struct Params {
|
||||
pub id: Option<uuid::Uuid>,
|
||||
@@ -53,11 +58,10 @@ pub mod request {
|
||||
}
|
||||
|
||||
pub mod response {
|
||||
|
||||
pub mod queue_metadata {
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Default, Deserialize, Serialize)]
|
||||
#[derive(Default, Deserialize, Serialize, utoipa::ToSchema)]
|
||||
pub struct Response {
|
||||
pub message: String,
|
||||
pub data: Vec<uuid::Uuid>,
|
||||
@@ -67,7 +71,7 @@ pub mod response {
|
||||
pub mod fetch_metadata {
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Default, Deserialize, Serialize)]
|
||||
#[derive(Default, Deserialize, Serialize, utoipa::ToSchema)]
|
||||
pub struct Response {
|
||||
pub message: String,
|
||||
pub data: Vec<crate::callers::metadata::metadata_queue::MetadataQueue>,
|
||||
@@ -83,7 +87,7 @@ pub mod metadata_queue {
|
||||
pub id: uuid::Uuid,
|
||||
}
|
||||
|
||||
#[derive(Debug, serde::Deserialize, serde::Serialize, sqlx::FromRow)]
|
||||
#[derive(Debug, serde::Deserialize, serde::Serialize, sqlx::FromRow, utoipa::ToSchema)]
|
||||
pub struct MetadataQueue {
|
||||
pub id: uuid::Uuid,
|
||||
pub metadata: serde_json::Value,
|
||||
@@ -204,20 +208,22 @@ pub mod metadata_queue {
|
||||
}
|
||||
}
|
||||
|
||||
/// Module for metadata related endpoints
|
||||
pub mod endpoint {
|
||||
use axum::{Json, http::StatusCode};
|
||||
|
||||
/// Endpoint to create queued metadata
|
||||
#[utoipa::path(
|
||||
post,
|
||||
path = "/api/v2/song/queue/link",
|
||||
path = super::super::endpoints::QUEUEMETADATA,
|
||||
request_body(
|
||||
content = super::request::link_user_id::Request,
|
||||
description = "User Id and queued song id",
|
||||
content = super::request::queue_metadata::Request,
|
||||
description = "Data required to create queued metadata",
|
||||
content_type = "application/json"
|
||||
),
|
||||
responses(
|
||||
(status = 200, description = "Queued song linked", body = super::response::link_user_id::Response),
|
||||
(status = 400, description = "Linkage failed", body = super::response::link_user_id::Response)
|
||||
(status = 200, description = "Queued metadata created", body = super::response::queue_metadata::Response),
|
||||
(status = 400, description = "Error creating queued metadata", body = super::response::queue_metadata::Response)
|
||||
)
|
||||
)]
|
||||
pub async fn queue_metadata(
|
||||
@@ -234,7 +240,7 @@ pub mod endpoint {
|
||||
response.message = if response.data.is_empty() {
|
||||
String::from("Error")
|
||||
} else {
|
||||
String::from("Success")
|
||||
String::from(super::super::response::SUCCESSFUL)
|
||||
};
|
||||
|
||||
(StatusCode::OK, Json(response))
|
||||
@@ -246,17 +252,17 @@ pub mod endpoint {
|
||||
}
|
||||
}
|
||||
|
||||
/// Endpoint to get queued metadata
|
||||
#[utoipa::path(
|
||||
post,
|
||||
path = "/api/v2/song/queue/link",
|
||||
request_body(
|
||||
content = super::request::link_user_id::Request,
|
||||
description = "User Id and queued song id",
|
||||
content_type = "application/json"
|
||||
get,
|
||||
path = super::super::endpoints::QUEUEMETADATA,
|
||||
params(
|
||||
("id" = uuid::Uuid, Path, description = "Id of queued metadata"),
|
||||
("song_queue_id" = uuid::Uuid, Path, description = "Id of queued song")
|
||||
),
|
||||
responses(
|
||||
(status = 200, description = "Queued song linked", body = super::response::link_user_id::Response),
|
||||
(status = 400, description = "Linkage failed", body = super::response::link_user_id::Response)
|
||||
(status = 200, description = "Queued metadata retrieved", body = super::response::fetch_metadata::Response),
|
||||
(status = 400, description = "Error retrieving queued metadata", body = super::response::fetch_metadata::Response)
|
||||
)
|
||||
)]
|
||||
pub async fn fetch_metadata(
|
||||
|
||||
+4
-3
@@ -1323,17 +1323,18 @@ pub mod endpoint {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
// Endpoint to get songs
|
||||
#[utoipa::path(
|
||||
get,
|
||||
path = super::super::endpoints::GETSONGS,
|
||||
params(super::request::get_songs::Params),
|
||||
params(
|
||||
("id" = uuid::Uuid, Path, description = "Id of song")
|
||||
),
|
||||
responses(
|
||||
(status = 200, description = "Songs found", body = super::response::get_songs::Response),
|
||||
(status = 400, description = "Error getting songs", body = super::response::get_songs::Response)
|
||||
)
|
||||
)]
|
||||
*/
|
||||
pub async fn get_songs(
|
||||
axum::Extension(pool): axum::Extension<sqlx::PgPool>,
|
||||
axum::extract::Query(params): axum::extract::Query<super::request::get_songs::Params>,
|
||||
|
||||
Reference in New Issue
Block a user