Skip to main content

paperless_api/metadata/
tag.rs

1//! Types related to document tags.
2
3use serde::{Deserialize, Serialize};
4
5use paperless_api_macros::{CreateDto, Item, UpdateDto};
6
7use super::MatchAlgorithm;
8use crate::id::TagId;
9
10/// A document tag
11#[derive(Debug, Default, Clone, Deserialize, Serialize, CreateDto, UpdateDto, Item)]
12#[api_info(endpoint = "tags")]
13pub struct Tag {
14    /// Unique identifier of the tag.
15    #[dto(skip)]
16    pub id: TagId,
17
18    /// Slug of the tag.
19    #[dto(skip)]
20    pub slug: String,
21
22    /// Name of the tag.
23    pub name: String,
24
25    /// Color of the tag, in hex format.
26    pub color: String,
27
28    /// Color of the text on the tag, in hex format.
29    #[dto(skip)]
30    pub text_color: String,
31
32    /// Matching pattern for the tag.
33    #[serde(rename = "match")]
34    pub match_pattern: String,
35
36    /// Matching algorithm for the tag.
37    pub matching_algorithm: MatchAlgorithm,
38
39    /// Whether the tag matching is case-insensitive.
40    pub is_insensitive: bool,
41
42    /// Whether the tag is an inbox tag.
43    pub is_inbox_tag: bool,
44
45    /// Number of documents associated with this tag.
46    #[dto(skip)]
47    #[serde(default)]
48    pub document_count: u32,
49
50    /// Owner of the tag.
51    pub owner: Option<crate::id::UserId>,
52
53    /// Parent tag of this tag.
54    pub parent: Option<TagId>,
55
56    /// Children tags of this tag.
57    #[dto(skip)]
58    pub children: Vec<Box<Tag>>,
59
60    /// The permissions for this tag.
61    #[dto(skip)]
62    #[serde(flatten)]
63    pub permissions: super::permission::ItemPermissions,
64}