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