shared/api/endpoints/image/
tag.rs

1//! Routes to manage image tags
2
3use super::super::ApiEndpoint;
4use crate::{
5    api::Method,
6    domain::image::tag::{
7        ImageTagCreatePath, ImageTagCreateRequest, ImageTagDeletePath, ImageTagListPath,
8        ImageTagListResponse, ImageTagResponse, ImageTagUpdatePath, ImageTagUpdateRequest,
9    },
10    error::EmptyError,
11};
12
13/// List all image tags.
14///
15/// # Authorization
16/// Standard + [`UserScope::Admin`](crate::domain::user::UserScope)
17///
18/// # Errors
19/// [`Unauthorized`](http::StatusCode::UNAUTHORIZED) if authorization is not valid.
20///
21/// [`Forbidden`](http::StatusCode::FORBIDDEN) if the user does not have sufficient permission to perform the action.
22pub struct List;
23
24impl ApiEndpoint for List {
25    type Path = ImageTagListPath;
26    type Req = ();
27    type Res = ImageTagListResponse;
28    type Err = EmptyError;
29    const METHOD: Method = Method::Get;
30}
31
32/// Create an image tag.
33///
34/// # Authorization
35/// Standard + [`UserScope::Admin`](crate::domain::user::UserScope)
36///
37/// # Errors
38/// [`Unauthorized`](http::StatusCode::UNAUTHORIZED) if authorization is not valid.
39///
40/// [`Forbidden`](http::StatusCode::FORBIDDEN) if the user does not have sufficient permission to perform the action.
41///
42/// [`BadRequest`](http::StatusCode::BAD_REQUEST) if the request is missing/invalid.
43///
44/// [`Conflict`](http::StatusCode::CONFLICT) if the requested `index` is already occupied.
45pub struct Create;
46
47impl ApiEndpoint for Create {
48    type Path = ImageTagCreatePath;
49    type Req = ImageTagCreateRequest;
50    type Res = ImageTagResponse;
51    type Err = EmptyError;
52    const METHOD: Method = Method::Post;
53}
54
55/// Update an image tag by index.
56///
57/// # Authorization
58/// Standard + [`UserScope::Admin`](crate::domain::user::UserScope)
59///
60/// # Errors
61///
62/// * [`Unauthorized`](http::StatusCode::UNAUTHORIZED) if authorization is not valid.
63/// * [`Forbidden`](http::StatusCode::FORBIDDEN) if the user does not have sufficient permission to perform the action.
64/// * [`BadRequest`](http::StatusCode::BAD_REQUEST) if the request is missing/invalid.
65/// * [`NotFound`](http::StatusCode::NOT_FOUND) if the image tag does not exist.
66/// * [`Conflict`](http::StatusCode::CONFLICT) if the requested `index` is already occupied.
67pub struct Update;
68
69impl ApiEndpoint for Update {
70    type Path = ImageTagUpdatePath;
71    type Req = ImageTagUpdateRequest;
72    type Res = ();
73    type Err = EmptyError;
74    const METHOD: Method = Method::Patch;
75}
76
77/// Delete an image tag by index.
78///
79/// # Authorization
80/// Standard + [`UserScope::Admin`](crate::domain::user::UserScope)
81///
82/// # Errors
83///
84/// * [`Unauthorized`](http::StatusCode::UNAUTHORIZED) if authorization is not valid.
85/// * [`Forbidden`](http::StatusCode::FORBIDDEN) if the user does not have sufficient permission to perform the action.
86/// * [`BadRequest`](http::StatusCode::BAD_REQUEST) if the given `id` is not a [`Uuid`](uuid::Uuid) or the request is missing/invalid.
87/// * [`NotFound`](http::StatusCode::NOT_FOUND) if the image tag does not exist.
88pub struct Delete;
89
90impl ApiEndpoint for Delete {
91    type Path = ImageTagDeletePath;
92    type Req = ();
93    type Res = ();
94    type Err = EmptyError;
95    const METHOD: Method = Method::Delete;
96}