shared/api/endpoints/additional_resource.rs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
use crate::{
api::Method,
domain::{
additional_resource::{
AdditionalResource, AdditionalResourceCreateRequest, AdditionalResourceId,
AdditionalResourceUpdateRequest, AssetIdResource, CreateAssetResourcePath,
DeleteAssetResourcePath, GetAssetResourceDraftPath, GetAssetResourceLivePath,
UpdateAssetResourcePath,
},
CreateResponse,
},
error::EmptyError,
};
use super::ApiEndpoint;
/// Get an additional resource on a draft JIG or Playlist copy by id.
///
/// # Authorization
/// Standard
///
/// # Errors
///
/// * [`Unauthorized`](http::StatusCode::UNAUTHORIZED) if authorization is not valid.
/// * [`NotFound`](http::StatusCode::NOT_FOUND) if the additional resource or the parent JIG or Playlist doesn't exist.
pub struct GetDraft;
impl ApiEndpoint for GetDraft {
type Req = AssetIdResource;
type Res = AdditionalResource;
type Path = GetAssetResourceDraftPath;
type Err = EmptyError;
const METHOD: Method = Method::Get;
}
/// Get an additional resource on a live JIG or Playlist copy by id.
///
/// # Authorization
/// Standard
///
/// # Errors
///
/// * [`Unauthorized`](http::StatusCode::UNAUTHORIZED) if authorization is not valid.
/// * [`NotFound`](http::StatusCode::NOT_FOUND) if the additional resource or the parent JIG or Playlist doesn't exist.
pub struct GetLive;
impl ApiEndpoint for GetLive {
type Path = GetAssetResourceLivePath;
type Req = AssetIdResource;
type Res = AdditionalResource;
type Err = EmptyError;
const METHOD: Method = Method::Get;
}
/// Add an additional resource to a draft JIG or Playlist.
///
/// # Authorization
///
/// * Standard + [`UserScope::ManageJig`](crate::domain::user::UserScope)
///
/// # Errors
///
/// * [`Unauthorized`](http::StatusCode::UNAUTHORIZED) if authorization is not valid.
/// * [`Forbidden`](http::StatusCode::FORBIDDEN) if the user does not have sufficient permission to perform the action.
/// * [`BadRequest`](http::StatusCode::BAD_REQUEST) if the request is missing/invalid.
pub struct Create;
impl ApiEndpoint for Create {
type Path = CreateAssetResourcePath;
type Req = AdditionalResourceCreateRequest;
type Res = CreateResponse<AdditionalResourceId>;
type Err = EmptyError;
const METHOD: Method = Method::Post;
}
/// Update an additional resources to a draft JIG or Playlist.
///
/// # Authorization
///
/// * Standard + [`UserScope::ManageJig`](crate::domain::user::UserScope)
///
/// # Errors
///
/// * [`Unauthorized`](http::StatusCode::UNAUTHORIZED) if authorization is not valid.
/// * [`Forbidden`](http::StatusCode::FORBIDDEN) if the user does not have sufficient permission to perform the action.
/// * [`BadRequest`](http::StatusCode::BAD_REQUEST) if the request is missing/invalid.
pub struct Update;
impl ApiEndpoint for Update {
type Path = UpdateAssetResourcePath;
type Req = AdditionalResourceUpdateRequest;
type Res = ();
type Err = EmptyError;
const METHOD: Method = Method::Patch;
}
/// Delete an additional resource URL from a draft JIG or Playlist.
///
/// # Authorization
///
/// * Standard + [`UserScope::ManageJig`](crate::domain::user::UserScope)
///
/// # Errors
///
/// * [`Unauthorized`](http::StatusCode::UNAUTHORIZED) if authorization is not valid.
/// * [`Forbidden`](http::StatusCode::FORBIDDEN) if the user does not have sufficient permission to perform the action.
/// * [`NotFound`](http::StatusCode::NOT_FOUND) if the additional resource or parent JIG or Playlist does not exist.
/// * [`BadRequest`](http::StatusCode::BAD_REQUEST) if the given `id` is not a [`Uuid`](uuid::Uuid) or the request is missing/invalid.
pub struct Delete;
impl ApiEndpoint for Delete {
type Path = DeleteAssetResourcePath;
type Req = AssetIdResource;
type Res = ();
type Err = EmptyError;
const METHOD: Method = Method::Delete;
}