shared/api/endpoints/
media.rs

1use crate::{
2    api::Method,
3    domain::media::{
4        MediaCreatePath, MediaIdDeletePath, MediaIdGetPath, MediaUrlDeletePath, MediaUrlGetPath,
5        UrlCreatedResponse, WebMediaMetadataResponse, WebMediaUrlCreateRequest,
6    },
7    error::EmptyError,
8};
9
10use super::ApiEndpoint;
11
12/// Add a URL to the web media library.
13/// Note: These routes match the ones from [`super::search`]
14pub struct Create;
15impl ApiEndpoint for Create {
16    type Path = MediaCreatePath;
17    type Req = WebMediaUrlCreateRequest;
18    type Res = UrlCreatedResponse;
19    type Err = EmptyError;
20    const METHOD: Method = Method::Post;
21}
22
23/// Get media from the web media library by url.
24pub struct GetUrl;
25impl ApiEndpoint for GetUrl {
26    type Path = MediaUrlGetPath;
27    type Req = ();
28    type Res = WebMediaMetadataResponse;
29    type Err = EmptyError;
30    const METHOD: Method = Method::Get;
31}
32
33/// Get media from the web media library by id.
34pub struct GetId;
35impl ApiEndpoint for GetId {
36    type Path = MediaIdGetPath;
37    type Req = ();
38    type Res = WebMediaMetadataResponse;
39    type Err = EmptyError;
40    const METHOD: Method = Method::Get;
41}
42
43/// Remove a URL from the web media library.
44pub struct DeleteUrl;
45impl ApiEndpoint for DeleteUrl {
46    type Path = MediaUrlDeletePath;
47    type Req = ();
48    type Res = ();
49    type Err = EmptyError;
50    const METHOD: Method = Method::Delete;
51}
52
53/// Remove media from the web media library.
54pub struct DeleteId;
55impl ApiEndpoint for DeleteId {
56    type Path = MediaIdDeletePath;
57    type Req = ();
58    type Res = ();
59    type Err = EmptyError;
60    const METHOD: Method = Method::Delete;
61}