shared/domain/image/
tag.rs

1//! Types to manage image tags.
2
3use macros::make_path_parts;
4use serde::{Deserialize, Serialize};
5
6use crate::{api::endpoints::PathPart, domain::meta::ImageTagIndex};
7
8// i16 is tag index (ImageTag.as_index())
9make_path_parts!(ImageTagCreatePath => "/v1/image/tag/{}" => i16);
10
11/// Request to create an image tag.
12#[derive(Serialize, Deserialize, Debug)]
13pub struct ImageTagCreateRequest {
14    /// Display name of the image tag.
15    pub display_name: String,
16}
17
18make_path_parts!(ImageTagListPath => "/v1/image/tag/all");
19
20/// Response returned to list all image tags.
21#[derive(Serialize, Deserialize)]
22pub struct ImageTagListResponse {
23    /// Indices for all the image tags.
24    pub image_tags: Vec<ImageTagResponse>,
25}
26
27/// Response for a single tag.
28#[derive(Serialize, Deserialize)]
29pub struct ImageTagResponse {
30    /// The index of the image tag found.
31    pub index: ImageTagIndex,
32
33    /// The display name of the image tag found.
34    pub display_name: String,
35}
36
37// i16 is tag index (ImageTag.as_index())
38make_path_parts!(ImageTagUpdatePath => "/v1/image/tag/{}" => i16);
39
40/// Request to update an image tag.
41#[derive(Serialize, Deserialize, Debug)]
42pub struct ImageTagUpdateRequest {
43    /// Display name of the image tag. `None` means no change to be made.
44    pub display_name: Option<String>,
45
46    /// If [`Some`] attempt to move tag to the given index. If it is already occupied, do no
47    /// change the indexing.
48    ///
49    /// If `index` is [`None`] then it will not be updated.
50    pub index: Option<ImageTagIndex>,
51}
52
53// i16 is tag index (ImageTag.as_index())
54make_path_parts!(ImageTagDeletePath => "/v1/image/tag/{}" => i16);