Coverage for src/paperap/models/document/metadata/model.py: 100%
21 statements
« prev ^ index » next coverage.py v7.6.12, created at 2025-03-22 16:02 -0400
« prev ^ index » next coverage.py v7.6.12, created at 2025-03-22 16:02 -0400
1"""
2----------------------------------------------------------------------------
4METADATA:
6File: metadata.py
7 Project: paperap
8Created: 2025-03-18
9 Version: 0.0.9
10Author: Jess Mann
11Email: jess@jmann.me
12 Copyright (c) 2025 Jess Mann
14----------------------------------------------------------------------------
16LAST MODIFIED:
182025-03-18 By Jess Mann
20"""
22from __future__ import annotations
24import pydantic
26from paperap.models.abstract import StandardModel
29class MetadataElement(pydantic.BaseModel):
30 """
31 Represents metadata for a document in Paperless-NgX.
33 This is a key-value pair of metadata information.
34 """
36 key: str
37 value: str
40class DocumentMetadata(StandardModel):
41 """
42 Represents a Paperless-NgX document's metadata.
44 Attributes:
45 original_checksum: The checksum of the original document.
46 original_size: The size of the original document in bytes.
47 original_mime_type: The MIME type of the original document.
48 media_filename: The filename of the media file.
49 has_archive_version: Whether the document has an archive version.
50 original_metadata: Metadata of the original document.
51 archive_checksum: The checksum of the archived document.
52 archive_media_filename: The filename of the archived media file.
53 original_filename: The original filename of the document.
54 lang: The language of the document.
55 archive_size: The size of the archived document in bytes.
56 archive_metadata: Metadata of the archived document.
58 """
60 original_checksum: str | None = None
61 original_size: int | None = None
62 original_mime_type: str | None = None
63 media_filename: str | None = None
64 has_archive_version: bool | None = None
65 original_metadata: list[MetadataElement] = []
66 archive_checksum: str | None = None
67 archive_media_filename: str | None = None
68 original_filename: str | None = None
69 lang: str | None = None
70 archive_size: int | None = None
71 archive_metadata: list[MetadataElement] = []
73 class Meta(StandardModel.Meta):
74 read_only_fields = {
75 "original_checksum",
76 "original_size",
77 "original_mime_type",
78 "media_filename",
79 "has_archive_version",
80 "original_metadata",
81 "archive_checksum",
82 "archive_media_filename",
83 "original_filename",
84 "lang",
85 "archive_size",
86 "archive_metadata",
87 }