Skip to main content

paperless_api/metadata/
document_type.rs

1//! Types related to document types.
2
3use serde::{Deserialize, Serialize};
4
5use paperless_api_macros::{CreateDto, Item, UpdateDto};
6
7use super::MatchAlgorithm;
8use super::permission::ItemPermissions;
9
10/// A document type.
11#[derive(Debug, Clone, Deserialize, Serialize, CreateDto, UpdateDto, Item)]
12#[api_info(endpoint = "document_types")]
13pub struct DocumentType {
14    /// Unique identifier of the document type.
15    #[dto(skip)]
16    pub id: crate::id::DocumentTypeId,
17
18    /// Slug of the document type.
19    #[dto(skip)]
20    pub slug: String,
21
22    /// Name of the document type.
23    pub name: String,
24
25    /// Matching pattern for the document type.
26    #[serde(rename = "match")]
27    pub match_pattern: String,
28
29    /// Matching algorithm for the document type.
30    pub matching_algorithm: MatchAlgorithm,
31
32    /// Whether the document type matching is case-insensitive.
33    pub is_insensitive: Option<bool>,
34
35    /// Number of documents with this type.
36    #[dto(skip)]
37    #[serde(default)]
38    pub document_count: u32,
39
40    /// Owner of the document type.
41    pub owner: Option<crate::id::UserId>,
42
43    /// The permissions for this document type.
44    #[dto(skip)]
45    #[serde(flatten)]
46    pub permissions: ItemPermissions,
47}