easypaperless.resources

Resource Classes

The following resource classes are _internal classes. Methods can be accessed via the instance of easypaperless.PaperlessClient or easypaperless.SyncPaperlessClient

Example:

async with PaperlessClient(url="http://localhost:8000", api_token="abc") as client: docs = await client.documents.list(max_results=10)

 1"""Resource Classes
 2
 3The following resource classes are _internal classes. Methods can be accessed via the instance of
 4`easypaperless.PaperlessClient` or `easypaperless.SyncPaperlessClient`
 5
 6Example:
 7    async with PaperlessClient(url="http://localhost:8000", api_token="abc") as client:
 8        docs = await client.documents.list(max_results=10)
 9
10"""
11
12# internal comment: the doc string above is also rendered in the pdoc documentation.
13#
14# original was:
15#
16# Public resource classes — for type annotations and IDE support.
17#
18# Re-exports all async and sync resource classes from the internal modules
19# so that pdoc can document them as a full page with all methods.
20#
21# Example:
22#    from easypaperless.resources import DocumentsResource
23
24from easypaperless._internal.resources.correspondents import CorrespondentsResource
25from easypaperless._internal.resources.custom_fields import CustomFieldsResource
26from easypaperless._internal.resources.document_types import DocumentTypesResource
27from easypaperless._internal.resources.documents import DocumentsResource
28from easypaperless._internal.resources.groups import GroupsResource
29from easypaperless._internal.resources.notes import NotesResource
30from easypaperless._internal.resources.storage_paths import StoragePathsResource
31from easypaperless._internal.resources.tags import TagsResource
32from easypaperless._internal.resources.tasks import TasksResource
33from easypaperless._internal.resources.trash import TrashResource
34from easypaperless._internal.resources.users import UsersResource
35from easypaperless._internal.sync_resources.correspondents import SyncCorrespondentsResource
36from easypaperless._internal.sync_resources.custom_fields import SyncCustomFieldsResource
37from easypaperless._internal.sync_resources.document_types import SyncDocumentTypesResource
38from easypaperless._internal.sync_resources.documents import SyncDocumentsResource
39from easypaperless._internal.sync_resources.groups import SyncGroupsResource
40from easypaperless._internal.sync_resources.notes import SyncNotesResource
41from easypaperless._internal.sync_resources.storage_paths import SyncStoragePathsResource
42from easypaperless._internal.sync_resources.tags import SyncTagsResource
43from easypaperless._internal.sync_resources.tasks import SyncTasksResource
44from easypaperless._internal.sync_resources.trash import SyncTrashResource
45from easypaperless._internal.sync_resources.users import SyncUsersResource
46
47__all__ = [
48    "CorrespondentsResource",
49    "CustomFieldsResource",
50    "DocumentTypesResource",
51    "DocumentsResource",
52    "NotesResource",
53    "StoragePathsResource",
54    "TagsResource",
55    "SyncCorrespondentsResource",
56    "SyncCustomFieldsResource",
57    "SyncDocumentTypesResource",
58    "SyncDocumentsResource",
59    "SyncNotesResource",
60    "SyncStoragePathsResource",
61    "SyncTagsResource",
62    "UsersResource",
63    "SyncUsersResource",
64    "GroupsResource",
65    "SyncGroupsResource",
66    "TrashResource",
67    "SyncTrashResource",
68    "TasksResource",
69    "SyncTasksResource",
70]
class CorrespondentsResource:
 21class CorrespondentsResource:
 22    """Accessor for correspondents: ``client.correspondents``."""
 23
 24    def __init__(self, core: _ClientCore) -> None:
 25        self._core = core
 26
 27    async def list(
 28        self,
 29        *,
 30        ids: List[int] | None = None,
 31        name_contains: str | None = None,
 32        name_exact: str | None = None,
 33        page: int | None = None,
 34        page_size: int | None = None,
 35        ordering: str | None = None,
 36        descending: bool = False,
 37    ) -> PagedResult[Correspondent]:
 38        """Return correspondents defined in paperless-ngx.
 39
 40        When ``page`` is ``None`` (the default), all pages are fetched
 41        automatically and ``next`` / ``previous`` in the result are always
 42        ``None``.  When ``page`` is set, only that page is fetched and
 43        ``next`` / ``previous`` reflect the raw API values.
 44
 45        Args:
 46            ids: Return only correspondents whose ID is in this list.
 47            name_contains: Case-insensitive substring filter on name.
 48            name_exact: Case-insensitive exact match on name.
 49            page: Return only this specific page (1-based).
 50            page_size: Number of results per page.
 51            ordering: Field to sort by.
 52            descending: When ``True``, reverses the sort direction.
 53
 54        Returns:
 55            :class:`~easypaperless.models.paged_result.PagedResult` of
 56            :class:`~easypaperless.models.correspondents.Correspondent` objects.
 57        """
 58        logger.info("Listing correspondents")
 59        params: dict[str, Any] = {}
 60        if ids is not None:
 61            params["id__in"] = ",".join(str(i) for i in ids)
 62        if name_contains is not None:
 63            params["name__icontains"] = name_contains
 64        if name_exact is not None:
 65            params["name__iexact"] = name_exact
 66        if page is not None:
 67            params["page"] = page
 68        if page_size is not None:
 69            params["page_size"] = page_size
 70        if ordering is not None:
 71            params["ordering"] = f"-{ordering}" if descending else ordering
 72        return cast(
 73            PagedResult[Correspondent],
 74            await self._core._list_resource("correspondents", Correspondent, params or None),
 75        )
 76
 77    async def get(self, id: int) -> Correspondent:
 78        """Fetch a single correspondent by its ID.
 79
 80        Args:
 81            id: Numeric correspondent ID.
 82
 83        Returns:
 84            The :class:`~easypaperless.models.correspondents.Correspondent` with the given ID.
 85
 86        Raises:
 87            ~easypaperless.exceptions.NotFoundError: If no correspondent exists with that ID.
 88        """
 89        logger.info("Getting correspondent id=%d", id)
 90        return cast(
 91            Correspondent, await self._core._get_resource("correspondents", id, Correspondent)
 92        )
 93
 94    async def create(
 95        self,
 96        *,
 97        name: str,
 98        match: str | Unset = UNSET,
 99        matching_algorithm: MatchingAlgorithm | Unset = UNSET,
100        is_insensitive: bool = True,
101        owner: int | None | Unset = UNSET,
102        set_permissions: SetPermissions | None | Unset = UNSET,
103    ) -> Correspondent:
104        """Create a new correspondent.
105
106        Args:
107            name: Correspondent name. Must be unique.
108            match: Auto-matching pattern.
109            matching_algorithm: Controls how ``match`` is applied.
110                E.g. ``matching_algorithm=MatchingAlgorithm.REGEX`` for
111                regular-expression matching.
112            is_insensitive: When ``True``, ``match`` is case-insensitive.
113                Defaults to ``True``, matching the paperless-ngx API default.
114            owner: Numeric user ID to assign as owner.
115            set_permissions: Explicit view/change permission sets.
116                Pass ``None`` to create with empty permissions.
117
118        Returns:
119            The newly created :class:`~easypaperless.models.correspondents.Correspondent`.
120        """
121        logger.info("Creating correspondent name=%r", name)
122        return cast(
123            Correspondent,
124            await self._core._create_resource(
125                "correspondents",
126                Correspondent,
127                owner=owner,
128                set_permissions=set_permissions,
129                name=name,
130                match=match,
131                matching_algorithm=matching_algorithm,
132                is_insensitive=is_insensitive,
133            ),
134        )
135
136    async def update(
137        self,
138        id: int,
139        *,
140        name: str | Unset = UNSET,
141        match: str | Unset = UNSET,
142        matching_algorithm: MatchingAlgorithm | Unset = UNSET,
143        is_insensitive: bool | Unset = UNSET,
144        owner: int | None | Unset = UNSET,
145        set_permissions: SetPermissions | None | Unset = UNSET,
146    ) -> Correspondent:
147        """Partially update a correspondent (PATCH semantics).
148
149        Args:
150            id: Numeric ID of the correspondent to update.
151            name: Correspondent name.
152            match: Auto-matching pattern.
153            matching_algorithm: Controls how ``match`` is applied.
154                E.g. ``matching_algorithm=MatchingAlgorithm.REGEX`` for
155                regular-expression matching.
156            is_insensitive: When ``True``, ``match`` is case-insensitive.
157            owner: Numeric user ID to assign as owner.
158                Pass ``None`` to clear the owner.
159                Omit (or pass :data:`~easypaperless.UNSET`) to leave unchanged.
160            set_permissions: Explicit view/change permission sets.
161                Pass ``None`` to clear all permissions (overwrite with empty).
162                Omit (or pass :data:`~easypaperless.UNSET`) to leave unchanged.
163
164        Returns:
165            The updated :class:`~easypaperless.models.correspondents.Correspondent`.
166        """
167        logger.info("Updating correspondent id=%d", id)
168        return cast(
169            Correspondent,
170            await self._core._update_resource(
171                "correspondents",
172                id,
173                Correspondent,
174                name=name,
175                match=match,
176                matching_algorithm=matching_algorithm,
177                is_insensitive=is_insensitive,
178                owner=owner,
179                set_permissions=set_permissions,
180            ),
181        )
182
183    async def delete(self, id: int) -> None:
184        """Delete a correspondent.
185
186        Args:
187            id: Numeric ID of the correspondent to delete.
188
189        Raises:
190            ~easypaperless.exceptions.NotFoundError: If no correspondent exists with that ID.
191        """
192        logger.info("Deleting correspondent id=%d", id)
193        await self._core._delete_resource("correspondents", id)
194
195    async def bulk_delete(self, ids: List[int]) -> None:
196        """Permanently delete multiple correspondents in a single request.
197
198        Args:
199            ids: List of correspondent IDs to delete.
200        """
201        logger.info("Bulk deleting %d correspondents", len(ids))
202        await self._core._bulk_edit_objects("correspondents", ids, "delete")
203
204    async def bulk_set_permissions(
205        self,
206        ids: List[int],
207        *,
208        set_permissions: SetPermissions | Unset = UNSET,
209        owner: int | None | Unset = UNSET,
210        merge: bool = False,
211    ) -> None:
212        """Set permissions and/or owner on multiple correspondents.
213
214        Args:
215            ids: List of correspondent IDs to modify.
216            set_permissions: Explicit view/change permission sets.
217                Omit (or pass :data:`~easypaperless.UNSET`) to leave unchanged.
218            owner: Numeric user ID to assign as owner.
219                Pass ``None`` to clear the owner.
220                Omit (or pass :data:`~easypaperless.UNSET`) to leave unchanged.
221            merge: When ``True``, new permissions are merged with existing ones.
222        """
223        logger.info("Bulk setting permissions on %d correspondents", len(ids))
224        params: dict[str, Any] = {"merge": merge}
225        if not isinstance(set_permissions, Unset):
226            params["permissions"] = set_permissions.model_dump()
227        if not isinstance(owner, Unset):
228            params["owner"] = owner
229        await self._core._bulk_edit_objects("correspondents", ids, "set_permissions", **params)

Accessor for correspondents: client.correspondents.

CorrespondentsResource(core: easypaperless.client._ClientCore)
24    def __init__(self, core: _ClientCore) -> None:
25        self._core = core
async def list( self, *, ids: Optional[List[int]] = None, name_contains: str | None = None, name_exact: str | None = None, page: int | None = None, page_size: int | None = None, ordering: str | None = None, descending: bool = False) -> easypaperless.PagedResult[Correspondent]:
27    async def list(
28        self,
29        *,
30        ids: List[int] | None = None,
31        name_contains: str | None = None,
32        name_exact: str | None = None,
33        page: int | None = None,
34        page_size: int | None = None,
35        ordering: str | None = None,
36        descending: bool = False,
37    ) -> PagedResult[Correspondent]:
38        """Return correspondents defined in paperless-ngx.
39
40        When ``page`` is ``None`` (the default), all pages are fetched
41        automatically and ``next`` / ``previous`` in the result are always
42        ``None``.  When ``page`` is set, only that page is fetched and
43        ``next`` / ``previous`` reflect the raw API values.
44
45        Args:
46            ids: Return only correspondents whose ID is in this list.
47            name_contains: Case-insensitive substring filter on name.
48            name_exact: Case-insensitive exact match on name.
49            page: Return only this specific page (1-based).
50            page_size: Number of results per page.
51            ordering: Field to sort by.
52            descending: When ``True``, reverses the sort direction.
53
54        Returns:
55            :class:`~easypaperless.models.paged_result.PagedResult` of
56            :class:`~easypaperless.models.correspondents.Correspondent` objects.
57        """
58        logger.info("Listing correspondents")
59        params: dict[str, Any] = {}
60        if ids is not None:
61            params["id__in"] = ",".join(str(i) for i in ids)
62        if name_contains is not None:
63            params["name__icontains"] = name_contains
64        if name_exact is not None:
65            params["name__iexact"] = name_exact
66        if page is not None:
67            params["page"] = page
68        if page_size is not None:
69            params["page_size"] = page_size
70        if ordering is not None:
71            params["ordering"] = f"-{ordering}" if descending else ordering
72        return cast(
73            PagedResult[Correspondent],
74            await self._core._list_resource("correspondents", Correspondent, params or None),
75        )

Return correspondents defined in paperless-ngx.

When page is None (the default), all pages are fetched automatically and next / previous in the result are always None. When page is set, only that page is fetched and next / previous reflect the raw API values.

Arguments:
  • ids: Return only correspondents whose ID is in this list.
  • name_contains: Case-insensitive substring filter on name.
  • name_exact: Case-insensitive exact match on name.
  • page: Return only this specific page (1-based).
  • page_size: Number of results per page.
  • ordering: Field to sort by.
  • descending: When True, reverses the sort direction.
Returns:

~easypaperless.models.paged_result.PagedResult of ~easypaperless.models.correspondents.Correspondent objects.

async def get(self, id: int) -> easypaperless.Correspondent:
77    async def get(self, id: int) -> Correspondent:
78        """Fetch a single correspondent by its ID.
79
80        Args:
81            id: Numeric correspondent ID.
82
83        Returns:
84            The :class:`~easypaperless.models.correspondents.Correspondent` with the given ID.
85
86        Raises:
87            ~easypaperless.exceptions.NotFoundError: If no correspondent exists with that ID.
88        """
89        logger.info("Getting correspondent id=%d", id)
90        return cast(
91            Correspondent, await self._core._get_resource("correspondents", id, Correspondent)
92        )

Fetch a single correspondent by its ID.

Arguments:
  • id: Numeric correspondent ID.
Returns:

The ~easypaperless.models.correspondents.Correspondent with the given ID.

Raises:
async def create( self, *, name: str, match: str | easypaperless.Unset = UNSET, matching_algorithm: easypaperless.MatchingAlgorithm | easypaperless.Unset = UNSET, is_insensitive: bool = True, owner: int | None | easypaperless.Unset = UNSET, set_permissions: easypaperless.SetPermissions | None | easypaperless.Unset = UNSET) -> easypaperless.Correspondent:
 94    async def create(
 95        self,
 96        *,
 97        name: str,
 98        match: str | Unset = UNSET,
 99        matching_algorithm: MatchingAlgorithm | Unset = UNSET,
100        is_insensitive: bool = True,
101        owner: int | None | Unset = UNSET,
102        set_permissions: SetPermissions | None | Unset = UNSET,
103    ) -> Correspondent:
104        """Create a new correspondent.
105
106        Args:
107            name: Correspondent name. Must be unique.
108            match: Auto-matching pattern.
109            matching_algorithm: Controls how ``match`` is applied.
110                E.g. ``matching_algorithm=MatchingAlgorithm.REGEX`` for
111                regular-expression matching.
112            is_insensitive: When ``True``, ``match`` is case-insensitive.
113                Defaults to ``True``, matching the paperless-ngx API default.
114            owner: Numeric user ID to assign as owner.
115            set_permissions: Explicit view/change permission sets.
116                Pass ``None`` to create with empty permissions.
117
118        Returns:
119            The newly created :class:`~easypaperless.models.correspondents.Correspondent`.
120        """
121        logger.info("Creating correspondent name=%r", name)
122        return cast(
123            Correspondent,
124            await self._core._create_resource(
125                "correspondents",
126                Correspondent,
127                owner=owner,
128                set_permissions=set_permissions,
129                name=name,
130                match=match,
131                matching_algorithm=matching_algorithm,
132                is_insensitive=is_insensitive,
133            ),
134        )

Create a new correspondent.

Arguments:
  • name: Correspondent name. Must be unique.
  • match: Auto-matching pattern.
  • matching_algorithm: Controls how match is applied. E.g. matching_algorithm=MatchingAlgorithm.REGEX for regular-expression matching.
  • is_insensitive: When True, match is case-insensitive. Defaults to True, matching the paperless-ngx API default.
  • owner: Numeric user ID to assign as owner.
  • set_permissions: Explicit view/change permission sets. Pass None to create with empty permissions.
Returns:

The newly created ~easypaperless.models.correspondents.Correspondent.

async def update( self, id: int, *, name: str | easypaperless.Unset = UNSET, match: str | easypaperless.Unset = UNSET, matching_algorithm: easypaperless.MatchingAlgorithm | easypaperless.Unset = UNSET, is_insensitive: bool | easypaperless.Unset = UNSET, owner: int | None | easypaperless.Unset = UNSET, set_permissions: easypaperless.SetPermissions | None | easypaperless.Unset = UNSET) -> easypaperless.Correspondent:
136    async def update(
137        self,
138        id: int,
139        *,
140        name: str | Unset = UNSET,
141        match: str | Unset = UNSET,
142        matching_algorithm: MatchingAlgorithm | Unset = UNSET,
143        is_insensitive: bool | Unset = UNSET,
144        owner: int | None | Unset = UNSET,
145        set_permissions: SetPermissions | None | Unset = UNSET,
146    ) -> Correspondent:
147        """Partially update a correspondent (PATCH semantics).
148
149        Args:
150            id: Numeric ID of the correspondent to update.
151            name: Correspondent name.
152            match: Auto-matching pattern.
153            matching_algorithm: Controls how ``match`` is applied.
154                E.g. ``matching_algorithm=MatchingAlgorithm.REGEX`` for
155                regular-expression matching.
156            is_insensitive: When ``True``, ``match`` is case-insensitive.
157            owner: Numeric user ID to assign as owner.
158                Pass ``None`` to clear the owner.
159                Omit (or pass :data:`~easypaperless.UNSET`) to leave unchanged.
160            set_permissions: Explicit view/change permission sets.
161                Pass ``None`` to clear all permissions (overwrite with empty).
162                Omit (or pass :data:`~easypaperless.UNSET`) to leave unchanged.
163
164        Returns:
165            The updated :class:`~easypaperless.models.correspondents.Correspondent`.
166        """
167        logger.info("Updating correspondent id=%d", id)
168        return cast(
169            Correspondent,
170            await self._core._update_resource(
171                "correspondents",
172                id,
173                Correspondent,
174                name=name,
175                match=match,
176                matching_algorithm=matching_algorithm,
177                is_insensitive=is_insensitive,
178                owner=owner,
179                set_permissions=set_permissions,
180            ),
181        )

Partially update a correspondent (PATCH semantics).

Arguments:
  • id: Numeric ID of the correspondent to update.
  • name: Correspondent name.
  • match: Auto-matching pattern.
  • matching_algorithm: Controls how match is applied. E.g. matching_algorithm=MatchingAlgorithm.REGEX for regular-expression matching.
  • is_insensitive: When True, match is case-insensitive.
  • owner: Numeric user ID to assign as owner. Pass None to clear the owner. Omit (or pass ~easypaperless.UNSET) to leave unchanged.
  • set_permissions: Explicit view/change permission sets. Pass None to clear all permissions (overwrite with empty). Omit (or pass ~easypaperless.UNSET) to leave unchanged.
Returns:

The updated ~easypaperless.models.correspondents.Correspondent.

async def delete(self, id: int) -> None:
183    async def delete(self, id: int) -> None:
184        """Delete a correspondent.
185
186        Args:
187            id: Numeric ID of the correspondent to delete.
188
189        Raises:
190            ~easypaperless.exceptions.NotFoundError: If no correspondent exists with that ID.
191        """
192        logger.info("Deleting correspondent id=%d", id)
193        await self._core._delete_resource("correspondents", id)

Delete a correspondent.

Arguments:
  • id: Numeric ID of the correspondent to delete.
Raises:
async def bulk_delete(self, ids: List[int]) -> None:
195    async def bulk_delete(self, ids: List[int]) -> None:
196        """Permanently delete multiple correspondents in a single request.
197
198        Args:
199            ids: List of correspondent IDs to delete.
200        """
201        logger.info("Bulk deleting %d correspondents", len(ids))
202        await self._core._bulk_edit_objects("correspondents", ids, "delete")

Permanently delete multiple correspondents in a single request.

Arguments:
  • ids: List of correspondent IDs to delete.
async def bulk_set_permissions( self, ids: List[int], *, set_permissions: easypaperless.SetPermissions | easypaperless.Unset = UNSET, owner: int | None | easypaperless.Unset = UNSET, merge: bool = False) -> None:
204    async def bulk_set_permissions(
205        self,
206        ids: List[int],
207        *,
208        set_permissions: SetPermissions | Unset = UNSET,
209        owner: int | None | Unset = UNSET,
210        merge: bool = False,
211    ) -> None:
212        """Set permissions and/or owner on multiple correspondents.
213
214        Args:
215            ids: List of correspondent IDs to modify.
216            set_permissions: Explicit view/change permission sets.
217                Omit (or pass :data:`~easypaperless.UNSET`) to leave unchanged.
218            owner: Numeric user ID to assign as owner.
219                Pass ``None`` to clear the owner.
220                Omit (or pass :data:`~easypaperless.UNSET`) to leave unchanged.
221            merge: When ``True``, new permissions are merged with existing ones.
222        """
223        logger.info("Bulk setting permissions on %d correspondents", len(ids))
224        params: dict[str, Any] = {"merge": merge}
225        if not isinstance(set_permissions, Unset):
226            params["permissions"] = set_permissions.model_dump()
227        if not isinstance(owner, Unset):
228            params["owner"] = owner
229        await self._core._bulk_edit_objects("correspondents", ids, "set_permissions", **params)

Set permissions and/or owner on multiple correspondents.

Arguments:
  • ids: List of correspondent IDs to modify.
  • set_permissions: Explicit view/change permission sets. Omit (or pass ~easypaperless.UNSET) to leave unchanged.
  • owner: Numeric user ID to assign as owner. Pass None to clear the owner. Omit (or pass ~easypaperless.UNSET) to leave unchanged.
  • merge: When True, new permissions are merged with existing ones.
class CustomFieldsResource:
 20class CustomFieldsResource:
 21    """Accessor for custom fields: ``client.custom_fields``."""
 22
 23    def __init__(self, core: _ClientCore) -> None:
 24        self._core = core
 25
 26    async def list(
 27        self,
 28        *,
 29        name_contains: str | None = None,
 30        name_exact: str | None = None,
 31        page: int | None = None,
 32        page_size: int | None = None,
 33        ordering: str | None = None,
 34        descending: bool = False,
 35    ) -> PagedResult[CustomField]:
 36        """Return all custom fields defined in paperless-ngx.
 37
 38        When ``page`` is ``None`` (the default), all pages are fetched
 39        automatically and ``next`` / ``previous`` in the result are always
 40        ``None``.  When ``page`` is set, only that page is fetched and
 41        ``next`` / ``previous`` reflect the raw API values.
 42
 43        Args:
 44            name_contains: Case-insensitive substring filter on name.
 45            name_exact: Case-insensitive exact match on name.
 46            page: Return only this specific page (1-based).
 47            page_size: Number of results per page.
 48            ordering: Field to sort by.
 49            descending: When ``True``, reverses the sort direction.
 50
 51        Returns:
 52            :class:`~easypaperless.models.paged_result.PagedResult` of
 53            :class:`~easypaperless.models.custom_fields.CustomField` objects.
 54        """
 55        logger.info("Listing custom fields")
 56        params: dict[str, Any] = {}
 57        if name_contains is not None:
 58            params["name__icontains"] = name_contains
 59        if name_exact is not None:
 60            params["name__iexact"] = name_exact
 61        if page is not None:
 62            params["page"] = page
 63        if page_size is not None:
 64            params["page_size"] = page_size
 65        if ordering is not None:
 66            params["ordering"] = f"-{ordering}" if descending else ordering
 67        return cast(
 68            PagedResult[CustomField],
 69            await self._core._list_resource("custom_fields", CustomField, params or None),
 70        )
 71
 72    async def get(self, id: int) -> CustomField:
 73        """Fetch a single custom field by its ID.
 74
 75        Args:
 76            id: Numeric custom-field ID.
 77
 78        Returns:
 79            The :class:`~easypaperless.models.custom_fields.CustomField` with the given ID.
 80
 81        Raises:
 82            ~easypaperless.exceptions.NotFoundError: If no custom field exists with that ID.
 83        """
 84        logger.info("Getting custom field id=%d", id)
 85        return cast(CustomField, await self._core._get_resource("custom_fields", id, CustomField))
 86
 87    async def create(
 88        self,
 89        *,
 90        name: str,
 91        data_type: str,
 92        extra_data: Any | None = None,
 93        owner: int | None | Unset = UNSET,
 94        set_permissions: SetPermissions | None | Unset = UNSET,
 95    ) -> CustomField:
 96        """Create a new custom field.
 97
 98        Args:
 99            name: Field name shown in the UI. Must be unique.
100            data_type: Value type. One of ``"string"``, ``"boolean"``,
101                ``"integer"``, ``"float"``, ``"monetary"``, ``"date"``,
102                ``"url"``, ``"documentlink"``, ``"select"``.
103            extra_data: Additional configuration for the field type.
104            owner: Numeric user ID to assign as owner.
105            set_permissions: Explicit view/change permission sets.
106                Pass ``None`` to create with empty permissions.
107
108        Returns:
109            The newly created :class:`~easypaperless.models.custom_fields.CustomField`.
110        """
111        logger.info("Creating custom field name=%r data_type=%r", name, data_type)
112        return cast(
113            CustomField,
114            await self._core._create_resource(
115                "custom_fields",
116                CustomField,
117                owner=owner,
118                set_permissions=set_permissions,
119                name=name,
120                data_type=data_type,
121                extra_data=extra_data,
122            ),
123        )
124
125    async def update(
126        self,
127        id: int,
128        *,
129        name: str | Unset = UNSET,
130        data_type: str | Unset = UNSET,
131        extra_data: Any | None | Unset = UNSET,
132        owner: int | None | Unset = UNSET,
133        set_permissions: SetPermissions | None | Unset = UNSET,
134    ) -> CustomField:
135        """Partially update a custom field (PATCH semantics).
136
137        Args:
138            id: Numeric ID of the custom field to update.
139            name: Field name shown in the UI.
140            data_type: Value type (e.g. ``"string"``, ``"boolean"``, ``"integer"``).
141                Omit (or pass :data:`~easypaperless.UNSET`) to leave unchanged.
142            extra_data: Additional configuration for the field type.
143            owner: Numeric user ID to assign as owner.
144                Pass ``None`` to clear the owner.
145                Omit (or pass :data:`~easypaperless.UNSET`) to leave unchanged.
146            set_permissions: Explicit view/change permission sets.
147                Pass ``None`` to clear all permissions (overwrite with empty).
148                Omit (or pass :data:`~easypaperless.UNSET`) to leave unchanged.
149
150        Returns:
151            The updated :class:`~easypaperless.models.custom_fields.CustomField`.
152        """
153        logger.info("Updating custom field id=%d", id)
154        return cast(
155            CustomField,
156            await self._core._update_resource(
157                "custom_fields",
158                id,
159                CustomField,
160                name=name,
161                data_type=data_type,
162                extra_data=extra_data,
163                owner=owner,
164                set_permissions=set_permissions,
165            ),
166        )
167
168    async def delete(self, id: int) -> None:
169        """Delete a custom field.
170
171        Args:
172            id: Numeric ID of the custom field to delete.
173
174        Raises:
175            ~easypaperless.exceptions.NotFoundError: If no custom field exists with that ID.
176        """
177        logger.info("Deleting custom field id=%d", id)
178        await self._core._delete_resource("custom_fields", id)

Accessor for custom fields: client.custom_fields.

CustomFieldsResource(core: easypaperless.client._ClientCore)
23    def __init__(self, core: _ClientCore) -> None:
24        self._core = core
async def list( self, *, name_contains: str | None = None, name_exact: str | None = None, page: int | None = None, page_size: int | None = None, ordering: str | None = None, descending: bool = False) -> easypaperless.PagedResult[CustomField]:
26    async def list(
27        self,
28        *,
29        name_contains: str | None = None,
30        name_exact: str | None = None,
31        page: int | None = None,
32        page_size: int | None = None,
33        ordering: str | None = None,
34        descending: bool = False,
35    ) -> PagedResult[CustomField]:
36        """Return all custom fields defined in paperless-ngx.
37
38        When ``page`` is ``None`` (the default), all pages are fetched
39        automatically and ``next`` / ``previous`` in the result are always
40        ``None``.  When ``page`` is set, only that page is fetched and
41        ``next`` / ``previous`` reflect the raw API values.
42
43        Args:
44            name_contains: Case-insensitive substring filter on name.
45            name_exact: Case-insensitive exact match on name.
46            page: Return only this specific page (1-based).
47            page_size: Number of results per page.
48            ordering: Field to sort by.
49            descending: When ``True``, reverses the sort direction.
50
51        Returns:
52            :class:`~easypaperless.models.paged_result.PagedResult` of
53            :class:`~easypaperless.models.custom_fields.CustomField` objects.
54        """
55        logger.info("Listing custom fields")
56        params: dict[str, Any] = {}
57        if name_contains is not None:
58            params["name__icontains"] = name_contains
59        if name_exact is not None:
60            params["name__iexact"] = name_exact
61        if page is not None:
62            params["page"] = page
63        if page_size is not None:
64            params["page_size"] = page_size
65        if ordering is not None:
66            params["ordering"] = f"-{ordering}" if descending else ordering
67        return cast(
68            PagedResult[CustomField],
69            await self._core._list_resource("custom_fields", CustomField, params or None),
70        )

Return all custom fields defined in paperless-ngx.

When page is None (the default), all pages are fetched automatically and next / previous in the result are always None. When page is set, only that page is fetched and next / previous reflect the raw API values.

Arguments:
  • name_contains: Case-insensitive substring filter on name.
  • name_exact: Case-insensitive exact match on name.
  • page: Return only this specific page (1-based).
  • page_size: Number of results per page.
  • ordering: Field to sort by.
  • descending: When True, reverses the sort direction.
Returns:

~easypaperless.models.paged_result.PagedResult of ~easypaperless.models.custom_fields.CustomField objects.

async def get(self, id: int) -> easypaperless.CustomField:
72    async def get(self, id: int) -> CustomField:
73        """Fetch a single custom field by its ID.
74
75        Args:
76            id: Numeric custom-field ID.
77
78        Returns:
79            The :class:`~easypaperless.models.custom_fields.CustomField` with the given ID.
80
81        Raises:
82            ~easypaperless.exceptions.NotFoundError: If no custom field exists with that ID.
83        """
84        logger.info("Getting custom field id=%d", id)
85        return cast(CustomField, await self._core._get_resource("custom_fields", id, CustomField))

Fetch a single custom field by its ID.

Arguments:
  • id: Numeric custom-field ID.
Returns:

The ~easypaperless.models.custom_fields.CustomField with the given ID.

Raises:
async def create( self, *, name: str, data_type: str, extra_data: typing.Any | None = None, owner: int | None | easypaperless.Unset = UNSET, set_permissions: easypaperless.SetPermissions | None | easypaperless.Unset = UNSET) -> easypaperless.CustomField:
 87    async def create(
 88        self,
 89        *,
 90        name: str,
 91        data_type: str,
 92        extra_data: Any | None = None,
 93        owner: int | None | Unset = UNSET,
 94        set_permissions: SetPermissions | None | Unset = UNSET,
 95    ) -> CustomField:
 96        """Create a new custom field.
 97
 98        Args:
 99            name: Field name shown in the UI. Must be unique.
100            data_type: Value type. One of ``"string"``, ``"boolean"``,
101                ``"integer"``, ``"float"``, ``"monetary"``, ``"date"``,
102                ``"url"``, ``"documentlink"``, ``"select"``.
103            extra_data: Additional configuration for the field type.
104            owner: Numeric user ID to assign as owner.
105            set_permissions: Explicit view/change permission sets.
106                Pass ``None`` to create with empty permissions.
107
108        Returns:
109            The newly created :class:`~easypaperless.models.custom_fields.CustomField`.
110        """
111        logger.info("Creating custom field name=%r data_type=%r", name, data_type)
112        return cast(
113            CustomField,
114            await self._core._create_resource(
115                "custom_fields",
116                CustomField,
117                owner=owner,
118                set_permissions=set_permissions,
119                name=name,
120                data_type=data_type,
121                extra_data=extra_data,
122            ),
123        )

Create a new custom field.

Arguments:
  • name: Field name shown in the UI. Must be unique.
  • data_type: Value type. One of "string", "boolean", "integer", "float", "monetary", "date", "url", "documentlink", "select".
  • extra_data: Additional configuration for the field type.
  • owner: Numeric user ID to assign as owner.
  • set_permissions: Explicit view/change permission sets. Pass None to create with empty permissions.
Returns:

The newly created ~easypaperless.models.custom_fields.CustomField.

async def update( self, id: int, *, name: str | easypaperless.Unset = UNSET, data_type: str | easypaperless.Unset = UNSET, extra_data: typing.Any | None | easypaperless.Unset = UNSET, owner: int | None | easypaperless.Unset = UNSET, set_permissions: easypaperless.SetPermissions | None | easypaperless.Unset = UNSET) -> easypaperless.CustomField:
125    async def update(
126        self,
127        id: int,
128        *,
129        name: str | Unset = UNSET,
130        data_type: str | Unset = UNSET,
131        extra_data: Any | None | Unset = UNSET,
132        owner: int | None | Unset = UNSET,
133        set_permissions: SetPermissions | None | Unset = UNSET,
134    ) -> CustomField:
135        """Partially update a custom field (PATCH semantics).
136
137        Args:
138            id: Numeric ID of the custom field to update.
139            name: Field name shown in the UI.
140            data_type: Value type (e.g. ``"string"``, ``"boolean"``, ``"integer"``).
141                Omit (or pass :data:`~easypaperless.UNSET`) to leave unchanged.
142            extra_data: Additional configuration for the field type.
143            owner: Numeric user ID to assign as owner.
144                Pass ``None`` to clear the owner.
145                Omit (or pass :data:`~easypaperless.UNSET`) to leave unchanged.
146            set_permissions: Explicit view/change permission sets.
147                Pass ``None`` to clear all permissions (overwrite with empty).
148                Omit (or pass :data:`~easypaperless.UNSET`) to leave unchanged.
149
150        Returns:
151            The updated :class:`~easypaperless.models.custom_fields.CustomField`.
152        """
153        logger.info("Updating custom field id=%d", id)
154        return cast(
155            CustomField,
156            await self._core._update_resource(
157                "custom_fields",
158                id,
159                CustomField,
160                name=name,
161                data_type=data_type,
162                extra_data=extra_data,
163                owner=owner,
164                set_permissions=set_permissions,
165            ),
166        )

Partially update a custom field (PATCH semantics).

Arguments:
  • id: Numeric ID of the custom field to update.
  • name: Field name shown in the UI.
  • data_type: Value type (e.g. "string", "boolean", "integer"). Omit (or pass ~easypaperless.UNSET) to leave unchanged.
  • extra_data: Additional configuration for the field type.
  • owner: Numeric user ID to assign as owner. Pass None to clear the owner. Omit (or pass ~easypaperless.UNSET) to leave unchanged.
  • set_permissions: Explicit view/change permission sets. Pass None to clear all permissions (overwrite with empty). Omit (or pass ~easypaperless.UNSET) to leave unchanged.
Returns:

The updated ~easypaperless.models.custom_fields.CustomField.

async def delete(self, id: int) -> None:
168    async def delete(self, id: int) -> None:
169        """Delete a custom field.
170
171        Args:
172            id: Numeric ID of the custom field to delete.
173
174        Raises:
175            ~easypaperless.exceptions.NotFoundError: If no custom field exists with that ID.
176        """
177        logger.info("Deleting custom field id=%d", id)
178        await self._core._delete_resource("custom_fields", id)

Delete a custom field.

Arguments:
  • id: Numeric ID of the custom field to delete.
Raises:
class DocumentTypesResource:
 21class DocumentTypesResource:
 22    """Accessor for document types: ``client.document_types``."""
 23
 24    def __init__(self, core: _ClientCore) -> None:
 25        self._core = core
 26
 27    async def list(
 28        self,
 29        *,
 30        ids: List[int] | None = None,
 31        name_contains: str | None = None,
 32        name_exact: str | None = None,
 33        page: int | None = None,
 34        page_size: int | None = None,
 35        ordering: str | None = None,
 36        descending: bool = False,
 37    ) -> PagedResult[DocumentType]:
 38        """Return document types defined in paperless-ngx.
 39
 40        When ``page`` is ``None`` (the default), all pages are fetched
 41        automatically and ``next`` / ``previous`` in the result are always
 42        ``None``.  When ``page`` is set, only that page is fetched and
 43        ``next`` / ``previous`` reflect the raw API values.
 44
 45        Args:
 46            ids: Return only document types whose ID is in this list.
 47            name_contains: Case-insensitive substring filter on name.
 48            name_exact: Case-insensitive exact match on name.
 49            page: Return only this specific page (1-based).
 50            page_size: Number of results per page.
 51            ordering: Field to sort by.
 52            descending: When ``True``, reverses the sort direction.
 53
 54        Returns:
 55            :class:`~easypaperless.models.paged_result.PagedResult` of
 56            :class:`~easypaperless.models.document_types.DocumentType` objects.
 57        """
 58        logger.info("Listing document types")
 59        params: dict[str, Any] = {}
 60        if ids is not None:
 61            params["id__in"] = ",".join(str(i) for i in ids)
 62        if name_contains is not None:
 63            params["name__icontains"] = name_contains
 64        if name_exact is not None:
 65            params["name__iexact"] = name_exact
 66        if page is not None:
 67            params["page"] = page
 68        if page_size is not None:
 69            params["page_size"] = page_size
 70        if ordering is not None:
 71            params["ordering"] = f"-{ordering}" if descending else ordering
 72        return cast(
 73            PagedResult[DocumentType],
 74            await self._core._list_resource("document_types", DocumentType, params or None),
 75        )
 76
 77    async def get(self, id: int) -> DocumentType:
 78        """Fetch a single document type by its ID.
 79
 80        Args:
 81            id: Numeric document-type ID.
 82
 83        Returns:
 84            The :class:`~easypaperless.models.document_types.DocumentType` with the given ID.
 85
 86        Raises:
 87            ~easypaperless.exceptions.NotFoundError: If no document type exists with that ID.
 88        """
 89        logger.info("Getting document type id=%d", id)
 90        return cast(
 91            DocumentType, await self._core._get_resource("document_types", id, DocumentType)
 92        )
 93
 94    async def create(
 95        self,
 96        *,
 97        name: str,
 98        match: str | Unset = UNSET,
 99        matching_algorithm: MatchingAlgorithm | Unset = UNSET,
100        is_insensitive: bool = True,
101        owner: int | None | Unset = UNSET,
102        set_permissions: SetPermissions | None | Unset = UNSET,
103    ) -> DocumentType:
104        """Create a new document type.
105
106        Args:
107            name: Document-type name. Must be unique.
108            match: Auto-matching pattern.
109            matching_algorithm: Controls how ``match`` is applied.
110                E.g. ``matching_algorithm=MatchingAlgorithm.REGEX`` for
111                regular-expression matching.
112            is_insensitive: When ``True``, ``match`` is case-insensitive.
113                Defaults to ``True``, matching the paperless-ngx API default.
114            owner: Numeric user ID to assign as owner.
115            set_permissions: Explicit view/change permission sets.
116                Pass ``None`` to create with empty permissions.
117
118        Returns:
119            The newly created :class:`~easypaperless.models.document_types.DocumentType`.
120        """
121        logger.info("Creating document type name=%r", name)
122        return cast(
123            DocumentType,
124            await self._core._create_resource(
125                "document_types",
126                DocumentType,
127                owner=owner,
128                set_permissions=set_permissions,
129                name=name,
130                match=match,
131                matching_algorithm=matching_algorithm,
132                is_insensitive=is_insensitive,
133            ),
134        )
135
136    async def update(
137        self,
138        id: int,
139        *,
140        name: str | Unset = UNSET,
141        match: str | Unset = UNSET,
142        matching_algorithm: MatchingAlgorithm | Unset = UNSET,
143        is_insensitive: bool | Unset = UNSET,
144        owner: int | None | Unset = UNSET,
145        set_permissions: SetPermissions | None | Unset = UNSET,
146    ) -> DocumentType:
147        """Partially update a document type (PATCH semantics).
148
149        Args:
150            id: Numeric ID of the document type to update.
151            name: Document-type name.
152            match: Auto-matching pattern.
153            matching_algorithm: Controls how ``match`` is applied.
154                E.g. ``matching_algorithm=MatchingAlgorithm.REGEX`` for
155                regular-expression matching.
156            is_insensitive: When ``True``, ``match`` is case-insensitive.
157            owner: Numeric user ID to assign as owner.
158                Pass ``None`` to clear the owner.
159                Omit (or pass :data:`~easypaperless.UNSET`) to leave unchanged.
160            set_permissions: Explicit view/change permission sets.
161                Pass ``None`` to clear all permissions (overwrite with empty).
162                Omit (or pass :data:`~easypaperless.UNSET`) to leave unchanged.
163
164        Returns:
165            The updated :class:`~easypaperless.models.document_types.DocumentType`.
166        """
167        logger.info("Updating document type id=%d", id)
168        return cast(
169            DocumentType,
170            await self._core._update_resource(
171                "document_types",
172                id,
173                DocumentType,
174                name=name,
175                match=match,
176                matching_algorithm=matching_algorithm,
177                is_insensitive=is_insensitive,
178                owner=owner,
179                set_permissions=set_permissions,
180            ),
181        )
182
183    async def delete(self, id: int) -> None:
184        """Delete a document type.
185
186        Args:
187            id: Numeric ID of the document type to delete.
188
189        Raises:
190            ~easypaperless.exceptions.NotFoundError: If no document type exists with that ID.
191        """
192        logger.info("Deleting document type id=%d", id)
193        await self._core._delete_resource("document_types", id)
194
195    async def bulk_delete(self, ids: List[int]) -> None:
196        """Permanently delete multiple document types in a single request.
197
198        Args:
199            ids: List of document type IDs to delete.
200        """
201        logger.info("Bulk deleting %d document types", len(ids))
202        await self._core._bulk_edit_objects("document_types", ids, "delete")
203
204    async def bulk_set_permissions(
205        self,
206        ids: List[int],
207        *,
208        set_permissions: SetPermissions | Unset = UNSET,
209        owner: int | None | Unset = UNSET,
210        merge: bool = False,
211    ) -> None:
212        """Set permissions and/or owner on multiple document types.
213
214        Args:
215            ids: List of document type IDs to modify.
216            set_permissions: Explicit view/change permission sets.
217                Omit (or pass :data:`~easypaperless.UNSET`) to leave unchanged.
218            owner: Numeric user ID to assign as owner.
219                Pass ``None`` to clear the owner.
220                Omit (or pass :data:`~easypaperless.UNSET`) to leave unchanged.
221            merge: When ``True``, new permissions are merged with existing ones.
222        """
223        logger.info("Bulk setting permissions on %d document types", len(ids))
224        params: dict[str, Any] = {"merge": merge}
225        if not isinstance(set_permissions, Unset):
226            params["permissions"] = set_permissions.model_dump()
227        if not isinstance(owner, Unset):
228            params["owner"] = owner
229        await self._core._bulk_edit_objects("document_types", ids, "set_permissions", **params)

Accessor for document types: client.document_types.

DocumentTypesResource(core: easypaperless.client._ClientCore)
24    def __init__(self, core: _ClientCore) -> None:
25        self._core = core
async def list( self, *, ids: Optional[List[int]] = None, name_contains: str | None = None, name_exact: str | None = None, page: int | None = None, page_size: int | None = None, ordering: str | None = None, descending: bool = False) -> easypaperless.PagedResult[DocumentType]:
27    async def list(
28        self,
29        *,
30        ids: List[int] | None = None,
31        name_contains: str | None = None,
32        name_exact: str | None = None,
33        page: int | None = None,
34        page_size: int | None = None,
35        ordering: str | None = None,
36        descending: bool = False,
37    ) -> PagedResult[DocumentType]:
38        """Return document types defined in paperless-ngx.
39
40        When ``page`` is ``None`` (the default), all pages are fetched
41        automatically and ``next`` / ``previous`` in the result are always
42        ``None``.  When ``page`` is set, only that page is fetched and
43        ``next`` / ``previous`` reflect the raw API values.
44
45        Args:
46            ids: Return only document types whose ID is in this list.
47            name_contains: Case-insensitive substring filter on name.
48            name_exact: Case-insensitive exact match on name.
49            page: Return only this specific page (1-based).
50            page_size: Number of results per page.
51            ordering: Field to sort by.
52            descending: When ``True``, reverses the sort direction.
53
54        Returns:
55            :class:`~easypaperless.models.paged_result.PagedResult` of
56            :class:`~easypaperless.models.document_types.DocumentType` objects.
57        """
58        logger.info("Listing document types")
59        params: dict[str, Any] = {}
60        if ids is not None:
61            params["id__in"] = ",".join(str(i) for i in ids)
62        if name_contains is not None:
63            params["name__icontains"] = name_contains
64        if name_exact is not None:
65            params["name__iexact"] = name_exact
66        if page is not None:
67            params["page"] = page
68        if page_size is not None:
69            params["page_size"] = page_size
70        if ordering is not None:
71            params["ordering"] = f"-{ordering}" if descending else ordering
72        return cast(
73            PagedResult[DocumentType],
74            await self._core._list_resource("document_types", DocumentType, params or None),
75        )

Return document types defined in paperless-ngx.

When page is None (the default), all pages are fetched automatically and next / previous in the result are always None. When page is set, only that page is fetched and next / previous reflect the raw API values.

Arguments:
  • ids: Return only document types whose ID is in this list.
  • name_contains: Case-insensitive substring filter on name.
  • name_exact: Case-insensitive exact match on name.
  • page: Return only this specific page (1-based).
  • page_size: Number of results per page.
  • ordering: Field to sort by.
  • descending: When True, reverses the sort direction.
Returns:

~easypaperless.models.paged_result.PagedResult of ~easypaperless.models.document_types.DocumentType objects.

async def get(self, id: int) -> easypaperless.DocumentType:
77    async def get(self, id: int) -> DocumentType:
78        """Fetch a single document type by its ID.
79
80        Args:
81            id: Numeric document-type ID.
82
83        Returns:
84            The :class:`~easypaperless.models.document_types.DocumentType` with the given ID.
85
86        Raises:
87            ~easypaperless.exceptions.NotFoundError: If no document type exists with that ID.
88        """
89        logger.info("Getting document type id=%d", id)
90        return cast(
91            DocumentType, await self._core._get_resource("document_types", id, DocumentType)
92        )

Fetch a single document type by its ID.

Arguments:
  • id: Numeric document-type ID.
Returns:

The ~easypaperless.models.document_types.DocumentType with the given ID.

Raises:
async def create( self, *, name: str, match: str | easypaperless.Unset = UNSET, matching_algorithm: easypaperless.MatchingAlgorithm | easypaperless.Unset = UNSET, is_insensitive: bool = True, owner: int | None | easypaperless.Unset = UNSET, set_permissions: easypaperless.SetPermissions | None | easypaperless.Unset = UNSET) -> easypaperless.DocumentType:
 94    async def create(
 95        self,
 96        *,
 97        name: str,
 98        match: str | Unset = UNSET,
 99        matching_algorithm: MatchingAlgorithm | Unset = UNSET,
100        is_insensitive: bool = True,
101        owner: int | None | Unset = UNSET,
102        set_permissions: SetPermissions | None | Unset = UNSET,
103    ) -> DocumentType:
104        """Create a new document type.
105
106        Args:
107            name: Document-type name. Must be unique.
108            match: Auto-matching pattern.
109            matching_algorithm: Controls how ``match`` is applied.
110                E.g. ``matching_algorithm=MatchingAlgorithm.REGEX`` for
111                regular-expression matching.
112            is_insensitive: When ``True``, ``match`` is case-insensitive.
113                Defaults to ``True``, matching the paperless-ngx API default.
114            owner: Numeric user ID to assign as owner.
115            set_permissions: Explicit view/change permission sets.
116                Pass ``None`` to create with empty permissions.
117
118        Returns:
119            The newly created :class:`~easypaperless.models.document_types.DocumentType`.
120        """
121        logger.info("Creating document type name=%r", name)
122        return cast(
123            DocumentType,
124            await self._core._create_resource(
125                "document_types",
126                DocumentType,
127                owner=owner,
128                set_permissions=set_permissions,
129                name=name,
130                match=match,
131                matching_algorithm=matching_algorithm,
132                is_insensitive=is_insensitive,
133            ),
134        )

Create a new document type.

Arguments:
  • name: Document-type name. Must be unique.
  • match: Auto-matching pattern.
  • matching_algorithm: Controls how match is applied. E.g. matching_algorithm=MatchingAlgorithm.REGEX for regular-expression matching.
  • is_insensitive: When True, match is case-insensitive. Defaults to True, matching the paperless-ngx API default.
  • owner: Numeric user ID to assign as owner.
  • set_permissions: Explicit view/change permission sets. Pass None to create with empty permissions.
Returns:

The newly created ~easypaperless.models.document_types.DocumentType.

async def update( self, id: int, *, name: str | easypaperless.Unset = UNSET, match: str | easypaperless.Unset = UNSET, matching_algorithm: easypaperless.MatchingAlgorithm | easypaperless.Unset = UNSET, is_insensitive: bool | easypaperless.Unset = UNSET, owner: int | None | easypaperless.Unset = UNSET, set_permissions: easypaperless.SetPermissions | None | easypaperless.Unset = UNSET) -> easypaperless.DocumentType:
136    async def update(
137        self,
138        id: int,
139        *,
140        name: str | Unset = UNSET,
141        match: str | Unset = UNSET,
142        matching_algorithm: MatchingAlgorithm | Unset = UNSET,
143        is_insensitive: bool | Unset = UNSET,
144        owner: int | None | Unset = UNSET,
145        set_permissions: SetPermissions | None | Unset = UNSET,
146    ) -> DocumentType:
147        """Partially update a document type (PATCH semantics).
148
149        Args:
150            id: Numeric ID of the document type to update.
151            name: Document-type name.
152            match: Auto-matching pattern.
153            matching_algorithm: Controls how ``match`` is applied.
154                E.g. ``matching_algorithm=MatchingAlgorithm.REGEX`` for
155                regular-expression matching.
156            is_insensitive: When ``True``, ``match`` is case-insensitive.
157            owner: Numeric user ID to assign as owner.
158                Pass ``None`` to clear the owner.
159                Omit (or pass :data:`~easypaperless.UNSET`) to leave unchanged.
160            set_permissions: Explicit view/change permission sets.
161                Pass ``None`` to clear all permissions (overwrite with empty).
162                Omit (or pass :data:`~easypaperless.UNSET`) to leave unchanged.
163
164        Returns:
165            The updated :class:`~easypaperless.models.document_types.DocumentType`.
166        """
167        logger.info("Updating document type id=%d", id)
168        return cast(
169            DocumentType,
170            await self._core._update_resource(
171                "document_types",
172                id,
173                DocumentType,
174                name=name,
175                match=match,
176                matching_algorithm=matching_algorithm,
177                is_insensitive=is_insensitive,
178                owner=owner,
179                set_permissions=set_permissions,
180            ),
181        )

Partially update a document type (PATCH semantics).

Arguments:
  • id: Numeric ID of the document type to update.
  • name: Document-type name.
  • match: Auto-matching pattern.
  • matching_algorithm: Controls how match is applied. E.g. matching_algorithm=MatchingAlgorithm.REGEX for regular-expression matching.
  • is_insensitive: When True, match is case-insensitive.
  • owner: Numeric user ID to assign as owner. Pass None to clear the owner. Omit (or pass ~easypaperless.UNSET) to leave unchanged.
  • set_permissions: Explicit view/change permission sets. Pass None to clear all permissions (overwrite with empty). Omit (or pass ~easypaperless.UNSET) to leave unchanged.
Returns:

The updated ~easypaperless.models.document_types.DocumentType.

async def delete(self, id: int) -> None:
183    async def delete(self, id: int) -> None:
184        """Delete a document type.
185
186        Args:
187            id: Numeric ID of the document type to delete.
188
189        Raises:
190            ~easypaperless.exceptions.NotFoundError: If no document type exists with that ID.
191        """
192        logger.info("Deleting document type id=%d", id)
193        await self._core._delete_resource("document_types", id)

Delete a document type.

Arguments:
  • id: Numeric ID of the document type to delete.
Raises:
async def bulk_delete(self, ids: List[int]) -> None:
195    async def bulk_delete(self, ids: List[int]) -> None:
196        """Permanently delete multiple document types in a single request.
197
198        Args:
199            ids: List of document type IDs to delete.
200        """
201        logger.info("Bulk deleting %d document types", len(ids))
202        await self._core._bulk_edit_objects("document_types", ids, "delete")

Permanently delete multiple document types in a single request.

Arguments:
  • ids: List of document type IDs to delete.
async def bulk_set_permissions( self, ids: List[int], *, set_permissions: easypaperless.SetPermissions | easypaperless.Unset = UNSET, owner: int | None | easypaperless.Unset = UNSET, merge: bool = False) -> None:
204    async def bulk_set_permissions(
205        self,
206        ids: List[int],
207        *,
208        set_permissions: SetPermissions | Unset = UNSET,
209        owner: int | None | Unset = UNSET,
210        merge: bool = False,
211    ) -> None:
212        """Set permissions and/or owner on multiple document types.
213
214        Args:
215            ids: List of document type IDs to modify.
216            set_permissions: Explicit view/change permission sets.
217                Omit (or pass :data:`~easypaperless.UNSET`) to leave unchanged.
218            owner: Numeric user ID to assign as owner.
219                Pass ``None`` to clear the owner.
220                Omit (or pass :data:`~easypaperless.UNSET`) to leave unchanged.
221            merge: When ``True``, new permissions are merged with existing ones.
222        """
223        logger.info("Bulk setting permissions on %d document types", len(ids))
224        params: dict[str, Any] = {"merge": merge}
225        if not isinstance(set_permissions, Unset):
226            params["permissions"] = set_permissions.model_dump()
227        if not isinstance(owner, Unset):
228            params["owner"] = owner
229        await self._core._bulk_edit_objects("document_types", ids, "set_permissions", **params)

Set permissions and/or owner on multiple document types.

Arguments:
  • ids: List of document type IDs to modify.
  • set_permissions: Explicit view/change permission sets. Omit (or pass ~easypaperless.UNSET) to leave unchanged.
  • owner: Numeric user ID to assign as owner. Pass None to clear the owner. Omit (or pass ~easypaperless.UNSET) to leave unchanged.
  • merge: When True, new permissions are merged with existing ones.
class DocumentsResource:
  64class DocumentsResource:
  65    """Accessor for documents: ``client.documents``."""
  66
  67    def __init__(self, core: _ClientCore) -> None:
  68        self._core = core
  69        self.notes = NotesResource(core)
  70
  71    async def history(
  72        self,
  73        document_id: int,
  74        *,
  75        page: int | None = None,
  76        page_size: int | None = None,
  77    ) -> PagedResult[AuditLogEntry]:
  78        """Fetch the audit log for a document.
  79
  80        The paperless-ngx ``/api/documents/{id}/history/`` endpoint returns a
  81        plain JSON array rather than a paginated envelope.  This method wraps
  82        the response into a :class:`~easypaperless.models.paged_result.PagedResult`
  83        so callers always receive a consistent return type.
  84
  85        Args:
  86            document_id: Numeric ID of the document whose history to retrieve.
  87            page: Forwarded to the API as a query parameter when provided.
  88                Effect depends on the paperless-ngx version; the server may
  89                ignore this parameter.
  90            page_size: Forwarded to the API as a query parameter when provided.
  91
  92        Returns:
  93            :class:`~easypaperless.models.paged_result.PagedResult` of
  94            :class:`~easypaperless.models.documents.AuditLogEntry` objects,
  95            ordered by timestamp descending.
  96
  97        Raises:
  98            ~easypaperless.exceptions.NotFoundError: If no document exists
  99                with that ID.
 100        """
 101        logger.info("Fetching history for document id=%d", document_id)
 102        path = f"/documents/{document_id}/history/"
 103        params: dict[str, Any] = {}
 104        if page is not None:
 105            params["page"] = page
 106        if page_size is not None:
 107            params["page_size"] = page_size
 108
 109        resp = await self._core._session.get(path, params=params or None)
 110        data = resp.json()
 111
 112        if isinstance(data, list):
 113            entries = [AuditLogEntry.model_validate(item) for item in data]
 114            entry_ids: list[int] = [e.id for e in entries]
 115            return PagedResult(
 116                count=len(entries),
 117                next=None,
 118                previous=None,
 119                all=entry_ids if entry_ids else None,
 120                results=entries,
 121            )
 122
 123        # Forward-compatible: handle a paginated envelope if the API ever adds one.
 124        items: list[Any] = list(data.get("results", []))
 125        count: int = data.get("count", 0)
 126        all_ids: list[int] | None = data.get("all")
 127        return PagedResult(
 128            count=count,
 129            next=data.get("next"),
 130            previous=data.get("previous"),
 131            all=all_ids,
 132            results=[AuditLogEntry.model_validate(item) for item in items],
 133        )
 134
 135    @staticmethod
 136    def _format_date_value(value: date | datetime | str) -> str:
 137        if isinstance(value, datetime):
 138            return value.isoformat()
 139        if isinstance(value, date):
 140            return value.isoformat()
 141        return value
 142
 143    @staticmethod
 144    def _is_datetime(value: date | datetime | str) -> bool:
 145        if isinstance(value, datetime):
 146            return True
 147        if isinstance(value, str):
 148            return bool(_DATETIME_STR_RE.match(value))
 149        return False
 150
 151    async def get(self, id: int, *, include_metadata: bool = False) -> Document:
 152        """Fetch a single document by its ID.
 153
 154        Args:
 155            id: Numeric paperless-ngx document ID.
 156            include_metadata: When ``True``, the extended file-level metadata
 157                is fetched concurrently and attached to the document.
 158                Default: ``False``.
 159
 160        Returns:
 161            The :class:`~easypaperless.models.documents.Document` with the
 162            given ID.
 163
 164        Raises:
 165            ~easypaperless.exceptions.NotFoundError: If no document exists
 166                with that ID.
 167        """
 168        logger.info("Getting document id=%d", id)
 169        if include_metadata:
 170            doc_resp, meta_resp = await asyncio.gather(
 171                self._core._session.get(f"/documents/{id}/"),
 172                self._core._session.get(f"/documents/{id}/metadata/"),
 173            )
 174            data = doc_resp.json()
 175            data["metadata"] = meta_resp.json()
 176        else:
 177            resp = await self._core._session.get(f"/documents/{id}/")
 178            data = resp.json()
 179        return Document.model_validate(data)
 180
 181    async def get_metadata(self, id: int) -> DocumentMetadata:
 182        """Fetch the extended file-level metadata for a document.
 183
 184        Args:
 185            id: Numeric paperless-ngx document ID.
 186
 187        Returns:
 188            A :class:`~easypaperless.models.documents.DocumentMetadata` instance.
 189
 190        Raises:
 191            ~easypaperless.exceptions.NotFoundError: If no document exists
 192                with that ID.
 193        """
 194        logger.info("Getting metadata for document id=%d", id)
 195        resp = await self._core._session.get(f"/documents/{id}/metadata/")
 196        return DocumentMetadata.model_validate(resp.json())
 197
 198    async def list(
 199        self,
 200        *,
 201        search: str | None = None,
 202        search_mode: str = "title_or_content",
 203        ids: List[int] | None = None,
 204        tags: List[int | str] | None = None,
 205        any_tags: List[int | str] | None = None,
 206        exclude_tags: List[int | str] | None = None,
 207        correspondent: int | str | None | Unset = UNSET,
 208        any_correspondent: List[int | str] | None = None,
 209        exclude_correspondents: List[int | str] | None = None,
 210        document_type: int | str | None | Unset = UNSET,
 211        document_type_name_contains: str | None = None,
 212        document_type_name_exact: str | None = None,
 213        any_document_type: List[int | str] | None = None,
 214        exclude_document_types: List[int | str] | None = None,
 215        storage_path: int | str | None | Unset = UNSET,
 216        any_storage_paths: List[int | str] | None = None,
 217        exclude_storage_paths: List[int | str] | None = None,
 218        owner: int | None | Unset = UNSET,
 219        exclude_owners: List[int] | None = None,
 220        custom_fields: List[int | str] | None = None,
 221        any_custom_fields: List[int | str] | None = None,
 222        exclude_custom_fields: List[int | str] | None = None,
 223        custom_field_query: List[Any] | None = None,
 224        archive_serial_number: int | None | Unset = UNSET,
 225        archive_serial_number_from: int | None = None,
 226        archive_serial_number_till: int | None = None,
 227        created_after: date | str | None = None,
 228        created_before: date | str | None = None,
 229        added_after: date | datetime | str | None = None,
 230        added_from: date | datetime | str | None = None,
 231        added_before: date | datetime | str | None = None,
 232        added_until: date | datetime | str | None = None,
 233        modified_after: date | datetime | str | None = None,
 234        modified_from: date | datetime | str | None = None,
 235        modified_before: date | datetime | str | None = None,
 236        modified_until: date | datetime | str | None = None,
 237        checksum: str | None = None,
 238        page_size: int = 25,
 239        page: int | None = None,
 240        ordering: str | None = None,
 241        descending: bool = False,
 242        max_results: int | None = None,
 243        on_page: Callable[[int, int | None], None] | None = None,
 244    ) -> PagedResult[Document]:
 245        """Return a filtered list of documents.
 246
 247        All tag, correspondent, document-type, storage-path, and custom-field
 248        parameters accept either integer IDs or string names.
 249
 250        When ``page`` is ``None`` (the default), all pages are fetched
 251        automatically and ``next`` / ``previous`` in the returned
 252        :class:`~easypaperless.models.paged_result.PagedResult` are always
 253        ``None`` — even if ``max_results`` truncates the final result set.
 254        ``count`` always reflects the server total, not the truncated length.
 255        When ``page`` is set to a specific integer, only that one page is
 256        fetched and ``next`` / ``previous`` contain the raw API values.
 257
 258        Args:
 259            search: Search string.  Behaviour depends on ``search_mode``.
 260            search_mode: How ``search`` is applied.  One of:
 261                ``"title_or_content"`` *(default)*, ``"title"``, ``"query"``,
 262                ``"original_filename"``.
 263            ids: Return only documents whose ID is in this list.
 264            tags: Documents must have **all** of these tags (AND semantics).
 265            any_tags: Documents must have **at least one** of these tags.
 266            exclude_tags: Documents must have **none** of these tags.
 267            correspondent: Filter to documents assigned to this correspondent.
 268                Pass ``None`` to return only documents with no correspondent set.
 269            any_correspondent: Filter to documents assigned to any of these.
 270            exclude_correspondents: Exclude documents assigned to any of these.
 271            document_type: Filter to documents of exactly this type.
 272                Pass ``None`` to return only documents with no document type set.
 273            document_type_name_contains: Case-insensitive substring filter on document type name.
 274            document_type_name_exact: Case-insensitive exact match on document type name.
 275            any_document_type: Filter to documents whose type is any of these.
 276            exclude_document_types: Exclude documents whose type is any of these.
 277            storage_path: Filter to documents assigned to this storage path.
 278                Pass ``None`` to return only documents with no storage path set.
 279            any_storage_paths: Filter to documents assigned to any of these paths.
 280            exclude_storage_paths: Exclude documents assigned to any of these paths.
 281            owner: Filter to documents owned by this user ID.
 282                Pass ``None`` to return only documents with no owner set.
 283            exclude_owners: Exclude documents owned by any of these user IDs.
 284            custom_fields: Documents must have **all** of these custom fields set.
 285            any_custom_fields: Documents must have **at least one** of these fields.
 286            exclude_custom_fields: Documents must have **none** of these fields.
 287            custom_field_query: Filter documents by custom field values using a nested
 288                query structure. See the `paperless-ngx API docs
 289                <https://docs.paperless-ngx.com/api/#filtering-by-custom-fields>`_ for
 290                the query format.
 291            archive_serial_number: Filter by exact archive serial number.
 292                Pass ``None`` to return only documents with no ASN set.
 293            archive_serial_number_from: Filter by ASN >= this value.
 294            archive_serial_number_till: Filter by ASN <= this value.
 295            created_after: Only documents created after this date.
 296                String input must be ISO-8601: ``"YYYY-MM-DD"``.
 297            created_before: Only documents created before this date.
 298                String input must be ISO-8601: ``"YYYY-MM-DD"``.
 299            added_after: Only documents added after this date/time.
 300                String input must be ISO-8601: ``"YYYY-MM-DD"`` for date precision or
 301                ``"YYYY-MM-DDTHH:MM:SS"`` for datetime precision.
 302            added_from: Only documents added on or after this date/time.
 303                String input must be ISO-8601: ``"YYYY-MM-DD"`` or ``"YYYY-MM-DDTHH:MM:SS"``.
 304            added_before: Only documents added before this date/time.
 305                String input must be ISO-8601: ``"YYYY-MM-DD"`` or ``"YYYY-MM-DDTHH:MM:SS"``.
 306            added_until: Only documents added on or before this date/time.
 307                String input must be ISO-8601: ``"YYYY-MM-DD"`` or ``"YYYY-MM-DDTHH:MM:SS"``.
 308            modified_after: Only documents modified after this date/time.
 309                String input must be ISO-8601: ``"YYYY-MM-DD"`` or ``"YYYY-MM-DDTHH:MM:SS"``.
 310            modified_from: Only documents modified on or after this date/time.
 311                String input must be ISO-8601: ``"YYYY-MM-DD"`` or ``"YYYY-MM-DDTHH:MM:SS"``.
 312            modified_before: Only documents modified before this date/time.
 313                String input must be ISO-8601: ``"YYYY-MM-DD"`` or ``"YYYY-MM-DDTHH:MM:SS"``.
 314            modified_until: Only documents modified on or before this date/time.
 315                String input must be ISO-8601: ``"YYYY-MM-DD"`` or ``"YYYY-MM-DDTHH:MM:SS"``.
 316            checksum: MD5 checksum (hex) of the original uploaded file, matched
 317                exactly but case-insensitively (sent as ``checksum__iexact``).
 318                Documents in the trash are **not** found, yet paperless-ngx
 319                still rejects a re-upload of the same file as a duplicate.  To
 320                detect that case, catch the
 321                :exc:`~easypaperless.exceptions.UploadError` of
 322                ``upload(wait=True)`` (or of ``tasks.wait()``): ``err.task.result``
 323                contains ``": It is a duplicate of "`` and ends in
 324                ``"Note: existing document is in the trash."``, and
 325                ``err.task.related_document`` is ``None`` (for a live duplicate
 326                it is the existing document's ID).  ``client.trash.list()``
 327                shows the trashed document; ``client.trash.restore()`` brings
 328                it back.
 329            page_size: Number of results per API page.  Default: ``25``.
 330            page: Return only this specific page (1-based).
 331            ordering: Field name to sort by.
 332            descending: When ``True``, reverses the sort direction.
 333            max_results: Stop after collecting this many documents.
 334            on_page: Callback invoked after each page fetch.
 335
 336        Returns:
 337            :class:`~easypaperless.models.paged_result.PagedResult` of
 338            :class:`~easypaperless.models.documents.Document` objects.
 339        """
 340        logger.info("Listing documents")
 341        resolver = self._core._resolver
 342        params: dict[str, Any] = {"page_size": page_size}
 343
 344        if search is not None:
 345            api_param = _SEARCH_MODE_MAP.get(search_mode, "search")
 346            params[api_param] = search
 347
 348        if ids is not None:
 349            params["id__in"] = ",".join(str(i) for i in ids)
 350
 351        if tags is not None:
 352            resolved = await resolver.resolve_list("tags", tags)
 353            params["tags__id__all"] = ",".join(str(t) for t in resolved)
 354
 355        if any_tags is not None:
 356            resolved = await resolver.resolve_list("tags", any_tags)
 357            params["tags__id__in"] = ",".join(str(t) for t in resolved)
 358
 359        if exclude_tags is not None:
 360            resolved = await resolver.resolve_list("tags", exclude_tags)
 361            params["tags__id__none"] = ",".join(str(t) for t in resolved)
 362
 363        if any_correspondent is not None:
 364            resolved = await resolver.resolve_list("correspondents", any_correspondent)
 365            params["correspondent__id__in"] = ",".join(str(c) for c in resolved)
 366        elif not isinstance(correspondent, Unset):
 367            if correspondent is None:
 368                params["correspondent__isnull"] = "true"
 369            else:
 370                resolved_id = await resolver.resolve("correspondents", correspondent)
 371                params["correspondent__id"] = resolved_id
 372
 373        if exclude_correspondents is not None:
 374            resolved = await resolver.resolve_list("correspondents", exclude_correspondents)
 375            params["correspondent__id__none"] = ",".join(str(c) for c in resolved)
 376
 377        if document_type_name_contains is not None:
 378            params["document_type__name__icontains"] = document_type_name_contains
 379        if document_type_name_exact is not None:
 380            params["document_type__name__iexact"] = document_type_name_exact
 381
 382        if any_document_type is not None:
 383            resolved = await resolver.resolve_list("document_types", any_document_type)
 384            params["document_type__id__in"] = ",".join(str(d) for d in resolved)
 385        elif not isinstance(document_type, Unset):
 386            if document_type is None:
 387                params["document_type__isnull"] = "true"
 388            else:
 389                resolved_id = await resolver.resolve("document_types", document_type)
 390                params["document_type__id"] = resolved_id
 391
 392        if exclude_document_types is not None:
 393            resolved = await resolver.resolve_list("document_types", exclude_document_types)
 394            params["document_type__id__none"] = ",".join(str(d) for d in resolved)
 395
 396        if any_storage_paths is not None:
 397            resolved = await resolver.resolve_list("storage_paths", any_storage_paths)
 398            params["storage_path__id__in"] = ",".join(str(s) for s in resolved)
 399        elif not isinstance(storage_path, Unset):
 400            if storage_path is None:
 401                params["storage_path__isnull"] = "true"
 402            else:
 403                resolved_id = await resolver.resolve("storage_paths", storage_path)
 404                params["storage_path__id"] = resolved_id
 405
 406        if exclude_storage_paths is not None:
 407            resolved = await resolver.resolve_list("storage_paths", exclude_storage_paths)
 408            params["storage_path__id__none"] = ",".join(str(s) for s in resolved)
 409
 410        if not isinstance(owner, Unset):
 411            if owner is None:
 412                params["owner__isnull"] = "true"
 413            else:
 414                params["owner__id"] = owner
 415
 416        if exclude_owners is not None:
 417            params["owner__id__none"] = ",".join(str(o) for o in exclude_owners)
 418
 419        if custom_fields is not None:
 420            resolved = await resolver.resolve_list("custom_fields", custom_fields)
 421            params["custom_fields__id__all"] = ",".join(str(f) for f in resolved)
 422
 423        if any_custom_fields is not None:
 424            resolved = await resolver.resolve_list("custom_fields", any_custom_fields)
 425            params["custom_fields__id__in"] = ",".join(str(f) for f in resolved)
 426
 427        if exclude_custom_fields is not None:
 428            resolved = await resolver.resolve_list("custom_fields", exclude_custom_fields)
 429            params["custom_fields__id__none"] = ",".join(str(f) for f in resolved)
 430
 431        if custom_field_query is not None:
 432            params["custom_field_query"] = json.dumps(custom_field_query)
 433
 434        if not isinstance(archive_serial_number, Unset):
 435            if archive_serial_number is None:
 436                params["archive_serial_number__isnull"] = "true"
 437            else:
 438                params["archive_serial_number"] = archive_serial_number
 439
 440        if archive_serial_number_from is not None:
 441            params["archive_serial_number__gte"] = archive_serial_number_from
 442
 443        if archive_serial_number_till is not None:
 444            params["archive_serial_number__lte"] = archive_serial_number_till
 445
 446        if created_after is not None:
 447            params["created__date__gt"] = self._format_date_value(created_after)
 448
 449        if created_before is not None:
 450            params["created__date__lt"] = self._format_date_value(created_before)
 451
 452        if added_after is not None:
 453            key = "added__gt" if self._is_datetime(added_after) else "added__date__gt"
 454            params[key] = self._format_date_value(added_after)
 455
 456        if added_from is not None:
 457            key = "added__gte" if self._is_datetime(added_from) else "added__date__gte"
 458            params[key] = self._format_date_value(added_from)
 459
 460        if added_before is not None:
 461            key = "added__lt" if self._is_datetime(added_before) else "added__date__lt"
 462            params[key] = self._format_date_value(added_before)
 463
 464        if added_until is not None:
 465            key = "added__lte" if self._is_datetime(added_until) else "added__date__lte"
 466            params[key] = self._format_date_value(added_until)
 467
 468        if modified_after is not None:
 469            key = "modified__gt" if self._is_datetime(modified_after) else "modified__date__gt"
 470            params[key] = self._format_date_value(modified_after)
 471
 472        if modified_from is not None:
 473            key = "modified__gte" if self._is_datetime(modified_from) else "modified__date__gte"
 474            params[key] = self._format_date_value(modified_from)
 475
 476        if modified_before is not None:
 477            key = "modified__lt" if self._is_datetime(modified_before) else "modified__date__lt"
 478            params[key] = self._format_date_value(modified_before)
 479
 480        if modified_until is not None:
 481            key = "modified__lte" if self._is_datetime(modified_until) else "modified__date__lte"
 482            params[key] = self._format_date_value(modified_until)
 483
 484        if checksum is not None:
 485            params["checksum__iexact"] = checksum
 486
 487        if ordering is not None:
 488            params["ordering"] = f"-{ordering}" if descending else ordering
 489
 490        if page is not None:
 491            params["page"] = page
 492            raw = await self._core._session.get_page("/documents/", params=params)
 493            items = raw.items
 494            if max_results is not None:
 495                items = items[:max_results]
 496            return PagedResult(
 497                count=raw.count,
 498                next=raw.next,
 499                previous=raw.previous,
 500                all=raw.all_ids,
 501                results=[Document.model_validate(item) for item in items],
 502            )
 503
 504        raw = await self._core._session.get_all_pages_paged(
 505            "/documents/", params, max_results=max_results, on_page=on_page
 506        )
 507        return PagedResult(
 508            count=raw.count,
 509            next=raw.next,
 510            previous=raw.previous,
 511            all=raw.all_ids,
 512            results=[Document.model_validate(item) for item in raw.items],
 513        )
 514
 515    async def update(
 516        self,
 517        id: int,
 518        *,
 519        title: str | Unset = UNSET,
 520        content: str | Unset = UNSET,
 521        created: date | str | None | Unset = UNSET,
 522        correspondent: int | str | None | Unset = UNSET,
 523        document_type: int | str | None | Unset = UNSET,
 524        storage_path: int | str | None | Unset = UNSET,
 525        tags: List[int | str] | None | Unset = UNSET,
 526        archive_serial_number: int | None | Unset = UNSET,
 527        custom_fields: List[dict[str, Any]] | None | Unset = UNSET,
 528        owner: int | None | Unset = UNSET,
 529        set_permissions: SetPermissions | None | Unset = UNSET,
 530        remove_inbox_tags: bool | None | Unset = UNSET,
 531    ) -> Document:
 532        """Partially update a document (PATCH semantics).
 533
 534        Args:
 535            id: Numeric ID of the document to update.
 536            title: New document title.
 537            content: OCR text content of the document.
 538            created: Creation date as an ISO-8601 string (``"YYYY-MM-DD"``) or a
 539                :class:`~datetime.date` object.
 540            correspondent: Correspondent to assign, as an ID or name.
 541                Pass ``None`` to clear the correspondent.
 542            document_type: Document type to assign, as an ID or name.
 543                Pass ``None`` to clear the document type.
 544            storage_path: Storage path to assign, as an ID or name.
 545                Pass ``None`` to clear the storage path.
 546            tags: Full replacement list of tags (IDs or names).
 547            archive_serial_number: Archive serial number to assign.
 548                Pass ``None`` to clear the archive serial number.
 549            custom_fields: List of ``{"field": <field_id>, "value": ...}`` dicts.
 550            owner: Numeric user ID to assign as document owner.
 551                Pass ``None`` to clear the owner.
 552            set_permissions: Explicit view/change permission sets.
 553                Pass ``None`` to clear all permissions (overwrite with empty).
 554                Omit (or pass :data:`~easypaperless.UNSET`) to leave unchanged.
 555                The given sets replace the document's current view and change
 556                users and groups.  Together with ``owner`` everything goes out
 557                in one PATCH, which paperless-ngx applies as a whole.
 558            remove_inbox_tags: When ``True``, removes all inbox tags from the document.
 559
 560        Returns:
 561            The updated :class:`~easypaperless.models.documents.Document`.
 562        """
 563        logger.info("Updating document id=%d", id)
 564        resolver = self._core._resolver
 565        payload: dict[str, Any] = {}
 566
 567        if not isinstance(title, Unset):
 568            payload["title"] = title
 569        if not isinstance(content, Unset):
 570            payload["content"] = content
 571        if not isinstance(created, Unset):
 572            payload["created"] = self._format_date_value(created) if created is not None else None
 573        if not isinstance(correspondent, Unset):
 574            payload["correspondent"] = (
 575                None
 576                if correspondent is None
 577                else await resolver.resolve("correspondents", correspondent)
 578            )
 579        if not isinstance(document_type, Unset):
 580            payload["document_type"] = (
 581                None
 582                if document_type is None
 583                else await resolver.resolve("document_types", document_type)
 584            )
 585        if not isinstance(storage_path, Unset):
 586            payload["storage_path"] = (
 587                None
 588                if storage_path is None
 589                else await resolver.resolve("storage_paths", storage_path)
 590            )
 591        if not isinstance(tags, Unset):
 592            payload["tags"] = await resolver.resolve_list("tags", tags or [])
 593        if not isinstance(archive_serial_number, Unset):
 594            payload["archive_serial_number"] = archive_serial_number
 595        if not isinstance(custom_fields, Unset):
 596            payload["custom_fields"] = custom_fields
 597        if not isinstance(owner, Unset):
 598            payload["owner"] = owner
 599        if not isinstance(set_permissions, Unset):
 600            payload["set_permissions"] = (
 601                SetPermissions().model_dump()
 602                if set_permissions is None
 603                else set_permissions.model_dump()
 604            )
 605        if not isinstance(remove_inbox_tags, Unset):
 606            payload["remove_inbox_tags"] = remove_inbox_tags
 607
 608        resp = await self._core._session.patch(f"/documents/{id}/", json=payload)
 609        return Document.model_validate(resp.json())
 610
 611    async def delete(self, id: int) -> None:
 612        """Permanently delete a document.
 613
 614        Args:
 615            id: Numeric ID of the document to delete.
 616
 617        Raises:
 618            ~easypaperless.exceptions.NotFoundError: If no document exists
 619                with that ID.
 620        """
 621        logger.info("Deleting document id=%d", id)
 622        await self._core._session.delete(f"/documents/{id}/")
 623
 624    async def download(self, id: int, *, original: bool = False) -> bytes:
 625        """Download the binary content of a document.
 626
 627        Args:
 628            id: Numeric ID of the document to download.
 629            original: If ``False`` *(default)*, returns the archived PDF
 630                (``GET /documents/{id}/download/``).
 631                If ``True``, returns the original uploaded file
 632                (``GET /documents/{id}/download/?original=true``).
 633
 634        Returns:
 635            Raw file bytes.
 636        """
 637        logger.info("Downloading document id=%d (original=%s)", id, original)
 638        path = f"/documents/{id}/download/"
 639        if original:
 640            path += "?original=true"
 641        resp = await self._core._session.get_download(path)
 642        return _binary_content(resp, "Download")
 643
 644    async def thumbnail(self, id: int) -> bytes:
 645        """Fetch the thumbnail image of a document.
 646
 647        Args:
 648            id: Numeric ID of the document whose thumbnail to retrieve.
 649
 650        Returns:
 651            Raw binary content of the thumbnail image.
 652
 653        Raises:
 654            ~easypaperless.exceptions.NotFoundError: If no document exists
 655                with that ID.
 656            ~easypaperless.exceptions.ServerResponseError: If the server returns an
 657                HTML page (e.g. an auth redirect) instead of the image.
 658        """
 659        logger.info("Fetching thumbnail for document id=%d", id)
 660        resp = await self._core._session.get_download(f"/documents/{id}/thumb/")
 661        return _binary_content(resp, "Thumbnail")
 662
 663    async def upload(
 664        self,
 665        file: str | Path | bytes,
 666        *,
 667        filename: str | None = None,
 668        content_type: str | None = None,
 669        request_timeout: float | None = None,
 670        title: str | Unset = UNSET,
 671        created: date | str | None = None,
 672        correspondent: int | str | None | Unset = UNSET,
 673        document_type: int | str | None | Unset = UNSET,
 674        storage_path: int | str | None | Unset = UNSET,
 675        tags: List[int | str] | None = None,
 676        archive_serial_number: int | None | Unset = UNSET,
 677        custom_fields: List[dict[str, Any]] | None = None,
 678        wait: bool = False,
 679        poll_interval: float | None = None,
 680        poll_timeout: float | None = None,
 681    ) -> str | Document:
 682        """Upload a document to paperless-ngx.
 683
 684        The upload request is never retried automatically, whatever the
 685        client's ``retry_attempts`` / ``tenacity_retrying`` settings: if the
 686        connection fails after paperless-ngx has accepted the file, a retry
 687        would create a duplicate.  A failed upload raises (e.g.
 688        :exc:`~easypaperless.exceptions.TransportTimeoutError`) so you can
 689        decide whether to check for the document and upload again.
 690
 691        Args:
 692            file: Path to the file to upload (``str`` or :class:`~pathlib.Path`),
 693                or the file content as ``bytes``.  Bytes are sent directly; no
 694                temporary file is written.
 695            filename: File name sent to paperless-ngx.  Required when *file* is
 696                ``bytes`` (omitting it raises
 697                :exc:`~easypaperless.exceptions.ValidationError` before any
 698                request).  For a path, overrides the name taken from the path.
 699            content_type: MIME type of the file part, sent as given (e.g.
 700                ``"application/pdf"``).  When omitted, it is guessed from the
 701                file name as before.  paperless-ngx detects the file type from
 702                the bytes and does not rely on this value to accept the file.
 703            request_timeout: HTTP timeout in seconds for the upload request
 704                only, overriding the client's ``timeout`` for this call.  Does
 705                not affect task polling (see ``poll_timeout``).  When omitted,
 706                the client's ``timeout`` applies.
 707            title: Title to assign to the document.
 708            created: Creation date as an ISO-8601 string (``"YYYY-MM-DD"``) or a
 709                :class:`~datetime.date` object.
 710            correspondent: Correspondent to assign, as an ID or name.
 711            document_type: Document type to assign, as an ID or name.
 712            storage_path: Storage path to assign, as an ID or name.
 713            tags: Tags to assign, as IDs or names.
 714            archive_serial_number: Archive serial number to assign.
 715            custom_fields: List of ``{"field": <field_id>, "value": ...}`` dicts.
 716            wait: If ``False`` *(default)*, returns immediately with the task ID.
 717                If ``True``, polls until processing completes.
 718            poll_interval: Seconds between task-status checks while waiting for
 719                processing to complete (requires ``wait=True``). Overrides the
 720                client-level default. When omitted, falls back to the client-level
 721                ``poll_interval`` (``2.0`` s unless changed at construction).
 722            poll_timeout: Maximum seconds to wait before raising
 723                :exc:`~easypaperless.exceptions.TaskTimeoutError` (requires
 724                ``wait=True``). Overrides the client-level default. When omitted,
 725                falls back to the client-level ``poll_timeout`` (``60.0`` s unless
 726                changed at construction).
 727
 728        Returns:
 729            The Celery task ID string when ``wait=False``, or the fully
 730            processed :class:`~easypaperless.models.documents.Document`
 731            when ``wait=True``.
 732
 733        Raises:
 734            ~easypaperless.exceptions.ValidationError: If *file* is ``bytes``
 735                and no *filename* is given.
 736            ~easypaperless.exceptions.BadRequestError: If paperless-ngx rejects
 737                the file before processing starts, e.g. an unsupported file
 738                type or an empty file (``err.field_errors["document"]``).
 739            ~easypaperless.exceptions.UploadError: If processing fails;
 740                ``err.task`` holds the task with paperless-ngx's ``result``
 741                unaltered.  For a duplicate, ``err.task.result`` contains
 742                ``": It is a duplicate of "`` and ``err.task.related_document``
 743                is the existing document's ID (``None`` if that document is
 744                in the trash).
 745            ~easypaperless.exceptions.TaskTimeoutError: If timeout is exceeded;
 746                resume with ``client.tasks.wait(err.task_id)``.
 747        """
 748        resolver = self._core._resolver
 749        if isinstance(file, bytes):
 750            if not filename:
 751                raise ValidationError("filename is required when uploading from bytes")
 752            file_bytes = file
 753            upload_name = filename
 754        else:
 755            file_path = Path(file)
 756            file_bytes = file_path.read_bytes()
 757            upload_name = filename if filename is not None else file_path.name
 758        logger.info("Uploading %r (%d bytes)", upload_name, len(file_bytes))
 759
 760        data: dict[str, Any] = {}
 761        if not isinstance(title, Unset):
 762            data["title"] = title
 763        if created is not None:
 764            data["created"] = self._format_date_value(created)
 765        if not isinstance(correspondent, Unset) and correspondent is not None:
 766            data["correspondent"] = await resolver.resolve("correspondents", correspondent)
 767        if not isinstance(document_type, Unset) and document_type is not None:
 768            data["document_type"] = await resolver.resolve("document_types", document_type)
 769        if not isinstance(storage_path, Unset) and storage_path is not None:
 770            data["storage_path"] = await resolver.resolve("storage_paths", storage_path)
 771        if tags is not None:
 772            resolved = await resolver.resolve_list("tags", tags)
 773            data["tags"] = resolved
 774        if not isinstance(archive_serial_number, Unset) and archive_serial_number is not None:
 775            data["archive_serial_number"] = archive_serial_number
 776        if custom_fields is not None:
 777            data["custom_fields"] = json.dumps(custom_fields)
 778
 779        # Without content_type httpx derives it from the file name (previous behaviour).
 780        document_part: tuple[str, bytes] | tuple[str, bytes, str] = (
 781            (upload_name, file_bytes)
 782            if content_type is None
 783            else (upload_name, file_bytes, content_type)
 784        )
 785        files = {"document": document_part}
 786        resp = await self._core._session.post(
 787            "/documents/post_document/",
 788            data=data,
 789            files=files,
 790            timeout=request_timeout,
 791            retry=False,  # a retry after a lost response would upload a duplicate
 792        )
 793        task_id: str = resp.text.strip('"')
 794        logger.debug("Upload accepted, task_id=%r", task_id)
 795
 796        if not wait:
 797            return task_id
 798
 799        task = await self._core.tasks.wait(
 800            task_id, poll_interval=poll_interval, poll_timeout=poll_timeout
 801        )
 802        if task.related_document is None:
 803            raise UploadError(f"Task {task_id!r} succeeded but returned no document ID", task=task)
 804        doc_id = int(task.related_document)
 805        logger.info("Task %r produced document_id=%d", task_id, doc_id)
 806        return await self.get(doc_id)
 807
 808    # -------------------------------------------------------------------------
 809    # Document bulk operations
 810    # -------------------------------------------------------------------------
 811
 812    async def _bulk_edit(self, document_ids: List[int], method: str, **parameters: Any) -> None:
 813        """Execute a bulk-edit operation on a list of documents.
 814
 815        Args:
 816            document_ids: List of document IDs to operate on.
 817            method: Bulk-edit method name (e.g. ``"add_tag"``, ``"delete"``).
 818            **parameters: Additional keyword arguments forwarded to the API.
 819        """
 820        payload = {"documents": document_ids, "method": method, "parameters": parameters}
 821        await self._core._session.post("/documents/bulk_edit/", json=payload, timeout=120.0)
 822
 823    async def bulk_add_tag(self, document_ids: List[int], tag: int | str) -> None:
 824        """Add a tag to multiple documents in a single request.
 825
 826        Args:
 827            document_ids: List of document IDs to tag.
 828            tag: Tag to add, as an ID or name.
 829        """
 830        logger.info("Bulk adding tag %r to %d documents", tag, len(document_ids))
 831        tag_id = await self._core._resolver.resolve("tags", tag)
 832        await self._bulk_edit(document_ids, "add_tag", tag=tag_id)
 833
 834    async def bulk_remove_tag(self, document_ids: List[int], tag: int | str) -> None:
 835        """Remove a tag from multiple documents in a single request.
 836
 837        Args:
 838            document_ids: List of document IDs to un-tag.
 839            tag: Tag to remove, as an ID or name.
 840        """
 841        logger.info("Bulk removing tag %r from %d documents", tag, len(document_ids))
 842        tag_id = await self._core._resolver.resolve("tags", tag)
 843        await self._bulk_edit(document_ids, "remove_tag", tag=tag_id)
 844
 845    async def bulk_modify_tags(
 846        self,
 847        document_ids: List[int],
 848        *,
 849        add_tags: List[int | str] | None = None,
 850        remove_tags: List[int | str] | None = None,
 851    ) -> None:
 852        """Add and/or remove tags on multiple documents atomically.
 853
 854        Args:
 855            document_ids: List of document IDs to modify.
 856            add_tags: Tags to add, as IDs or names.
 857            remove_tags: Tags to remove, as IDs or names.
 858        """
 859        logger.info("Bulk modifying tags on %d documents", len(document_ids))
 860        resolver = self._core._resolver
 861        add_ids = await resolver.resolve_list("tags", add_tags or [])
 862        remove_ids = await resolver.resolve_list("tags", remove_tags or [])
 863        await self._bulk_edit(document_ids, "modify_tags", add_tags=add_ids, remove_tags=remove_ids)
 864
 865    async def bulk_delete(self, document_ids: List[int]) -> None:
 866        """Permanently delete multiple documents in a single request.
 867
 868        Args:
 869            document_ids: List of document IDs to delete.
 870        """
 871        logger.info("Bulk deleting %d documents", len(document_ids))
 872        await self._bulk_edit(document_ids, "delete")
 873
 874    async def bulk_set_correspondent(
 875        self, document_ids: List[int], correspondent: int | str | None
 876    ) -> None:
 877        """Assign a correspondent to multiple documents in a single request.
 878
 879        Args:
 880            document_ids: List of document IDs to modify.
 881            correspondent: Correspondent to assign, as an ID or name.
 882                Pass ``None`` to clear.
 883        """
 884        logger.info(
 885            "Bulk setting correspondent %r on %d documents", correspondent, len(document_ids)
 886        )
 887        cor_id: int | None = None
 888        if correspondent is not None:
 889            cor_id = await self._core._resolver.resolve("correspondents", correspondent)
 890        await self._bulk_edit(document_ids, "set_correspondent", correspondent=cor_id)
 891
 892    async def bulk_set_document_type(
 893        self, document_ids: List[int], document_type: int | str | None
 894    ) -> None:
 895        """Assign a document type to multiple documents in a single request.
 896
 897        Args:
 898            document_ids: List of document IDs to modify.
 899            document_type: Document type to assign, as an ID or name.
 900                Pass ``None`` to clear.
 901        """
 902        logger.info(
 903            "Bulk setting document type %r on %d documents", document_type, len(document_ids)
 904        )
 905        dt_id: int | None = None
 906        if document_type is not None:
 907            dt_id = await self._core._resolver.resolve("document_types", document_type)
 908        await self._bulk_edit(document_ids, "set_document_type", document_type=dt_id)
 909
 910    async def bulk_set_storage_path(
 911        self, document_ids: List[int], storage_path: int | str | None
 912    ) -> None:
 913        """Assign a storage path to multiple documents in a single request.
 914
 915        Args:
 916            document_ids: List of document IDs to modify.
 917            storage_path: Storage path to assign, as an ID or name.
 918                Pass ``None`` to clear.
 919        """
 920        logger.info("Bulk setting storage path %r on %d documents", storage_path, len(document_ids))
 921        sp_id: int | None = None
 922        if storage_path is not None:
 923            sp_id = await self._core._resolver.resolve("storage_paths", storage_path)
 924        await self._bulk_edit(document_ids, "set_storage_path", storage_path=sp_id)
 925
 926    async def bulk_modify_custom_fields(
 927        self,
 928        document_ids: List[int],
 929        *,
 930        add_fields: List[dict[str, Any]] | None = None,
 931        remove_fields: List[int] | None = None,
 932    ) -> None:
 933        """Add and/or remove custom field values on multiple documents.
 934
 935        Args:
 936            document_ids: List of document IDs to modify.
 937            add_fields: Custom-field value dicts to add.
 938            remove_fields: Custom-field IDs whose values should be removed.
 939        """
 940        logger.info("Bulk modifying custom fields on %d documents", len(document_ids))
 941        await self._bulk_edit(
 942            document_ids,
 943            "modify_custom_fields",
 944            add_custom_fields=add_fields or [],
 945            remove_custom_fields=remove_fields or [],
 946        )
 947
 948    async def bulk_set_permissions(
 949        self,
 950        document_ids: List[int],
 951        *,
 952        set_permissions: SetPermissions | Unset = UNSET,
 953        owner: int | None | Unset = UNSET,
 954        merge: bool = False,
 955    ) -> None:
 956        """Set permissions and/or owner on multiple documents.
 957
 958        Args:
 959            document_ids: List of document IDs to modify.
 960            set_permissions: Explicit view/change permission sets.
 961                Omit (or pass :data:`~easypaperless.UNSET`) to leave unchanged.
 962            owner: Numeric user ID to assign as document owner.
 963                Pass ``None`` to clear the owner.
 964                Omit (or pass :data:`~easypaperless.UNSET`) to leave unchanged.
 965            merge: When ``True``, new permissions are merged with existing ones.
 966        """
 967        logger.info("Bulk setting permissions on %d documents", len(document_ids))
 968        params: dict[str, Any] = {"merge": merge}
 969        if not isinstance(set_permissions, Unset):
 970            params["set_permissions"] = set_permissions.model_dump()
 971        if not isinstance(owner, Unset):
 972            params["owner"] = owner
 973        await self._bulk_edit(document_ids, "set_permissions", **params)
 974
 975    async def bulk_download(
 976        self,
 977        document_ids: List[int],
 978        *,
 979        content: Literal["archive", "originals", "both"] = "archive",
 980        compression: Literal["none", "deflated", "bzip2", "lzma"] = "none",
 981        follow_formatting: bool = False,
 982    ) -> bytes:
 983        """Download multiple documents as a single ZIP archive.
 984
 985        Args:
 986            document_ids: List of document IDs to include in the ZIP.
 987            content: File variant to include.  One of ``"archive"`` *(default)*,
 988                ``"originals"``, or ``"both"``.
 989            compression: ZIP compression algorithm.  One of ``"none"`` *(default)*,
 990                ``"deflated"``, ``"bzip2"``, or ``"lzma"``.
 991            follow_formatting: When ``True``, filenames inside the ZIP follow
 992                the storage path formatting configured in paperless-ngx.
 993                Default: ``False``.
 994
 995        Returns:
 996            Raw bytes of the ZIP archive.
 997        """
 998        logger.info(
 999            "Bulk downloading %d documents (content=%s, compression=%s)",
1000            len(document_ids),
1001            content,
1002            compression,
1003        )
1004        payload: dict[str, Any] = {
1005            "documents": document_ids,
1006            "content": content,
1007            "compression": compression,
1008            "follow_formatting": follow_formatting,
1009        }
1010        resp = await self._core._session.post("/documents/bulk_download/", json=payload)
1011        return resp.content

Accessor for documents: client.documents.

DocumentsResource(core: easypaperless.client._ClientCore)
67    def __init__(self, core: _ClientCore) -> None:
68        self._core = core
69        self.notes = NotesResource(core)
notes
async def history( self, document_id: int, *, page: int | None = None, page_size: int | None = None) -> easypaperless.PagedResult[AuditLogEntry]:
 71    async def history(
 72        self,
 73        document_id: int,
 74        *,
 75        page: int | None = None,
 76        page_size: int | None = None,
 77    ) -> PagedResult[AuditLogEntry]:
 78        """Fetch the audit log for a document.
 79
 80        The paperless-ngx ``/api/documents/{id}/history/`` endpoint returns a
 81        plain JSON array rather than a paginated envelope.  This method wraps
 82        the response into a :class:`~easypaperless.models.paged_result.PagedResult`
 83        so callers always receive a consistent return type.
 84
 85        Args:
 86            document_id: Numeric ID of the document whose history to retrieve.
 87            page: Forwarded to the API as a query parameter when provided.
 88                Effect depends on the paperless-ngx version; the server may
 89                ignore this parameter.
 90            page_size: Forwarded to the API as a query parameter when provided.
 91
 92        Returns:
 93            :class:`~easypaperless.models.paged_result.PagedResult` of
 94            :class:`~easypaperless.models.documents.AuditLogEntry` objects,
 95            ordered by timestamp descending.
 96
 97        Raises:
 98            ~easypaperless.exceptions.NotFoundError: If no document exists
 99                with that ID.
100        """
101        logger.info("Fetching history for document id=%d", document_id)
102        path = f"/documents/{document_id}/history/"
103        params: dict[str, Any] = {}
104        if page is not None:
105            params["page"] = page
106        if page_size is not None:
107            params["page_size"] = page_size
108
109        resp = await self._core._session.get(path, params=params or None)
110        data = resp.json()
111
112        if isinstance(data, list):
113            entries = [AuditLogEntry.model_validate(item) for item in data]
114            entry_ids: list[int] = [e.id for e in entries]
115            return PagedResult(
116                count=len(entries),
117                next=None,
118                previous=None,
119                all=entry_ids if entry_ids else None,
120                results=entries,
121            )
122
123        # Forward-compatible: handle a paginated envelope if the API ever adds one.
124        items: list[Any] = list(data.get("results", []))
125        count: int = data.get("count", 0)
126        all_ids: list[int] | None = data.get("all")
127        return PagedResult(
128            count=count,
129            next=data.get("next"),
130            previous=data.get("previous"),
131            all=all_ids,
132            results=[AuditLogEntry.model_validate(item) for item in items],
133        )

Fetch the audit log for a document.

The paperless-ngx /api/documents/{id}/history/ endpoint returns a plain JSON array rather than a paginated envelope. This method wraps the response into a ~easypaperless.models.paged_result.PagedResult so callers always receive a consistent return type.

Arguments:
  • document_id: Numeric ID of the document whose history to retrieve.
  • page: Forwarded to the API as a query parameter when provided. Effect depends on the paperless-ngx version; the server may ignore this parameter.
  • page_size: Forwarded to the API as a query parameter when provided.
Returns:

~easypaperless.models.paged_result.PagedResult of ~easypaperless.models.documents.AuditLogEntry objects, ordered by timestamp descending.

Raises:
async def get( self, id: int, *, include_metadata: bool = False) -> easypaperless.Document:
151    async def get(self, id: int, *, include_metadata: bool = False) -> Document:
152        """Fetch a single document by its ID.
153
154        Args:
155            id: Numeric paperless-ngx document ID.
156            include_metadata: When ``True``, the extended file-level metadata
157                is fetched concurrently and attached to the document.
158                Default: ``False``.
159
160        Returns:
161            The :class:`~easypaperless.models.documents.Document` with the
162            given ID.
163
164        Raises:
165            ~easypaperless.exceptions.NotFoundError: If no document exists
166                with that ID.
167        """
168        logger.info("Getting document id=%d", id)
169        if include_metadata:
170            doc_resp, meta_resp = await asyncio.gather(
171                self._core._session.get(f"/documents/{id}/"),
172                self._core._session.get(f"/documents/{id}/metadata/"),
173            )
174            data = doc_resp.json()
175            data["metadata"] = meta_resp.json()
176        else:
177            resp = await self._core._session.get(f"/documents/{id}/")
178            data = resp.json()
179        return Document.model_validate(data)

Fetch a single document by its ID.

Arguments:
  • id: Numeric paperless-ngx document ID.
  • include_metadata: When True, the extended file-level metadata is fetched concurrently and attached to the document. Default: False.
Returns:

The ~easypaperless.models.documents.Document with the given ID.

Raises:
async def get_metadata(self, id: int) -> easypaperless.DocumentMetadata:
181    async def get_metadata(self, id: int) -> DocumentMetadata:
182        """Fetch the extended file-level metadata for a document.
183
184        Args:
185            id: Numeric paperless-ngx document ID.
186
187        Returns:
188            A :class:`~easypaperless.models.documents.DocumentMetadata` instance.
189
190        Raises:
191            ~easypaperless.exceptions.NotFoundError: If no document exists
192                with that ID.
193        """
194        logger.info("Getting metadata for document id=%d", id)
195        resp = await self._core._session.get(f"/documents/{id}/metadata/")
196        return DocumentMetadata.model_validate(resp.json())

Fetch the extended file-level metadata for a document.

Arguments:
  • id: Numeric paperless-ngx document ID.
Returns:

A ~easypaperless.models.documents.DocumentMetadata instance.

Raises:
async def list( self, *, search: str | None = None, search_mode: str = 'title_or_content', ids: Optional[List[int]] = None, tags: Optional[List[Union[str, int]]] = None, any_tags: Optional[List[Union[str, int]]] = None, exclude_tags: Optional[List[Union[str, int]]] = None, correspondent: int | str | None | easypaperless.Unset = UNSET, any_correspondent: Optional[List[Union[str, int]]] = None, exclude_correspondents: Optional[List[Union[str, int]]] = None, document_type: int | str | None | easypaperless.Unset = UNSET, document_type_name_contains: str | None = None, document_type_name_exact: str | None = None, any_document_type: Optional[List[Union[str, int]]] = None, exclude_document_types: Optional[List[Union[str, int]]] = None, storage_path: int | str | None | easypaperless.Unset = UNSET, any_storage_paths: Optional[List[Union[str, int]]] = None, exclude_storage_paths: Optional[List[Union[str, int]]] = None, owner: int | None | easypaperless.Unset = UNSET, exclude_owners: Optional[List[int]] = None, custom_fields: Optional[List[Union[str, int]]] = None, any_custom_fields: Optional[List[Union[str, int]]] = None, exclude_custom_fields: Optional[List[Union[str, int]]] = None, custom_field_query: Optional[List[Any]] = None, archive_serial_number: int | None | easypaperless.Unset = UNSET, archive_serial_number_from: int | None = None, archive_serial_number_till: int | None = None, created_after: datetime.date | str | None = None, created_before: datetime.date | str | None = None, added_after: datetime.date | datetime.datetime | str | None = None, added_from: datetime.date | datetime.datetime | str | None = None, added_before: datetime.date | datetime.datetime | str | None = None, added_until: datetime.date | datetime.datetime | str | None = None, modified_after: datetime.date | datetime.datetime | str | None = None, modified_from: datetime.date | datetime.datetime | str | None = None, modified_before: datetime.date | datetime.datetime | str | None = None, modified_until: datetime.date | datetime.datetime | str | None = None, checksum: str | None = None, page_size: int = 25, page: int | None = None, ordering: str | None = None, descending: bool = False, max_results: int | None = None, on_page: Callable[[int, int | None], None] | None = None) -> easypaperless.PagedResult[Document]:
198    async def list(
199        self,
200        *,
201        search: str | None = None,
202        search_mode: str = "title_or_content",
203        ids: List[int] | None = None,
204        tags: List[int | str] | None = None,
205        any_tags: List[int | str] | None = None,
206        exclude_tags: List[int | str] | None = None,
207        correspondent: int | str | None | Unset = UNSET,
208        any_correspondent: List[int | str] | None = None,
209        exclude_correspondents: List[int | str] | None = None,
210        document_type: int | str | None | Unset = UNSET,
211        document_type_name_contains: str | None = None,
212        document_type_name_exact: str | None = None,
213        any_document_type: List[int | str] | None = None,
214        exclude_document_types: List[int | str] | None = None,
215        storage_path: int | str | None | Unset = UNSET,
216        any_storage_paths: List[int | str] | None = None,
217        exclude_storage_paths: List[int | str] | None = None,
218        owner: int | None | Unset = UNSET,
219        exclude_owners: List[int] | None = None,
220        custom_fields: List[int | str] | None = None,
221        any_custom_fields: List[int | str] | None = None,
222        exclude_custom_fields: List[int | str] | None = None,
223        custom_field_query: List[Any] | None = None,
224        archive_serial_number: int | None | Unset = UNSET,
225        archive_serial_number_from: int | None = None,
226        archive_serial_number_till: int | None = None,
227        created_after: date | str | None = None,
228        created_before: date | str | None = None,
229        added_after: date | datetime | str | None = None,
230        added_from: date | datetime | str | None = None,
231        added_before: date | datetime | str | None = None,
232        added_until: date | datetime | str | None = None,
233        modified_after: date | datetime | str | None = None,
234        modified_from: date | datetime | str | None = None,
235        modified_before: date | datetime | str | None = None,
236        modified_until: date | datetime | str | None = None,
237        checksum: str | None = None,
238        page_size: int = 25,
239        page: int | None = None,
240        ordering: str | None = None,
241        descending: bool = False,
242        max_results: int | None = None,
243        on_page: Callable[[int, int | None], None] | None = None,
244    ) -> PagedResult[Document]:
245        """Return a filtered list of documents.
246
247        All tag, correspondent, document-type, storage-path, and custom-field
248        parameters accept either integer IDs or string names.
249
250        When ``page`` is ``None`` (the default), all pages are fetched
251        automatically and ``next`` / ``previous`` in the returned
252        :class:`~easypaperless.models.paged_result.PagedResult` are always
253        ``None`` — even if ``max_results`` truncates the final result set.
254        ``count`` always reflects the server total, not the truncated length.
255        When ``page`` is set to a specific integer, only that one page is
256        fetched and ``next`` / ``previous`` contain the raw API values.
257
258        Args:
259            search: Search string.  Behaviour depends on ``search_mode``.
260            search_mode: How ``search`` is applied.  One of:
261                ``"title_or_content"`` *(default)*, ``"title"``, ``"query"``,
262                ``"original_filename"``.
263            ids: Return only documents whose ID is in this list.
264            tags: Documents must have **all** of these tags (AND semantics).
265            any_tags: Documents must have **at least one** of these tags.
266            exclude_tags: Documents must have **none** of these tags.
267            correspondent: Filter to documents assigned to this correspondent.
268                Pass ``None`` to return only documents with no correspondent set.
269            any_correspondent: Filter to documents assigned to any of these.
270            exclude_correspondents: Exclude documents assigned to any of these.
271            document_type: Filter to documents of exactly this type.
272                Pass ``None`` to return only documents with no document type set.
273            document_type_name_contains: Case-insensitive substring filter on document type name.
274            document_type_name_exact: Case-insensitive exact match on document type name.
275            any_document_type: Filter to documents whose type is any of these.
276            exclude_document_types: Exclude documents whose type is any of these.
277            storage_path: Filter to documents assigned to this storage path.
278                Pass ``None`` to return only documents with no storage path set.
279            any_storage_paths: Filter to documents assigned to any of these paths.
280            exclude_storage_paths: Exclude documents assigned to any of these paths.
281            owner: Filter to documents owned by this user ID.
282                Pass ``None`` to return only documents with no owner set.
283            exclude_owners: Exclude documents owned by any of these user IDs.
284            custom_fields: Documents must have **all** of these custom fields set.
285            any_custom_fields: Documents must have **at least one** of these fields.
286            exclude_custom_fields: Documents must have **none** of these fields.
287            custom_field_query: Filter documents by custom field values using a nested
288                query structure. See the `paperless-ngx API docs
289                <https://docs.paperless-ngx.com/api/#filtering-by-custom-fields>`_ for
290                the query format.
291            archive_serial_number: Filter by exact archive serial number.
292                Pass ``None`` to return only documents with no ASN set.
293            archive_serial_number_from: Filter by ASN >= this value.
294            archive_serial_number_till: Filter by ASN <= this value.
295            created_after: Only documents created after this date.
296                String input must be ISO-8601: ``"YYYY-MM-DD"``.
297            created_before: Only documents created before this date.
298                String input must be ISO-8601: ``"YYYY-MM-DD"``.
299            added_after: Only documents added after this date/time.
300                String input must be ISO-8601: ``"YYYY-MM-DD"`` for date precision or
301                ``"YYYY-MM-DDTHH:MM:SS"`` for datetime precision.
302            added_from: Only documents added on or after this date/time.
303                String input must be ISO-8601: ``"YYYY-MM-DD"`` or ``"YYYY-MM-DDTHH:MM:SS"``.
304            added_before: Only documents added before this date/time.
305                String input must be ISO-8601: ``"YYYY-MM-DD"`` or ``"YYYY-MM-DDTHH:MM:SS"``.
306            added_until: Only documents added on or before this date/time.
307                String input must be ISO-8601: ``"YYYY-MM-DD"`` or ``"YYYY-MM-DDTHH:MM:SS"``.
308            modified_after: Only documents modified after this date/time.
309                String input must be ISO-8601: ``"YYYY-MM-DD"`` or ``"YYYY-MM-DDTHH:MM:SS"``.
310            modified_from: Only documents modified on or after this date/time.
311                String input must be ISO-8601: ``"YYYY-MM-DD"`` or ``"YYYY-MM-DDTHH:MM:SS"``.
312            modified_before: Only documents modified before this date/time.
313                String input must be ISO-8601: ``"YYYY-MM-DD"`` or ``"YYYY-MM-DDTHH:MM:SS"``.
314            modified_until: Only documents modified on or before this date/time.
315                String input must be ISO-8601: ``"YYYY-MM-DD"`` or ``"YYYY-MM-DDTHH:MM:SS"``.
316            checksum: MD5 checksum (hex) of the original uploaded file, matched
317                exactly but case-insensitively (sent as ``checksum__iexact``).
318                Documents in the trash are **not** found, yet paperless-ngx
319                still rejects a re-upload of the same file as a duplicate.  To
320                detect that case, catch the
321                :exc:`~easypaperless.exceptions.UploadError` of
322                ``upload(wait=True)`` (or of ``tasks.wait()``): ``err.task.result``
323                contains ``": It is a duplicate of "`` and ends in
324                ``"Note: existing document is in the trash."``, and
325                ``err.task.related_document`` is ``None`` (for a live duplicate
326                it is the existing document's ID).  ``client.trash.list()``
327                shows the trashed document; ``client.trash.restore()`` brings
328                it back.
329            page_size: Number of results per API page.  Default: ``25``.
330            page: Return only this specific page (1-based).
331            ordering: Field name to sort by.
332            descending: When ``True``, reverses the sort direction.
333            max_results: Stop after collecting this many documents.
334            on_page: Callback invoked after each page fetch.
335
336        Returns:
337            :class:`~easypaperless.models.paged_result.PagedResult` of
338            :class:`~easypaperless.models.documents.Document` objects.
339        """
340        logger.info("Listing documents")
341        resolver = self._core._resolver
342        params: dict[str, Any] = {"page_size": page_size}
343
344        if search is not None:
345            api_param = _SEARCH_MODE_MAP.get(search_mode, "search")
346            params[api_param] = search
347
348        if ids is not None:
349            params["id__in"] = ",".join(str(i) for i in ids)
350
351        if tags is not None:
352            resolved = await resolver.resolve_list("tags", tags)
353            params["tags__id__all"] = ",".join(str(t) for t in resolved)
354
355        if any_tags is not None:
356            resolved = await resolver.resolve_list("tags", any_tags)
357            params["tags__id__in"] = ",".join(str(t) for t in resolved)
358
359        if exclude_tags is not None:
360            resolved = await resolver.resolve_list("tags", exclude_tags)
361            params["tags__id__none"] = ",".join(str(t) for t in resolved)
362
363        if any_correspondent is not None:
364            resolved = await resolver.resolve_list("correspondents", any_correspondent)
365            params["correspondent__id__in"] = ",".join(str(c) for c in resolved)
366        elif not isinstance(correspondent, Unset):
367            if correspondent is None:
368                params["correspondent__isnull"] = "true"
369            else:
370                resolved_id = await resolver.resolve("correspondents", correspondent)
371                params["correspondent__id"] = resolved_id
372
373        if exclude_correspondents is not None:
374            resolved = await resolver.resolve_list("correspondents", exclude_correspondents)
375            params["correspondent__id__none"] = ",".join(str(c) for c in resolved)
376
377        if document_type_name_contains is not None:
378            params["document_type__name__icontains"] = document_type_name_contains
379        if document_type_name_exact is not None:
380            params["document_type__name__iexact"] = document_type_name_exact
381
382        if any_document_type is not None:
383            resolved = await resolver.resolve_list("document_types", any_document_type)
384            params["document_type__id__in"] = ",".join(str(d) for d in resolved)
385        elif not isinstance(document_type, Unset):
386            if document_type is None:
387                params["document_type__isnull"] = "true"
388            else:
389                resolved_id = await resolver.resolve("document_types", document_type)
390                params["document_type__id"] = resolved_id
391
392        if exclude_document_types is not None:
393            resolved = await resolver.resolve_list("document_types", exclude_document_types)
394            params["document_type__id__none"] = ",".join(str(d) for d in resolved)
395
396        if any_storage_paths is not None:
397            resolved = await resolver.resolve_list("storage_paths", any_storage_paths)
398            params["storage_path__id__in"] = ",".join(str(s) for s in resolved)
399        elif not isinstance(storage_path, Unset):
400            if storage_path is None:
401                params["storage_path__isnull"] = "true"
402            else:
403                resolved_id = await resolver.resolve("storage_paths", storage_path)
404                params["storage_path__id"] = resolved_id
405
406        if exclude_storage_paths is not None:
407            resolved = await resolver.resolve_list("storage_paths", exclude_storage_paths)
408            params["storage_path__id__none"] = ",".join(str(s) for s in resolved)
409
410        if not isinstance(owner, Unset):
411            if owner is None:
412                params["owner__isnull"] = "true"
413            else:
414                params["owner__id"] = owner
415
416        if exclude_owners is not None:
417            params["owner__id__none"] = ",".join(str(o) for o in exclude_owners)
418
419        if custom_fields is not None:
420            resolved = await resolver.resolve_list("custom_fields", custom_fields)
421            params["custom_fields__id__all"] = ",".join(str(f) for f in resolved)
422
423        if any_custom_fields is not None:
424            resolved = await resolver.resolve_list("custom_fields", any_custom_fields)
425            params["custom_fields__id__in"] = ",".join(str(f) for f in resolved)
426
427        if exclude_custom_fields is not None:
428            resolved = await resolver.resolve_list("custom_fields", exclude_custom_fields)
429            params["custom_fields__id__none"] = ",".join(str(f) for f in resolved)
430
431        if custom_field_query is not None:
432            params["custom_field_query"] = json.dumps(custom_field_query)
433
434        if not isinstance(archive_serial_number, Unset):
435            if archive_serial_number is None:
436                params["archive_serial_number__isnull"] = "true"
437            else:
438                params["archive_serial_number"] = archive_serial_number
439
440        if archive_serial_number_from is not None:
441            params["archive_serial_number__gte"] = archive_serial_number_from
442
443        if archive_serial_number_till is not None:
444            params["archive_serial_number__lte"] = archive_serial_number_till
445
446        if created_after is not None:
447            params["created__date__gt"] = self._format_date_value(created_after)
448
449        if created_before is not None:
450            params["created__date__lt"] = self._format_date_value(created_before)
451
452        if added_after is not None:
453            key = "added__gt" if self._is_datetime(added_after) else "added__date__gt"
454            params[key] = self._format_date_value(added_after)
455
456        if added_from is not None:
457            key = "added__gte" if self._is_datetime(added_from) else "added__date__gte"
458            params[key] = self._format_date_value(added_from)
459
460        if added_before is not None:
461            key = "added__lt" if self._is_datetime(added_before) else "added__date__lt"
462            params[key] = self._format_date_value(added_before)
463
464        if added_until is not None:
465            key = "added__lte" if self._is_datetime(added_until) else "added__date__lte"
466            params[key] = self._format_date_value(added_until)
467
468        if modified_after is not None:
469            key = "modified__gt" if self._is_datetime(modified_after) else "modified__date__gt"
470            params[key] = self._format_date_value(modified_after)
471
472        if modified_from is not None:
473            key = "modified__gte" if self._is_datetime(modified_from) else "modified__date__gte"
474            params[key] = self._format_date_value(modified_from)
475
476        if modified_before is not None:
477            key = "modified__lt" if self._is_datetime(modified_before) else "modified__date__lt"
478            params[key] = self._format_date_value(modified_before)
479
480        if modified_until is not None:
481            key = "modified__lte" if self._is_datetime(modified_until) else "modified__date__lte"
482            params[key] = self._format_date_value(modified_until)
483
484        if checksum is not None:
485            params["checksum__iexact"] = checksum
486
487        if ordering is not None:
488            params["ordering"] = f"-{ordering}" if descending else ordering
489
490        if page is not None:
491            params["page"] = page
492            raw = await self._core._session.get_page("/documents/", params=params)
493            items = raw.items
494            if max_results is not None:
495                items = items[:max_results]
496            return PagedResult(
497                count=raw.count,
498                next=raw.next,
499                previous=raw.previous,
500                all=raw.all_ids,
501                results=[Document.model_validate(item) for item in items],
502            )
503
504        raw = await self._core._session.get_all_pages_paged(
505            "/documents/", params, max_results=max_results, on_page=on_page
506        )
507        return PagedResult(
508            count=raw.count,
509            next=raw.next,
510            previous=raw.previous,
511            all=raw.all_ids,
512            results=[Document.model_validate(item) for item in raw.items],
513        )

Return a filtered list of documents.

All tag, correspondent, document-type, storage-path, and custom-field parameters accept either integer IDs or string names.

When page is None (the default), all pages are fetched automatically and next / previous in the returned ~easypaperless.models.paged_result.PagedResult are always None — even if max_results truncates the final result set. count always reflects the server total, not the truncated length. When page is set to a specific integer, only that one page is fetched and next / previous contain the raw API values.

Arguments:
  • search: Search string. Behaviour depends on search_mode.
  • search_mode: How search is applied. One of: "title_or_content" (default), "title", "query", "original_filename".
  • ids: Return only documents whose ID is in this list.
  • tags: Documents must have all of these tags (AND semantics).
  • any_tags: Documents must have at least one of these tags.
  • exclude_tags: Documents must have none of these tags.
  • correspondent: Filter to documents assigned to this correspondent. Pass None to return only documents with no correspondent set.
  • any_correspondent: Filter to documents assigned to any of these.
  • exclude_correspondents: Exclude documents assigned to any of these.
  • document_type: Filter to documents of exactly this type. Pass None to return only documents with no document type set.
  • document_type_name_contains: Case-insensitive substring filter on document type name.
  • document_type_name_exact: Case-insensitive exact match on document type name.
  • any_document_type: Filter to documents whose type is any of these.
  • exclude_document_types: Exclude documents whose type is any of these.
  • storage_path: Filter to documents assigned to this storage path. Pass None to return only documents with no storage path set.
  • any_storage_paths: Filter to documents assigned to any of these paths.
  • exclude_storage_paths: Exclude documents assigned to any of these paths.
  • owner: Filter to documents owned by this user ID. Pass None to return only documents with no owner set.
  • exclude_owners: Exclude documents owned by any of these user IDs.
  • custom_fields: Documents must have all of these custom fields set.
  • any_custom_fields: Documents must have at least one of these fields.
  • exclude_custom_fields: Documents must have none of these fields.
  • custom_field_query: Filter documents by custom field values using a nested query structure. See the paperless-ngx API docs for the query format.
  • archive_serial_number: Filter by exact archive serial number. Pass None to return only documents with no ASN set.
  • archive_serial_number_from: Filter by ASN >= this value.
  • archive_serial_number_till: Filter by ASN <= this value.
  • created_after: Only documents created after this date. String input must be ISO-8601: "YYYY-MM-DD".
  • created_before: Only documents created before this date. String input must be ISO-8601: "YYYY-MM-DD".
  • added_after: Only documents added after this date/time. String input must be ISO-8601: "YYYY-MM-DD" for date precision or "YYYY-MM-DDTHH:MM:SS" for datetime precision.
  • added_from: Only documents added on or after this date/time. String input must be ISO-8601: "YYYY-MM-DD" or "YYYY-MM-DDTHH:MM:SS".
  • added_before: Only documents added before this date/time. String input must be ISO-8601: "YYYY-MM-DD" or "YYYY-MM-DDTHH:MM:SS".
  • added_until: Only documents added on or before this date/time. String input must be ISO-8601: "YYYY-MM-DD" or "YYYY-MM-DDTHH:MM:SS".
  • modified_after: Only documents modified after this date/time. String input must be ISO-8601: "YYYY-MM-DD" or "YYYY-MM-DDTHH:MM:SS".
  • modified_from: Only documents modified on or after this date/time. String input must be ISO-8601: "YYYY-MM-DD" or "YYYY-MM-DDTHH:MM:SS".
  • modified_before: Only documents modified before this date/time. String input must be ISO-8601: "YYYY-MM-DD" or "YYYY-MM-DDTHH:MM:SS".
  • modified_until: Only documents modified on or before this date/time. String input must be ISO-8601: "YYYY-MM-DD" or "YYYY-MM-DDTHH:MM:SS".
  • checksum: MD5 checksum (hex) of the original uploaded file, matched exactly but case-insensitively (sent as checksum__iexact). Documents in the trash are not found, yet paperless-ngx still rejects a re-upload of the same file as a duplicate. To detect that case, catch the ~easypaperless.exceptions.UploadError of upload(wait=True) (or of tasks.wait()): err.task.result contains ": It is a duplicate of " and ends in "Note: existing document is in the trash.", and err.task.related_document is None (for a live duplicate it is the existing document's ID). client.trash.list() shows the trashed document; client.trash.restore() brings it back.
  • page_size: Number of results per API page. Default: 25.
  • page: Return only this specific page (1-based).
  • ordering: Field name to sort by.
  • descending: When True, reverses the sort direction.
  • max_results: Stop after collecting this many documents.
  • on_page: Callback invoked after each page fetch.
Returns:

~easypaperless.models.paged_result.PagedResult of ~easypaperless.models.documents.Document objects.

async def update( self, id: int, *, title: str | easypaperless.Unset = UNSET, content: str | easypaperless.Unset = UNSET, created: datetime.date | str | None | easypaperless.Unset = UNSET, correspondent: int | str | None | easypaperless.Unset = UNSET, document_type: int | str | None | easypaperless.Unset = UNSET, storage_path: int | str | None | easypaperless.Unset = UNSET, tags: Union[List[Union[str, int]], NoneType, easypaperless.Unset] = UNSET, archive_serial_number: int | None | easypaperless.Unset = UNSET, custom_fields: Union[List[dict[str, Any]], NoneType, easypaperless.Unset] = UNSET, owner: int | None | easypaperless.Unset = UNSET, set_permissions: easypaperless.SetPermissions | None | easypaperless.Unset = UNSET, remove_inbox_tags: bool | None | easypaperless.Unset = UNSET) -> easypaperless.Document:
515    async def update(
516        self,
517        id: int,
518        *,
519        title: str | Unset = UNSET,
520        content: str | Unset = UNSET,
521        created: date | str | None | Unset = UNSET,
522        correspondent: int | str | None | Unset = UNSET,
523        document_type: int | str | None | Unset = UNSET,
524        storage_path: int | str | None | Unset = UNSET,
525        tags: List[int | str] | None | Unset = UNSET,
526        archive_serial_number: int | None | Unset = UNSET,
527        custom_fields: List[dict[str, Any]] | None | Unset = UNSET,
528        owner: int | None | Unset = UNSET,
529        set_permissions: SetPermissions | None | Unset = UNSET,
530        remove_inbox_tags: bool | None | Unset = UNSET,
531    ) -> Document:
532        """Partially update a document (PATCH semantics).
533
534        Args:
535            id: Numeric ID of the document to update.
536            title: New document title.
537            content: OCR text content of the document.
538            created: Creation date as an ISO-8601 string (``"YYYY-MM-DD"``) or a
539                :class:`~datetime.date` object.
540            correspondent: Correspondent to assign, as an ID or name.
541                Pass ``None`` to clear the correspondent.
542            document_type: Document type to assign, as an ID or name.
543                Pass ``None`` to clear the document type.
544            storage_path: Storage path to assign, as an ID or name.
545                Pass ``None`` to clear the storage path.
546            tags: Full replacement list of tags (IDs or names).
547            archive_serial_number: Archive serial number to assign.
548                Pass ``None`` to clear the archive serial number.
549            custom_fields: List of ``{"field": <field_id>, "value": ...}`` dicts.
550            owner: Numeric user ID to assign as document owner.
551                Pass ``None`` to clear the owner.
552            set_permissions: Explicit view/change permission sets.
553                Pass ``None`` to clear all permissions (overwrite with empty).
554                Omit (or pass :data:`~easypaperless.UNSET`) to leave unchanged.
555                The given sets replace the document's current view and change
556                users and groups.  Together with ``owner`` everything goes out
557                in one PATCH, which paperless-ngx applies as a whole.
558            remove_inbox_tags: When ``True``, removes all inbox tags from the document.
559
560        Returns:
561            The updated :class:`~easypaperless.models.documents.Document`.
562        """
563        logger.info("Updating document id=%d", id)
564        resolver = self._core._resolver
565        payload: dict[str, Any] = {}
566
567        if not isinstance(title, Unset):
568            payload["title"] = title
569        if not isinstance(content, Unset):
570            payload["content"] = content
571        if not isinstance(created, Unset):
572            payload["created"] = self._format_date_value(created) if created is not None else None
573        if not isinstance(correspondent, Unset):
574            payload["correspondent"] = (
575                None
576                if correspondent is None
577                else await resolver.resolve("correspondents", correspondent)
578            )
579        if not isinstance(document_type, Unset):
580            payload["document_type"] = (
581                None
582                if document_type is None
583                else await resolver.resolve("document_types", document_type)
584            )
585        if not isinstance(storage_path, Unset):
586            payload["storage_path"] = (
587                None
588                if storage_path is None
589                else await resolver.resolve("storage_paths", storage_path)
590            )
591        if not isinstance(tags, Unset):
592            payload["tags"] = await resolver.resolve_list("tags", tags or [])
593        if not isinstance(archive_serial_number, Unset):
594            payload["archive_serial_number"] = archive_serial_number
595        if not isinstance(custom_fields, Unset):
596            payload["custom_fields"] = custom_fields
597        if not isinstance(owner, Unset):
598            payload["owner"] = owner
599        if not isinstance(set_permissions, Unset):
600            payload["set_permissions"] = (
601                SetPermissions().model_dump()
602                if set_permissions is None
603                else set_permissions.model_dump()
604            )
605        if not isinstance(remove_inbox_tags, Unset):
606            payload["remove_inbox_tags"] = remove_inbox_tags
607
608        resp = await self._core._session.patch(f"/documents/{id}/", json=payload)
609        return Document.model_validate(resp.json())

Partially update a document (PATCH semantics).

Arguments:
  • id: Numeric ID of the document to update.
  • title: New document title.
  • content: OCR text content of the document.
  • created: Creation date as an ISO-8601 string ("YYYY-MM-DD") or a ~datetime.date object.
  • correspondent: Correspondent to assign, as an ID or name. Pass None to clear the correspondent.
  • document_type: Document type to assign, as an ID or name. Pass None to clear the document type.
  • storage_path: Storage path to assign, as an ID or name. Pass None to clear the storage path.
  • tags: Full replacement list of tags (IDs or names).
  • archive_serial_number: Archive serial number to assign. Pass None to clear the archive serial number.
  • custom_fields: List of {"field": <field_id>, "value": ...} dicts.
  • owner: Numeric user ID to assign as document owner. Pass None to clear the owner.
  • set_permissions: Explicit view/change permission sets. Pass None to clear all permissions (overwrite with empty). Omit (or pass ~easypaperless.UNSET) to leave unchanged. The given sets replace the document's current view and change users and groups. Together with owner everything goes out in one PATCH, which paperless-ngx applies as a whole.
  • remove_inbox_tags: When True, removes all inbox tags from the document.
Returns:

The updated ~easypaperless.models.documents.Document.

async def delete(self, id: int) -> None:
611    async def delete(self, id: int) -> None:
612        """Permanently delete a document.
613
614        Args:
615            id: Numeric ID of the document to delete.
616
617        Raises:
618            ~easypaperless.exceptions.NotFoundError: If no document exists
619                with that ID.
620        """
621        logger.info("Deleting document id=%d", id)
622        await self._core._session.delete(f"/documents/{id}/")

Permanently delete a document.

Arguments:
  • id: Numeric ID of the document to delete.
Raises:
async def download(self, id: int, *, original: bool = False) -> bytes:
624    async def download(self, id: int, *, original: bool = False) -> bytes:
625        """Download the binary content of a document.
626
627        Args:
628            id: Numeric ID of the document to download.
629            original: If ``False`` *(default)*, returns the archived PDF
630                (``GET /documents/{id}/download/``).
631                If ``True``, returns the original uploaded file
632                (``GET /documents/{id}/download/?original=true``).
633
634        Returns:
635            Raw file bytes.
636        """
637        logger.info("Downloading document id=%d (original=%s)", id, original)
638        path = f"/documents/{id}/download/"
639        if original:
640            path += "?original=true"
641        resp = await self._core._session.get_download(path)
642        return _binary_content(resp, "Download")

Download the binary content of a document.

Arguments:
  • id: Numeric ID of the document to download.
  • original: If False (default), returns the archived PDF (GET /documents/{id}/download/). If True, returns the original uploaded file (GET /documents/{id}/download/?original=true).
Returns:

Raw file bytes.

async def thumbnail(self, id: int) -> bytes:
644    async def thumbnail(self, id: int) -> bytes:
645        """Fetch the thumbnail image of a document.
646
647        Args:
648            id: Numeric ID of the document whose thumbnail to retrieve.
649
650        Returns:
651            Raw binary content of the thumbnail image.
652
653        Raises:
654            ~easypaperless.exceptions.NotFoundError: If no document exists
655                with that ID.
656            ~easypaperless.exceptions.ServerResponseError: If the server returns an
657                HTML page (e.g. an auth redirect) instead of the image.
658        """
659        logger.info("Fetching thumbnail for document id=%d", id)
660        resp = await self._core._session.get_download(f"/documents/{id}/thumb/")
661        return _binary_content(resp, "Thumbnail")

Fetch the thumbnail image of a document.

Arguments:
  • id: Numeric ID of the document whose thumbnail to retrieve.
Returns:

Raw binary content of the thumbnail image.

Raises:
async def upload( self, file: str | pathlib._local.Path | bytes, *, filename: str | None = None, content_type: str | None = None, request_timeout: float | None = None, title: str | easypaperless.Unset = UNSET, created: datetime.date | str | None = None, correspondent: int | str | None | easypaperless.Unset = UNSET, document_type: int | str | None | easypaperless.Unset = UNSET, storage_path: int | str | None | easypaperless.Unset = UNSET, tags: Optional[List[Union[str, int]]] = None, archive_serial_number: int | None | easypaperless.Unset = UNSET, custom_fields: Optional[List[dict[str, Any]]] = None, wait: bool = False, poll_interval: float | None = None, poll_timeout: float | None = None) -> str | easypaperless.Document:
663    async def upload(
664        self,
665        file: str | Path | bytes,
666        *,
667        filename: str | None = None,
668        content_type: str | None = None,
669        request_timeout: float | None = None,
670        title: str | Unset = UNSET,
671        created: date | str | None = None,
672        correspondent: int | str | None | Unset = UNSET,
673        document_type: int | str | None | Unset = UNSET,
674        storage_path: int | str | None | Unset = UNSET,
675        tags: List[int | str] | None = None,
676        archive_serial_number: int | None | Unset = UNSET,
677        custom_fields: List[dict[str, Any]] | None = None,
678        wait: bool = False,
679        poll_interval: float | None = None,
680        poll_timeout: float | None = None,
681    ) -> str | Document:
682        """Upload a document to paperless-ngx.
683
684        The upload request is never retried automatically, whatever the
685        client's ``retry_attempts`` / ``tenacity_retrying`` settings: if the
686        connection fails after paperless-ngx has accepted the file, a retry
687        would create a duplicate.  A failed upload raises (e.g.
688        :exc:`~easypaperless.exceptions.TransportTimeoutError`) so you can
689        decide whether to check for the document and upload again.
690
691        Args:
692            file: Path to the file to upload (``str`` or :class:`~pathlib.Path`),
693                or the file content as ``bytes``.  Bytes are sent directly; no
694                temporary file is written.
695            filename: File name sent to paperless-ngx.  Required when *file* is
696                ``bytes`` (omitting it raises
697                :exc:`~easypaperless.exceptions.ValidationError` before any
698                request).  For a path, overrides the name taken from the path.
699            content_type: MIME type of the file part, sent as given (e.g.
700                ``"application/pdf"``).  When omitted, it is guessed from the
701                file name as before.  paperless-ngx detects the file type from
702                the bytes and does not rely on this value to accept the file.
703            request_timeout: HTTP timeout in seconds for the upload request
704                only, overriding the client's ``timeout`` for this call.  Does
705                not affect task polling (see ``poll_timeout``).  When omitted,
706                the client's ``timeout`` applies.
707            title: Title to assign to the document.
708            created: Creation date as an ISO-8601 string (``"YYYY-MM-DD"``) or a
709                :class:`~datetime.date` object.
710            correspondent: Correspondent to assign, as an ID or name.
711            document_type: Document type to assign, as an ID or name.
712            storage_path: Storage path to assign, as an ID or name.
713            tags: Tags to assign, as IDs or names.
714            archive_serial_number: Archive serial number to assign.
715            custom_fields: List of ``{"field": <field_id>, "value": ...}`` dicts.
716            wait: If ``False`` *(default)*, returns immediately with the task ID.
717                If ``True``, polls until processing completes.
718            poll_interval: Seconds between task-status checks while waiting for
719                processing to complete (requires ``wait=True``). Overrides the
720                client-level default. When omitted, falls back to the client-level
721                ``poll_interval`` (``2.0`` s unless changed at construction).
722            poll_timeout: Maximum seconds to wait before raising
723                :exc:`~easypaperless.exceptions.TaskTimeoutError` (requires
724                ``wait=True``). Overrides the client-level default. When omitted,
725                falls back to the client-level ``poll_timeout`` (``60.0`` s unless
726                changed at construction).
727
728        Returns:
729            The Celery task ID string when ``wait=False``, or the fully
730            processed :class:`~easypaperless.models.documents.Document`
731            when ``wait=True``.
732
733        Raises:
734            ~easypaperless.exceptions.ValidationError: If *file* is ``bytes``
735                and no *filename* is given.
736            ~easypaperless.exceptions.BadRequestError: If paperless-ngx rejects
737                the file before processing starts, e.g. an unsupported file
738                type or an empty file (``err.field_errors["document"]``).
739            ~easypaperless.exceptions.UploadError: If processing fails;
740                ``err.task`` holds the task with paperless-ngx's ``result``
741                unaltered.  For a duplicate, ``err.task.result`` contains
742                ``": It is a duplicate of "`` and ``err.task.related_document``
743                is the existing document's ID (``None`` if that document is
744                in the trash).
745            ~easypaperless.exceptions.TaskTimeoutError: If timeout is exceeded;
746                resume with ``client.tasks.wait(err.task_id)``.
747        """
748        resolver = self._core._resolver
749        if isinstance(file, bytes):
750            if not filename:
751                raise ValidationError("filename is required when uploading from bytes")
752            file_bytes = file
753            upload_name = filename
754        else:
755            file_path = Path(file)
756            file_bytes = file_path.read_bytes()
757            upload_name = filename if filename is not None else file_path.name
758        logger.info("Uploading %r (%d bytes)", upload_name, len(file_bytes))
759
760        data: dict[str, Any] = {}
761        if not isinstance(title, Unset):
762            data["title"] = title
763        if created is not None:
764            data["created"] = self._format_date_value(created)
765        if not isinstance(correspondent, Unset) and correspondent is not None:
766            data["correspondent"] = await resolver.resolve("correspondents", correspondent)
767        if not isinstance(document_type, Unset) and document_type is not None:
768            data["document_type"] = await resolver.resolve("document_types", document_type)
769        if not isinstance(storage_path, Unset) and storage_path is not None:
770            data["storage_path"] = await resolver.resolve("storage_paths", storage_path)
771        if tags is not None:
772            resolved = await resolver.resolve_list("tags", tags)
773            data["tags"] = resolved
774        if not isinstance(archive_serial_number, Unset) and archive_serial_number is not None:
775            data["archive_serial_number"] = archive_serial_number
776        if custom_fields is not None:
777            data["custom_fields"] = json.dumps(custom_fields)
778
779        # Without content_type httpx derives it from the file name (previous behaviour).
780        document_part: tuple[str, bytes] | tuple[str, bytes, str] = (
781            (upload_name, file_bytes)
782            if content_type is None
783            else (upload_name, file_bytes, content_type)
784        )
785        files = {"document": document_part}
786        resp = await self._core._session.post(
787            "/documents/post_document/",
788            data=data,
789            files=files,
790            timeout=request_timeout,
791            retry=False,  # a retry after a lost response would upload a duplicate
792        )
793        task_id: str = resp.text.strip('"')
794        logger.debug("Upload accepted, task_id=%r", task_id)
795
796        if not wait:
797            return task_id
798
799        task = await self._core.tasks.wait(
800            task_id, poll_interval=poll_interval, poll_timeout=poll_timeout
801        )
802        if task.related_document is None:
803            raise UploadError(f"Task {task_id!r} succeeded but returned no document ID", task=task)
804        doc_id = int(task.related_document)
805        logger.info("Task %r produced document_id=%d", task_id, doc_id)
806        return await self.get(doc_id)

Upload a document to paperless-ngx.

The upload request is never retried automatically, whatever the client's retry_attempts / tenacity_retrying settings: if the connection fails after paperless-ngx has accepted the file, a retry would create a duplicate. A failed upload raises (e.g. ~easypaperless.exceptions.TransportTimeoutError) so you can decide whether to check for the document and upload again.

Arguments:
  • file: Path to the file to upload (str or ~pathlib.Path), or the file content as bytes. Bytes are sent directly; no temporary file is written.
  • filename: File name sent to paperless-ngx. Required when file is bytes (omitting it raises ~easypaperless.exceptions.ValidationError before any request). For a path, overrides the name taken from the path.
  • content_type: MIME type of the file part, sent as given (e.g. "application/pdf"). When omitted, it is guessed from the file name as before. paperless-ngx detects the file type from the bytes and does not rely on this value to accept the file.
  • request_timeout: HTTP timeout in seconds for the upload request only, overriding the client's timeout for this call. Does not affect task polling (see poll_timeout). When omitted, the client's timeout applies.
  • title: Title to assign to the document.
  • created: Creation date as an ISO-8601 string ("YYYY-MM-DD") or a ~datetime.date object.
  • correspondent: Correspondent to assign, as an ID or name.
  • document_type: Document type to assign, as an ID or name.
  • storage_path: Storage path to assign, as an ID or name.
  • tags: Tags to assign, as IDs or names.
  • archive_serial_number: Archive serial number to assign.
  • custom_fields: List of {"field": <field_id>, "value": ...} dicts.
  • wait: If False (default), returns immediately with the task ID. If True, polls until processing completes.
  • poll_interval: Seconds between task-status checks while waiting for processing to complete (requires wait=True). Overrides the client-level default. When omitted, falls back to the client-level poll_interval (2.0 s unless changed at construction).
  • poll_timeout: Maximum seconds to wait before raising ~easypaperless.exceptions.TaskTimeoutError (requires wait=True). Overrides the client-level default. When omitted, falls back to the client-level poll_timeout (60.0 s unless changed at construction).
Returns:

The Celery task ID string when wait=False, or the fully processed ~easypaperless.models.documents.Document when wait=True.

Raises:
async def bulk_add_tag(self, document_ids: List[int], tag: int | str) -> None:
823    async def bulk_add_tag(self, document_ids: List[int], tag: int | str) -> None:
824        """Add a tag to multiple documents in a single request.
825
826        Args:
827            document_ids: List of document IDs to tag.
828            tag: Tag to add, as an ID or name.
829        """
830        logger.info("Bulk adding tag %r to %d documents", tag, len(document_ids))
831        tag_id = await self._core._resolver.resolve("tags", tag)
832        await self._bulk_edit(document_ids, "add_tag", tag=tag_id)

Add a tag to multiple documents in a single request.

Arguments:
  • document_ids: List of document IDs to tag.
  • tag: Tag to add, as an ID or name.
async def bulk_remove_tag(self, document_ids: List[int], tag: int | str) -> None:
834    async def bulk_remove_tag(self, document_ids: List[int], tag: int | str) -> None:
835        """Remove a tag from multiple documents in a single request.
836
837        Args:
838            document_ids: List of document IDs to un-tag.
839            tag: Tag to remove, as an ID or name.
840        """
841        logger.info("Bulk removing tag %r from %d documents", tag, len(document_ids))
842        tag_id = await self._core._resolver.resolve("tags", tag)
843        await self._bulk_edit(document_ids, "remove_tag", tag=tag_id)

Remove a tag from multiple documents in a single request.

Arguments:
  • document_ids: List of document IDs to un-tag.
  • tag: Tag to remove, as an ID or name.
async def bulk_modify_tags( self, document_ids: List[int], *, add_tags: Optional[List[Union[str, int]]] = None, remove_tags: Optional[List[Union[str, int]]] = None) -> None:
845    async def bulk_modify_tags(
846        self,
847        document_ids: List[int],
848        *,
849        add_tags: List[int | str] | None = None,
850        remove_tags: List[int | str] | None = None,
851    ) -> None:
852        """Add and/or remove tags on multiple documents atomically.
853
854        Args:
855            document_ids: List of document IDs to modify.
856            add_tags: Tags to add, as IDs or names.
857            remove_tags: Tags to remove, as IDs or names.
858        """
859        logger.info("Bulk modifying tags on %d documents", len(document_ids))
860        resolver = self._core._resolver
861        add_ids = await resolver.resolve_list("tags", add_tags or [])
862        remove_ids = await resolver.resolve_list("tags", remove_tags or [])
863        await self._bulk_edit(document_ids, "modify_tags", add_tags=add_ids, remove_tags=remove_ids)

Add and/or remove tags on multiple documents atomically.

Arguments:
  • document_ids: List of document IDs to modify.
  • add_tags: Tags to add, as IDs or names.
  • remove_tags: Tags to remove, as IDs or names.
async def bulk_delete(self, document_ids: List[int]) -> None:
865    async def bulk_delete(self, document_ids: List[int]) -> None:
866        """Permanently delete multiple documents in a single request.
867
868        Args:
869            document_ids: List of document IDs to delete.
870        """
871        logger.info("Bulk deleting %d documents", len(document_ids))
872        await self._bulk_edit(document_ids, "delete")

Permanently delete multiple documents in a single request.

Arguments:
  • document_ids: List of document IDs to delete.
async def bulk_set_correspondent(self, document_ids: List[int], correspondent: int | str | None) -> None:
874    async def bulk_set_correspondent(
875        self, document_ids: List[int], correspondent: int | str | None
876    ) -> None:
877        """Assign a correspondent to multiple documents in a single request.
878
879        Args:
880            document_ids: List of document IDs to modify.
881            correspondent: Correspondent to assign, as an ID or name.
882                Pass ``None`` to clear.
883        """
884        logger.info(
885            "Bulk setting correspondent %r on %d documents", correspondent, len(document_ids)
886        )
887        cor_id: int | None = None
888        if correspondent is not None:
889            cor_id = await self._core._resolver.resolve("correspondents", correspondent)
890        await self._bulk_edit(document_ids, "set_correspondent", correspondent=cor_id)

Assign a correspondent to multiple documents in a single request.

Arguments:
  • document_ids: List of document IDs to modify.
  • correspondent: Correspondent to assign, as an ID or name. Pass None to clear.
async def bulk_set_document_type(self, document_ids: List[int], document_type: int | str | None) -> None:
892    async def bulk_set_document_type(
893        self, document_ids: List[int], document_type: int | str | None
894    ) -> None:
895        """Assign a document type to multiple documents in a single request.
896
897        Args:
898            document_ids: List of document IDs to modify.
899            document_type: Document type to assign, as an ID or name.
900                Pass ``None`` to clear.
901        """
902        logger.info(
903            "Bulk setting document type %r on %d documents", document_type, len(document_ids)
904        )
905        dt_id: int | None = None
906        if document_type is not None:
907            dt_id = await self._core._resolver.resolve("document_types", document_type)
908        await self._bulk_edit(document_ids, "set_document_type", document_type=dt_id)

Assign a document type to multiple documents in a single request.

Arguments:
  • document_ids: List of document IDs to modify.
  • document_type: Document type to assign, as an ID or name. Pass None to clear.
async def bulk_set_storage_path(self, document_ids: List[int], storage_path: int | str | None) -> None:
910    async def bulk_set_storage_path(
911        self, document_ids: List[int], storage_path: int | str | None
912    ) -> None:
913        """Assign a storage path to multiple documents in a single request.
914
915        Args:
916            document_ids: List of document IDs to modify.
917            storage_path: Storage path to assign, as an ID or name.
918                Pass ``None`` to clear.
919        """
920        logger.info("Bulk setting storage path %r on %d documents", storage_path, len(document_ids))
921        sp_id: int | None = None
922        if storage_path is not None:
923            sp_id = await self._core._resolver.resolve("storage_paths", storage_path)
924        await self._bulk_edit(document_ids, "set_storage_path", storage_path=sp_id)

Assign a storage path to multiple documents in a single request.

Arguments:
  • document_ids: List of document IDs to modify.
  • storage_path: Storage path to assign, as an ID or name. Pass None to clear.
async def bulk_modify_custom_fields( self, document_ids: List[int], *, add_fields: Optional[List[dict[str, Any]]] = None, remove_fields: Optional[List[int]] = None) -> None:
926    async def bulk_modify_custom_fields(
927        self,
928        document_ids: List[int],
929        *,
930        add_fields: List[dict[str, Any]] | None = None,
931        remove_fields: List[int] | None = None,
932    ) -> None:
933        """Add and/or remove custom field values on multiple documents.
934
935        Args:
936            document_ids: List of document IDs to modify.
937            add_fields: Custom-field value dicts to add.
938            remove_fields: Custom-field IDs whose values should be removed.
939        """
940        logger.info("Bulk modifying custom fields on %d documents", len(document_ids))
941        await self._bulk_edit(
942            document_ids,
943            "modify_custom_fields",
944            add_custom_fields=add_fields or [],
945            remove_custom_fields=remove_fields or [],
946        )

Add and/or remove custom field values on multiple documents.

Arguments:
  • document_ids: List of document IDs to modify.
  • add_fields: Custom-field value dicts to add.
  • remove_fields: Custom-field IDs whose values should be removed.
async def bulk_set_permissions( self, document_ids: List[int], *, set_permissions: easypaperless.SetPermissions | easypaperless.Unset = UNSET, owner: int | None | easypaperless.Unset = UNSET, merge: bool = False) -> None:
948    async def bulk_set_permissions(
949        self,
950        document_ids: List[int],
951        *,
952        set_permissions: SetPermissions | Unset = UNSET,
953        owner: int | None | Unset = UNSET,
954        merge: bool = False,
955    ) -> None:
956        """Set permissions and/or owner on multiple documents.
957
958        Args:
959            document_ids: List of document IDs to modify.
960            set_permissions: Explicit view/change permission sets.
961                Omit (or pass :data:`~easypaperless.UNSET`) to leave unchanged.
962            owner: Numeric user ID to assign as document owner.
963                Pass ``None`` to clear the owner.
964                Omit (or pass :data:`~easypaperless.UNSET`) to leave unchanged.
965            merge: When ``True``, new permissions are merged with existing ones.
966        """
967        logger.info("Bulk setting permissions on %d documents", len(document_ids))
968        params: dict[str, Any] = {"merge": merge}
969        if not isinstance(set_permissions, Unset):
970            params["set_permissions"] = set_permissions.model_dump()
971        if not isinstance(owner, Unset):
972            params["owner"] = owner
973        await self._bulk_edit(document_ids, "set_permissions", **params)

Set permissions and/or owner on multiple documents.

Arguments:
  • document_ids: List of document IDs to modify.
  • set_permissions: Explicit view/change permission sets. Omit (or pass ~easypaperless.UNSET) to leave unchanged.
  • owner: Numeric user ID to assign as document owner. Pass None to clear the owner. Omit (or pass ~easypaperless.UNSET) to leave unchanged.
  • merge: When True, new permissions are merged with existing ones.
async def bulk_download( self, document_ids: List[int], *, content: Literal['archive', 'originals', 'both'] = 'archive', compression: Literal['none', 'deflated', 'bzip2', 'lzma'] = 'none', follow_formatting: bool = False) -> bytes:
 975    async def bulk_download(
 976        self,
 977        document_ids: List[int],
 978        *,
 979        content: Literal["archive", "originals", "both"] = "archive",
 980        compression: Literal["none", "deflated", "bzip2", "lzma"] = "none",
 981        follow_formatting: bool = False,
 982    ) -> bytes:
 983        """Download multiple documents as a single ZIP archive.
 984
 985        Args:
 986            document_ids: List of document IDs to include in the ZIP.
 987            content: File variant to include.  One of ``"archive"`` *(default)*,
 988                ``"originals"``, or ``"both"``.
 989            compression: ZIP compression algorithm.  One of ``"none"`` *(default)*,
 990                ``"deflated"``, ``"bzip2"``, or ``"lzma"``.
 991            follow_formatting: When ``True``, filenames inside the ZIP follow
 992                the storage path formatting configured in paperless-ngx.
 993                Default: ``False``.
 994
 995        Returns:
 996            Raw bytes of the ZIP archive.
 997        """
 998        logger.info(
 999            "Bulk downloading %d documents (content=%s, compression=%s)",
1000            len(document_ids),
1001            content,
1002            compression,
1003        )
1004        payload: dict[str, Any] = {
1005            "documents": document_ids,
1006            "content": content,
1007            "compression": compression,
1008            "follow_formatting": follow_formatting,
1009        }
1010        resp = await self._core._session.post("/documents/bulk_download/", json=payload)
1011        return resp.content

Download multiple documents as a single ZIP archive.

Arguments:
  • document_ids: List of document IDs to include in the ZIP.
  • content: File variant to include. One of "archive" (default), "originals", or "both".
  • compression: ZIP compression algorithm. One of "none" (default), "deflated", "bzip2", or "lzma".
  • follow_formatting: When True, filenames inside the ZIP follow the storage path formatting configured in paperless-ngx. Default: False.
Returns:

Raw bytes of the ZIP archive.

class NotesResource:
 18class NotesResource:
 19    """Accessor for document notes: ``client.documents.notes``."""
 20
 21    def __init__(self, core: _ClientCore) -> None:
 22        self._core = core
 23
 24    async def list(
 25        self,
 26        document_id: int,
 27        *,
 28        page: int | None = None,
 29        page_size: int | None = None,
 30    ) -> PagedResult[DocumentNote]:
 31        """Fetch notes attached to a document.
 32
 33        When ``page`` is ``None`` (the default), all pages are fetched
 34        automatically and ``next`` / ``previous`` in the returned
 35        :class:`~easypaperless.models.paged_result.PagedResult` are always
 36        ``None``.  When ``page`` is set to a specific integer, only that one
 37        page is fetched and ``next`` / ``previous`` contain the raw API values.
 38
 39        Args:
 40            document_id: Numeric ID of the document whose notes to retrieve.
 41            page: Return only this specific page (1-based).
 42            page_size: Number of results per page.
 43
 44        Returns:
 45            :class:`~easypaperless.models.paged_result.PagedResult` of
 46            :class:`~easypaperless.models.documents.DocumentNote` objects,
 47            ordered by creation time.
 48
 49        Raises:
 50            ~easypaperless.exceptions.NotFoundError: If no document exists
 51                with that ID.
 52        """
 53        logger.info("Listing notes for document id=%d", document_id)
 54        path = f"/documents/{document_id}/notes/"
 55        params: dict[str, Any] = {}
 56        if page_size is not None:
 57            params["page_size"] = page_size
 58        if page is not None:
 59            params["page"] = page
 60
 61        raw = await self._core._session.get_list(
 62            path, params=params or None, all_pages=page is None
 63        )
 64        notes = [DocumentNote.model_validate(item) for item in raw.items]
 65        all_ids = raw.all_ids
 66        if not raw.paginated:
 67            # paperless-ngx answers with a plain JSON array: list the note IDs.
 68            all_ids = [n.id for n in notes if n.id is not None] or None
 69        return PagedResult(
 70            count=raw.count,
 71            next=raw.next,
 72            previous=raw.previous,
 73            all=all_ids,
 74            results=notes,
 75        )
 76
 77    async def create(self, document_id: int, *, note: str) -> DocumentNote:
 78        """Create a new note on a document.
 79
 80        Args:
 81            document_id: Numeric ID of the document to annotate.
 82            note: Text content of the note.
 83
 84        Returns:
 85            The newly created :class:`~easypaperless.models.documents.DocumentNote`.
 86
 87        Raises:
 88            ~easypaperless.exceptions.NotFoundError: If no document exists
 89                with that ID.
 90        """
 91        logger.info("Creating note for document id=%d", document_id)
 92        resp = await self._core._session.post(
 93            f"/documents/{document_id}/notes/",
 94            json={"note": note},
 95            retry=False,  # a retry after a lost response could add the note twice
 96        )
 97        data = resp.json()
 98        if isinstance(data, list):
 99            return DocumentNote.model_validate(data[-1])
100        return DocumentNote.model_validate(data)
101
102    async def delete(self, document_id: int, note_id: int) -> None:
103        """Delete a note from a document.
104
105        Args:
106            document_id: Numeric ID of the document that owns the note.
107            note_id: Numeric ID of the note to delete.
108
109        Raises:
110            ~easypaperless.exceptions.NotFoundError: If no document exists with
111                that ID.
112            ~easypaperless.exceptions.ServerResponseError: If the document has
113                no note with ``note_id``.  paperless-ngx answers an unknown note
114                ID with ``500 Server Error`` instead of 404 (verified against
115                paperless-ngx 2.18.2), so it cannot be told apart from a real
116                server error.  With ``retry_attempts`` set, the 500 is retried
117                like any other and ends in
118                :exc:`~easypaperless.exceptions.RetryExhaustedError`.  Use
119                ``notes.list(document_id)`` first if you need to be sure the
120                note exists.
121        """
122        logger.info("Deleting note id=%d from document id=%d", note_id, document_id)
123        await self._core._session.delete(f"/documents/{document_id}/notes/", params={"id": note_id})

Accessor for document notes: client.documents.notes.

NotesResource(core: easypaperless.client._ClientCore)
21    def __init__(self, core: _ClientCore) -> None:
22        self._core = core
async def list( self, document_id: int, *, page: int | None = None, page_size: int | None = None) -> easypaperless.PagedResult[DocumentNote]:
24    async def list(
25        self,
26        document_id: int,
27        *,
28        page: int | None = None,
29        page_size: int | None = None,
30    ) -> PagedResult[DocumentNote]:
31        """Fetch notes attached to a document.
32
33        When ``page`` is ``None`` (the default), all pages are fetched
34        automatically and ``next`` / ``previous`` in the returned
35        :class:`~easypaperless.models.paged_result.PagedResult` are always
36        ``None``.  When ``page`` is set to a specific integer, only that one
37        page is fetched and ``next`` / ``previous`` contain the raw API values.
38
39        Args:
40            document_id: Numeric ID of the document whose notes to retrieve.
41            page: Return only this specific page (1-based).
42            page_size: Number of results per page.
43
44        Returns:
45            :class:`~easypaperless.models.paged_result.PagedResult` of
46            :class:`~easypaperless.models.documents.DocumentNote` objects,
47            ordered by creation time.
48
49        Raises:
50            ~easypaperless.exceptions.NotFoundError: If no document exists
51                with that ID.
52        """
53        logger.info("Listing notes for document id=%d", document_id)
54        path = f"/documents/{document_id}/notes/"
55        params: dict[str, Any] = {}
56        if page_size is not None:
57            params["page_size"] = page_size
58        if page is not None:
59            params["page"] = page
60
61        raw = await self._core._session.get_list(
62            path, params=params or None, all_pages=page is None
63        )
64        notes = [DocumentNote.model_validate(item) for item in raw.items]
65        all_ids = raw.all_ids
66        if not raw.paginated:
67            # paperless-ngx answers with a plain JSON array: list the note IDs.
68            all_ids = [n.id for n in notes if n.id is not None] or None
69        return PagedResult(
70            count=raw.count,
71            next=raw.next,
72            previous=raw.previous,
73            all=all_ids,
74            results=notes,
75        )

Fetch notes attached to a document.

When page is None (the default), all pages are fetched automatically and next / previous in the returned ~easypaperless.models.paged_result.PagedResult are always None. When page is set to a specific integer, only that one page is fetched and next / previous contain the raw API values.

Arguments:
  • document_id: Numeric ID of the document whose notes to retrieve.
  • page: Return only this specific page (1-based).
  • page_size: Number of results per page.
Returns:

~easypaperless.models.paged_result.PagedResult of ~easypaperless.models.documents.DocumentNote objects, ordered by creation time.

Raises:
async def create( self, document_id: int, *, note: str) -> easypaperless.DocumentNote:
 77    async def create(self, document_id: int, *, note: str) -> DocumentNote:
 78        """Create a new note on a document.
 79
 80        Args:
 81            document_id: Numeric ID of the document to annotate.
 82            note: Text content of the note.
 83
 84        Returns:
 85            The newly created :class:`~easypaperless.models.documents.DocumentNote`.
 86
 87        Raises:
 88            ~easypaperless.exceptions.NotFoundError: If no document exists
 89                with that ID.
 90        """
 91        logger.info("Creating note for document id=%d", document_id)
 92        resp = await self._core._session.post(
 93            f"/documents/{document_id}/notes/",
 94            json={"note": note},
 95            retry=False,  # a retry after a lost response could add the note twice
 96        )
 97        data = resp.json()
 98        if isinstance(data, list):
 99            return DocumentNote.model_validate(data[-1])
100        return DocumentNote.model_validate(data)

Create a new note on a document.

Arguments:
  • document_id: Numeric ID of the document to annotate.
  • note: Text content of the note.
Returns:

The newly created ~easypaperless.models.documents.DocumentNote.

Raises:
async def delete(self, document_id: int, note_id: int) -> None:
102    async def delete(self, document_id: int, note_id: int) -> None:
103        """Delete a note from a document.
104
105        Args:
106            document_id: Numeric ID of the document that owns the note.
107            note_id: Numeric ID of the note to delete.
108
109        Raises:
110            ~easypaperless.exceptions.NotFoundError: If no document exists with
111                that ID.
112            ~easypaperless.exceptions.ServerResponseError: If the document has
113                no note with ``note_id``.  paperless-ngx answers an unknown note
114                ID with ``500 Server Error`` instead of 404 (verified against
115                paperless-ngx 2.18.2), so it cannot be told apart from a real
116                server error.  With ``retry_attempts`` set, the 500 is retried
117                like any other and ends in
118                :exc:`~easypaperless.exceptions.RetryExhaustedError`.  Use
119                ``notes.list(document_id)`` first if you need to be sure the
120                note exists.
121        """
122        logger.info("Deleting note id=%d from document id=%d", note_id, document_id)
123        await self._core._session.delete(f"/documents/{document_id}/notes/", params={"id": note_id})

Delete a note from a document.

Arguments:
  • document_id: Numeric ID of the document that owns the note.
  • note_id: Numeric ID of the note to delete.
Raises:
class StoragePathsResource:
 21class StoragePathsResource:
 22    """Accessor for storage paths: ``client.storage_paths``."""
 23
 24    def __init__(self, core: _ClientCore) -> None:
 25        self._core = core
 26
 27    async def list(
 28        self,
 29        *,
 30        ids: List[int] | None = None,
 31        name_contains: str | None = None,
 32        name_exact: str | None = None,
 33        path_contains: str | None = None,
 34        path_exact: str | None = None,
 35        page: int | None = None,
 36        page_size: int | None = None,
 37        ordering: str | None = None,
 38        descending: bool = False,
 39    ) -> PagedResult[StoragePath]:
 40        """Return storage paths defined in paperless-ngx.
 41
 42        When ``page`` is ``None`` (the default), all pages are fetched
 43        automatically and ``next`` / ``previous`` in the result are always
 44        ``None``.  When ``page`` is set, only that page is fetched and
 45        ``next`` / ``previous`` reflect the raw API values.
 46
 47        Args:
 48            ids: Return only storage paths whose ID is in this list.
 49            name_contains: Case-insensitive substring filter on name.
 50            name_exact: Case-insensitive exact match on name.
 51            path_contains: Case-insensitive substring filter on path template.
 52            path_exact: Case-insensitive exact match on path template.
 53            page: Return only this specific page (1-based).
 54            page_size: Number of results per page.
 55            ordering: Field to sort by.
 56            descending: When ``True``, reverses the sort direction.
 57
 58        Returns:
 59            :class:`~easypaperless.models.paged_result.PagedResult` of
 60            :class:`~easypaperless.models.storage_paths.StoragePath` objects.
 61        """
 62        logger.info("Listing storage paths")
 63        params: dict[str, Any] = {}
 64        if ids is not None:
 65            params["id__in"] = ",".join(str(i) for i in ids)
 66        if name_contains is not None:
 67            params["name__icontains"] = name_contains
 68        if name_exact is not None:
 69            params["name__iexact"] = name_exact
 70        if path_contains is not None:
 71            params["path__icontains"] = path_contains
 72        if path_exact is not None:
 73            params["path__iexact"] = path_exact
 74        if page is not None:
 75            params["page"] = page
 76        if page_size is not None:
 77            params["page_size"] = page_size
 78        if ordering is not None:
 79            params["ordering"] = f"-{ordering}" if descending else ordering
 80        return cast(
 81            PagedResult[StoragePath],
 82            await self._core._list_resource("storage_paths", StoragePath, params or None),
 83        )
 84
 85    async def get(self, id: int) -> StoragePath:
 86        """Fetch a single storage path by its ID.
 87
 88        Args:
 89            id: Numeric storage-path ID.
 90
 91        Returns:
 92            The :class:`~easypaperless.models.storage_paths.StoragePath` with the given ID.
 93
 94        Raises:
 95            ~easypaperless.exceptions.NotFoundError: If no storage path exists with that ID.
 96        """
 97        logger.info("Getting storage path id=%d", id)
 98        return cast(StoragePath, await self._core._get_resource("storage_paths", id, StoragePath))
 99
100    async def create(
101        self,
102        *,
103        name: str,
104        path: str | Unset = UNSET,
105        match: str | Unset = UNSET,
106        matching_algorithm: MatchingAlgorithm | Unset = UNSET,
107        is_insensitive: bool = True,
108        owner: int | None | Unset = UNSET,
109        set_permissions: SetPermissions | None | Unset = UNSET,
110    ) -> StoragePath:
111        """Create a new storage path.
112
113        Args:
114            name: Storage-path name. Must be unique.
115            path: Template string for the archive file path.
116            match: Auto-matching pattern.
117            matching_algorithm: Controls how ``match`` is applied.
118                E.g. ``matching_algorithm=MatchingAlgorithm.REGEX`` for
119                regular-expression matching.
120            is_insensitive: When ``True``, ``match`` is case-insensitive.
121                Defaults to ``True``, matching the paperless-ngx API default.
122            owner: Numeric user ID to assign as owner.
123            set_permissions: Explicit view/change permission sets.
124                Pass ``None`` to create with empty permissions.
125
126        Returns:
127            The newly created :class:`~easypaperless.models.storage_paths.StoragePath`.
128        """
129        logger.info("Creating storage path name=%r", name)
130        return cast(
131            StoragePath,
132            await self._core._create_resource(
133                "storage_paths",
134                StoragePath,
135                owner=owner,
136                set_permissions=set_permissions,
137                name=name,
138                path=path,
139                match=match,
140                matching_algorithm=matching_algorithm,
141                is_insensitive=is_insensitive,
142            ),
143        )
144
145    async def update(
146        self,
147        id: int,
148        *,
149        name: str | Unset = UNSET,
150        path: str | Unset = UNSET,
151        match: str | Unset = UNSET,
152        matching_algorithm: MatchingAlgorithm | Unset = UNSET,
153        is_insensitive: bool | Unset = UNSET,
154        owner: int | None | Unset = UNSET,
155        set_permissions: SetPermissions | None | Unset = UNSET,
156    ) -> StoragePath:
157        """Partially update a storage path (PATCH semantics).
158
159        Args:
160            id: Numeric ID of the storage path to update.
161            name: Storage-path name.
162            path: Template string for the archive file path.
163            match: Auto-matching pattern.
164            matching_algorithm: Controls how ``match`` is applied.
165                E.g. ``matching_algorithm=MatchingAlgorithm.REGEX`` for
166                regular-expression matching.
167            is_insensitive: When ``True``, ``match`` is case-insensitive.
168            owner: Numeric user ID to assign as owner.
169                Pass ``None`` to clear the owner.
170                Omit (or pass :data:`~easypaperless.UNSET`) to leave unchanged.
171            set_permissions: Explicit view/change permission sets.
172                Pass ``None`` to clear all permissions (overwrite with empty).
173                Omit (or pass :data:`~easypaperless.UNSET`) to leave unchanged.
174
175        Returns:
176            The updated :class:`~easypaperless.models.storage_paths.StoragePath`.
177        """
178        logger.info("Updating storage path id=%d", id)
179        return cast(
180            StoragePath,
181            await self._core._update_resource(
182                "storage_paths",
183                id,
184                StoragePath,
185                name=name,
186                path=path,
187                match=match,
188                matching_algorithm=matching_algorithm,
189                is_insensitive=is_insensitive,
190                owner=owner,
191                set_permissions=set_permissions,
192            ),
193        )
194
195    async def delete(self, id: int) -> None:
196        """Delete a storage path.
197
198        Args:
199            id: Numeric ID of the storage path to delete.
200
201        Raises:
202            ~easypaperless.exceptions.NotFoundError: If no storage path exists with that ID.
203        """
204        logger.info("Deleting storage path id=%d", id)
205        await self._core._delete_resource("storage_paths", id)
206
207    async def bulk_delete(self, ids: List[int]) -> None:
208        """Permanently delete multiple storage paths in a single request.
209
210        Args:
211            ids: List of storage path IDs to delete.
212        """
213        logger.info("Bulk deleting %d storage paths", len(ids))
214        await self._core._bulk_edit_objects("storage_paths", ids, "delete")
215
216    async def bulk_set_permissions(
217        self,
218        ids: List[int],
219        *,
220        set_permissions: SetPermissions | Unset = UNSET,
221        owner: int | None | Unset = UNSET,
222        merge: bool = False,
223    ) -> None:
224        """Set permissions and/or owner on multiple storage paths.
225
226        Args:
227            ids: List of storage path IDs to modify.
228            set_permissions: Explicit view/change permission sets.
229                Omit (or pass :data:`~easypaperless.UNSET`) to leave unchanged.
230            owner: Numeric user ID to assign as owner.
231                Pass ``None`` to clear the owner.
232                Omit (or pass :data:`~easypaperless.UNSET`) to leave unchanged.
233            merge: When ``True``, new permissions are merged with existing ones.
234        """
235        logger.info("Bulk setting permissions on %d storage paths", len(ids))
236        params: dict[str, Any] = {"merge": merge}
237        if not isinstance(set_permissions, Unset):
238            params["permissions"] = set_permissions.model_dump()
239        if not isinstance(owner, Unset):
240            params["owner"] = owner
241        await self._core._bulk_edit_objects("storage_paths", ids, "set_permissions", **params)

Accessor for storage paths: client.storage_paths.

StoragePathsResource(core: easypaperless.client._ClientCore)
24    def __init__(self, core: _ClientCore) -> None:
25        self._core = core
async def list( self, *, ids: Optional[List[int]] = None, name_contains: str | None = None, name_exact: str | None = None, path_contains: str | None = None, path_exact: str | None = None, page: int | None = None, page_size: int | None = None, ordering: str | None = None, descending: bool = False) -> easypaperless.PagedResult[StoragePath]:
27    async def list(
28        self,
29        *,
30        ids: List[int] | None = None,
31        name_contains: str | None = None,
32        name_exact: str | None = None,
33        path_contains: str | None = None,
34        path_exact: str | None = None,
35        page: int | None = None,
36        page_size: int | None = None,
37        ordering: str | None = None,
38        descending: bool = False,
39    ) -> PagedResult[StoragePath]:
40        """Return storage paths defined in paperless-ngx.
41
42        When ``page`` is ``None`` (the default), all pages are fetched
43        automatically and ``next`` / ``previous`` in the result are always
44        ``None``.  When ``page`` is set, only that page is fetched and
45        ``next`` / ``previous`` reflect the raw API values.
46
47        Args:
48            ids: Return only storage paths whose ID is in this list.
49            name_contains: Case-insensitive substring filter on name.
50            name_exact: Case-insensitive exact match on name.
51            path_contains: Case-insensitive substring filter on path template.
52            path_exact: Case-insensitive exact match on path template.
53            page: Return only this specific page (1-based).
54            page_size: Number of results per page.
55            ordering: Field to sort by.
56            descending: When ``True``, reverses the sort direction.
57
58        Returns:
59            :class:`~easypaperless.models.paged_result.PagedResult` of
60            :class:`~easypaperless.models.storage_paths.StoragePath` objects.
61        """
62        logger.info("Listing storage paths")
63        params: dict[str, Any] = {}
64        if ids is not None:
65            params["id__in"] = ",".join(str(i) for i in ids)
66        if name_contains is not None:
67            params["name__icontains"] = name_contains
68        if name_exact is not None:
69            params["name__iexact"] = name_exact
70        if path_contains is not None:
71            params["path__icontains"] = path_contains
72        if path_exact is not None:
73            params["path__iexact"] = path_exact
74        if page is not None:
75            params["page"] = page
76        if page_size is not None:
77            params["page_size"] = page_size
78        if ordering is not None:
79            params["ordering"] = f"-{ordering}" if descending else ordering
80        return cast(
81            PagedResult[StoragePath],
82            await self._core._list_resource("storage_paths", StoragePath, params or None),
83        )

Return storage paths defined in paperless-ngx.

When page is None (the default), all pages are fetched automatically and next / previous in the result are always None. When page is set, only that page is fetched and next / previous reflect the raw API values.

Arguments:
  • ids: Return only storage paths whose ID is in this list.
  • name_contains: Case-insensitive substring filter on name.
  • name_exact: Case-insensitive exact match on name.
  • path_contains: Case-insensitive substring filter on path template.
  • path_exact: Case-insensitive exact match on path template.
  • page: Return only this specific page (1-based).
  • page_size: Number of results per page.
  • ordering: Field to sort by.
  • descending: When True, reverses the sort direction.
Returns:

~easypaperless.models.paged_result.PagedResult of ~easypaperless.models.storage_paths.StoragePath objects.

async def get(self, id: int) -> easypaperless.StoragePath:
85    async def get(self, id: int) -> StoragePath:
86        """Fetch a single storage path by its ID.
87
88        Args:
89            id: Numeric storage-path ID.
90
91        Returns:
92            The :class:`~easypaperless.models.storage_paths.StoragePath` with the given ID.
93
94        Raises:
95            ~easypaperless.exceptions.NotFoundError: If no storage path exists with that ID.
96        """
97        logger.info("Getting storage path id=%d", id)
98        return cast(StoragePath, await self._core._get_resource("storage_paths", id, StoragePath))

Fetch a single storage path by its ID.

Arguments:
  • id: Numeric storage-path ID.
Returns:

The ~easypaperless.models.storage_paths.StoragePath with the given ID.

Raises:
async def create( self, *, name: str, path: str | easypaperless.Unset = UNSET, match: str | easypaperless.Unset = UNSET, matching_algorithm: easypaperless.MatchingAlgorithm | easypaperless.Unset = UNSET, is_insensitive: bool = True, owner: int | None | easypaperless.Unset = UNSET, set_permissions: easypaperless.SetPermissions | None | easypaperless.Unset = UNSET) -> easypaperless.StoragePath:
100    async def create(
101        self,
102        *,
103        name: str,
104        path: str | Unset = UNSET,
105        match: str | Unset = UNSET,
106        matching_algorithm: MatchingAlgorithm | Unset = UNSET,
107        is_insensitive: bool = True,
108        owner: int | None | Unset = UNSET,
109        set_permissions: SetPermissions | None | Unset = UNSET,
110    ) -> StoragePath:
111        """Create a new storage path.
112
113        Args:
114            name: Storage-path name. Must be unique.
115            path: Template string for the archive file path.
116            match: Auto-matching pattern.
117            matching_algorithm: Controls how ``match`` is applied.
118                E.g. ``matching_algorithm=MatchingAlgorithm.REGEX`` for
119                regular-expression matching.
120            is_insensitive: When ``True``, ``match`` is case-insensitive.
121                Defaults to ``True``, matching the paperless-ngx API default.
122            owner: Numeric user ID to assign as owner.
123            set_permissions: Explicit view/change permission sets.
124                Pass ``None`` to create with empty permissions.
125
126        Returns:
127            The newly created :class:`~easypaperless.models.storage_paths.StoragePath`.
128        """
129        logger.info("Creating storage path name=%r", name)
130        return cast(
131            StoragePath,
132            await self._core._create_resource(
133                "storage_paths",
134                StoragePath,
135                owner=owner,
136                set_permissions=set_permissions,
137                name=name,
138                path=path,
139                match=match,
140                matching_algorithm=matching_algorithm,
141                is_insensitive=is_insensitive,
142            ),
143        )

Create a new storage path.

Arguments:
  • name: Storage-path name. Must be unique.
  • path: Template string for the archive file path.
  • match: Auto-matching pattern.
  • matching_algorithm: Controls how match is applied. E.g. matching_algorithm=MatchingAlgorithm.REGEX for regular-expression matching.
  • is_insensitive: When True, match is case-insensitive. Defaults to True, matching the paperless-ngx API default.
  • owner: Numeric user ID to assign as owner.
  • set_permissions: Explicit view/change permission sets. Pass None to create with empty permissions.
Returns:

The newly created ~easypaperless.models.storage_paths.StoragePath.

async def update( self, id: int, *, name: str | easypaperless.Unset = UNSET, path: str | easypaperless.Unset = UNSET, match: str | easypaperless.Unset = UNSET, matching_algorithm: easypaperless.MatchingAlgorithm | easypaperless.Unset = UNSET, is_insensitive: bool | easypaperless.Unset = UNSET, owner: int | None | easypaperless.Unset = UNSET, set_permissions: easypaperless.SetPermissions | None | easypaperless.Unset = UNSET) -> easypaperless.StoragePath:
145    async def update(
146        self,
147        id: int,
148        *,
149        name: str | Unset = UNSET,
150        path: str | Unset = UNSET,
151        match: str | Unset = UNSET,
152        matching_algorithm: MatchingAlgorithm | Unset = UNSET,
153        is_insensitive: bool | Unset = UNSET,
154        owner: int | None | Unset = UNSET,
155        set_permissions: SetPermissions | None | Unset = UNSET,
156    ) -> StoragePath:
157        """Partially update a storage path (PATCH semantics).
158
159        Args:
160            id: Numeric ID of the storage path to update.
161            name: Storage-path name.
162            path: Template string for the archive file path.
163            match: Auto-matching pattern.
164            matching_algorithm: Controls how ``match`` is applied.
165                E.g. ``matching_algorithm=MatchingAlgorithm.REGEX`` for
166                regular-expression matching.
167            is_insensitive: When ``True``, ``match`` is case-insensitive.
168            owner: Numeric user ID to assign as owner.
169                Pass ``None`` to clear the owner.
170                Omit (or pass :data:`~easypaperless.UNSET`) to leave unchanged.
171            set_permissions: Explicit view/change permission sets.
172                Pass ``None`` to clear all permissions (overwrite with empty).
173                Omit (or pass :data:`~easypaperless.UNSET`) to leave unchanged.
174
175        Returns:
176            The updated :class:`~easypaperless.models.storage_paths.StoragePath`.
177        """
178        logger.info("Updating storage path id=%d", id)
179        return cast(
180            StoragePath,
181            await self._core._update_resource(
182                "storage_paths",
183                id,
184                StoragePath,
185                name=name,
186                path=path,
187                match=match,
188                matching_algorithm=matching_algorithm,
189                is_insensitive=is_insensitive,
190                owner=owner,
191                set_permissions=set_permissions,
192            ),
193        )

Partially update a storage path (PATCH semantics).

Arguments:
  • id: Numeric ID of the storage path to update.
  • name: Storage-path name.
  • path: Template string for the archive file path.
  • match: Auto-matching pattern.
  • matching_algorithm: Controls how match is applied. E.g. matching_algorithm=MatchingAlgorithm.REGEX for regular-expression matching.
  • is_insensitive: When True, match is case-insensitive.
  • owner: Numeric user ID to assign as owner. Pass None to clear the owner. Omit (or pass ~easypaperless.UNSET) to leave unchanged.
  • set_permissions: Explicit view/change permission sets. Pass None to clear all permissions (overwrite with empty). Omit (or pass ~easypaperless.UNSET) to leave unchanged.
Returns:

The updated ~easypaperless.models.storage_paths.StoragePath.

async def delete(self, id: int) -> None:
195    async def delete(self, id: int) -> None:
196        """Delete a storage path.
197
198        Args:
199            id: Numeric ID of the storage path to delete.
200
201        Raises:
202            ~easypaperless.exceptions.NotFoundError: If no storage path exists with that ID.
203        """
204        logger.info("Deleting storage path id=%d", id)
205        await self._core._delete_resource("storage_paths", id)

Delete a storage path.

Arguments:
  • id: Numeric ID of the storage path to delete.
Raises:
async def bulk_delete(self, ids: List[int]) -> None:
207    async def bulk_delete(self, ids: List[int]) -> None:
208        """Permanently delete multiple storage paths in a single request.
209
210        Args:
211            ids: List of storage path IDs to delete.
212        """
213        logger.info("Bulk deleting %d storage paths", len(ids))
214        await self._core._bulk_edit_objects("storage_paths", ids, "delete")

Permanently delete multiple storage paths in a single request.

Arguments:
  • ids: List of storage path IDs to delete.
async def bulk_set_permissions( self, ids: List[int], *, set_permissions: easypaperless.SetPermissions | easypaperless.Unset = UNSET, owner: int | None | easypaperless.Unset = UNSET, merge: bool = False) -> None:
216    async def bulk_set_permissions(
217        self,
218        ids: List[int],
219        *,
220        set_permissions: SetPermissions | Unset = UNSET,
221        owner: int | None | Unset = UNSET,
222        merge: bool = False,
223    ) -> None:
224        """Set permissions and/or owner on multiple storage paths.
225
226        Args:
227            ids: List of storage path IDs to modify.
228            set_permissions: Explicit view/change permission sets.
229                Omit (or pass :data:`~easypaperless.UNSET`) to leave unchanged.
230            owner: Numeric user ID to assign as owner.
231                Pass ``None`` to clear the owner.
232                Omit (or pass :data:`~easypaperless.UNSET`) to leave unchanged.
233            merge: When ``True``, new permissions are merged with existing ones.
234        """
235        logger.info("Bulk setting permissions on %d storage paths", len(ids))
236        params: dict[str, Any] = {"merge": merge}
237        if not isinstance(set_permissions, Unset):
238            params["permissions"] = set_permissions.model_dump()
239        if not isinstance(owner, Unset):
240            params["owner"] = owner
241        await self._core._bulk_edit_objects("storage_paths", ids, "set_permissions", **params)

Set permissions and/or owner on multiple storage paths.

Arguments:
  • ids: List of storage path IDs to modify.
  • set_permissions: Explicit view/change permission sets. Omit (or pass ~easypaperless.UNSET) to leave unchanged.
  • owner: Numeric user ID to assign as owner. Pass None to clear the owner. Omit (or pass ~easypaperless.UNSET) to leave unchanged.
  • merge: When True, new permissions are merged with existing ones.
class TagsResource:
 21class TagsResource:
 22    """Accessor for tags: ``client.tags``."""
 23
 24    def __init__(self, core: _ClientCore) -> None:
 25        self._core = core
 26
 27    async def list(
 28        self,
 29        *,
 30        ids: List[int] | None = None,
 31        name_contains: str | None = None,
 32        name_exact: str | None = None,
 33        page: int | None = None,
 34        page_size: int | None = None,
 35        ordering: str | None = None,
 36        descending: bool = False,
 37    ) -> PagedResult[Tag]:
 38        """Return tags defined in paperless-ngx.
 39
 40        When ``page`` is ``None`` (the default), all pages are fetched
 41        automatically and ``next`` / ``previous`` in the result are always
 42        ``None``.  When ``page`` is set, only that page is fetched and
 43        ``next`` / ``previous`` reflect the raw API values.
 44
 45        Args:
 46            ids: Return only tags whose ID is in this list.
 47            name_contains: Case-insensitive substring filter on tag name.
 48            name_exact: Case-insensitive exact match on tag name.
 49            page: Return only this specific page (1-based).
 50            page_size: Number of results per page.
 51            ordering: Field to sort by.
 52            descending: When ``True``, reverses the sort direction.
 53
 54        Returns:
 55            :class:`~easypaperless.models.paged_result.PagedResult` of
 56            :class:`~easypaperless.models.tags.Tag` objects.
 57        """
 58        logger.info("Listing tags")
 59        params: dict[str, Any] = {}
 60        if ids is not None:
 61            params["id__in"] = ",".join(str(i) for i in ids)
 62        if name_contains is not None:
 63            params["name__icontains"] = name_contains
 64        if name_exact is not None:
 65            params["name__iexact"] = name_exact
 66        if page is not None:
 67            params["page"] = page
 68        if page_size is not None:
 69            params["page_size"] = page_size
 70        if ordering is not None:
 71            params["ordering"] = f"-{ordering}" if descending else ordering
 72        return cast(
 73            PagedResult[Tag],
 74            await self._core._list_resource("tags", Tag, params or None),
 75        )
 76
 77    async def get(self, id: int) -> Tag:
 78        """Fetch a single tag by its ID.
 79
 80        Args:
 81            id: Numeric tag ID.
 82
 83        Returns:
 84            The :class:`~easypaperless.models.tags.Tag` with the given ID.
 85
 86        Raises:
 87            ~easypaperless.exceptions.NotFoundError: If no tag exists with
 88                that ID.
 89        """
 90        logger.info("Getting tag id=%d", id)
 91        return cast(Tag, await self._core._get_resource("tags", id, Tag))
 92
 93    async def create(
 94        self,
 95        *,
 96        name: str,
 97        color: str | Unset = UNSET,
 98        is_inbox_tag: bool | Unset = UNSET,
 99        match: str | Unset = UNSET,
100        matching_algorithm: MatchingAlgorithm | Unset = UNSET,
101        is_insensitive: bool = True,
102        parent: int | None | Unset = UNSET,
103        owner: int | None | Unset = UNSET,
104        set_permissions: SetPermissions | None | Unset = UNSET,
105    ) -> Tag:
106        """Create a new tag.
107
108        Args:
109            name: Tag name. Must be unique.
110            color: Background colour as a CSS hex string.
111            is_inbox_tag: When ``True``, newly ingested documents get this tag.
112            match: Auto-matching pattern.
113            matching_algorithm: Controls how ``match`` is applied.
114                E.g. ``matching_algorithm=MatchingAlgorithm.REGEX`` for
115                regular-expression matching.
116            is_insensitive: When ``True``, ``match`` is case-insensitive.
117                Defaults to ``True``, matching the paperless-ngx API default.
118            parent: ID of parent tag for hierarchical trees.
119            owner: Numeric user ID to assign as owner.
120            set_permissions: Explicit view/change permission sets.
121                Pass ``None`` to create with empty permissions.
122
123        Returns:
124            The newly created :class:`~easypaperless.models.tags.Tag`.
125        """
126        logger.info("Creating tag name=%r", name)
127        return cast(
128            Tag,
129            await self._core._create_resource(
130                "tags",
131                Tag,
132                owner=owner,
133                set_permissions=set_permissions,
134                name=name,
135                color=color,
136                is_inbox_tag=is_inbox_tag,
137                match=match,
138                matching_algorithm=matching_algorithm,
139                is_insensitive=is_insensitive,
140                parent=parent,
141            ),
142        )
143
144    async def update(
145        self,
146        id: int,
147        *,
148        name: str | Unset = UNSET,
149        color: str | Unset = UNSET,
150        is_inbox_tag: bool | Unset = UNSET,
151        match: str | Unset = UNSET,
152        matching_algorithm: MatchingAlgorithm | Unset = UNSET,
153        is_insensitive: bool | Unset = UNSET,
154        parent: int | None | Unset = UNSET,
155        owner: int | None | Unset = UNSET,
156        set_permissions: SetPermissions | None | Unset = UNSET,
157    ) -> Tag:
158        """Partially update a tag (PATCH semantics).
159
160        Args:
161            id: Numeric ID of the tag to update.
162            name: Tag name.
163            color: Background colour as a CSS hex string.
164            is_inbox_tag: When ``True``, newly ingested documents get this tag.
165            match: Auto-matching pattern.
166            matching_algorithm: Controls how ``match`` is applied.
167                E.g. ``matching_algorithm=MatchingAlgorithm.REGEX`` for
168                regular-expression matching.
169            is_insensitive: When ``True``, ``match`` is case-insensitive.
170            parent: ID of parent tag.
171                Pass ``None`` to clear (make root tag).
172                Omit (or pass :data:`~easypaperless.UNSET`) to leave unchanged.
173            owner: Numeric user ID to assign as owner.
174                Pass ``None`` to clear the owner.
175                Omit (or pass :data:`~easypaperless.UNSET`) to leave unchanged.
176            set_permissions: Explicit view/change permission sets.
177                Pass ``None`` to clear all permissions (overwrite with empty).
178                Omit (or pass :data:`~easypaperless.UNSET`) to leave unchanged.
179
180        Returns:
181            The updated :class:`~easypaperless.models.tags.Tag`.
182        """
183        logger.info("Updating tag id=%d", id)
184        return cast(
185            Tag,
186            await self._core._update_resource(
187                "tags",
188                id,
189                Tag,
190                name=name,
191                color=color,
192                is_inbox_tag=is_inbox_tag,
193                match=match,
194                matching_algorithm=matching_algorithm,
195                is_insensitive=is_insensitive,
196                parent=parent,
197                owner=owner,
198                set_permissions=set_permissions,
199            ),
200        )
201
202    async def delete(self, id: int) -> None:
203        """Delete a tag.
204
205        Args:
206            id: Numeric ID of the tag to delete.
207
208        Raises:
209            ~easypaperless.exceptions.NotFoundError: If no tag exists with
210                that ID.
211        """
212        logger.info("Deleting tag id=%d", id)
213        await self._core._delete_resource("tags", id)
214
215    async def bulk_delete(self, ids: List[int]) -> None:
216        """Permanently delete multiple tags in a single request.
217
218        Args:
219            ids: List of tag IDs to delete.
220        """
221        logger.info("Bulk deleting %d tags", len(ids))
222        await self._core._bulk_edit_objects("tags", ids, "delete")
223
224    async def bulk_set_permissions(
225        self,
226        ids: List[int],
227        *,
228        set_permissions: SetPermissions | Unset = UNSET,
229        owner: int | None | Unset = UNSET,
230        merge: bool = False,
231    ) -> None:
232        """Set permissions and/or owner on multiple tags.
233
234        Args:
235            ids: List of tag IDs to modify.
236            set_permissions: Explicit view/change permission sets.
237                Omit (or pass :data:`~easypaperless.UNSET`) to leave unchanged.
238            owner: Numeric user ID to assign as owner.
239                Pass ``None`` to clear the owner.
240                Omit (or pass :data:`~easypaperless.UNSET`) to leave unchanged.
241            merge: When ``True``, new permissions are merged with existing ones.
242        """
243        logger.info("Bulk setting permissions on %d tags", len(ids))
244        params: dict[str, Any] = {"merge": merge}
245        if not isinstance(set_permissions, Unset):
246            params["permissions"] = set_permissions.model_dump()
247        if not isinstance(owner, Unset):
248            params["owner"] = owner
249        await self._core._bulk_edit_objects("tags", ids, "set_permissions", **params)

Accessor for tags: client.tags.

TagsResource(core: easypaperless.client._ClientCore)
24    def __init__(self, core: _ClientCore) -> None:
25        self._core = core
async def list( self, *, ids: Optional[List[int]] = None, name_contains: str | None = None, name_exact: str | None = None, page: int | None = None, page_size: int | None = None, ordering: str | None = None, descending: bool = False) -> easypaperless.PagedResult[Tag]:
27    async def list(
28        self,
29        *,
30        ids: List[int] | None = None,
31        name_contains: str | None = None,
32        name_exact: str | None = None,
33        page: int | None = None,
34        page_size: int | None = None,
35        ordering: str | None = None,
36        descending: bool = False,
37    ) -> PagedResult[Tag]:
38        """Return tags defined in paperless-ngx.
39
40        When ``page`` is ``None`` (the default), all pages are fetched
41        automatically and ``next`` / ``previous`` in the result are always
42        ``None``.  When ``page`` is set, only that page is fetched and
43        ``next`` / ``previous`` reflect the raw API values.
44
45        Args:
46            ids: Return only tags whose ID is in this list.
47            name_contains: Case-insensitive substring filter on tag name.
48            name_exact: Case-insensitive exact match on tag name.
49            page: Return only this specific page (1-based).
50            page_size: Number of results per page.
51            ordering: Field to sort by.
52            descending: When ``True``, reverses the sort direction.
53
54        Returns:
55            :class:`~easypaperless.models.paged_result.PagedResult` of
56            :class:`~easypaperless.models.tags.Tag` objects.
57        """
58        logger.info("Listing tags")
59        params: dict[str, Any] = {}
60        if ids is not None:
61            params["id__in"] = ",".join(str(i) for i in ids)
62        if name_contains is not None:
63            params["name__icontains"] = name_contains
64        if name_exact is not None:
65            params["name__iexact"] = name_exact
66        if page is not None:
67            params["page"] = page
68        if page_size is not None:
69            params["page_size"] = page_size
70        if ordering is not None:
71            params["ordering"] = f"-{ordering}" if descending else ordering
72        return cast(
73            PagedResult[Tag],
74            await self._core._list_resource("tags", Tag, params or None),
75        )

Return tags defined in paperless-ngx.

When page is None (the default), all pages are fetched automatically and next / previous in the result are always None. When page is set, only that page is fetched and next / previous reflect the raw API values.

Arguments:
  • ids: Return only tags whose ID is in this list.
  • name_contains: Case-insensitive substring filter on tag name.
  • name_exact: Case-insensitive exact match on tag name.
  • page: Return only this specific page (1-based).
  • page_size: Number of results per page.
  • ordering: Field to sort by.
  • descending: When True, reverses the sort direction.
Returns:

~easypaperless.models.paged_result.PagedResult of ~easypaperless.models.tags.Tag objects.

async def get(self, id: int) -> easypaperless.Tag:
77    async def get(self, id: int) -> Tag:
78        """Fetch a single tag by its ID.
79
80        Args:
81            id: Numeric tag ID.
82
83        Returns:
84            The :class:`~easypaperless.models.tags.Tag` with the given ID.
85
86        Raises:
87            ~easypaperless.exceptions.NotFoundError: If no tag exists with
88                that ID.
89        """
90        logger.info("Getting tag id=%d", id)
91        return cast(Tag, await self._core._get_resource("tags", id, Tag))

Fetch a single tag by its ID.

Arguments:
  • id: Numeric tag ID.
Returns:

The ~easypaperless.models.tags.Tag with the given ID.

Raises:
async def create( self, *, name: str, color: str | easypaperless.Unset = UNSET, is_inbox_tag: bool | easypaperless.Unset = UNSET, match: str | easypaperless.Unset = UNSET, matching_algorithm: easypaperless.MatchingAlgorithm | easypaperless.Unset = UNSET, is_insensitive: bool = True, parent: int | None | easypaperless.Unset = UNSET, owner: int | None | easypaperless.Unset = UNSET, set_permissions: easypaperless.SetPermissions | None | easypaperless.Unset = UNSET) -> easypaperless.Tag:
 93    async def create(
 94        self,
 95        *,
 96        name: str,
 97        color: str | Unset = UNSET,
 98        is_inbox_tag: bool | Unset = UNSET,
 99        match: str | Unset = UNSET,
100        matching_algorithm: MatchingAlgorithm | Unset = UNSET,
101        is_insensitive: bool = True,
102        parent: int | None | Unset = UNSET,
103        owner: int | None | Unset = UNSET,
104        set_permissions: SetPermissions | None | Unset = UNSET,
105    ) -> Tag:
106        """Create a new tag.
107
108        Args:
109            name: Tag name. Must be unique.
110            color: Background colour as a CSS hex string.
111            is_inbox_tag: When ``True``, newly ingested documents get this tag.
112            match: Auto-matching pattern.
113            matching_algorithm: Controls how ``match`` is applied.
114                E.g. ``matching_algorithm=MatchingAlgorithm.REGEX`` for
115                regular-expression matching.
116            is_insensitive: When ``True``, ``match`` is case-insensitive.
117                Defaults to ``True``, matching the paperless-ngx API default.
118            parent: ID of parent tag for hierarchical trees.
119            owner: Numeric user ID to assign as owner.
120            set_permissions: Explicit view/change permission sets.
121                Pass ``None`` to create with empty permissions.
122
123        Returns:
124            The newly created :class:`~easypaperless.models.tags.Tag`.
125        """
126        logger.info("Creating tag name=%r", name)
127        return cast(
128            Tag,
129            await self._core._create_resource(
130                "tags",
131                Tag,
132                owner=owner,
133                set_permissions=set_permissions,
134                name=name,
135                color=color,
136                is_inbox_tag=is_inbox_tag,
137                match=match,
138                matching_algorithm=matching_algorithm,
139                is_insensitive=is_insensitive,
140                parent=parent,
141            ),
142        )

Create a new tag.

Arguments:
  • name: Tag name. Must be unique.
  • color: Background colour as a CSS hex string.
  • is_inbox_tag: When True, newly ingested documents get this tag.
  • match: Auto-matching pattern.
  • matching_algorithm: Controls how match is applied. E.g. matching_algorithm=MatchingAlgorithm.REGEX for regular-expression matching.
  • is_insensitive: When True, match is case-insensitive. Defaults to True, matching the paperless-ngx API default.
  • parent: ID of parent tag for hierarchical trees.
  • owner: Numeric user ID to assign as owner.
  • set_permissions: Explicit view/change permission sets. Pass None to create with empty permissions.
Returns:

The newly created ~easypaperless.models.tags.Tag.

async def update( self, id: int, *, name: str | easypaperless.Unset = UNSET, color: str | easypaperless.Unset = UNSET, is_inbox_tag: bool | easypaperless.Unset = UNSET, match: str | easypaperless.Unset = UNSET, matching_algorithm: easypaperless.MatchingAlgorithm | easypaperless.Unset = UNSET, is_insensitive: bool | easypaperless.Unset = UNSET, parent: int | None | easypaperless.Unset = UNSET, owner: int | None | easypaperless.Unset = UNSET, set_permissions: easypaperless.SetPermissions | None | easypaperless.Unset = UNSET) -> easypaperless.Tag:
144    async def update(
145        self,
146        id: int,
147        *,
148        name: str | Unset = UNSET,
149        color: str | Unset = UNSET,
150        is_inbox_tag: bool | Unset = UNSET,
151        match: str | Unset = UNSET,
152        matching_algorithm: MatchingAlgorithm | Unset = UNSET,
153        is_insensitive: bool | Unset = UNSET,
154        parent: int | None | Unset = UNSET,
155        owner: int | None | Unset = UNSET,
156        set_permissions: SetPermissions | None | Unset = UNSET,
157    ) -> Tag:
158        """Partially update a tag (PATCH semantics).
159
160        Args:
161            id: Numeric ID of the tag to update.
162            name: Tag name.
163            color: Background colour as a CSS hex string.
164            is_inbox_tag: When ``True``, newly ingested documents get this tag.
165            match: Auto-matching pattern.
166            matching_algorithm: Controls how ``match`` is applied.
167                E.g. ``matching_algorithm=MatchingAlgorithm.REGEX`` for
168                regular-expression matching.
169            is_insensitive: When ``True``, ``match`` is case-insensitive.
170            parent: ID of parent tag.
171                Pass ``None`` to clear (make root tag).
172                Omit (or pass :data:`~easypaperless.UNSET`) to leave unchanged.
173            owner: Numeric user ID to assign as owner.
174                Pass ``None`` to clear the owner.
175                Omit (or pass :data:`~easypaperless.UNSET`) to leave unchanged.
176            set_permissions: Explicit view/change permission sets.
177                Pass ``None`` to clear all permissions (overwrite with empty).
178                Omit (or pass :data:`~easypaperless.UNSET`) to leave unchanged.
179
180        Returns:
181            The updated :class:`~easypaperless.models.tags.Tag`.
182        """
183        logger.info("Updating tag id=%d", id)
184        return cast(
185            Tag,
186            await self._core._update_resource(
187                "tags",
188                id,
189                Tag,
190                name=name,
191                color=color,
192                is_inbox_tag=is_inbox_tag,
193                match=match,
194                matching_algorithm=matching_algorithm,
195                is_insensitive=is_insensitive,
196                parent=parent,
197                owner=owner,
198                set_permissions=set_permissions,
199            ),
200        )

Partially update a tag (PATCH semantics).

Arguments:
  • id: Numeric ID of the tag to update.
  • name: Tag name.
  • color: Background colour as a CSS hex string.
  • is_inbox_tag: When True, newly ingested documents get this tag.
  • match: Auto-matching pattern.
  • matching_algorithm: Controls how match is applied. E.g. matching_algorithm=MatchingAlgorithm.REGEX for regular-expression matching.
  • is_insensitive: When True, match is case-insensitive.
  • parent: ID of parent tag. Pass None to clear (make root tag). Omit (or pass ~easypaperless.UNSET) to leave unchanged.
  • owner: Numeric user ID to assign as owner. Pass None to clear the owner. Omit (or pass ~easypaperless.UNSET) to leave unchanged.
  • set_permissions: Explicit view/change permission sets. Pass None to clear all permissions (overwrite with empty). Omit (or pass ~easypaperless.UNSET) to leave unchanged.
Returns:

The updated ~easypaperless.models.tags.Tag.

async def delete(self, id: int) -> None:
202    async def delete(self, id: int) -> None:
203        """Delete a tag.
204
205        Args:
206            id: Numeric ID of the tag to delete.
207
208        Raises:
209            ~easypaperless.exceptions.NotFoundError: If no tag exists with
210                that ID.
211        """
212        logger.info("Deleting tag id=%d", id)
213        await self._core._delete_resource("tags", id)

Delete a tag.

Arguments:
  • id: Numeric ID of the tag to delete.
Raises:
async def bulk_delete(self, ids: List[int]) -> None:
215    async def bulk_delete(self, ids: List[int]) -> None:
216        """Permanently delete multiple tags in a single request.
217
218        Args:
219            ids: List of tag IDs to delete.
220        """
221        logger.info("Bulk deleting %d tags", len(ids))
222        await self._core._bulk_edit_objects("tags", ids, "delete")

Permanently delete multiple tags in a single request.

Arguments:
  • ids: List of tag IDs to delete.
async def bulk_set_permissions( self, ids: List[int], *, set_permissions: easypaperless.SetPermissions | easypaperless.Unset = UNSET, owner: int | None | easypaperless.Unset = UNSET, merge: bool = False) -> None:
224    async def bulk_set_permissions(
225        self,
226        ids: List[int],
227        *,
228        set_permissions: SetPermissions | Unset = UNSET,
229        owner: int | None | Unset = UNSET,
230        merge: bool = False,
231    ) -> None:
232        """Set permissions and/or owner on multiple tags.
233
234        Args:
235            ids: List of tag IDs to modify.
236            set_permissions: Explicit view/change permission sets.
237                Omit (or pass :data:`~easypaperless.UNSET`) to leave unchanged.
238            owner: Numeric user ID to assign as owner.
239                Pass ``None`` to clear the owner.
240                Omit (or pass :data:`~easypaperless.UNSET`) to leave unchanged.
241            merge: When ``True``, new permissions are merged with existing ones.
242        """
243        logger.info("Bulk setting permissions on %d tags", len(ids))
244        params: dict[str, Any] = {"merge": merge}
245        if not isinstance(set_permissions, Unset):
246            params["permissions"] = set_permissions.model_dump()
247        if not isinstance(owner, Unset):
248            params["owner"] = owner
249        await self._core._bulk_edit_objects("tags", ids, "set_permissions", **params)

Set permissions and/or owner on multiple tags.

Arguments:
  • ids: List of tag IDs to modify.
  • set_permissions: Explicit view/change permission sets. Omit (or pass ~easypaperless.UNSET) to leave unchanged.
  • owner: Numeric user ID to assign as owner. Pass None to clear the owner. Omit (or pass ~easypaperless.UNSET) to leave unchanged.
  • merge: When True, new permissions are merged with existing ones.
class SyncCorrespondentsResource:
 18class SyncCorrespondentsResource:
 19    """Sync accessor for correspondents: ``client.correspondents``."""
 20
 21    def __init__(self, async_correspondents: CorrespondentsResource, run: Any) -> None:
 22        self._async_correspondents = async_correspondents
 23        self._run = run
 24
 25    def list(
 26        self,
 27        *,
 28        ids: List[int] | None = None,
 29        name_contains: str | None = None,
 30        name_exact: str | None = None,
 31        page: int | None = None,
 32        page_size: int | None = None,
 33        ordering: str | None = None,
 34        descending: bool = False,
 35    ) -> PagedResult[Correspondent]:
 36        """Return correspondents defined in paperless-ngx.
 37
 38        When ``page`` is ``None`` (the default), all pages are fetched
 39        automatically and ``next`` / ``previous`` in the result are always
 40        ``None``.  When ``page`` is set, only that page is fetched and
 41        ``next`` / ``previous`` reflect the raw API values.
 42
 43        Args:
 44            ids: Return only correspondents whose ID is in this list.
 45            name_contains: Case-insensitive substring filter on name.
 46            name_exact: Case-insensitive exact match on name.
 47            page: Return only this specific page (1-based).
 48            page_size: Number of results per page.
 49            ordering: Field to sort by.
 50            descending: When ``True``, reverses the sort direction.
 51
 52        Returns:
 53            :class:`~easypaperless.models.paged_result.PagedResult` of
 54            :class:`~easypaperless.models.correspondents.Correspondent` objects.
 55        """
 56        return cast(
 57            PagedResult[Correspondent],
 58            self._run(
 59                self._async_correspondents.list(
 60                    ids=ids,
 61                    name_contains=name_contains,
 62                    name_exact=name_exact,
 63                    page=page,
 64                    page_size=page_size,
 65                    ordering=ordering,
 66                    descending=descending,
 67                )
 68            ),
 69        )
 70
 71    def get(self, id: int) -> Correspondent:
 72        """Fetch a single correspondent by its ID.
 73
 74        Args:
 75            id: Numeric correspondent ID.
 76
 77        Returns:
 78            The :class:`~easypaperless.models.correspondents.Correspondent` with the given ID.
 79
 80        Raises:
 81            ~easypaperless.exceptions.NotFoundError: If no correspondent exists with that ID.
 82        """
 83        return cast(Correspondent, self._run(self._async_correspondents.get(id)))
 84
 85    def create(
 86        self,
 87        *,
 88        name: str,
 89        match: str | Unset = UNSET,
 90        matching_algorithm: MatchingAlgorithm | Unset = UNSET,
 91        is_insensitive: bool = True,
 92        owner: int | None | Unset = UNSET,
 93        set_permissions: SetPermissions | None | Unset = UNSET,
 94    ) -> Correspondent:
 95        """Create a new correspondent.
 96
 97        Args:
 98            name: Correspondent name. Must be unique.
 99            match: Auto-matching pattern.
100            matching_algorithm: Controls how ``match`` is applied.
101                E.g. ``matching_algorithm=MatchingAlgorithm.REGEX`` for
102                regular-expression matching.
103            is_insensitive: When ``True``, ``match`` is case-insensitive.
104                Defaults to ``True``, matching the paperless-ngx API default.
105            owner: Numeric user ID to assign as owner.
106            set_permissions: Explicit view/change permission sets.
107                Pass ``None`` to create with empty permissions.
108
109        Returns:
110            The newly created :class:`~easypaperless.models.correspondents.Correspondent`.
111        """
112        return cast(
113            Correspondent,
114            self._run(
115                self._async_correspondents.create(
116                    name=name,
117                    match=match,
118                    matching_algorithm=matching_algorithm,
119                    is_insensitive=is_insensitive,
120                    owner=owner,
121                    set_permissions=set_permissions,
122                )
123            ),
124        )
125
126    def update(
127        self,
128        id: int,
129        *,
130        name: str | Unset = UNSET,
131        match: str | Unset = UNSET,
132        matching_algorithm: MatchingAlgorithm | Unset = UNSET,
133        is_insensitive: bool | Unset = UNSET,
134        owner: int | None | Unset = UNSET,
135        set_permissions: SetPermissions | None | Unset = UNSET,
136    ) -> Correspondent:
137        """Partially update a correspondent (PATCH semantics).
138
139        Args:
140            id: Numeric ID of the correspondent to update.
141            name: Correspondent name.
142            match: Auto-matching pattern.
143            matching_algorithm: Controls how ``match`` is applied.
144                E.g. ``matching_algorithm=MatchingAlgorithm.REGEX`` for
145                regular-expression matching.
146            is_insensitive: When ``True``, ``match`` is case-insensitive.
147            owner: Numeric user ID to assign as owner.
148                Pass ``None`` to clear the owner.
149                Omit (or pass :data:`~easypaperless.UNSET`) to leave unchanged.
150            set_permissions: Explicit view/change permission sets.
151                Pass ``None`` to clear all permissions (overwrite with empty).
152                Omit (or pass :data:`~easypaperless.UNSET`) to leave unchanged.
153
154        Returns:
155            The updated :class:`~easypaperless.models.correspondents.Correspondent`.
156        """
157        return cast(
158            Correspondent,
159            self._run(
160                self._async_correspondents.update(
161                    id,
162                    name=name,
163                    match=match,
164                    matching_algorithm=matching_algorithm,
165                    is_insensitive=is_insensitive,
166                    owner=owner,
167                    set_permissions=set_permissions,
168                )
169            ),
170        )
171
172    def delete(self, id: int) -> None:
173        """Delete a correspondent.
174
175        Args:
176            id: Numeric ID of the correspondent to delete.
177
178        Raises:
179            ~easypaperless.exceptions.NotFoundError: If no correspondent exists with that ID.
180        """
181        self._run(self._async_correspondents.delete(id))
182
183    def bulk_delete(self, ids: List[int]) -> None:
184        """Permanently delete multiple correspondents in a single request.
185
186        Args:
187            ids: List of correspondent IDs to delete.
188        """
189        self._run(self._async_correspondents.bulk_delete(ids))
190
191    def bulk_set_permissions(
192        self,
193        ids: List[int],
194        *,
195        set_permissions: SetPermissions | Unset = UNSET,
196        owner: int | None | Unset = UNSET,
197        merge: bool = False,
198    ) -> None:
199        """Set permissions and/or owner on multiple correspondents.
200
201        Args:
202            ids: List of correspondent IDs to modify.
203            set_permissions: Explicit view/change permission sets.
204                Omit (or pass :data:`~easypaperless.UNSET`) to leave unchanged.
205            owner: Numeric user ID to assign as owner.
206                Pass ``None`` to clear the owner.
207                Omit (or pass :data:`~easypaperless.UNSET`) to leave unchanged.
208            merge: When ``True``, new permissions are merged with existing ones.
209        """
210        self._run(
211            self._async_correspondents.bulk_set_permissions(
212                ids, set_permissions=set_permissions, owner=owner, merge=merge
213            )
214        )

Sync accessor for correspondents: client.correspondents.

SyncCorrespondentsResource( async_correspondents: CorrespondentsResource, run: Any)
21    def __init__(self, async_correspondents: CorrespondentsResource, run: Any) -> None:
22        self._async_correspondents = async_correspondents
23        self._run = run
def list( self, *, ids: Optional[List[int]] = None, name_contains: str | None = None, name_exact: str | None = None, page: int | None = None, page_size: int | None = None, ordering: str | None = None, descending: bool = False) -> easypaperless.PagedResult[Correspondent]:
25    def list(
26        self,
27        *,
28        ids: List[int] | None = None,
29        name_contains: str | None = None,
30        name_exact: str | None = None,
31        page: int | None = None,
32        page_size: int | None = None,
33        ordering: str | None = None,
34        descending: bool = False,
35    ) -> PagedResult[Correspondent]:
36        """Return correspondents defined in paperless-ngx.
37
38        When ``page`` is ``None`` (the default), all pages are fetched
39        automatically and ``next`` / ``previous`` in the result are always
40        ``None``.  When ``page`` is set, only that page is fetched and
41        ``next`` / ``previous`` reflect the raw API values.
42
43        Args:
44            ids: Return only correspondents whose ID is in this list.
45            name_contains: Case-insensitive substring filter on name.
46            name_exact: Case-insensitive exact match on name.
47            page: Return only this specific page (1-based).
48            page_size: Number of results per page.
49            ordering: Field to sort by.
50            descending: When ``True``, reverses the sort direction.
51
52        Returns:
53            :class:`~easypaperless.models.paged_result.PagedResult` of
54            :class:`~easypaperless.models.correspondents.Correspondent` objects.
55        """
56        return cast(
57            PagedResult[Correspondent],
58            self._run(
59                self._async_correspondents.list(
60                    ids=ids,
61                    name_contains=name_contains,
62                    name_exact=name_exact,
63                    page=page,
64                    page_size=page_size,
65                    ordering=ordering,
66                    descending=descending,
67                )
68            ),
69        )

Return correspondents defined in paperless-ngx.

When page is None (the default), all pages are fetched automatically and next / previous in the result are always None. When page is set, only that page is fetched and next / previous reflect the raw API values.

Arguments:
  • ids: Return only correspondents whose ID is in this list.
  • name_contains: Case-insensitive substring filter on name.
  • name_exact: Case-insensitive exact match on name.
  • page: Return only this specific page (1-based).
  • page_size: Number of results per page.
  • ordering: Field to sort by.
  • descending: When True, reverses the sort direction.
Returns:

~easypaperless.models.paged_result.PagedResult of ~easypaperless.models.correspondents.Correspondent objects.

def get(self, id: int) -> easypaperless.Correspondent:
71    def get(self, id: int) -> Correspondent:
72        """Fetch a single correspondent by its ID.
73
74        Args:
75            id: Numeric correspondent ID.
76
77        Returns:
78            The :class:`~easypaperless.models.correspondents.Correspondent` with the given ID.
79
80        Raises:
81            ~easypaperless.exceptions.NotFoundError: If no correspondent exists with that ID.
82        """
83        return cast(Correspondent, self._run(self._async_correspondents.get(id)))

Fetch a single correspondent by its ID.

Arguments:
  • id: Numeric correspondent ID.
Returns:

The ~easypaperless.models.correspondents.Correspondent with the given ID.

Raises:
def create( self, *, name: str, match: str | easypaperless.Unset = UNSET, matching_algorithm: easypaperless.MatchingAlgorithm | easypaperless.Unset = UNSET, is_insensitive: bool = True, owner: int | None | easypaperless.Unset = UNSET, set_permissions: easypaperless.SetPermissions | None | easypaperless.Unset = UNSET) -> easypaperless.Correspondent:
 85    def create(
 86        self,
 87        *,
 88        name: str,
 89        match: str | Unset = UNSET,
 90        matching_algorithm: MatchingAlgorithm | Unset = UNSET,
 91        is_insensitive: bool = True,
 92        owner: int | None | Unset = UNSET,
 93        set_permissions: SetPermissions | None | Unset = UNSET,
 94    ) -> Correspondent:
 95        """Create a new correspondent.
 96
 97        Args:
 98            name: Correspondent name. Must be unique.
 99            match: Auto-matching pattern.
100            matching_algorithm: Controls how ``match`` is applied.
101                E.g. ``matching_algorithm=MatchingAlgorithm.REGEX`` for
102                regular-expression matching.
103            is_insensitive: When ``True``, ``match`` is case-insensitive.
104                Defaults to ``True``, matching the paperless-ngx API default.
105            owner: Numeric user ID to assign as owner.
106            set_permissions: Explicit view/change permission sets.
107                Pass ``None`` to create with empty permissions.
108
109        Returns:
110            The newly created :class:`~easypaperless.models.correspondents.Correspondent`.
111        """
112        return cast(
113            Correspondent,
114            self._run(
115                self._async_correspondents.create(
116                    name=name,
117                    match=match,
118                    matching_algorithm=matching_algorithm,
119                    is_insensitive=is_insensitive,
120                    owner=owner,
121                    set_permissions=set_permissions,
122                )
123            ),
124        )

Create a new correspondent.

Arguments:
  • name: Correspondent name. Must be unique.
  • match: Auto-matching pattern.
  • matching_algorithm: Controls how match is applied. E.g. matching_algorithm=MatchingAlgorithm.REGEX for regular-expression matching.
  • is_insensitive: When True, match is case-insensitive. Defaults to True, matching the paperless-ngx API default.
  • owner: Numeric user ID to assign as owner.
  • set_permissions: Explicit view/change permission sets. Pass None to create with empty permissions.
Returns:

The newly created ~easypaperless.models.correspondents.Correspondent.

def update( self, id: int, *, name: str | easypaperless.Unset = UNSET, match: str | easypaperless.Unset = UNSET, matching_algorithm: easypaperless.MatchingAlgorithm | easypaperless.Unset = UNSET, is_insensitive: bool | easypaperless.Unset = UNSET, owner: int | None | easypaperless.Unset = UNSET, set_permissions: easypaperless.SetPermissions | None | easypaperless.Unset = UNSET) -> easypaperless.Correspondent:
126    def update(
127        self,
128        id: int,
129        *,
130        name: str | Unset = UNSET,
131        match: str | Unset = UNSET,
132        matching_algorithm: MatchingAlgorithm | Unset = UNSET,
133        is_insensitive: bool | Unset = UNSET,
134        owner: int | None | Unset = UNSET,
135        set_permissions: SetPermissions | None | Unset = UNSET,
136    ) -> Correspondent:
137        """Partially update a correspondent (PATCH semantics).
138
139        Args:
140            id: Numeric ID of the correspondent to update.
141            name: Correspondent name.
142            match: Auto-matching pattern.
143            matching_algorithm: Controls how ``match`` is applied.
144                E.g. ``matching_algorithm=MatchingAlgorithm.REGEX`` for
145                regular-expression matching.
146            is_insensitive: When ``True``, ``match`` is case-insensitive.
147            owner: Numeric user ID to assign as owner.
148                Pass ``None`` to clear the owner.
149                Omit (or pass :data:`~easypaperless.UNSET`) to leave unchanged.
150            set_permissions: Explicit view/change permission sets.
151                Pass ``None`` to clear all permissions (overwrite with empty).
152                Omit (or pass :data:`~easypaperless.UNSET`) to leave unchanged.
153
154        Returns:
155            The updated :class:`~easypaperless.models.correspondents.Correspondent`.
156        """
157        return cast(
158            Correspondent,
159            self._run(
160                self._async_correspondents.update(
161                    id,
162                    name=name,
163                    match=match,
164                    matching_algorithm=matching_algorithm,
165                    is_insensitive=is_insensitive,
166                    owner=owner,
167                    set_permissions=set_permissions,
168                )
169            ),
170        )

Partially update a correspondent (PATCH semantics).

Arguments:
  • id: Numeric ID of the correspondent to update.
  • name: Correspondent name.
  • match: Auto-matching pattern.
  • matching_algorithm: Controls how match is applied. E.g. matching_algorithm=MatchingAlgorithm.REGEX for regular-expression matching.
  • is_insensitive: When True, match is case-insensitive.
  • owner: Numeric user ID to assign as owner. Pass None to clear the owner. Omit (or pass ~easypaperless.UNSET) to leave unchanged.
  • set_permissions: Explicit view/change permission sets. Pass None to clear all permissions (overwrite with empty). Omit (or pass ~easypaperless.UNSET) to leave unchanged.
Returns:

The updated ~easypaperless.models.correspondents.Correspondent.

def delete(self, id: int) -> None:
172    def delete(self, id: int) -> None:
173        """Delete a correspondent.
174
175        Args:
176            id: Numeric ID of the correspondent to delete.
177
178        Raises:
179            ~easypaperless.exceptions.NotFoundError: If no correspondent exists with that ID.
180        """
181        self._run(self._async_correspondents.delete(id))

Delete a correspondent.

Arguments:
  • id: Numeric ID of the correspondent to delete.
Raises:
def bulk_delete(self, ids: List[int]) -> None:
183    def bulk_delete(self, ids: List[int]) -> None:
184        """Permanently delete multiple correspondents in a single request.
185
186        Args:
187            ids: List of correspondent IDs to delete.
188        """
189        self._run(self._async_correspondents.bulk_delete(ids))

Permanently delete multiple correspondents in a single request.

Arguments:
  • ids: List of correspondent IDs to delete.
def bulk_set_permissions( self, ids: List[int], *, set_permissions: easypaperless.SetPermissions | easypaperless.Unset = UNSET, owner: int | None | easypaperless.Unset = UNSET, merge: bool = False) -> None:
191    def bulk_set_permissions(
192        self,
193        ids: List[int],
194        *,
195        set_permissions: SetPermissions | Unset = UNSET,
196        owner: int | None | Unset = UNSET,
197        merge: bool = False,
198    ) -> None:
199        """Set permissions and/or owner on multiple correspondents.
200
201        Args:
202            ids: List of correspondent IDs to modify.
203            set_permissions: Explicit view/change permission sets.
204                Omit (or pass :data:`~easypaperless.UNSET`) to leave unchanged.
205            owner: Numeric user ID to assign as owner.
206                Pass ``None`` to clear the owner.
207                Omit (or pass :data:`~easypaperless.UNSET`) to leave unchanged.
208            merge: When ``True``, new permissions are merged with existing ones.
209        """
210        self._run(
211            self._async_correspondents.bulk_set_permissions(
212                ids, set_permissions=set_permissions, owner=owner, merge=merge
213            )
214        )

Set permissions and/or owner on multiple correspondents.

Arguments:
  • ids: List of correspondent IDs to modify.
  • set_permissions: Explicit view/change permission sets. Omit (or pass ~easypaperless.UNSET) to leave unchanged.
  • owner: Numeric user ID to assign as owner. Pass None to clear the owner. Omit (or pass ~easypaperless.UNSET) to leave unchanged.
  • merge: When True, new permissions are merged with existing ones.
class SyncCustomFieldsResource:
 17class SyncCustomFieldsResource:
 18    """Sync accessor for custom fields: ``client.custom_fields``."""
 19
 20    def __init__(self, async_custom_fields: CustomFieldsResource, run: Any) -> None:
 21        self._async_custom_fields = async_custom_fields
 22        self._run = run
 23
 24    def list(
 25        self,
 26        *,
 27        name_contains: str | None = None,
 28        name_exact: str | None = None,
 29        page: int | None = None,
 30        page_size: int | None = None,
 31        ordering: str | None = None,
 32        descending: bool = False,
 33    ) -> PagedResult[CustomField]:
 34        """Return all custom fields defined in paperless-ngx.
 35
 36        When ``page`` is ``None`` (the default), all pages are fetched
 37        automatically and ``next`` / ``previous`` in the result are always
 38        ``None``.  When ``page`` is set, only that page is fetched and
 39        ``next`` / ``previous`` reflect the raw API values.
 40
 41        Args:
 42            name_contains: Case-insensitive substring filter on name.
 43            name_exact: Case-insensitive exact match on name.
 44            page: Return only this specific page (1-based).
 45            page_size: Number of results per page.
 46            ordering: Field to sort by.
 47            descending: When ``True``, reverses the sort direction.
 48
 49        Returns:
 50            :class:`~easypaperless.models.paged_result.PagedResult` of
 51            :class:`~easypaperless.models.custom_fields.CustomField` objects.
 52        """
 53        return cast(
 54            PagedResult[CustomField],
 55            self._run(
 56                self._async_custom_fields.list(
 57                    name_contains=name_contains,
 58                    name_exact=name_exact,
 59                    page=page,
 60                    page_size=page_size,
 61                    ordering=ordering,
 62                    descending=descending,
 63                )
 64            ),
 65        )
 66
 67    def get(self, id: int) -> CustomField:
 68        """Fetch a single custom field by its ID.
 69
 70        Args:
 71            id: Numeric custom-field ID.
 72
 73        Returns:
 74            The :class:`~easypaperless.models.custom_fields.CustomField` with the given ID.
 75
 76        Raises:
 77            ~easypaperless.exceptions.NotFoundError: If no custom field exists with that ID.
 78        """
 79        return cast(CustomField, self._run(self._async_custom_fields.get(id)))
 80
 81    def create(
 82        self,
 83        *,
 84        name: str,
 85        data_type: str,
 86        extra_data: Any | None = None,
 87        owner: int | None | Unset = UNSET,
 88        set_permissions: SetPermissions | None | Unset = UNSET,
 89    ) -> CustomField:
 90        """Create a new custom field.
 91
 92        Args:
 93            name: Field name shown in the UI. Must be unique.
 94            data_type: Value type. One of ``"string"``, ``"boolean"``,
 95                ``"integer"``, ``"float"``, ``"monetary"``, ``"date"``,
 96                ``"url"``, ``"documentlink"``, ``"select"``.
 97            extra_data: Additional configuration for the field type.
 98            owner: Numeric user ID to assign as owner.
 99            set_permissions: Explicit view/change permission sets.
100                Pass ``None`` to create with empty permissions.
101
102        Returns:
103            The newly created :class:`~easypaperless.models.custom_fields.CustomField`.
104        """
105        return cast(
106            CustomField,
107            self._run(
108                self._async_custom_fields.create(
109                    name=name,
110                    data_type=data_type,
111                    extra_data=extra_data,
112                    owner=owner,
113                    set_permissions=set_permissions,
114                )
115            ),
116        )
117
118    def update(
119        self,
120        id: int,
121        *,
122        name: str | Unset = UNSET,
123        data_type: str | Unset = UNSET,
124        extra_data: Any | None | Unset = UNSET,
125        owner: int | None | Unset = UNSET,
126        set_permissions: SetPermissions | None | Unset = UNSET,
127    ) -> CustomField:
128        """Partially update a custom field (PATCH semantics).
129
130        Args:
131            id: Numeric ID of the custom field to update.
132            name: Field name shown in the UI.
133            data_type: Value type (e.g. ``"string"``, ``"boolean"``, ``"integer"``).
134                Omit (or pass :data:`~easypaperless.UNSET`) to leave unchanged.
135            extra_data: Additional configuration for the field type.
136            owner: Numeric user ID to assign as owner.
137                Pass ``None`` to clear the owner.
138                Omit (or pass :data:`~easypaperless.UNSET`) to leave unchanged.
139            set_permissions: Explicit view/change permission sets.
140                Pass ``None`` to clear all permissions (overwrite with empty).
141                Omit (or pass :data:`~easypaperless.UNSET`) to leave unchanged.
142
143        Returns:
144            The updated :class:`~easypaperless.models.custom_fields.CustomField`.
145        """
146        return cast(
147            CustomField,
148            self._run(
149                self._async_custom_fields.update(
150                    id,
151                    name=name,
152                    data_type=data_type,
153                    extra_data=extra_data,
154                    owner=owner,
155                    set_permissions=set_permissions,
156                )
157            ),
158        )
159
160    def delete(self, id: int) -> None:
161        """Delete a custom field.
162
163        Args:
164            id: Numeric ID of the custom field to delete.
165
166        Raises:
167            ~easypaperless.exceptions.NotFoundError: If no custom field exists with that ID.
168        """
169        self._run(self._async_custom_fields.delete(id))

Sync accessor for custom fields: client.custom_fields.

SyncCustomFieldsResource( async_custom_fields: CustomFieldsResource, run: Any)
20    def __init__(self, async_custom_fields: CustomFieldsResource, run: Any) -> None:
21        self._async_custom_fields = async_custom_fields
22        self._run = run
def list( self, *, name_contains: str | None = None, name_exact: str | None = None, page: int | None = None, page_size: int | None = None, ordering: str | None = None, descending: bool = False) -> easypaperless.PagedResult[CustomField]:
24    def list(
25        self,
26        *,
27        name_contains: str | None = None,
28        name_exact: str | None = None,
29        page: int | None = None,
30        page_size: int | None = None,
31        ordering: str | None = None,
32        descending: bool = False,
33    ) -> PagedResult[CustomField]:
34        """Return all custom fields defined in paperless-ngx.
35
36        When ``page`` is ``None`` (the default), all pages are fetched
37        automatically and ``next`` / ``previous`` in the result are always
38        ``None``.  When ``page`` is set, only that page is fetched and
39        ``next`` / ``previous`` reflect the raw API values.
40
41        Args:
42            name_contains: Case-insensitive substring filter on name.
43            name_exact: Case-insensitive exact match on name.
44            page: Return only this specific page (1-based).
45            page_size: Number of results per page.
46            ordering: Field to sort by.
47            descending: When ``True``, reverses the sort direction.
48
49        Returns:
50            :class:`~easypaperless.models.paged_result.PagedResult` of
51            :class:`~easypaperless.models.custom_fields.CustomField` objects.
52        """
53        return cast(
54            PagedResult[CustomField],
55            self._run(
56                self._async_custom_fields.list(
57                    name_contains=name_contains,
58                    name_exact=name_exact,
59                    page=page,
60                    page_size=page_size,
61                    ordering=ordering,
62                    descending=descending,
63                )
64            ),
65        )

Return all custom fields defined in paperless-ngx.

When page is None (the default), all pages are fetched automatically and next / previous in the result are always None. When page is set, only that page is fetched and next / previous reflect the raw API values.

Arguments:
  • name_contains: Case-insensitive substring filter on name.
  • name_exact: Case-insensitive exact match on name.
  • page: Return only this specific page (1-based).
  • page_size: Number of results per page.
  • ordering: Field to sort by.
  • descending: When True, reverses the sort direction.
Returns:

~easypaperless.models.paged_result.PagedResult of ~easypaperless.models.custom_fields.CustomField objects.

def get(self, id: int) -> easypaperless.CustomField:
67    def get(self, id: int) -> CustomField:
68        """Fetch a single custom field by its ID.
69
70        Args:
71            id: Numeric custom-field ID.
72
73        Returns:
74            The :class:`~easypaperless.models.custom_fields.CustomField` with the given ID.
75
76        Raises:
77            ~easypaperless.exceptions.NotFoundError: If no custom field exists with that ID.
78        """
79        return cast(CustomField, self._run(self._async_custom_fields.get(id)))

Fetch a single custom field by its ID.

Arguments:
  • id: Numeric custom-field ID.
Returns:

The ~easypaperless.models.custom_fields.CustomField with the given ID.

Raises:
def create( self, *, name: str, data_type: str, extra_data: typing.Any | None = None, owner: int | None | easypaperless.Unset = UNSET, set_permissions: easypaperless.SetPermissions | None | easypaperless.Unset = UNSET) -> easypaperless.CustomField:
 81    def create(
 82        self,
 83        *,
 84        name: str,
 85        data_type: str,
 86        extra_data: Any | None = None,
 87        owner: int | None | Unset = UNSET,
 88        set_permissions: SetPermissions | None | Unset = UNSET,
 89    ) -> CustomField:
 90        """Create a new custom field.
 91
 92        Args:
 93            name: Field name shown in the UI. Must be unique.
 94            data_type: Value type. One of ``"string"``, ``"boolean"``,
 95                ``"integer"``, ``"float"``, ``"monetary"``, ``"date"``,
 96                ``"url"``, ``"documentlink"``, ``"select"``.
 97            extra_data: Additional configuration for the field type.
 98            owner: Numeric user ID to assign as owner.
 99            set_permissions: Explicit view/change permission sets.
100                Pass ``None`` to create with empty permissions.
101
102        Returns:
103            The newly created :class:`~easypaperless.models.custom_fields.CustomField`.
104        """
105        return cast(
106            CustomField,
107            self._run(
108                self._async_custom_fields.create(
109                    name=name,
110                    data_type=data_type,
111                    extra_data=extra_data,
112                    owner=owner,
113                    set_permissions=set_permissions,
114                )
115            ),
116        )

Create a new custom field.

Arguments:
  • name: Field name shown in the UI. Must be unique.
  • data_type: Value type. One of "string", "boolean", "integer", "float", "monetary", "date", "url", "documentlink", "select".
  • extra_data: Additional configuration for the field type.
  • owner: Numeric user ID to assign as owner.
  • set_permissions: Explicit view/change permission sets. Pass None to create with empty permissions.
Returns:

The newly created ~easypaperless.models.custom_fields.CustomField.

def update( self, id: int, *, name: str | easypaperless.Unset = UNSET, data_type: str | easypaperless.Unset = UNSET, extra_data: typing.Any | None | easypaperless.Unset = UNSET, owner: int | None | easypaperless.Unset = UNSET, set_permissions: easypaperless.SetPermissions | None | easypaperless.Unset = UNSET) -> easypaperless.CustomField:
118    def update(
119        self,
120        id: int,
121        *,
122        name: str | Unset = UNSET,
123        data_type: str | Unset = UNSET,
124        extra_data: Any | None | Unset = UNSET,
125        owner: int | None | Unset = UNSET,
126        set_permissions: SetPermissions | None | Unset = UNSET,
127    ) -> CustomField:
128        """Partially update a custom field (PATCH semantics).
129
130        Args:
131            id: Numeric ID of the custom field to update.
132            name: Field name shown in the UI.
133            data_type: Value type (e.g. ``"string"``, ``"boolean"``, ``"integer"``).
134                Omit (or pass :data:`~easypaperless.UNSET`) to leave unchanged.
135            extra_data: Additional configuration for the field type.
136            owner: Numeric user ID to assign as owner.
137                Pass ``None`` to clear the owner.
138                Omit (or pass :data:`~easypaperless.UNSET`) to leave unchanged.
139            set_permissions: Explicit view/change permission sets.
140                Pass ``None`` to clear all permissions (overwrite with empty).
141                Omit (or pass :data:`~easypaperless.UNSET`) to leave unchanged.
142
143        Returns:
144            The updated :class:`~easypaperless.models.custom_fields.CustomField`.
145        """
146        return cast(
147            CustomField,
148            self._run(
149                self._async_custom_fields.update(
150                    id,
151                    name=name,
152                    data_type=data_type,
153                    extra_data=extra_data,
154                    owner=owner,
155                    set_permissions=set_permissions,
156                )
157            ),
158        )

Partially update a custom field (PATCH semantics).

Arguments:
  • id: Numeric ID of the custom field to update.
  • name: Field name shown in the UI.
  • data_type: Value type (e.g. "string", "boolean", "integer"). Omit (or pass ~easypaperless.UNSET) to leave unchanged.
  • extra_data: Additional configuration for the field type.
  • owner: Numeric user ID to assign as owner. Pass None to clear the owner. Omit (or pass ~easypaperless.UNSET) to leave unchanged.
  • set_permissions: Explicit view/change permission sets. Pass None to clear all permissions (overwrite with empty). Omit (or pass ~easypaperless.UNSET) to leave unchanged.
Returns:

The updated ~easypaperless.models.custom_fields.CustomField.

def delete(self, id: int) -> None:
160    def delete(self, id: int) -> None:
161        """Delete a custom field.
162
163        Args:
164            id: Numeric ID of the custom field to delete.
165
166        Raises:
167            ~easypaperless.exceptions.NotFoundError: If no custom field exists with that ID.
168        """
169        self._run(self._async_custom_fields.delete(id))

Delete a custom field.

Arguments:
  • id: Numeric ID of the custom field to delete.
Raises:
class SyncDocumentTypesResource:
 18class SyncDocumentTypesResource:
 19    """Sync accessor for document types: ``client.document_types``."""
 20
 21    def __init__(self, async_document_types: DocumentTypesResource, run: Any) -> None:
 22        self._async_document_types = async_document_types
 23        self._run = run
 24
 25    def list(
 26        self,
 27        *,
 28        ids: List[int] | None = None,
 29        name_contains: str | None = None,
 30        name_exact: str | None = None,
 31        page: int | None = None,
 32        page_size: int | None = None,
 33        ordering: str | None = None,
 34        descending: bool = False,
 35    ) -> PagedResult[DocumentType]:
 36        """Return document types defined in paperless-ngx.
 37
 38        When ``page`` is ``None`` (the default), all pages are fetched
 39        automatically and ``next`` / ``previous`` in the result are always
 40        ``None``.  When ``page`` is set, only that page is fetched and
 41        ``next`` / ``previous`` reflect the raw API values.
 42
 43        Args:
 44            ids: Return only document types whose ID is in this list.
 45            name_contains: Case-insensitive substring filter on name.
 46            name_exact: Case-insensitive exact match on name.
 47            page: Return only this specific page (1-based).
 48            page_size: Number of results per page.
 49            ordering: Field to sort by.
 50            descending: When ``True``, reverses the sort direction.
 51
 52        Returns:
 53            :class:`~easypaperless.models.paged_result.PagedResult` of
 54            :class:`~easypaperless.models.document_types.DocumentType` objects.
 55        """
 56        return cast(
 57            PagedResult[DocumentType],
 58            self._run(
 59                self._async_document_types.list(
 60                    ids=ids,
 61                    name_contains=name_contains,
 62                    name_exact=name_exact,
 63                    page=page,
 64                    page_size=page_size,
 65                    ordering=ordering,
 66                    descending=descending,
 67                )
 68            ),
 69        )
 70
 71    def get(self, id: int) -> DocumentType:
 72        """Fetch a single document type by its ID.
 73
 74        Args:
 75            id: Numeric document-type ID.
 76
 77        Returns:
 78            The :class:`~easypaperless.models.document_types.DocumentType` with the given ID.
 79
 80        Raises:
 81            ~easypaperless.exceptions.NotFoundError: If no document type exists with that ID.
 82        """
 83        return cast(DocumentType, self._run(self._async_document_types.get(id)))
 84
 85    def create(
 86        self,
 87        *,
 88        name: str,
 89        match: str | Unset = UNSET,
 90        matching_algorithm: MatchingAlgorithm | Unset = UNSET,
 91        is_insensitive: bool = True,
 92        owner: int | None | Unset = UNSET,
 93        set_permissions: SetPermissions | None | Unset = UNSET,
 94    ) -> DocumentType:
 95        """Create a new document type.
 96
 97        Args:
 98            name: Document-type name. Must be unique.
 99            match: Auto-matching pattern.
100            matching_algorithm: Controls how ``match`` is applied.
101                E.g. ``matching_algorithm=MatchingAlgorithm.REGEX`` for
102                regular-expression matching.
103            is_insensitive: When ``True``, ``match`` is case-insensitive.
104                Defaults to ``True``, matching the paperless-ngx API default.
105            owner: Numeric user ID to assign as owner.
106            set_permissions: Explicit view/change permission sets.
107                Pass ``None`` to create with empty permissions.
108
109        Returns:
110            The newly created :class:`~easypaperless.models.document_types.DocumentType`.
111        """
112        return cast(
113            DocumentType,
114            self._run(
115                self._async_document_types.create(
116                    name=name,
117                    match=match,
118                    matching_algorithm=matching_algorithm,
119                    is_insensitive=is_insensitive,
120                    owner=owner,
121                    set_permissions=set_permissions,
122                )
123            ),
124        )
125
126    def update(
127        self,
128        id: int,
129        *,
130        name: str | Unset = UNSET,
131        match: str | Unset = UNSET,
132        matching_algorithm: MatchingAlgorithm | Unset = UNSET,
133        is_insensitive: bool | Unset = UNSET,
134        owner: int | None | Unset = UNSET,
135        set_permissions: SetPermissions | None | Unset = UNSET,
136    ) -> DocumentType:
137        """Partially update a document type (PATCH semantics).
138
139        Args:
140            id: Numeric ID of the document type to update.
141            name: Document-type name.
142            match: Auto-matching pattern.
143            matching_algorithm: Controls how ``match`` is applied.
144                E.g. ``matching_algorithm=MatchingAlgorithm.REGEX`` for
145                regular-expression matching.
146            is_insensitive: When ``True``, ``match`` is case-insensitive.
147            owner: Numeric user ID to assign as owner.
148                Pass ``None`` to clear the owner.
149                Omit (or pass :data:`~easypaperless.UNSET`) to leave unchanged.
150            set_permissions: Explicit view/change permission sets.
151                Pass ``None`` to clear all permissions (overwrite with empty).
152                Omit (or pass :data:`~easypaperless.UNSET`) to leave unchanged.
153
154        Returns:
155            The updated :class:`~easypaperless.models.document_types.DocumentType`.
156        """
157        return cast(
158            DocumentType,
159            self._run(
160                self._async_document_types.update(
161                    id,
162                    name=name,
163                    match=match,
164                    matching_algorithm=matching_algorithm,
165                    is_insensitive=is_insensitive,
166                    owner=owner,
167                    set_permissions=set_permissions,
168                )
169            ),
170        )
171
172    def delete(self, id: int) -> None:
173        """Delete a document type.
174
175        Args:
176            id: Numeric ID of the document type to delete.
177
178        Raises:
179            ~easypaperless.exceptions.NotFoundError: If no document type exists with that ID.
180        """
181        self._run(self._async_document_types.delete(id))
182
183    def bulk_delete(self, ids: List[int]) -> None:
184        """Permanently delete multiple document types in a single request.
185
186        Args:
187            ids: List of document type IDs to delete.
188        """
189        self._run(self._async_document_types.bulk_delete(ids))
190
191    def bulk_set_permissions(
192        self,
193        ids: List[int],
194        *,
195        set_permissions: SetPermissions | Unset = UNSET,
196        owner: int | None | Unset = UNSET,
197        merge: bool = False,
198    ) -> None:
199        """Set permissions and/or owner on multiple document types.
200
201        Args:
202            ids: List of document type IDs to modify.
203            set_permissions: Explicit view/change permission sets.
204                Omit (or pass :data:`~easypaperless.UNSET`) to leave unchanged.
205            owner: Numeric user ID to assign as owner.
206                Pass ``None`` to clear the owner.
207                Omit (or pass :data:`~easypaperless.UNSET`) to leave unchanged.
208            merge: When ``True``, new permissions are merged with existing ones.
209        """
210        self._run(
211            self._async_document_types.bulk_set_permissions(
212                ids, set_permissions=set_permissions, owner=owner, merge=merge
213            )
214        )

Sync accessor for document types: client.document_types.

SyncDocumentTypesResource( async_document_types: DocumentTypesResource, run: Any)
21    def __init__(self, async_document_types: DocumentTypesResource, run: Any) -> None:
22        self._async_document_types = async_document_types
23        self._run = run
def list( self, *, ids: Optional[List[int]] = None, name_contains: str | None = None, name_exact: str | None = None, page: int | None = None, page_size: int | None = None, ordering: str | None = None, descending: bool = False) -> easypaperless.PagedResult[DocumentType]:
25    def list(
26        self,
27        *,
28        ids: List[int] | None = None,
29        name_contains: str | None = None,
30        name_exact: str | None = None,
31        page: int | None = None,
32        page_size: int | None = None,
33        ordering: str | None = None,
34        descending: bool = False,
35    ) -> PagedResult[DocumentType]:
36        """Return document types defined in paperless-ngx.
37
38        When ``page`` is ``None`` (the default), all pages are fetched
39        automatically and ``next`` / ``previous`` in the result are always
40        ``None``.  When ``page`` is set, only that page is fetched and
41        ``next`` / ``previous`` reflect the raw API values.
42
43        Args:
44            ids: Return only document types whose ID is in this list.
45            name_contains: Case-insensitive substring filter on name.
46            name_exact: Case-insensitive exact match on name.
47            page: Return only this specific page (1-based).
48            page_size: Number of results per page.
49            ordering: Field to sort by.
50            descending: When ``True``, reverses the sort direction.
51
52        Returns:
53            :class:`~easypaperless.models.paged_result.PagedResult` of
54            :class:`~easypaperless.models.document_types.DocumentType` objects.
55        """
56        return cast(
57            PagedResult[DocumentType],
58            self._run(
59                self._async_document_types.list(
60                    ids=ids,
61                    name_contains=name_contains,
62                    name_exact=name_exact,
63                    page=page,
64                    page_size=page_size,
65                    ordering=ordering,
66                    descending=descending,
67                )
68            ),
69        )

Return document types defined in paperless-ngx.

When page is None (the default), all pages are fetched automatically and next / previous in the result are always None. When page is set, only that page is fetched and next / previous reflect the raw API values.

Arguments:
  • ids: Return only document types whose ID is in this list.
  • name_contains: Case-insensitive substring filter on name.
  • name_exact: Case-insensitive exact match on name.
  • page: Return only this specific page (1-based).
  • page_size: Number of results per page.
  • ordering: Field to sort by.
  • descending: When True, reverses the sort direction.
Returns:

~easypaperless.models.paged_result.PagedResult of ~easypaperless.models.document_types.DocumentType objects.

def get(self, id: int) -> easypaperless.DocumentType:
71    def get(self, id: int) -> DocumentType:
72        """Fetch a single document type by its ID.
73
74        Args:
75            id: Numeric document-type ID.
76
77        Returns:
78            The :class:`~easypaperless.models.document_types.DocumentType` with the given ID.
79
80        Raises:
81            ~easypaperless.exceptions.NotFoundError: If no document type exists with that ID.
82        """
83        return cast(DocumentType, self._run(self._async_document_types.get(id)))

Fetch a single document type by its ID.

Arguments:
  • id: Numeric document-type ID.
Returns:

The ~easypaperless.models.document_types.DocumentType with the given ID.

Raises:
def create( self, *, name: str, match: str | easypaperless.Unset = UNSET, matching_algorithm: easypaperless.MatchingAlgorithm | easypaperless.Unset = UNSET, is_insensitive: bool = True, owner: int | None | easypaperless.Unset = UNSET, set_permissions: easypaperless.SetPermissions | None | easypaperless.Unset = UNSET) -> easypaperless.DocumentType:
 85    def create(
 86        self,
 87        *,
 88        name: str,
 89        match: str | Unset = UNSET,
 90        matching_algorithm: MatchingAlgorithm | Unset = UNSET,
 91        is_insensitive: bool = True,
 92        owner: int | None | Unset = UNSET,
 93        set_permissions: SetPermissions | None | Unset = UNSET,
 94    ) -> DocumentType:
 95        """Create a new document type.
 96
 97        Args:
 98            name: Document-type name. Must be unique.
 99            match: Auto-matching pattern.
100            matching_algorithm: Controls how ``match`` is applied.
101                E.g. ``matching_algorithm=MatchingAlgorithm.REGEX`` for
102                regular-expression matching.
103            is_insensitive: When ``True``, ``match`` is case-insensitive.
104                Defaults to ``True``, matching the paperless-ngx API default.
105            owner: Numeric user ID to assign as owner.
106            set_permissions: Explicit view/change permission sets.
107                Pass ``None`` to create with empty permissions.
108
109        Returns:
110            The newly created :class:`~easypaperless.models.document_types.DocumentType`.
111        """
112        return cast(
113            DocumentType,
114            self._run(
115                self._async_document_types.create(
116                    name=name,
117                    match=match,
118                    matching_algorithm=matching_algorithm,
119                    is_insensitive=is_insensitive,
120                    owner=owner,
121                    set_permissions=set_permissions,
122                )
123            ),
124        )

Create a new document type.

Arguments:
  • name: Document-type name. Must be unique.
  • match: Auto-matching pattern.
  • matching_algorithm: Controls how match is applied. E.g. matching_algorithm=MatchingAlgorithm.REGEX for regular-expression matching.
  • is_insensitive: When True, match is case-insensitive. Defaults to True, matching the paperless-ngx API default.
  • owner: Numeric user ID to assign as owner.
  • set_permissions: Explicit view/change permission sets. Pass None to create with empty permissions.
Returns:

The newly created ~easypaperless.models.document_types.DocumentType.

def update( self, id: int, *, name: str | easypaperless.Unset = UNSET, match: str | easypaperless.Unset = UNSET, matching_algorithm: easypaperless.MatchingAlgorithm | easypaperless.Unset = UNSET, is_insensitive: bool | easypaperless.Unset = UNSET, owner: int | None | easypaperless.Unset = UNSET, set_permissions: easypaperless.SetPermissions | None | easypaperless.Unset = UNSET) -> easypaperless.DocumentType:
126    def update(
127        self,
128        id: int,
129        *,
130        name: str | Unset = UNSET,
131        match: str | Unset = UNSET,
132        matching_algorithm: MatchingAlgorithm | Unset = UNSET,
133        is_insensitive: bool | Unset = UNSET,
134        owner: int | None | Unset = UNSET,
135        set_permissions: SetPermissions | None | Unset = UNSET,
136    ) -> DocumentType:
137        """Partially update a document type (PATCH semantics).
138
139        Args:
140            id: Numeric ID of the document type to update.
141            name: Document-type name.
142            match: Auto-matching pattern.
143            matching_algorithm: Controls how ``match`` is applied.
144                E.g. ``matching_algorithm=MatchingAlgorithm.REGEX`` for
145                regular-expression matching.
146            is_insensitive: When ``True``, ``match`` is case-insensitive.
147            owner: Numeric user ID to assign as owner.
148                Pass ``None`` to clear the owner.
149                Omit (or pass :data:`~easypaperless.UNSET`) to leave unchanged.
150            set_permissions: Explicit view/change permission sets.
151                Pass ``None`` to clear all permissions (overwrite with empty).
152                Omit (or pass :data:`~easypaperless.UNSET`) to leave unchanged.
153
154        Returns:
155            The updated :class:`~easypaperless.models.document_types.DocumentType`.
156        """
157        return cast(
158            DocumentType,
159            self._run(
160                self._async_document_types.update(
161                    id,
162                    name=name,
163                    match=match,
164                    matching_algorithm=matching_algorithm,
165                    is_insensitive=is_insensitive,
166                    owner=owner,
167                    set_permissions=set_permissions,
168                )
169            ),
170        )

Partially update a document type (PATCH semantics).

Arguments:
  • id: Numeric ID of the document type to update.
  • name: Document-type name.
  • match: Auto-matching pattern.
  • matching_algorithm: Controls how match is applied. E.g. matching_algorithm=MatchingAlgorithm.REGEX for regular-expression matching.
  • is_insensitive: When True, match is case-insensitive.
  • owner: Numeric user ID to assign as owner. Pass None to clear the owner. Omit (or pass ~easypaperless.UNSET) to leave unchanged.
  • set_permissions: Explicit view/change permission sets. Pass None to clear all permissions (overwrite with empty). Omit (or pass ~easypaperless.UNSET) to leave unchanged.
Returns:

The updated ~easypaperless.models.document_types.DocumentType.

def delete(self, id: int) -> None:
172    def delete(self, id: int) -> None:
173        """Delete a document type.
174
175        Args:
176            id: Numeric ID of the document type to delete.
177
178        Raises:
179            ~easypaperless.exceptions.NotFoundError: If no document type exists with that ID.
180        """
181        self._run(self._async_document_types.delete(id))

Delete a document type.

Arguments:
  • id: Numeric ID of the document type to delete.
Raises:
def bulk_delete(self, ids: List[int]) -> None:
183    def bulk_delete(self, ids: List[int]) -> None:
184        """Permanently delete multiple document types in a single request.
185
186        Args:
187            ids: List of document type IDs to delete.
188        """
189        self._run(self._async_document_types.bulk_delete(ids))

Permanently delete multiple document types in a single request.

Arguments:
  • ids: List of document type IDs to delete.
def bulk_set_permissions( self, ids: List[int], *, set_permissions: easypaperless.SetPermissions | easypaperless.Unset = UNSET, owner: int | None | easypaperless.Unset = UNSET, merge: bool = False) -> None:
191    def bulk_set_permissions(
192        self,
193        ids: List[int],
194        *,
195        set_permissions: SetPermissions | Unset = UNSET,
196        owner: int | None | Unset = UNSET,
197        merge: bool = False,
198    ) -> None:
199        """Set permissions and/or owner on multiple document types.
200
201        Args:
202            ids: List of document type IDs to modify.
203            set_permissions: Explicit view/change permission sets.
204                Omit (or pass :data:`~easypaperless.UNSET`) to leave unchanged.
205            owner: Numeric user ID to assign as owner.
206                Pass ``None`` to clear the owner.
207                Omit (or pass :data:`~easypaperless.UNSET`) to leave unchanged.
208            merge: When ``True``, new permissions are merged with existing ones.
209        """
210        self._run(
211            self._async_document_types.bulk_set_permissions(
212                ids, set_permissions=set_permissions, owner=owner, merge=merge
213            )
214        )

Set permissions and/or owner on multiple document types.

Arguments:
  • ids: List of document type IDs to modify.
  • set_permissions: Explicit view/change permission sets. Omit (or pass ~easypaperless.UNSET) to leave unchanged.
  • owner: Numeric user ID to assign as owner. Pass None to clear the owner. Omit (or pass ~easypaperless.UNSET) to leave unchanged.
  • merge: When True, new permissions are merged with existing ones.
class SyncDocumentsResource:
 23class SyncDocumentsResource:
 24    """Sync accessor for documents: ``client.documents``."""
 25
 26    def __init__(self, async_documents: DocumentsResource, run: Any) -> None:
 27        self._async_documents = async_documents
 28        self._run = run
 29        self.notes = SyncNotesResource(async_documents.notes, run)
 30
 31    def history(
 32        self,
 33        document_id: int,
 34        *,
 35        page: int | None = None,
 36        page_size: int | None = None,
 37    ) -> PagedResult[AuditLogEntry]:
 38        """Fetch the audit log for a document.
 39
 40        The paperless-ngx ``/api/documents/{id}/history/`` endpoint returns a
 41        plain JSON array rather than a paginated envelope.  This method wraps
 42        the response into a :class:`~easypaperless.models.paged_result.PagedResult`
 43        so callers always receive a consistent return type.
 44
 45        Args:
 46            document_id: Numeric ID of the document whose history to retrieve.
 47            page: Forwarded to the API as a query parameter when provided.
 48                Effect depends on the paperless-ngx version; the server may
 49                ignore this parameter.
 50            page_size: Forwarded to the API as a query parameter when provided.
 51
 52        Returns:
 53            :class:`~easypaperless.models.paged_result.PagedResult` of
 54            :class:`~easypaperless.models.documents.AuditLogEntry` objects,
 55            ordered by timestamp descending.
 56
 57        Raises:
 58            ~easypaperless.exceptions.NotFoundError: If no document exists
 59                with that ID.
 60        """
 61        return cast(
 62            PagedResult[AuditLogEntry],
 63            self._run(self._async_documents.history(document_id, page=page, page_size=page_size)),
 64        )
 65
 66    def get(self, id: int, *, include_metadata: bool = False) -> Document:
 67        """Fetch a single document by its ID.
 68
 69        Args:
 70            id: Numeric paperless-ngx document ID.
 71            include_metadata: When ``True``, the extended file-level metadata
 72                is fetched concurrently and attached to the document.
 73                Default: ``False``.
 74
 75        Returns:
 76            The :class:`~easypaperless.models.documents.Document` with the
 77            given ID.
 78
 79        Raises:
 80            ~easypaperless.exceptions.NotFoundError: If no document exists
 81                with that ID.
 82        """
 83        return cast(
 84            Document, self._run(self._async_documents.get(id, include_metadata=include_metadata))
 85        )
 86
 87    def get_metadata(self, id: int) -> DocumentMetadata:
 88        """Fetch the extended file-level metadata for a document.
 89
 90        Args:
 91            id: Numeric paperless-ngx document ID.
 92
 93        Returns:
 94            A :class:`~easypaperless.models.documents.DocumentMetadata` instance.
 95
 96        Raises:
 97            ~easypaperless.exceptions.NotFoundError: If no document exists
 98                with that ID.
 99        """
100        return cast(DocumentMetadata, self._run(self._async_documents.get_metadata(id)))
101
102    def list(
103        self,
104        *,
105        search: str | None = None,
106        search_mode: str = "title_or_content",
107        ids: List[int] | None = None,
108        tags: List[int | str] | None = None,
109        any_tags: List[int | str] | None = None,
110        exclude_tags: List[int | str] | None = None,
111        correspondent: int | str | None | Unset = UNSET,
112        any_correspondent: List[int | str] | None = None,
113        exclude_correspondents: List[int | str] | None = None,
114        document_type: int | str | None | Unset = UNSET,
115        document_type_name_contains: str | None = None,
116        document_type_name_exact: str | None = None,
117        any_document_type: List[int | str] | None = None,
118        exclude_document_types: List[int | str] | None = None,
119        storage_path: int | str | None | Unset = UNSET,
120        any_storage_paths: List[int | str] | None = None,
121        exclude_storage_paths: List[int | str] | None = None,
122        owner: int | None | Unset = UNSET,
123        exclude_owners: List[int] | None = None,
124        custom_fields: List[int | str] | None = None,
125        any_custom_fields: List[int | str] | None = None,
126        exclude_custom_fields: List[int | str] | None = None,
127        custom_field_query: List[Any] | None = None,
128        archive_serial_number: int | None | Unset = UNSET,
129        archive_serial_number_from: int | None = None,
130        archive_serial_number_till: int | None = None,
131        created_after: date | str | None = None,
132        created_before: date | str | None = None,
133        added_after: date | datetime | str | None = None,
134        added_from: date | datetime | str | None = None,
135        added_before: date | datetime | str | None = None,
136        added_until: date | datetime | str | None = None,
137        modified_after: date | datetime | str | None = None,
138        modified_from: date | datetime | str | None = None,
139        modified_before: date | datetime | str | None = None,
140        modified_until: date | datetime | str | None = None,
141        checksum: str | None = None,
142        page_size: int = 25,
143        page: int | None = None,
144        ordering: str | None = None,
145        descending: bool = False,
146        max_results: int | None = None,
147        on_page: Callable[[int, int | None], None] | None = None,
148    ) -> PagedResult[Document]:
149        """Return a filtered list of documents.
150
151        All tag, correspondent, document-type, storage-path, and custom-field
152        parameters accept either integer IDs or string names.
153
154        When ``page`` is ``None`` (the default), all pages are fetched
155        automatically and ``next`` / ``previous`` in the returned
156        :class:`~easypaperless.models.paged_result.PagedResult` are always
157        ``None`` — even if ``max_results`` truncates the final result set.
158        ``count`` always reflects the server total, not the truncated length.
159        When ``page`` is set to a specific integer, only that one page is
160        fetched and ``next`` / ``previous`` contain the raw API values.
161
162        Args:
163            search: Search string.  Behaviour depends on ``search_mode``.
164            search_mode: How ``search`` is applied.  One of:
165                ``"title_or_content"`` *(default)*, ``"title"``, ``"query"``,
166                ``"original_filename"``.
167            ids: Return only documents whose ID is in this list.
168            tags: Documents must have **all** of these tags (AND semantics).
169            any_tags: Documents must have **at least one** of these tags.
170            exclude_tags: Documents must have **none** of these tags.
171            correspondent: Filter to documents assigned to this correspondent.
172                Pass ``None`` to return only documents with no correspondent set.
173            any_correspondent: Filter to documents assigned to any of these.
174            exclude_correspondents: Exclude documents assigned to any of these.
175            document_type: Filter to documents of exactly this type.
176                Pass ``None`` to return only documents with no document type set.
177            document_type_name_contains: Case-insensitive substring filter on document type name.
178            document_type_name_exact: Case-insensitive exact match on document type name.
179            any_document_type: Filter to documents whose type is any of these.
180            exclude_document_types: Exclude documents whose type is any of these.
181            storage_path: Filter to documents assigned to this storage path.
182                Pass ``None`` to return only documents with no storage path set.
183            any_storage_paths: Filter to documents assigned to any of these paths.
184            exclude_storage_paths: Exclude documents assigned to any of these paths.
185            owner: Filter to documents owned by this user ID.
186                Pass ``None`` to return only documents with no owner set.
187            exclude_owners: Exclude documents owned by any of these user IDs.
188            custom_fields: Documents must have **all** of these custom fields set.
189            any_custom_fields: Documents must have **at least one** of these fields.
190            exclude_custom_fields: Documents must have **none** of these fields.
191            custom_field_query: Filter documents by custom field values using a nested
192                query structure. See the `paperless-ngx API docs
193                <https://docs.paperless-ngx.com/api/#filtering-by-custom-fields>`_ for
194                the query format.
195            archive_serial_number: Filter by exact archive serial number.
196                Pass ``None`` to return only documents with no ASN set.
197            archive_serial_number_from: Filter by ASN >= this value.
198            archive_serial_number_till: Filter by ASN <= this value.
199            created_after: Only documents created after this date.
200                String input must be ISO-8601: ``"YYYY-MM-DD"``.
201            created_before: Only documents created before this date.
202                String input must be ISO-8601: ``"YYYY-MM-DD"``.
203            added_after: Only documents added after this date/time.
204                String input must be ISO-8601: ``"YYYY-MM-DD"`` for date precision or
205                ``"YYYY-MM-DDTHH:MM:SS"`` for datetime precision.
206            added_from: Only documents added on or after this date/time.
207                String input must be ISO-8601: ``"YYYY-MM-DD"`` or ``"YYYY-MM-DDTHH:MM:SS"``.
208            added_before: Only documents added before this date/time.
209                String input must be ISO-8601: ``"YYYY-MM-DD"`` or ``"YYYY-MM-DDTHH:MM:SS"``.
210            added_until: Only documents added on or before this date/time.
211                String input must be ISO-8601: ``"YYYY-MM-DD"`` or ``"YYYY-MM-DDTHH:MM:SS"``.
212            modified_after: Only documents modified after this date/time.
213                String input must be ISO-8601: ``"YYYY-MM-DD"`` or ``"YYYY-MM-DDTHH:MM:SS"``.
214            modified_from: Only documents modified on or after this date/time.
215                String input must be ISO-8601: ``"YYYY-MM-DD"`` or ``"YYYY-MM-DDTHH:MM:SS"``.
216            modified_before: Only documents modified before this date/time.
217                String input must be ISO-8601: ``"YYYY-MM-DD"`` or ``"YYYY-MM-DDTHH:MM:SS"``.
218            modified_until: Only documents modified on or before this date/time.
219                String input must be ISO-8601: ``"YYYY-MM-DD"`` or ``"YYYY-MM-DDTHH:MM:SS"``.
220            checksum: MD5 checksum (hex) of the original uploaded file, matched
221                exactly but case-insensitively (sent as ``checksum__iexact``).
222                Documents in the trash are **not** found, yet paperless-ngx
223                still rejects a re-upload of the same file as a duplicate.  To
224                detect that case, catch the
225                :exc:`~easypaperless.exceptions.UploadError` of
226                ``upload(wait=True)`` (or of ``tasks.wait()``): ``err.task.result``
227                contains ``": It is a duplicate of "`` and ends in
228                ``"Note: existing document is in the trash."``, and
229                ``err.task.related_document`` is ``None`` (for a live duplicate
230                it is the existing document's ID).  ``client.trash.list()``
231                shows the trashed document; ``client.trash.restore()`` brings
232                it back.
233            page_size: Number of results per API page.  Default: ``25``.
234            page: Return only this specific page (1-based).
235            ordering: Field name to sort by.
236            descending: When ``True``, reverses the sort direction.
237            max_results: Stop after collecting this many documents.
238            on_page: Callback invoked after each page fetch.
239
240        Returns:
241            :class:`~easypaperless.models.paged_result.PagedResult` of
242            :class:`~easypaperless.models.documents.Document` objects.
243        """
244        return cast(
245            PagedResult[Document],
246            self._run(
247                self._async_documents.list(
248                    search=search,
249                    search_mode=search_mode,
250                    ids=ids,
251                    tags=tags,
252                    any_tags=any_tags,
253                    exclude_tags=exclude_tags,
254                    correspondent=correspondent,
255                    any_correspondent=any_correspondent,
256                    exclude_correspondents=exclude_correspondents,
257                    document_type=document_type,
258                    document_type_name_contains=document_type_name_contains,
259                    document_type_name_exact=document_type_name_exact,
260                    any_document_type=any_document_type,
261                    exclude_document_types=exclude_document_types,
262                    storage_path=storage_path,
263                    any_storage_paths=any_storage_paths,
264                    exclude_storage_paths=exclude_storage_paths,
265                    owner=owner,
266                    exclude_owners=exclude_owners,
267                    custom_fields=custom_fields,
268                    any_custom_fields=any_custom_fields,
269                    exclude_custom_fields=exclude_custom_fields,
270                    custom_field_query=custom_field_query,
271                    archive_serial_number=archive_serial_number,
272                    archive_serial_number_from=archive_serial_number_from,
273                    archive_serial_number_till=archive_serial_number_till,
274                    created_after=created_after,
275                    created_before=created_before,
276                    added_after=added_after,
277                    added_from=added_from,
278                    added_before=added_before,
279                    added_until=added_until,
280                    modified_after=modified_after,
281                    modified_from=modified_from,
282                    modified_before=modified_before,
283                    modified_until=modified_until,
284                    checksum=checksum,
285                    page_size=page_size,
286                    page=page,
287                    ordering=ordering,
288                    descending=descending,
289                    max_results=max_results,
290                    on_page=on_page,
291                )
292            ),
293        )
294
295    def update(
296        self,
297        id: int,
298        *,
299        title: str | Unset = UNSET,
300        content: str | Unset = UNSET,
301        created: date | str | None | Unset = UNSET,
302        correspondent: int | str | None | Unset = UNSET,
303        document_type: int | str | None | Unset = UNSET,
304        storage_path: int | str | None | Unset = UNSET,
305        tags: List[int | str] | None | Unset = UNSET,
306        archive_serial_number: int | None | Unset = UNSET,
307        custom_fields: List[dict[str, Any]] | None | Unset = UNSET,
308        owner: int | None | Unset = UNSET,
309        set_permissions: SetPermissions | None | Unset = UNSET,
310        remove_inbox_tags: bool | None | Unset = UNSET,
311    ) -> Document:
312        """Partially update a document (PATCH semantics).
313
314        Args:
315            id: Numeric ID of the document to update.
316            title: New document title.
317            content: OCR text content of the document.
318            created: Creation date as an ISO-8601 string (``"YYYY-MM-DD"``) or a
319                :class:`~datetime.date` object.
320            correspondent: Correspondent to assign, as an ID or name.
321                Pass ``None`` to clear the correspondent.
322            document_type: Document type to assign, as an ID or name.
323                Pass ``None`` to clear the document type.
324            storage_path: Storage path to assign, as an ID or name.
325                Pass ``None`` to clear the storage path.
326            tags: Full replacement list of tags (IDs or names).
327            archive_serial_number: Archive serial number to assign.
328                Pass ``None`` to clear the archive serial number.
329            custom_fields: List of ``{"field": <field_id>, "value": ...}`` dicts.
330            owner: Numeric user ID to assign as document owner.
331                Pass ``None`` to clear the owner.
332            set_permissions: Explicit view/change permission sets.
333                Pass ``None`` to clear all permissions (overwrite with empty).
334                Omit (or pass :data:`~easypaperless.UNSET`) to leave unchanged.
335                The given sets replace the document's current view and change
336                users and groups.  Together with ``owner`` everything goes out
337                in one PATCH, which paperless-ngx applies as a whole.
338            remove_inbox_tags: When ``True``, removes all inbox tags from the document.
339
340        Returns:
341            The updated :class:`~easypaperless.models.documents.Document`.
342        """
343        return cast(
344            Document,
345            self._run(
346                self._async_documents.update(
347                    id,
348                    title=title,
349                    content=content,
350                    created=created,
351                    correspondent=correspondent,
352                    document_type=document_type,
353                    storage_path=storage_path,
354                    tags=tags,
355                    archive_serial_number=archive_serial_number,
356                    custom_fields=custom_fields,
357                    owner=owner,
358                    set_permissions=set_permissions,
359                    remove_inbox_tags=remove_inbox_tags,
360                )
361            ),
362        )
363
364    def delete(self, id: int) -> None:
365        """Permanently delete a document.
366
367        Args:
368            id: Numeric ID of the document to delete.
369
370        Raises:
371            ~easypaperless.exceptions.NotFoundError: If no document exists
372                with that ID.
373        """
374        self._run(self._async_documents.delete(id))
375
376    def download(self, id: int, *, original: bool = False) -> bytes:
377        """Download the binary content of a document.
378
379        Args:
380            id: Numeric ID of the document to download.
381            original: If ``False`` *(default)*, returns the archived PDF
382                (``GET /documents/{id}/download/``).
383                If ``True``, returns the original uploaded file
384                (``GET /documents/{id}/download/?original=true``).
385
386        Returns:
387            Raw file bytes.
388        """
389        return cast(bytes, self._run(self._async_documents.download(id, original=original)))
390
391    def thumbnail(self, id: int) -> bytes:
392        """Fetch the thumbnail image of a document.
393
394        Args:
395            id: Numeric ID of the document whose thumbnail to retrieve.
396
397        Returns:
398            Raw binary content of the thumbnail image.
399
400        Raises:
401            ~easypaperless.exceptions.NotFoundError: If no document exists
402                with that ID.
403            ~easypaperless.exceptions.ServerResponseError: If the server returns an
404                HTML page (e.g. an auth redirect) instead of the image.
405        """
406        return cast(bytes, self._run(self._async_documents.thumbnail(id)))
407
408    def upload(
409        self,
410        file: str | Path | bytes,
411        *,
412        filename: str | None = None,
413        content_type: str | None = None,
414        request_timeout: float | None = None,
415        title: str | Unset = UNSET,
416        created: date | str | None = None,
417        correspondent: int | str | None | Unset = UNSET,
418        document_type: int | str | None | Unset = UNSET,
419        storage_path: int | str | None | Unset = UNSET,
420        tags: List[int | str] | None = None,
421        archive_serial_number: int | None | Unset = UNSET,
422        custom_fields: List[dict[str, Any]] | None = None,
423        wait: bool = False,
424        poll_interval: float | None = None,
425        poll_timeout: float | None = None,
426    ) -> str | Document:
427        """Upload a document to paperless-ngx.
428
429        The upload request is never retried automatically, whatever the
430        client's ``retry_attempts`` / ``tenacity_retrying`` settings: if the
431        connection fails after paperless-ngx has accepted the file, a retry
432        would create a duplicate.  A failed upload raises (e.g.
433        :exc:`~easypaperless.exceptions.TransportTimeoutError`) so you can
434        decide whether to check for the document and upload again.
435
436        Args:
437            file: Path to the file to upload (``str`` or :class:`~pathlib.Path`),
438                or the file content as ``bytes``.  Bytes are sent directly; no
439                temporary file is written.
440            filename: File name sent to paperless-ngx.  Required when *file* is
441                ``bytes`` (omitting it raises
442                :exc:`~easypaperless.exceptions.ValidationError` before any
443                request).  For a path, overrides the name taken from the path.
444            content_type: MIME type of the file part, sent as given (e.g.
445                ``"application/pdf"``).  When omitted, it is guessed from the
446                file name as before.  paperless-ngx detects the file type from
447                the bytes and does not rely on this value to accept the file.
448            request_timeout: HTTP timeout in seconds for the upload request
449                only, overriding the client's ``timeout`` for this call.  Does
450                not affect task polling (see ``poll_timeout``).  When omitted,
451                the client's ``timeout`` applies.
452            title: Title to assign to the document.
453            created: Creation date as an ISO-8601 string (``"YYYY-MM-DD"``) or a
454                :class:`~datetime.date` object.
455            correspondent: Correspondent to assign, as an ID or name.
456            document_type: Document type to assign, as an ID or name.
457            storage_path: Storage path to assign, as an ID or name.
458            tags: Tags to assign, as IDs or names.
459            archive_serial_number: Archive serial number to assign.
460            custom_fields: List of ``{"field": <field_id>, "value": ...}`` dicts.
461            wait: If ``False`` *(default)*, returns immediately with the task ID.
462                If ``True``, polls until processing completes.
463            poll_interval: Seconds between task-status checks while waiting for
464                processing to complete (requires ``wait=True``). Overrides the
465                client-level default. When omitted, falls back to the client-level
466                ``poll_interval`` (``2.0`` s unless changed at construction).
467            poll_timeout: Maximum seconds to wait before raising
468                :exc:`~easypaperless.exceptions.TaskTimeoutError` (requires
469                ``wait=True``). Overrides the client-level default. When omitted,
470                falls back to the client-level ``poll_timeout`` (``60.0`` s unless
471                changed at construction).
472
473        Returns:
474            The Celery task ID string when ``wait=False``, or the fully
475            processed :class:`~easypaperless.models.documents.Document`
476            when ``wait=True``.
477
478        Raises:
479            ~easypaperless.exceptions.ValidationError: If *file* is ``bytes``
480                and no *filename* is given.
481            ~easypaperless.exceptions.BadRequestError: If paperless-ngx rejects
482                the file before processing starts, e.g. an unsupported file
483                type or an empty file (``err.field_errors["document"]``).
484            ~easypaperless.exceptions.UploadError: If processing fails;
485                ``err.task`` holds the task with paperless-ngx's ``result``
486                unaltered.  For a duplicate, ``err.task.result`` contains
487                ``": It is a duplicate of "`` and ``err.task.related_document``
488                is the existing document's ID (``None`` if that document is
489                in the trash).
490            ~easypaperless.exceptions.TaskTimeoutError: If timeout is exceeded;
491                resume with ``client.tasks.wait(err.task_id)``.
492        """
493        return cast(
494            str | Document,
495            self._run(
496                self._async_documents.upload(
497                    file,
498                    filename=filename,
499                    content_type=content_type,
500                    request_timeout=request_timeout,
501                    title=title,
502                    created=created,
503                    correspondent=correspondent,
504                    document_type=document_type,
505                    storage_path=storage_path,
506                    tags=tags,
507                    archive_serial_number=archive_serial_number,
508                    custom_fields=custom_fields,
509                    wait=wait,
510                    poll_interval=poll_interval,
511                    poll_timeout=poll_timeout,
512                )
513            ),
514        )
515
516    def bulk_add_tag(self, document_ids: List[int], tag: int | str) -> None:
517        """Add a tag to multiple documents in a single request.
518
519        Args:
520            document_ids: List of document IDs to tag.
521            tag: Tag to add, as an ID or name.
522        """
523        self._run(self._async_documents.bulk_add_tag(document_ids, tag))
524
525    def bulk_remove_tag(self, document_ids: List[int], tag: int | str) -> None:
526        """Remove a tag from multiple documents in a single request.
527
528        Args:
529            document_ids: List of document IDs to un-tag.
530            tag: Tag to remove, as an ID or name.
531        """
532        self._run(self._async_documents.bulk_remove_tag(document_ids, tag))
533
534    def bulk_modify_tags(
535        self,
536        document_ids: List[int],
537        *,
538        add_tags: List[int | str] | None = None,
539        remove_tags: List[int | str] | None = None,
540    ) -> None:
541        """Add and/or remove tags on multiple documents atomically.
542
543        Args:
544            document_ids: List of document IDs to modify.
545            add_tags: Tags to add, as IDs or names.
546            remove_tags: Tags to remove, as IDs or names.
547        """
548        self._run(
549            self._async_documents.bulk_modify_tags(
550                document_ids, add_tags=add_tags, remove_tags=remove_tags
551            )
552        )
553
554    def bulk_delete(self, document_ids: List[int]) -> None:
555        """Permanently delete multiple documents in a single request.
556
557        Args:
558            document_ids: List of document IDs to delete.
559        """
560        self._run(self._async_documents.bulk_delete(document_ids))
561
562    def bulk_set_correspondent(
563        self, document_ids: List[int], correspondent: int | str | None
564    ) -> None:
565        """Assign a correspondent to multiple documents in a single request.
566
567        Args:
568            document_ids: List of document IDs to modify.
569            correspondent: Correspondent to assign, as an ID or name.
570                Pass ``None`` to clear.
571        """
572        self._run(self._async_documents.bulk_set_correspondent(document_ids, correspondent))
573
574    def bulk_set_document_type(
575        self, document_ids: List[int], document_type: int | str | None
576    ) -> None:
577        """Assign a document type to multiple documents in a single request.
578
579        Args:
580            document_ids: List of document IDs to modify.
581            document_type: Document type to assign, as an ID or name.
582                Pass ``None`` to clear.
583        """
584        self._run(self._async_documents.bulk_set_document_type(document_ids, document_type))
585
586    def bulk_set_storage_path(
587        self, document_ids: List[int], storage_path: int | str | None
588    ) -> None:
589        """Assign a storage path to multiple documents in a single request.
590
591        Args:
592            document_ids: List of document IDs to modify.
593            storage_path: Storage path to assign, as an ID or name.
594                Pass ``None`` to clear.
595        """
596        self._run(self._async_documents.bulk_set_storage_path(document_ids, storage_path))
597
598    def bulk_modify_custom_fields(
599        self,
600        document_ids: List[int],
601        *,
602        add_fields: List[dict[str, Any]] | None = None,
603        remove_fields: List[int] | None = None,
604    ) -> None:
605        """Add and/or remove custom field values on multiple documents.
606
607        Args:
608            document_ids: List of document IDs to modify.
609            add_fields: Custom-field value dicts to add.
610            remove_fields: Custom-field IDs whose values should be removed.
611        """
612        self._run(
613            self._async_documents.bulk_modify_custom_fields(
614                document_ids, add_fields=add_fields, remove_fields=remove_fields
615            )
616        )
617
618    def bulk_set_permissions(
619        self,
620        document_ids: List[int],
621        *,
622        set_permissions: SetPermissions | Unset = UNSET,
623        owner: int | None | Unset = UNSET,
624        merge: bool = False,
625    ) -> None:
626        """Set permissions and/or owner on multiple documents.
627
628        Args:
629            document_ids: List of document IDs to modify.
630            set_permissions: Explicit view/change permission sets.
631                Omit (or pass :data:`~easypaperless.UNSET`) to leave unchanged.
632            owner: Numeric user ID to assign as document owner.
633                Pass ``None`` to clear the owner.
634                Omit (or pass :data:`~easypaperless.UNSET`) to leave unchanged.
635            merge: When ``True``, new permissions are merged with existing ones.
636        """
637        self._run(
638            self._async_documents.bulk_set_permissions(
639                document_ids,
640                set_permissions=set_permissions,
641                owner=owner,
642                merge=merge,
643            )
644        )
645
646    def bulk_download(
647        self,
648        document_ids: List[int],
649        *,
650        content: Literal["archive", "originals", "both"] = "archive",
651        compression: Literal["none", "deflated", "bzip2", "lzma"] = "none",
652        follow_formatting: bool = False,
653    ) -> bytes:
654        """Download multiple documents as a single ZIP archive.
655
656        Args:
657            document_ids: List of document IDs to include in the ZIP.
658            content: File variant to include.  One of ``"archive"`` *(default)*,
659                ``"originals"``, or ``"both"``.
660            compression: ZIP compression algorithm.  One of ``"none"`` *(default)*,
661                ``"deflated"``, ``"bzip2"``, or ``"lzma"``.
662            follow_formatting: When ``True``, filenames inside the ZIP follow
663                the storage path formatting configured in paperless-ngx.
664                Default: ``False``.
665
666        Returns:
667            Raw bytes of the ZIP archive.
668        """
669        return cast(
670            bytes,
671            self._run(
672                self._async_documents.bulk_download(
673                    document_ids,
674                    content=content,
675                    compression=compression,
676                    follow_formatting=follow_formatting,
677                )
678            ),
679        )

Sync accessor for documents: client.documents.

SyncDocumentsResource( async_documents: DocumentsResource, run: Any)
26    def __init__(self, async_documents: DocumentsResource, run: Any) -> None:
27        self._async_documents = async_documents
28        self._run = run
29        self.notes = SyncNotesResource(async_documents.notes, run)
notes
def history( self, document_id: int, *, page: int | None = None, page_size: int | None = None) -> easypaperless.PagedResult[AuditLogEntry]:
31    def history(
32        self,
33        document_id: int,
34        *,
35        page: int | None = None,
36        page_size: int | None = None,
37    ) -> PagedResult[AuditLogEntry]:
38        """Fetch the audit log for a document.
39
40        The paperless-ngx ``/api/documents/{id}/history/`` endpoint returns a
41        plain JSON array rather than a paginated envelope.  This method wraps
42        the response into a :class:`~easypaperless.models.paged_result.PagedResult`
43        so callers always receive a consistent return type.
44
45        Args:
46            document_id: Numeric ID of the document whose history to retrieve.
47            page: Forwarded to the API as a query parameter when provided.
48                Effect depends on the paperless-ngx version; the server may
49                ignore this parameter.
50            page_size: Forwarded to the API as a query parameter when provided.
51
52        Returns:
53            :class:`~easypaperless.models.paged_result.PagedResult` of
54            :class:`~easypaperless.models.documents.AuditLogEntry` objects,
55            ordered by timestamp descending.
56
57        Raises:
58            ~easypaperless.exceptions.NotFoundError: If no document exists
59                with that ID.
60        """
61        return cast(
62            PagedResult[AuditLogEntry],
63            self._run(self._async_documents.history(document_id, page=page, page_size=page_size)),
64        )

Fetch the audit log for a document.

The paperless-ngx /api/documents/{id}/history/ endpoint returns a plain JSON array rather than a paginated envelope. This method wraps the response into a ~easypaperless.models.paged_result.PagedResult so callers always receive a consistent return type.

Arguments:
  • document_id: Numeric ID of the document whose history to retrieve.
  • page: Forwarded to the API as a query parameter when provided. Effect depends on the paperless-ngx version; the server may ignore this parameter.
  • page_size: Forwarded to the API as a query parameter when provided.
Returns:

~easypaperless.models.paged_result.PagedResult of ~easypaperless.models.documents.AuditLogEntry objects, ordered by timestamp descending.

Raises:
def get( self, id: int, *, include_metadata: bool = False) -> easypaperless.Document:
66    def get(self, id: int, *, include_metadata: bool = False) -> Document:
67        """Fetch a single document by its ID.
68
69        Args:
70            id: Numeric paperless-ngx document ID.
71            include_metadata: When ``True``, the extended file-level metadata
72                is fetched concurrently and attached to the document.
73                Default: ``False``.
74
75        Returns:
76            The :class:`~easypaperless.models.documents.Document` with the
77            given ID.
78
79        Raises:
80            ~easypaperless.exceptions.NotFoundError: If no document exists
81                with that ID.
82        """
83        return cast(
84            Document, self._run(self._async_documents.get(id, include_metadata=include_metadata))
85        )

Fetch a single document by its ID.

Arguments:
  • id: Numeric paperless-ngx document ID.
  • include_metadata: When True, the extended file-level metadata is fetched concurrently and attached to the document. Default: False.
Returns:

The ~easypaperless.models.documents.Document with the given ID.

Raises:
def get_metadata(self, id: int) -> easypaperless.DocumentMetadata:
 87    def get_metadata(self, id: int) -> DocumentMetadata:
 88        """Fetch the extended file-level metadata for a document.
 89
 90        Args:
 91            id: Numeric paperless-ngx document ID.
 92
 93        Returns:
 94            A :class:`~easypaperless.models.documents.DocumentMetadata` instance.
 95
 96        Raises:
 97            ~easypaperless.exceptions.NotFoundError: If no document exists
 98                with that ID.
 99        """
100        return cast(DocumentMetadata, self._run(self._async_documents.get_metadata(id)))

Fetch the extended file-level metadata for a document.

Arguments:
  • id: Numeric paperless-ngx document ID.
Returns:

A ~easypaperless.models.documents.DocumentMetadata instance.

Raises:
def list( self, *, search: str | None = None, search_mode: str = 'title_or_content', ids: Optional[List[int]] = None, tags: Optional[List[Union[str, int]]] = None, any_tags: Optional[List[Union[str, int]]] = None, exclude_tags: Optional[List[Union[str, int]]] = None, correspondent: int | str | None | easypaperless.Unset = UNSET, any_correspondent: Optional[List[Union[str, int]]] = None, exclude_correspondents: Optional[List[Union[str, int]]] = None, document_type: int | str | None | easypaperless.Unset = UNSET, document_type_name_contains: str | None = None, document_type_name_exact: str | None = None, any_document_type: Optional[List[Union[str, int]]] = None, exclude_document_types: Optional[List[Union[str, int]]] = None, storage_path: int | str | None | easypaperless.Unset = UNSET, any_storage_paths: Optional[List[Union[str, int]]] = None, exclude_storage_paths: Optional[List[Union[str, int]]] = None, owner: int | None | easypaperless.Unset = UNSET, exclude_owners: Optional[List[int]] = None, custom_fields: Optional[List[Union[str, int]]] = None, any_custom_fields: Optional[List[Union[str, int]]] = None, exclude_custom_fields: Optional[List[Union[str, int]]] = None, custom_field_query: Optional[List[Any]] = None, archive_serial_number: int | None | easypaperless.Unset = UNSET, archive_serial_number_from: int | None = None, archive_serial_number_till: int | None = None, created_after: datetime.date | str | None = None, created_before: datetime.date | str | None = None, added_after: datetime.date | datetime.datetime | str | None = None, added_from: datetime.date | datetime.datetime | str | None = None, added_before: datetime.date | datetime.datetime | str | None = None, added_until: datetime.date | datetime.datetime | str | None = None, modified_after: datetime.date | datetime.datetime | str | None = None, modified_from: datetime.date | datetime.datetime | str | None = None, modified_before: datetime.date | datetime.datetime | str | None = None, modified_until: datetime.date | datetime.datetime | str | None = None, checksum: str | None = None, page_size: int = 25, page: int | None = None, ordering: str | None = None, descending: bool = False, max_results: int | None = None, on_page: Callable[[int, int | None], None] | None = None) -> easypaperless.PagedResult[Document]:
102    def list(
103        self,
104        *,
105        search: str | None = None,
106        search_mode: str = "title_or_content",
107        ids: List[int] | None = None,
108        tags: List[int | str] | None = None,
109        any_tags: List[int | str] | None = None,
110        exclude_tags: List[int | str] | None = None,
111        correspondent: int | str | None | Unset = UNSET,
112        any_correspondent: List[int | str] | None = None,
113        exclude_correspondents: List[int | str] | None = None,
114        document_type: int | str | None | Unset = UNSET,
115        document_type_name_contains: str | None = None,
116        document_type_name_exact: str | None = None,
117        any_document_type: List[int | str] | None = None,
118        exclude_document_types: List[int | str] | None = None,
119        storage_path: int | str | None | Unset = UNSET,
120        any_storage_paths: List[int | str] | None = None,
121        exclude_storage_paths: List[int | str] | None = None,
122        owner: int | None | Unset = UNSET,
123        exclude_owners: List[int] | None = None,
124        custom_fields: List[int | str] | None = None,
125        any_custom_fields: List[int | str] | None = None,
126        exclude_custom_fields: List[int | str] | None = None,
127        custom_field_query: List[Any] | None = None,
128        archive_serial_number: int | None | Unset = UNSET,
129        archive_serial_number_from: int | None = None,
130        archive_serial_number_till: int | None = None,
131        created_after: date | str | None = None,
132        created_before: date | str | None = None,
133        added_after: date | datetime | str | None = None,
134        added_from: date | datetime | str | None = None,
135        added_before: date | datetime | str | None = None,
136        added_until: date | datetime | str | None = None,
137        modified_after: date | datetime | str | None = None,
138        modified_from: date | datetime | str | None = None,
139        modified_before: date | datetime | str | None = None,
140        modified_until: date | datetime | str | None = None,
141        checksum: str | None = None,
142        page_size: int = 25,
143        page: int | None = None,
144        ordering: str | None = None,
145        descending: bool = False,
146        max_results: int | None = None,
147        on_page: Callable[[int, int | None], None] | None = None,
148    ) -> PagedResult[Document]:
149        """Return a filtered list of documents.
150
151        All tag, correspondent, document-type, storage-path, and custom-field
152        parameters accept either integer IDs or string names.
153
154        When ``page`` is ``None`` (the default), all pages are fetched
155        automatically and ``next`` / ``previous`` in the returned
156        :class:`~easypaperless.models.paged_result.PagedResult` are always
157        ``None`` — even if ``max_results`` truncates the final result set.
158        ``count`` always reflects the server total, not the truncated length.
159        When ``page`` is set to a specific integer, only that one page is
160        fetched and ``next`` / ``previous`` contain the raw API values.
161
162        Args:
163            search: Search string.  Behaviour depends on ``search_mode``.
164            search_mode: How ``search`` is applied.  One of:
165                ``"title_or_content"`` *(default)*, ``"title"``, ``"query"``,
166                ``"original_filename"``.
167            ids: Return only documents whose ID is in this list.
168            tags: Documents must have **all** of these tags (AND semantics).
169            any_tags: Documents must have **at least one** of these tags.
170            exclude_tags: Documents must have **none** of these tags.
171            correspondent: Filter to documents assigned to this correspondent.
172                Pass ``None`` to return only documents with no correspondent set.
173            any_correspondent: Filter to documents assigned to any of these.
174            exclude_correspondents: Exclude documents assigned to any of these.
175            document_type: Filter to documents of exactly this type.
176                Pass ``None`` to return only documents with no document type set.
177            document_type_name_contains: Case-insensitive substring filter on document type name.
178            document_type_name_exact: Case-insensitive exact match on document type name.
179            any_document_type: Filter to documents whose type is any of these.
180            exclude_document_types: Exclude documents whose type is any of these.
181            storage_path: Filter to documents assigned to this storage path.
182                Pass ``None`` to return only documents with no storage path set.
183            any_storage_paths: Filter to documents assigned to any of these paths.
184            exclude_storage_paths: Exclude documents assigned to any of these paths.
185            owner: Filter to documents owned by this user ID.
186                Pass ``None`` to return only documents with no owner set.
187            exclude_owners: Exclude documents owned by any of these user IDs.
188            custom_fields: Documents must have **all** of these custom fields set.
189            any_custom_fields: Documents must have **at least one** of these fields.
190            exclude_custom_fields: Documents must have **none** of these fields.
191            custom_field_query: Filter documents by custom field values using a nested
192                query structure. See the `paperless-ngx API docs
193                <https://docs.paperless-ngx.com/api/#filtering-by-custom-fields>`_ for
194                the query format.
195            archive_serial_number: Filter by exact archive serial number.
196                Pass ``None`` to return only documents with no ASN set.
197            archive_serial_number_from: Filter by ASN >= this value.
198            archive_serial_number_till: Filter by ASN <= this value.
199            created_after: Only documents created after this date.
200                String input must be ISO-8601: ``"YYYY-MM-DD"``.
201            created_before: Only documents created before this date.
202                String input must be ISO-8601: ``"YYYY-MM-DD"``.
203            added_after: Only documents added after this date/time.
204                String input must be ISO-8601: ``"YYYY-MM-DD"`` for date precision or
205                ``"YYYY-MM-DDTHH:MM:SS"`` for datetime precision.
206            added_from: Only documents added on or after this date/time.
207                String input must be ISO-8601: ``"YYYY-MM-DD"`` or ``"YYYY-MM-DDTHH:MM:SS"``.
208            added_before: Only documents added before this date/time.
209                String input must be ISO-8601: ``"YYYY-MM-DD"`` or ``"YYYY-MM-DDTHH:MM:SS"``.
210            added_until: Only documents added on or before this date/time.
211                String input must be ISO-8601: ``"YYYY-MM-DD"`` or ``"YYYY-MM-DDTHH:MM:SS"``.
212            modified_after: Only documents modified after this date/time.
213                String input must be ISO-8601: ``"YYYY-MM-DD"`` or ``"YYYY-MM-DDTHH:MM:SS"``.
214            modified_from: Only documents modified on or after this date/time.
215                String input must be ISO-8601: ``"YYYY-MM-DD"`` or ``"YYYY-MM-DDTHH:MM:SS"``.
216            modified_before: Only documents modified before this date/time.
217                String input must be ISO-8601: ``"YYYY-MM-DD"`` or ``"YYYY-MM-DDTHH:MM:SS"``.
218            modified_until: Only documents modified on or before this date/time.
219                String input must be ISO-8601: ``"YYYY-MM-DD"`` or ``"YYYY-MM-DDTHH:MM:SS"``.
220            checksum: MD5 checksum (hex) of the original uploaded file, matched
221                exactly but case-insensitively (sent as ``checksum__iexact``).
222                Documents in the trash are **not** found, yet paperless-ngx
223                still rejects a re-upload of the same file as a duplicate.  To
224                detect that case, catch the
225                :exc:`~easypaperless.exceptions.UploadError` of
226                ``upload(wait=True)`` (or of ``tasks.wait()``): ``err.task.result``
227                contains ``": It is a duplicate of "`` and ends in
228                ``"Note: existing document is in the trash."``, and
229                ``err.task.related_document`` is ``None`` (for a live duplicate
230                it is the existing document's ID).  ``client.trash.list()``
231                shows the trashed document; ``client.trash.restore()`` brings
232                it back.
233            page_size: Number of results per API page.  Default: ``25``.
234            page: Return only this specific page (1-based).
235            ordering: Field name to sort by.
236            descending: When ``True``, reverses the sort direction.
237            max_results: Stop after collecting this many documents.
238            on_page: Callback invoked after each page fetch.
239
240        Returns:
241            :class:`~easypaperless.models.paged_result.PagedResult` of
242            :class:`~easypaperless.models.documents.Document` objects.
243        """
244        return cast(
245            PagedResult[Document],
246            self._run(
247                self._async_documents.list(
248                    search=search,
249                    search_mode=search_mode,
250                    ids=ids,
251                    tags=tags,
252                    any_tags=any_tags,
253                    exclude_tags=exclude_tags,
254                    correspondent=correspondent,
255                    any_correspondent=any_correspondent,
256                    exclude_correspondents=exclude_correspondents,
257                    document_type=document_type,
258                    document_type_name_contains=document_type_name_contains,
259                    document_type_name_exact=document_type_name_exact,
260                    any_document_type=any_document_type,
261                    exclude_document_types=exclude_document_types,
262                    storage_path=storage_path,
263                    any_storage_paths=any_storage_paths,
264                    exclude_storage_paths=exclude_storage_paths,
265                    owner=owner,
266                    exclude_owners=exclude_owners,
267                    custom_fields=custom_fields,
268                    any_custom_fields=any_custom_fields,
269                    exclude_custom_fields=exclude_custom_fields,
270                    custom_field_query=custom_field_query,
271                    archive_serial_number=archive_serial_number,
272                    archive_serial_number_from=archive_serial_number_from,
273                    archive_serial_number_till=archive_serial_number_till,
274                    created_after=created_after,
275                    created_before=created_before,
276                    added_after=added_after,
277                    added_from=added_from,
278                    added_before=added_before,
279                    added_until=added_until,
280                    modified_after=modified_after,
281                    modified_from=modified_from,
282                    modified_before=modified_before,
283                    modified_until=modified_until,
284                    checksum=checksum,
285                    page_size=page_size,
286                    page=page,
287                    ordering=ordering,
288                    descending=descending,
289                    max_results=max_results,
290                    on_page=on_page,
291                )
292            ),
293        )

Return a filtered list of documents.

All tag, correspondent, document-type, storage-path, and custom-field parameters accept either integer IDs or string names.

When page is None (the default), all pages are fetched automatically and next / previous in the returned ~easypaperless.models.paged_result.PagedResult are always None — even if max_results truncates the final result set. count always reflects the server total, not the truncated length. When page is set to a specific integer, only that one page is fetched and next / previous contain the raw API values.

Arguments:
  • search: Search string. Behaviour depends on search_mode.
  • search_mode: How search is applied. One of: "title_or_content" (default), "title", "query", "original_filename".
  • ids: Return only documents whose ID is in this list.
  • tags: Documents must have all of these tags (AND semantics).
  • any_tags: Documents must have at least one of these tags.
  • exclude_tags: Documents must have none of these tags.
  • correspondent: Filter to documents assigned to this correspondent. Pass None to return only documents with no correspondent set.
  • any_correspondent: Filter to documents assigned to any of these.
  • exclude_correspondents: Exclude documents assigned to any of these.
  • document_type: Filter to documents of exactly this type. Pass None to return only documents with no document type set.
  • document_type_name_contains: Case-insensitive substring filter on document type name.
  • document_type_name_exact: Case-insensitive exact match on document type name.
  • any_document_type: Filter to documents whose type is any of these.
  • exclude_document_types: Exclude documents whose type is any of these.
  • storage_path: Filter to documents assigned to this storage path. Pass None to return only documents with no storage path set.
  • any_storage_paths: Filter to documents assigned to any of these paths.
  • exclude_storage_paths: Exclude documents assigned to any of these paths.
  • owner: Filter to documents owned by this user ID. Pass None to return only documents with no owner set.
  • exclude_owners: Exclude documents owned by any of these user IDs.
  • custom_fields: Documents must have all of these custom fields set.
  • any_custom_fields: Documents must have at least one of these fields.
  • exclude_custom_fields: Documents must have none of these fields.
  • custom_field_query: Filter documents by custom field values using a nested query structure. See the paperless-ngx API docs for the query format.
  • archive_serial_number: Filter by exact archive serial number. Pass None to return only documents with no ASN set.
  • archive_serial_number_from: Filter by ASN >= this value.
  • archive_serial_number_till: Filter by ASN <= this value.
  • created_after: Only documents created after this date. String input must be ISO-8601: "YYYY-MM-DD".
  • created_before: Only documents created before this date. String input must be ISO-8601: "YYYY-MM-DD".
  • added_after: Only documents added after this date/time. String input must be ISO-8601: "YYYY-MM-DD" for date precision or "YYYY-MM-DDTHH:MM:SS" for datetime precision.
  • added_from: Only documents added on or after this date/time. String input must be ISO-8601: "YYYY-MM-DD" or "YYYY-MM-DDTHH:MM:SS".
  • added_before: Only documents added before this date/time. String input must be ISO-8601: "YYYY-MM-DD" or "YYYY-MM-DDTHH:MM:SS".
  • added_until: Only documents added on or before this date/time. String input must be ISO-8601: "YYYY-MM-DD" or "YYYY-MM-DDTHH:MM:SS".
  • modified_after: Only documents modified after this date/time. String input must be ISO-8601: "YYYY-MM-DD" or "YYYY-MM-DDTHH:MM:SS".
  • modified_from: Only documents modified on or after this date/time. String input must be ISO-8601: "YYYY-MM-DD" or "YYYY-MM-DDTHH:MM:SS".
  • modified_before: Only documents modified before this date/time. String input must be ISO-8601: "YYYY-MM-DD" or "YYYY-MM-DDTHH:MM:SS".
  • modified_until: Only documents modified on or before this date/time. String input must be ISO-8601: "YYYY-MM-DD" or "YYYY-MM-DDTHH:MM:SS".
  • checksum: MD5 checksum (hex) of the original uploaded file, matched exactly but case-insensitively (sent as checksum__iexact). Documents in the trash are not found, yet paperless-ngx still rejects a re-upload of the same file as a duplicate. To detect that case, catch the ~easypaperless.exceptions.UploadError of upload(wait=True) (or of tasks.wait()): err.task.result contains ": It is a duplicate of " and ends in "Note: existing document is in the trash.", and err.task.related_document is None (for a live duplicate it is the existing document's ID). client.trash.list() shows the trashed document; client.trash.restore() brings it back.
  • page_size: Number of results per API page. Default: 25.
  • page: Return only this specific page (1-based).
  • ordering: Field name to sort by.
  • descending: When True, reverses the sort direction.
  • max_results: Stop after collecting this many documents.
  • on_page: Callback invoked after each page fetch.
Returns:

~easypaperless.models.paged_result.PagedResult of ~easypaperless.models.documents.Document objects.

def update( self, id: int, *, title: str | easypaperless.Unset = UNSET, content: str | easypaperless.Unset = UNSET, created: datetime.date | str | None | easypaperless.Unset = UNSET, correspondent: int | str | None | easypaperless.Unset = UNSET, document_type: int | str | None | easypaperless.Unset = UNSET, storage_path: int | str | None | easypaperless.Unset = UNSET, tags: Union[List[Union[str, int]], NoneType, easypaperless.Unset] = UNSET, archive_serial_number: int | None | easypaperless.Unset = UNSET, custom_fields: Union[List[dict[str, Any]], NoneType, easypaperless.Unset] = UNSET, owner: int | None | easypaperless.Unset = UNSET, set_permissions: easypaperless.SetPermissions | None | easypaperless.Unset = UNSET, remove_inbox_tags: bool | None | easypaperless.Unset = UNSET) -> easypaperless.Document:
295    def update(
296        self,
297        id: int,
298        *,
299        title: str | Unset = UNSET,
300        content: str | Unset = UNSET,
301        created: date | str | None | Unset = UNSET,
302        correspondent: int | str | None | Unset = UNSET,
303        document_type: int | str | None | Unset = UNSET,
304        storage_path: int | str | None | Unset = UNSET,
305        tags: List[int | str] | None | Unset = UNSET,
306        archive_serial_number: int | None | Unset = UNSET,
307        custom_fields: List[dict[str, Any]] | None | Unset = UNSET,
308        owner: int | None | Unset = UNSET,
309        set_permissions: SetPermissions | None | Unset = UNSET,
310        remove_inbox_tags: bool | None | Unset = UNSET,
311    ) -> Document:
312        """Partially update a document (PATCH semantics).
313
314        Args:
315            id: Numeric ID of the document to update.
316            title: New document title.
317            content: OCR text content of the document.
318            created: Creation date as an ISO-8601 string (``"YYYY-MM-DD"``) or a
319                :class:`~datetime.date` object.
320            correspondent: Correspondent to assign, as an ID or name.
321                Pass ``None`` to clear the correspondent.
322            document_type: Document type to assign, as an ID or name.
323                Pass ``None`` to clear the document type.
324            storage_path: Storage path to assign, as an ID or name.
325                Pass ``None`` to clear the storage path.
326            tags: Full replacement list of tags (IDs or names).
327            archive_serial_number: Archive serial number to assign.
328                Pass ``None`` to clear the archive serial number.
329            custom_fields: List of ``{"field": <field_id>, "value": ...}`` dicts.
330            owner: Numeric user ID to assign as document owner.
331                Pass ``None`` to clear the owner.
332            set_permissions: Explicit view/change permission sets.
333                Pass ``None`` to clear all permissions (overwrite with empty).
334                Omit (or pass :data:`~easypaperless.UNSET`) to leave unchanged.
335                The given sets replace the document's current view and change
336                users and groups.  Together with ``owner`` everything goes out
337                in one PATCH, which paperless-ngx applies as a whole.
338            remove_inbox_tags: When ``True``, removes all inbox tags from the document.
339
340        Returns:
341            The updated :class:`~easypaperless.models.documents.Document`.
342        """
343        return cast(
344            Document,
345            self._run(
346                self._async_documents.update(
347                    id,
348                    title=title,
349                    content=content,
350                    created=created,
351                    correspondent=correspondent,
352                    document_type=document_type,
353                    storage_path=storage_path,
354                    tags=tags,
355                    archive_serial_number=archive_serial_number,
356                    custom_fields=custom_fields,
357                    owner=owner,
358                    set_permissions=set_permissions,
359                    remove_inbox_tags=remove_inbox_tags,
360                )
361            ),
362        )

Partially update a document (PATCH semantics).

Arguments:
  • id: Numeric ID of the document to update.
  • title: New document title.
  • content: OCR text content of the document.
  • created: Creation date as an ISO-8601 string ("YYYY-MM-DD") or a ~datetime.date object.
  • correspondent: Correspondent to assign, as an ID or name. Pass None to clear the correspondent.
  • document_type: Document type to assign, as an ID or name. Pass None to clear the document type.
  • storage_path: Storage path to assign, as an ID or name. Pass None to clear the storage path.
  • tags: Full replacement list of tags (IDs or names).
  • archive_serial_number: Archive serial number to assign. Pass None to clear the archive serial number.
  • custom_fields: List of {"field": <field_id>, "value": ...} dicts.
  • owner: Numeric user ID to assign as document owner. Pass None to clear the owner.
  • set_permissions: Explicit view/change permission sets. Pass None to clear all permissions (overwrite with empty). Omit (or pass ~easypaperless.UNSET) to leave unchanged. The given sets replace the document's current view and change users and groups. Together with owner everything goes out in one PATCH, which paperless-ngx applies as a whole.
  • remove_inbox_tags: When True, removes all inbox tags from the document.
Returns:

The updated ~easypaperless.models.documents.Document.

def delete(self, id: int) -> None:
364    def delete(self, id: int) -> None:
365        """Permanently delete a document.
366
367        Args:
368            id: Numeric ID of the document to delete.
369
370        Raises:
371            ~easypaperless.exceptions.NotFoundError: If no document exists
372                with that ID.
373        """
374        self._run(self._async_documents.delete(id))

Permanently delete a document.

Arguments:
  • id: Numeric ID of the document to delete.
Raises:
def download(self, id: int, *, original: bool = False) -> bytes:
376    def download(self, id: int, *, original: bool = False) -> bytes:
377        """Download the binary content of a document.
378
379        Args:
380            id: Numeric ID of the document to download.
381            original: If ``False`` *(default)*, returns the archived PDF
382                (``GET /documents/{id}/download/``).
383                If ``True``, returns the original uploaded file
384                (``GET /documents/{id}/download/?original=true``).
385
386        Returns:
387            Raw file bytes.
388        """
389        return cast(bytes, self._run(self._async_documents.download(id, original=original)))

Download the binary content of a document.

Arguments:
  • id: Numeric ID of the document to download.
  • original: If False (default), returns the archived PDF (GET /documents/{id}/download/). If True, returns the original uploaded file (GET /documents/{id}/download/?original=true).
Returns:

Raw file bytes.

def thumbnail(self, id: int) -> bytes:
391    def thumbnail(self, id: int) -> bytes:
392        """Fetch the thumbnail image of a document.
393
394        Args:
395            id: Numeric ID of the document whose thumbnail to retrieve.
396
397        Returns:
398            Raw binary content of the thumbnail image.
399
400        Raises:
401            ~easypaperless.exceptions.NotFoundError: If no document exists
402                with that ID.
403            ~easypaperless.exceptions.ServerResponseError: If the server returns an
404                HTML page (e.g. an auth redirect) instead of the image.
405        """
406        return cast(bytes, self._run(self._async_documents.thumbnail(id)))

Fetch the thumbnail image of a document.

Arguments:
  • id: Numeric ID of the document whose thumbnail to retrieve.
Returns:

Raw binary content of the thumbnail image.

Raises:
def upload( self, file: str | pathlib._local.Path | bytes, *, filename: str | None = None, content_type: str | None = None, request_timeout: float | None = None, title: str | easypaperless.Unset = UNSET, created: datetime.date | str | None = None, correspondent: int | str | None | easypaperless.Unset = UNSET, document_type: int | str | None | easypaperless.Unset = UNSET, storage_path: int | str | None | easypaperless.Unset = UNSET, tags: Optional[List[Union[str, int]]] = None, archive_serial_number: int | None | easypaperless.Unset = UNSET, custom_fields: Optional[List[dict[str, Any]]] = None, wait: bool = False, poll_interval: float | None = None, poll_timeout: float | None = None) -> str | easypaperless.Document:
408    def upload(
409        self,
410        file: str | Path | bytes,
411        *,
412        filename: str | None = None,
413        content_type: str | None = None,
414        request_timeout: float | None = None,
415        title: str | Unset = UNSET,
416        created: date | str | None = None,
417        correspondent: int | str | None | Unset = UNSET,
418        document_type: int | str | None | Unset = UNSET,
419        storage_path: int | str | None | Unset = UNSET,
420        tags: List[int | str] | None = None,
421        archive_serial_number: int | None | Unset = UNSET,
422        custom_fields: List[dict[str, Any]] | None = None,
423        wait: bool = False,
424        poll_interval: float | None = None,
425        poll_timeout: float | None = None,
426    ) -> str | Document:
427        """Upload a document to paperless-ngx.
428
429        The upload request is never retried automatically, whatever the
430        client's ``retry_attempts`` / ``tenacity_retrying`` settings: if the
431        connection fails after paperless-ngx has accepted the file, a retry
432        would create a duplicate.  A failed upload raises (e.g.
433        :exc:`~easypaperless.exceptions.TransportTimeoutError`) so you can
434        decide whether to check for the document and upload again.
435
436        Args:
437            file: Path to the file to upload (``str`` or :class:`~pathlib.Path`),
438                or the file content as ``bytes``.  Bytes are sent directly; no
439                temporary file is written.
440            filename: File name sent to paperless-ngx.  Required when *file* is
441                ``bytes`` (omitting it raises
442                :exc:`~easypaperless.exceptions.ValidationError` before any
443                request).  For a path, overrides the name taken from the path.
444            content_type: MIME type of the file part, sent as given (e.g.
445                ``"application/pdf"``).  When omitted, it is guessed from the
446                file name as before.  paperless-ngx detects the file type from
447                the bytes and does not rely on this value to accept the file.
448            request_timeout: HTTP timeout in seconds for the upload request
449                only, overriding the client's ``timeout`` for this call.  Does
450                not affect task polling (see ``poll_timeout``).  When omitted,
451                the client's ``timeout`` applies.
452            title: Title to assign to the document.
453            created: Creation date as an ISO-8601 string (``"YYYY-MM-DD"``) or a
454                :class:`~datetime.date` object.
455            correspondent: Correspondent to assign, as an ID or name.
456            document_type: Document type to assign, as an ID or name.
457            storage_path: Storage path to assign, as an ID or name.
458            tags: Tags to assign, as IDs or names.
459            archive_serial_number: Archive serial number to assign.
460            custom_fields: List of ``{"field": <field_id>, "value": ...}`` dicts.
461            wait: If ``False`` *(default)*, returns immediately with the task ID.
462                If ``True``, polls until processing completes.
463            poll_interval: Seconds between task-status checks while waiting for
464                processing to complete (requires ``wait=True``). Overrides the
465                client-level default. When omitted, falls back to the client-level
466                ``poll_interval`` (``2.0`` s unless changed at construction).
467            poll_timeout: Maximum seconds to wait before raising
468                :exc:`~easypaperless.exceptions.TaskTimeoutError` (requires
469                ``wait=True``). Overrides the client-level default. When omitted,
470                falls back to the client-level ``poll_timeout`` (``60.0`` s unless
471                changed at construction).
472
473        Returns:
474            The Celery task ID string when ``wait=False``, or the fully
475            processed :class:`~easypaperless.models.documents.Document`
476            when ``wait=True``.
477
478        Raises:
479            ~easypaperless.exceptions.ValidationError: If *file* is ``bytes``
480                and no *filename* is given.
481            ~easypaperless.exceptions.BadRequestError: If paperless-ngx rejects
482                the file before processing starts, e.g. an unsupported file
483                type or an empty file (``err.field_errors["document"]``).
484            ~easypaperless.exceptions.UploadError: If processing fails;
485                ``err.task`` holds the task with paperless-ngx's ``result``
486                unaltered.  For a duplicate, ``err.task.result`` contains
487                ``": It is a duplicate of "`` and ``err.task.related_document``
488                is the existing document's ID (``None`` if that document is
489                in the trash).
490            ~easypaperless.exceptions.TaskTimeoutError: If timeout is exceeded;
491                resume with ``client.tasks.wait(err.task_id)``.
492        """
493        return cast(
494            str | Document,
495            self._run(
496                self._async_documents.upload(
497                    file,
498                    filename=filename,
499                    content_type=content_type,
500                    request_timeout=request_timeout,
501                    title=title,
502                    created=created,
503                    correspondent=correspondent,
504                    document_type=document_type,
505                    storage_path=storage_path,
506                    tags=tags,
507                    archive_serial_number=archive_serial_number,
508                    custom_fields=custom_fields,
509                    wait=wait,
510                    poll_interval=poll_interval,
511                    poll_timeout=poll_timeout,
512                )
513            ),
514        )

Upload a document to paperless-ngx.

The upload request is never retried automatically, whatever the client's retry_attempts / tenacity_retrying settings: if the connection fails after paperless-ngx has accepted the file, a retry would create a duplicate. A failed upload raises (e.g. ~easypaperless.exceptions.TransportTimeoutError) so you can decide whether to check for the document and upload again.

Arguments:
  • file: Path to the file to upload (str or ~pathlib.Path), or the file content as bytes. Bytes are sent directly; no temporary file is written.
  • filename: File name sent to paperless-ngx. Required when file is bytes (omitting it raises ~easypaperless.exceptions.ValidationError before any request). For a path, overrides the name taken from the path.
  • content_type: MIME type of the file part, sent as given (e.g. "application/pdf"). When omitted, it is guessed from the file name as before. paperless-ngx detects the file type from the bytes and does not rely on this value to accept the file.
  • request_timeout: HTTP timeout in seconds for the upload request only, overriding the client's timeout for this call. Does not affect task polling (see poll_timeout). When omitted, the client's timeout applies.
  • title: Title to assign to the document.
  • created: Creation date as an ISO-8601 string ("YYYY-MM-DD") or a ~datetime.date object.
  • correspondent: Correspondent to assign, as an ID or name.
  • document_type: Document type to assign, as an ID or name.
  • storage_path: Storage path to assign, as an ID or name.
  • tags: Tags to assign, as IDs or names.
  • archive_serial_number: Archive serial number to assign.
  • custom_fields: List of {"field": <field_id>, "value": ...} dicts.
  • wait: If False (default), returns immediately with the task ID. If True, polls until processing completes.
  • poll_interval: Seconds between task-status checks while waiting for processing to complete (requires wait=True). Overrides the client-level default. When omitted, falls back to the client-level poll_interval (2.0 s unless changed at construction).
  • poll_timeout: Maximum seconds to wait before raising ~easypaperless.exceptions.TaskTimeoutError (requires wait=True). Overrides the client-level default. When omitted, falls back to the client-level poll_timeout (60.0 s unless changed at construction).
Returns:

The Celery task ID string when wait=False, or the fully processed ~easypaperless.models.documents.Document when wait=True.

Raises:
def bulk_add_tag(self, document_ids: List[int], tag: int | str) -> None:
516    def bulk_add_tag(self, document_ids: List[int], tag: int | str) -> None:
517        """Add a tag to multiple documents in a single request.
518
519        Args:
520            document_ids: List of document IDs to tag.
521            tag: Tag to add, as an ID or name.
522        """
523        self._run(self._async_documents.bulk_add_tag(document_ids, tag))

Add a tag to multiple documents in a single request.

Arguments:
  • document_ids: List of document IDs to tag.
  • tag: Tag to add, as an ID or name.
def bulk_remove_tag(self, document_ids: List[int], tag: int | str) -> None:
525    def bulk_remove_tag(self, document_ids: List[int], tag: int | str) -> None:
526        """Remove a tag from multiple documents in a single request.
527
528        Args:
529            document_ids: List of document IDs to un-tag.
530            tag: Tag to remove, as an ID or name.
531        """
532        self._run(self._async_documents.bulk_remove_tag(document_ids, tag))

Remove a tag from multiple documents in a single request.

Arguments:
  • document_ids: List of document IDs to un-tag.
  • tag: Tag to remove, as an ID or name.
def bulk_modify_tags( self, document_ids: List[int], *, add_tags: Optional[List[Union[str, int]]] = None, remove_tags: Optional[List[Union[str, int]]] = None) -> None:
534    def bulk_modify_tags(
535        self,
536        document_ids: List[int],
537        *,
538        add_tags: List[int | str] | None = None,
539        remove_tags: List[int | str] | None = None,
540    ) -> None:
541        """Add and/or remove tags on multiple documents atomically.
542
543        Args:
544            document_ids: List of document IDs to modify.
545            add_tags: Tags to add, as IDs or names.
546            remove_tags: Tags to remove, as IDs or names.
547        """
548        self._run(
549            self._async_documents.bulk_modify_tags(
550                document_ids, add_tags=add_tags, remove_tags=remove_tags
551            )
552        )

Add and/or remove tags on multiple documents atomically.

Arguments:
  • document_ids: List of document IDs to modify.
  • add_tags: Tags to add, as IDs or names.
  • remove_tags: Tags to remove, as IDs or names.
def bulk_delete(self, document_ids: List[int]) -> None:
554    def bulk_delete(self, document_ids: List[int]) -> None:
555        """Permanently delete multiple documents in a single request.
556
557        Args:
558            document_ids: List of document IDs to delete.
559        """
560        self._run(self._async_documents.bulk_delete(document_ids))

Permanently delete multiple documents in a single request.

Arguments:
  • document_ids: List of document IDs to delete.
def bulk_set_correspondent(self, document_ids: List[int], correspondent: int | str | None) -> None:
562    def bulk_set_correspondent(
563        self, document_ids: List[int], correspondent: int | str | None
564    ) -> None:
565        """Assign a correspondent to multiple documents in a single request.
566
567        Args:
568            document_ids: List of document IDs to modify.
569            correspondent: Correspondent to assign, as an ID or name.
570                Pass ``None`` to clear.
571        """
572        self._run(self._async_documents.bulk_set_correspondent(document_ids, correspondent))

Assign a correspondent to multiple documents in a single request.

Arguments:
  • document_ids: List of document IDs to modify.
  • correspondent: Correspondent to assign, as an ID or name. Pass None to clear.
def bulk_set_document_type(self, document_ids: List[int], document_type: int | str | None) -> None:
574    def bulk_set_document_type(
575        self, document_ids: List[int], document_type: int | str | None
576    ) -> None:
577        """Assign a document type to multiple documents in a single request.
578
579        Args:
580            document_ids: List of document IDs to modify.
581            document_type: Document type to assign, as an ID or name.
582                Pass ``None`` to clear.
583        """
584        self._run(self._async_documents.bulk_set_document_type(document_ids, document_type))

Assign a document type to multiple documents in a single request.

Arguments:
  • document_ids: List of document IDs to modify.
  • document_type: Document type to assign, as an ID or name. Pass None to clear.
def bulk_set_storage_path(self, document_ids: List[int], storage_path: int | str | None) -> None:
586    def bulk_set_storage_path(
587        self, document_ids: List[int], storage_path: int | str | None
588    ) -> None:
589        """Assign a storage path to multiple documents in a single request.
590
591        Args:
592            document_ids: List of document IDs to modify.
593            storage_path: Storage path to assign, as an ID or name.
594                Pass ``None`` to clear.
595        """
596        self._run(self._async_documents.bulk_set_storage_path(document_ids, storage_path))

Assign a storage path to multiple documents in a single request.

Arguments:
  • document_ids: List of document IDs to modify.
  • storage_path: Storage path to assign, as an ID or name. Pass None to clear.
def bulk_modify_custom_fields( self, document_ids: List[int], *, add_fields: Optional[List[dict[str, Any]]] = None, remove_fields: Optional[List[int]] = None) -> None:
598    def bulk_modify_custom_fields(
599        self,
600        document_ids: List[int],
601        *,
602        add_fields: List[dict[str, Any]] | None = None,
603        remove_fields: List[int] | None = None,
604    ) -> None:
605        """Add and/or remove custom field values on multiple documents.
606
607        Args:
608            document_ids: List of document IDs to modify.
609            add_fields: Custom-field value dicts to add.
610            remove_fields: Custom-field IDs whose values should be removed.
611        """
612        self._run(
613            self._async_documents.bulk_modify_custom_fields(
614                document_ids, add_fields=add_fields, remove_fields=remove_fields
615            )
616        )

Add and/or remove custom field values on multiple documents.

Arguments:
  • document_ids: List of document IDs to modify.
  • add_fields: Custom-field value dicts to add.
  • remove_fields: Custom-field IDs whose values should be removed.
def bulk_set_permissions( self, document_ids: List[int], *, set_permissions: easypaperless.SetPermissions | easypaperless.Unset = UNSET, owner: int | None | easypaperless.Unset = UNSET, merge: bool = False) -> None:
618    def bulk_set_permissions(
619        self,
620        document_ids: List[int],
621        *,
622        set_permissions: SetPermissions | Unset = UNSET,
623        owner: int | None | Unset = UNSET,
624        merge: bool = False,
625    ) -> None:
626        """Set permissions and/or owner on multiple documents.
627
628        Args:
629            document_ids: List of document IDs to modify.
630            set_permissions: Explicit view/change permission sets.
631                Omit (or pass :data:`~easypaperless.UNSET`) to leave unchanged.
632            owner: Numeric user ID to assign as document owner.
633                Pass ``None`` to clear the owner.
634                Omit (or pass :data:`~easypaperless.UNSET`) to leave unchanged.
635            merge: When ``True``, new permissions are merged with existing ones.
636        """
637        self._run(
638            self._async_documents.bulk_set_permissions(
639                document_ids,
640                set_permissions=set_permissions,
641                owner=owner,
642                merge=merge,
643            )
644        )

Set permissions and/or owner on multiple documents.

Arguments:
  • document_ids: List of document IDs to modify.
  • set_permissions: Explicit view/change permission sets. Omit (or pass ~easypaperless.UNSET) to leave unchanged.
  • owner: Numeric user ID to assign as document owner. Pass None to clear the owner. Omit (or pass ~easypaperless.UNSET) to leave unchanged.
  • merge: When True, new permissions are merged with existing ones.
def bulk_download( self, document_ids: List[int], *, content: Literal['archive', 'originals', 'both'] = 'archive', compression: Literal['none', 'deflated', 'bzip2', 'lzma'] = 'none', follow_formatting: bool = False) -> bytes:
646    def bulk_download(
647        self,
648        document_ids: List[int],
649        *,
650        content: Literal["archive", "originals", "both"] = "archive",
651        compression: Literal["none", "deflated", "bzip2", "lzma"] = "none",
652        follow_formatting: bool = False,
653    ) -> bytes:
654        """Download multiple documents as a single ZIP archive.
655
656        Args:
657            document_ids: List of document IDs to include in the ZIP.
658            content: File variant to include.  One of ``"archive"`` *(default)*,
659                ``"originals"``, or ``"both"``.
660            compression: ZIP compression algorithm.  One of ``"none"`` *(default)*,
661                ``"deflated"``, ``"bzip2"``, or ``"lzma"``.
662            follow_formatting: When ``True``, filenames inside the ZIP follow
663                the storage path formatting configured in paperless-ngx.
664                Default: ``False``.
665
666        Returns:
667            Raw bytes of the ZIP archive.
668        """
669        return cast(
670            bytes,
671            self._run(
672                self._async_documents.bulk_download(
673                    document_ids,
674                    content=content,
675                    compression=compression,
676                    follow_formatting=follow_formatting,
677                )
678            ),
679        )

Download multiple documents as a single ZIP archive.

Arguments:
  • document_ids: List of document IDs to include in the ZIP.
  • content: File variant to include. One of "archive" (default), "originals", or "both".
  • compression: ZIP compression algorithm. One of "none" (default), "deflated", "bzip2", or "lzma".
  • follow_formatting: When True, filenames inside the ZIP follow the storage path formatting configured in paperless-ngx. Default: False.
Returns:

Raw bytes of the ZIP archive.

class SyncNotesResource:
15class SyncNotesResource:
16    """Sync accessor for document notes: ``client.documents.notes``."""
17
18    def __init__(self, async_notes: NotesResource, run: Any) -> None:
19        self._async_notes = async_notes
20        self._run = run
21
22    def list(
23        self,
24        document_id: int,
25        *,
26        page: int | None = None,
27        page_size: int | None = None,
28    ) -> PagedResult[DocumentNote]:
29        """Fetch notes attached to a document.
30
31        When ``page`` is ``None`` (the default), all pages are fetched
32        automatically and ``next`` / ``previous`` in the returned
33        :class:`~easypaperless.models.paged_result.PagedResult` are always
34        ``None``.  When ``page`` is set to a specific integer, only that one
35        page is fetched and ``next`` / ``previous`` contain the raw API values.
36
37        Args:
38            document_id: Numeric ID of the document whose notes to retrieve.
39            page: Return only this specific page (1-based).
40            page_size: Number of results per page.
41
42        Returns:
43            :class:`~easypaperless.models.paged_result.PagedResult` of
44            :class:`~easypaperless.models.documents.DocumentNote` objects,
45            ordered by creation time.
46
47        Raises:
48            ~easypaperless.exceptions.NotFoundError: If no document exists
49                with that ID.
50        """
51        return cast(
52            PagedResult[DocumentNote],
53            self._run(self._async_notes.list(document_id, page=page, page_size=page_size)),
54        )
55
56    def create(self, document_id: int, *, note: str) -> DocumentNote:
57        """Create a new note on a document.
58
59        Args:
60            document_id: Numeric ID of the document to annotate.
61            note: Text content of the note.
62
63        Returns:
64            The newly created :class:`~easypaperless.models.documents.DocumentNote`.
65
66        Raises:
67            ~easypaperless.exceptions.NotFoundError: If no document exists
68                with that ID.
69        """
70        return cast(DocumentNote, self._run(self._async_notes.create(document_id, note=note)))
71
72    def delete(self, document_id: int, note_id: int) -> None:
73        """Delete a note from a document.
74
75        Args:
76            document_id: Numeric ID of the document that owns the note.
77            note_id: Numeric ID of the note to delete.
78
79        Raises:
80            ~easypaperless.exceptions.NotFoundError: If no document exists with
81                that ID.
82            ~easypaperless.exceptions.ServerResponseError: If the document has
83                no note with ``note_id``.  paperless-ngx answers an unknown note
84                ID with ``500 Server Error`` instead of 404 (verified against
85                paperless-ngx 2.18.2), so it cannot be told apart from a real
86                server error.  With ``retry_attempts`` set, the 500 is retried
87                like any other and ends in
88                :exc:`~easypaperless.exceptions.RetryExhaustedError`.  Use
89                ``notes.list(document_id)`` first if you need to be sure the
90                note exists.
91        """
92        self._run(self._async_notes.delete(document_id, note_id))

Sync accessor for document notes: client.documents.notes.

SyncNotesResource( async_notes: NotesResource, run: Any)
18    def __init__(self, async_notes: NotesResource, run: Any) -> None:
19        self._async_notes = async_notes
20        self._run = run
def list( self, document_id: int, *, page: int | None = None, page_size: int | None = None) -> easypaperless.PagedResult[DocumentNote]:
22    def list(
23        self,
24        document_id: int,
25        *,
26        page: int | None = None,
27        page_size: int | None = None,
28    ) -> PagedResult[DocumentNote]:
29        """Fetch notes attached to a document.
30
31        When ``page`` is ``None`` (the default), all pages are fetched
32        automatically and ``next`` / ``previous`` in the returned
33        :class:`~easypaperless.models.paged_result.PagedResult` are always
34        ``None``.  When ``page`` is set to a specific integer, only that one
35        page is fetched and ``next`` / ``previous`` contain the raw API values.
36
37        Args:
38            document_id: Numeric ID of the document whose notes to retrieve.
39            page: Return only this specific page (1-based).
40            page_size: Number of results per page.
41
42        Returns:
43            :class:`~easypaperless.models.paged_result.PagedResult` of
44            :class:`~easypaperless.models.documents.DocumentNote` objects,
45            ordered by creation time.
46
47        Raises:
48            ~easypaperless.exceptions.NotFoundError: If no document exists
49                with that ID.
50        """
51        return cast(
52            PagedResult[DocumentNote],
53            self._run(self._async_notes.list(document_id, page=page, page_size=page_size)),
54        )

Fetch notes attached to a document.

When page is None (the default), all pages are fetched automatically and next / previous in the returned ~easypaperless.models.paged_result.PagedResult are always None. When page is set to a specific integer, only that one page is fetched and next / previous contain the raw API values.

Arguments:
  • document_id: Numeric ID of the document whose notes to retrieve.
  • page: Return only this specific page (1-based).
  • page_size: Number of results per page.
Returns:

~easypaperless.models.paged_result.PagedResult of ~easypaperless.models.documents.DocumentNote objects, ordered by creation time.

Raises:
def create( self, document_id: int, *, note: str) -> easypaperless.DocumentNote:
56    def create(self, document_id: int, *, note: str) -> DocumentNote:
57        """Create a new note on a document.
58
59        Args:
60            document_id: Numeric ID of the document to annotate.
61            note: Text content of the note.
62
63        Returns:
64            The newly created :class:`~easypaperless.models.documents.DocumentNote`.
65
66        Raises:
67            ~easypaperless.exceptions.NotFoundError: If no document exists
68                with that ID.
69        """
70        return cast(DocumentNote, self._run(self._async_notes.create(document_id, note=note)))

Create a new note on a document.

Arguments:
  • document_id: Numeric ID of the document to annotate.
  • note: Text content of the note.
Returns:

The newly created ~easypaperless.models.documents.DocumentNote.

Raises:
def delete(self, document_id: int, note_id: int) -> None:
72    def delete(self, document_id: int, note_id: int) -> None:
73        """Delete a note from a document.
74
75        Args:
76            document_id: Numeric ID of the document that owns the note.
77            note_id: Numeric ID of the note to delete.
78
79        Raises:
80            ~easypaperless.exceptions.NotFoundError: If no document exists with
81                that ID.
82            ~easypaperless.exceptions.ServerResponseError: If the document has
83                no note with ``note_id``.  paperless-ngx answers an unknown note
84                ID with ``500 Server Error`` instead of 404 (verified against
85                paperless-ngx 2.18.2), so it cannot be told apart from a real
86                server error.  With ``retry_attempts`` set, the 500 is retried
87                like any other and ends in
88                :exc:`~easypaperless.exceptions.RetryExhaustedError`.  Use
89                ``notes.list(document_id)`` first if you need to be sure the
90                note exists.
91        """
92        self._run(self._async_notes.delete(document_id, note_id))

Delete a note from a document.

Arguments:
  • document_id: Numeric ID of the document that owns the note.
  • note_id: Numeric ID of the note to delete.
Raises:
class SyncStoragePathsResource:
 18class SyncStoragePathsResource:
 19    """Sync accessor for storage paths: ``client.storage_paths``."""
 20
 21    def __init__(self, async_storage_paths: StoragePathsResource, run: Any) -> None:
 22        self._async_storage_paths = async_storage_paths
 23        self._run = run
 24
 25    def list(
 26        self,
 27        *,
 28        ids: List[int] | None = None,
 29        name_contains: str | None = None,
 30        name_exact: str | None = None,
 31        path_contains: str | None = None,
 32        path_exact: str | None = None,
 33        page: int | None = None,
 34        page_size: int | None = None,
 35        ordering: str | None = None,
 36        descending: bool = False,
 37    ) -> PagedResult[StoragePath]:
 38        """Return storage paths defined in paperless-ngx.
 39
 40        When ``page`` is ``None`` (the default), all pages are fetched
 41        automatically and ``next`` / ``previous`` in the result are always
 42        ``None``.  When ``page`` is set, only that page is fetched and
 43        ``next`` / ``previous`` reflect the raw API values.
 44
 45        Args:
 46            ids: Return only storage paths whose ID is in this list.
 47            name_contains: Case-insensitive substring filter on name.
 48            name_exact: Case-insensitive exact match on name.
 49            path_contains: Case-insensitive substring filter on path template.
 50            path_exact: Case-insensitive exact match on path template.
 51            page: Return only this specific page (1-based).
 52            page_size: Number of results per page.
 53            ordering: Field to sort by.
 54            descending: When ``True``, reverses the sort direction.
 55
 56        Returns:
 57            :class:`~easypaperless.models.paged_result.PagedResult` of
 58            :class:`~easypaperless.models.storage_paths.StoragePath` objects.
 59        """
 60        return cast(
 61            PagedResult[StoragePath],
 62            self._run(
 63                self._async_storage_paths.list(
 64                    ids=ids,
 65                    name_contains=name_contains,
 66                    name_exact=name_exact,
 67                    path_contains=path_contains,
 68                    path_exact=path_exact,
 69                    page=page,
 70                    page_size=page_size,
 71                    ordering=ordering,
 72                    descending=descending,
 73                )
 74            ),
 75        )
 76
 77    def get(self, id: int) -> StoragePath:
 78        """Fetch a single storage path by its ID.
 79
 80        Args:
 81            id: Numeric storage-path ID.
 82
 83        Returns:
 84            The :class:`~easypaperless.models.storage_paths.StoragePath` with the given ID.
 85
 86        Raises:
 87            ~easypaperless.exceptions.NotFoundError: If no storage path exists with that ID.
 88        """
 89        return cast(StoragePath, self._run(self._async_storage_paths.get(id)))
 90
 91    def create(
 92        self,
 93        *,
 94        name: str,
 95        path: str | Unset = UNSET,
 96        match: str | Unset = UNSET,
 97        matching_algorithm: MatchingAlgorithm | Unset = UNSET,
 98        is_insensitive: bool = True,
 99        owner: int | None | Unset = UNSET,
100        set_permissions: SetPermissions | None | Unset = UNSET,
101    ) -> StoragePath:
102        """Create a new storage path.
103
104        Args:
105            name: Storage-path name. Must be unique.
106            path: Template string for the archive file path.
107            match: Auto-matching pattern.
108            matching_algorithm: Controls how ``match`` is applied.
109                E.g. ``matching_algorithm=MatchingAlgorithm.REGEX`` for
110                regular-expression matching.
111            is_insensitive: When ``True``, ``match`` is case-insensitive.
112                Defaults to ``True``, matching the paperless-ngx API default.
113            owner: Numeric user ID to assign as owner.
114            set_permissions: Explicit view/change permission sets.
115                Pass ``None`` to create with empty permissions.
116
117        Returns:
118            The newly created :class:`~easypaperless.models.storage_paths.StoragePath`.
119        """
120        return cast(
121            StoragePath,
122            self._run(
123                self._async_storage_paths.create(
124                    name=name,
125                    path=path,
126                    match=match,
127                    matching_algorithm=matching_algorithm,
128                    is_insensitive=is_insensitive,
129                    owner=owner,
130                    set_permissions=set_permissions,
131                )
132            ),
133        )
134
135    def update(
136        self,
137        id: int,
138        *,
139        name: str | Unset = UNSET,
140        path: str | Unset = UNSET,
141        match: str | Unset = UNSET,
142        matching_algorithm: MatchingAlgorithm | Unset = UNSET,
143        is_insensitive: bool | Unset = UNSET,
144        owner: int | None | Unset = UNSET,
145        set_permissions: SetPermissions | None | Unset = UNSET,
146    ) -> StoragePath:
147        """Partially update a storage path (PATCH semantics).
148
149        Args:
150            id: Numeric ID of the storage path to update.
151            name: Storage-path name.
152            path: Template string for the archive file path.
153            match: Auto-matching pattern.
154            matching_algorithm: Controls how ``match`` is applied.
155                E.g. ``matching_algorithm=MatchingAlgorithm.REGEX`` for
156                regular-expression matching.
157            is_insensitive: When ``True``, ``match`` is case-insensitive.
158            owner: Numeric user ID to assign as owner.
159                Pass ``None`` to clear the owner.
160                Omit (or pass :data:`~easypaperless.UNSET`) to leave unchanged.
161            set_permissions: Explicit view/change permission sets.
162                Pass ``None`` to clear all permissions (overwrite with empty).
163                Omit (or pass :data:`~easypaperless.UNSET`) to leave unchanged.
164
165        Returns:
166            The updated :class:`~easypaperless.models.storage_paths.StoragePath`.
167        """
168        return cast(
169            StoragePath,
170            self._run(
171                self._async_storage_paths.update(
172                    id,
173                    name=name,
174                    path=path,
175                    match=match,
176                    matching_algorithm=matching_algorithm,
177                    is_insensitive=is_insensitive,
178                    owner=owner,
179                    set_permissions=set_permissions,
180                )
181            ),
182        )
183
184    def delete(self, id: int) -> None:
185        """Delete a storage path.
186
187        Args:
188            id: Numeric ID of the storage path to delete.
189
190        Raises:
191            ~easypaperless.exceptions.NotFoundError: If no storage path exists with that ID.
192        """
193        self._run(self._async_storage_paths.delete(id))
194
195    def bulk_delete(self, ids: List[int]) -> None:
196        """Permanently delete multiple storage paths in a single request.
197
198        Args:
199            ids: List of storage path IDs to delete.
200        """
201        self._run(self._async_storage_paths.bulk_delete(ids))
202
203    def bulk_set_permissions(
204        self,
205        ids: List[int],
206        *,
207        set_permissions: SetPermissions | Unset = UNSET,
208        owner: int | None | Unset = UNSET,
209        merge: bool = False,
210    ) -> None:
211        """Set permissions and/or owner on multiple storage paths.
212
213        Args:
214            ids: List of storage path IDs to modify.
215            set_permissions: Explicit view/change permission sets.
216                Omit (or pass :data:`~easypaperless.UNSET`) to leave unchanged.
217            owner: Numeric user ID to assign as owner.
218                Pass ``None`` to clear the owner.
219                Omit (or pass :data:`~easypaperless.UNSET`) to leave unchanged.
220            merge: When ``True``, new permissions are merged with existing ones.
221        """
222        self._run(
223            self._async_storage_paths.bulk_set_permissions(
224                ids, set_permissions=set_permissions, owner=owner, merge=merge
225            )
226        )

Sync accessor for storage paths: client.storage_paths.

SyncStoragePathsResource( async_storage_paths: StoragePathsResource, run: Any)
21    def __init__(self, async_storage_paths: StoragePathsResource, run: Any) -> None:
22        self._async_storage_paths = async_storage_paths
23        self._run = run
def list( self, *, ids: Optional[List[int]] = None, name_contains: str | None = None, name_exact: str | None = None, path_contains: str | None = None, path_exact: str | None = None, page: int | None = None, page_size: int | None = None, ordering: str | None = None, descending: bool = False) -> easypaperless.PagedResult[StoragePath]:
25    def list(
26        self,
27        *,
28        ids: List[int] | None = None,
29        name_contains: str | None = None,
30        name_exact: str | None = None,
31        path_contains: str | None = None,
32        path_exact: str | None = None,
33        page: int | None = None,
34        page_size: int | None = None,
35        ordering: str | None = None,
36        descending: bool = False,
37    ) -> PagedResult[StoragePath]:
38        """Return storage paths defined in paperless-ngx.
39
40        When ``page`` is ``None`` (the default), all pages are fetched
41        automatically and ``next`` / ``previous`` in the result are always
42        ``None``.  When ``page`` is set, only that page is fetched and
43        ``next`` / ``previous`` reflect the raw API values.
44
45        Args:
46            ids: Return only storage paths whose ID is in this list.
47            name_contains: Case-insensitive substring filter on name.
48            name_exact: Case-insensitive exact match on name.
49            path_contains: Case-insensitive substring filter on path template.
50            path_exact: Case-insensitive exact match on path template.
51            page: Return only this specific page (1-based).
52            page_size: Number of results per page.
53            ordering: Field to sort by.
54            descending: When ``True``, reverses the sort direction.
55
56        Returns:
57            :class:`~easypaperless.models.paged_result.PagedResult` of
58            :class:`~easypaperless.models.storage_paths.StoragePath` objects.
59        """
60        return cast(
61            PagedResult[StoragePath],
62            self._run(
63                self._async_storage_paths.list(
64                    ids=ids,
65                    name_contains=name_contains,
66                    name_exact=name_exact,
67                    path_contains=path_contains,
68                    path_exact=path_exact,
69                    page=page,
70                    page_size=page_size,
71                    ordering=ordering,
72                    descending=descending,
73                )
74            ),
75        )

Return storage paths defined in paperless-ngx.

When page is None (the default), all pages are fetched automatically and next / previous in the result are always None. When page is set, only that page is fetched and next / previous reflect the raw API values.

Arguments:
  • ids: Return only storage paths whose ID is in this list.
  • name_contains: Case-insensitive substring filter on name.
  • name_exact: Case-insensitive exact match on name.
  • path_contains: Case-insensitive substring filter on path template.
  • path_exact: Case-insensitive exact match on path template.
  • page: Return only this specific page (1-based).
  • page_size: Number of results per page.
  • ordering: Field to sort by.
  • descending: When True, reverses the sort direction.
Returns:

~easypaperless.models.paged_result.PagedResult of ~easypaperless.models.storage_paths.StoragePath objects.

def get(self, id: int) -> easypaperless.StoragePath:
77    def get(self, id: int) -> StoragePath:
78        """Fetch a single storage path by its ID.
79
80        Args:
81            id: Numeric storage-path ID.
82
83        Returns:
84            The :class:`~easypaperless.models.storage_paths.StoragePath` with the given ID.
85
86        Raises:
87            ~easypaperless.exceptions.NotFoundError: If no storage path exists with that ID.
88        """
89        return cast(StoragePath, self._run(self._async_storage_paths.get(id)))

Fetch a single storage path by its ID.

Arguments:
  • id: Numeric storage-path ID.
Returns:

The ~easypaperless.models.storage_paths.StoragePath with the given ID.

Raises:
def create( self, *, name: str, path: str | easypaperless.Unset = UNSET, match: str | easypaperless.Unset = UNSET, matching_algorithm: easypaperless.MatchingAlgorithm | easypaperless.Unset = UNSET, is_insensitive: bool = True, owner: int | None | easypaperless.Unset = UNSET, set_permissions: easypaperless.SetPermissions | None | easypaperless.Unset = UNSET) -> easypaperless.StoragePath:
 91    def create(
 92        self,
 93        *,
 94        name: str,
 95        path: str | Unset = UNSET,
 96        match: str | Unset = UNSET,
 97        matching_algorithm: MatchingAlgorithm | Unset = UNSET,
 98        is_insensitive: bool = True,
 99        owner: int | None | Unset = UNSET,
100        set_permissions: SetPermissions | None | Unset = UNSET,
101    ) -> StoragePath:
102        """Create a new storage path.
103
104        Args:
105            name: Storage-path name. Must be unique.
106            path: Template string for the archive file path.
107            match: Auto-matching pattern.
108            matching_algorithm: Controls how ``match`` is applied.
109                E.g. ``matching_algorithm=MatchingAlgorithm.REGEX`` for
110                regular-expression matching.
111            is_insensitive: When ``True``, ``match`` is case-insensitive.
112                Defaults to ``True``, matching the paperless-ngx API default.
113            owner: Numeric user ID to assign as owner.
114            set_permissions: Explicit view/change permission sets.
115                Pass ``None`` to create with empty permissions.
116
117        Returns:
118            The newly created :class:`~easypaperless.models.storage_paths.StoragePath`.
119        """
120        return cast(
121            StoragePath,
122            self._run(
123                self._async_storage_paths.create(
124                    name=name,
125                    path=path,
126                    match=match,
127                    matching_algorithm=matching_algorithm,
128                    is_insensitive=is_insensitive,
129                    owner=owner,
130                    set_permissions=set_permissions,
131                )
132            ),
133        )

Create a new storage path.

Arguments:
  • name: Storage-path name. Must be unique.
  • path: Template string for the archive file path.
  • match: Auto-matching pattern.
  • matching_algorithm: Controls how match is applied. E.g. matching_algorithm=MatchingAlgorithm.REGEX for regular-expression matching.
  • is_insensitive: When True, match is case-insensitive. Defaults to True, matching the paperless-ngx API default.
  • owner: Numeric user ID to assign as owner.
  • set_permissions: Explicit view/change permission sets. Pass None to create with empty permissions.
Returns:

The newly created ~easypaperless.models.storage_paths.StoragePath.

def update( self, id: int, *, name: str | easypaperless.Unset = UNSET, path: str | easypaperless.Unset = UNSET, match: str | easypaperless.Unset = UNSET, matching_algorithm: easypaperless.MatchingAlgorithm | easypaperless.Unset = UNSET, is_insensitive: bool | easypaperless.Unset = UNSET, owner: int | None | easypaperless.Unset = UNSET, set_permissions: easypaperless.SetPermissions | None | easypaperless.Unset = UNSET) -> easypaperless.StoragePath:
135    def update(
136        self,
137        id: int,
138        *,
139        name: str | Unset = UNSET,
140        path: str | Unset = UNSET,
141        match: str | Unset = UNSET,
142        matching_algorithm: MatchingAlgorithm | Unset = UNSET,
143        is_insensitive: bool | Unset = UNSET,
144        owner: int | None | Unset = UNSET,
145        set_permissions: SetPermissions | None | Unset = UNSET,
146    ) -> StoragePath:
147        """Partially update a storage path (PATCH semantics).
148
149        Args:
150            id: Numeric ID of the storage path to update.
151            name: Storage-path name.
152            path: Template string for the archive file path.
153            match: Auto-matching pattern.
154            matching_algorithm: Controls how ``match`` is applied.
155                E.g. ``matching_algorithm=MatchingAlgorithm.REGEX`` for
156                regular-expression matching.
157            is_insensitive: When ``True``, ``match`` is case-insensitive.
158            owner: Numeric user ID to assign as owner.
159                Pass ``None`` to clear the owner.
160                Omit (or pass :data:`~easypaperless.UNSET`) to leave unchanged.
161            set_permissions: Explicit view/change permission sets.
162                Pass ``None`` to clear all permissions (overwrite with empty).
163                Omit (or pass :data:`~easypaperless.UNSET`) to leave unchanged.
164
165        Returns:
166            The updated :class:`~easypaperless.models.storage_paths.StoragePath`.
167        """
168        return cast(
169            StoragePath,
170            self._run(
171                self._async_storage_paths.update(
172                    id,
173                    name=name,
174                    path=path,
175                    match=match,
176                    matching_algorithm=matching_algorithm,
177                    is_insensitive=is_insensitive,
178                    owner=owner,
179                    set_permissions=set_permissions,
180                )
181            ),
182        )

Partially update a storage path (PATCH semantics).

Arguments:
  • id: Numeric ID of the storage path to update.
  • name: Storage-path name.
  • path: Template string for the archive file path.
  • match: Auto-matching pattern.
  • matching_algorithm: Controls how match is applied. E.g. matching_algorithm=MatchingAlgorithm.REGEX for regular-expression matching.
  • is_insensitive: When True, match is case-insensitive.
  • owner: Numeric user ID to assign as owner. Pass None to clear the owner. Omit (or pass ~easypaperless.UNSET) to leave unchanged.
  • set_permissions: Explicit view/change permission sets. Pass None to clear all permissions (overwrite with empty). Omit (or pass ~easypaperless.UNSET) to leave unchanged.
Returns:

The updated ~easypaperless.models.storage_paths.StoragePath.

def delete(self, id: int) -> None:
184    def delete(self, id: int) -> None:
185        """Delete a storage path.
186
187        Args:
188            id: Numeric ID of the storage path to delete.
189
190        Raises:
191            ~easypaperless.exceptions.NotFoundError: If no storage path exists with that ID.
192        """
193        self._run(self._async_storage_paths.delete(id))

Delete a storage path.

Arguments:
  • id: Numeric ID of the storage path to delete.
Raises:
def bulk_delete(self, ids: List[int]) -> None:
195    def bulk_delete(self, ids: List[int]) -> None:
196        """Permanently delete multiple storage paths in a single request.
197
198        Args:
199            ids: List of storage path IDs to delete.
200        """
201        self._run(self._async_storage_paths.bulk_delete(ids))

Permanently delete multiple storage paths in a single request.

Arguments:
  • ids: List of storage path IDs to delete.
def bulk_set_permissions( self, ids: List[int], *, set_permissions: easypaperless.SetPermissions | easypaperless.Unset = UNSET, owner: int | None | easypaperless.Unset = UNSET, merge: bool = False) -> None:
203    def bulk_set_permissions(
204        self,
205        ids: List[int],
206        *,
207        set_permissions: SetPermissions | Unset = UNSET,
208        owner: int | None | Unset = UNSET,
209        merge: bool = False,
210    ) -> None:
211        """Set permissions and/or owner on multiple storage paths.
212
213        Args:
214            ids: List of storage path IDs to modify.
215            set_permissions: Explicit view/change permission sets.
216                Omit (or pass :data:`~easypaperless.UNSET`) to leave unchanged.
217            owner: Numeric user ID to assign as owner.
218                Pass ``None`` to clear the owner.
219                Omit (or pass :data:`~easypaperless.UNSET`) to leave unchanged.
220            merge: When ``True``, new permissions are merged with existing ones.
221        """
222        self._run(
223            self._async_storage_paths.bulk_set_permissions(
224                ids, set_permissions=set_permissions, owner=owner, merge=merge
225            )
226        )

Set permissions and/or owner on multiple storage paths.

Arguments:
  • ids: List of storage path IDs to modify.
  • set_permissions: Explicit view/change permission sets. Omit (or pass ~easypaperless.UNSET) to leave unchanged.
  • owner: Numeric user ID to assign as owner. Pass None to clear the owner. Omit (or pass ~easypaperless.UNSET) to leave unchanged.
  • merge: When True, new permissions are merged with existing ones.
class SyncTagsResource:
 18class SyncTagsResource:
 19    """Sync accessor for tags: ``client.tags``."""
 20
 21    def __init__(self, async_tags: TagsResource, run: Any) -> None:
 22        self._async_tags = async_tags
 23        self._run = run
 24
 25    def list(
 26        self,
 27        *,
 28        ids: List[int] | None = None,
 29        name_contains: str | None = None,
 30        name_exact: str | None = None,
 31        page: int | None = None,
 32        page_size: int | None = None,
 33        ordering: str | None = None,
 34        descending: bool = False,
 35    ) -> PagedResult[Tag]:
 36        """Return tags defined in paperless-ngx.
 37
 38        When ``page`` is ``None`` (the default), all pages are fetched
 39        automatically and ``next`` / ``previous`` in the result are always
 40        ``None``.  When ``page`` is set, only that page is fetched and
 41        ``next`` / ``previous`` reflect the raw API values.
 42
 43        Args:
 44            ids: Return only tags whose ID is in this list.
 45            name_contains: Case-insensitive substring filter on tag name.
 46            name_exact: Case-insensitive exact match on tag name.
 47            page: Return only this specific page (1-based).
 48            page_size: Number of results per page.
 49            ordering: Field to sort by.
 50            descending: When ``True``, reverses the sort direction.
 51
 52        Returns:
 53            :class:`~easypaperless.models.paged_result.PagedResult` of
 54            :class:`~easypaperless.models.tags.Tag` objects.
 55        """
 56        return cast(
 57            PagedResult[Tag],
 58            self._run(
 59                self._async_tags.list(
 60                    ids=ids,
 61                    name_contains=name_contains,
 62                    name_exact=name_exact,
 63                    page=page,
 64                    page_size=page_size,
 65                    ordering=ordering,
 66                    descending=descending,
 67                )
 68            ),
 69        )
 70
 71    def get(self, id: int) -> Tag:
 72        """Fetch a single tag by its ID.
 73
 74        Args:
 75            id: Numeric tag ID.
 76
 77        Returns:
 78            The :class:`~easypaperless.models.tags.Tag` with the given ID.
 79
 80        Raises:
 81            ~easypaperless.exceptions.NotFoundError: If no tag exists with
 82                that ID.
 83        """
 84        return cast(Tag, self._run(self._async_tags.get(id)))
 85
 86    def create(
 87        self,
 88        *,
 89        name: str,
 90        color: str | Unset = UNSET,
 91        is_inbox_tag: bool | Unset = UNSET,
 92        match: str | Unset = UNSET,
 93        matching_algorithm: MatchingAlgorithm | Unset = UNSET,
 94        is_insensitive: bool = True,
 95        parent: int | None | Unset = UNSET,
 96        owner: int | None | Unset = UNSET,
 97        set_permissions: SetPermissions | None | Unset = UNSET,
 98    ) -> Tag:
 99        """Create a new tag.
100
101        Args:
102            name: Tag name. Must be unique.
103            color: Background colour as a CSS hex string.
104            is_inbox_tag: When ``True``, newly ingested documents get this tag.
105            match: Auto-matching pattern.
106            matching_algorithm: Controls how ``match`` is applied.
107                E.g. ``matching_algorithm=MatchingAlgorithm.REGEX`` for
108                regular-expression matching.
109            is_insensitive: When ``True``, ``match`` is case-insensitive.
110                Defaults to ``True``, matching the paperless-ngx API default.
111            parent: ID of parent tag for hierarchical trees.
112            owner: Numeric user ID to assign as owner.
113            set_permissions: Explicit view/change permission sets.
114                Pass ``None`` to create with empty permissions.
115
116        Returns:
117            The newly created :class:`~easypaperless.models.tags.Tag`.
118        """
119        return cast(
120            Tag,
121            self._run(
122                self._async_tags.create(
123                    name=name,
124                    color=color,
125                    is_inbox_tag=is_inbox_tag,
126                    match=match,
127                    matching_algorithm=matching_algorithm,
128                    is_insensitive=is_insensitive,
129                    parent=parent,
130                    owner=owner,
131                    set_permissions=set_permissions,
132                )
133            ),
134        )
135
136    def update(
137        self,
138        id: int,
139        *,
140        name: str | Unset = UNSET,
141        color: str | Unset = UNSET,
142        is_inbox_tag: bool | Unset = UNSET,
143        match: str | Unset = UNSET,
144        matching_algorithm: MatchingAlgorithm | Unset = UNSET,
145        is_insensitive: bool | Unset = UNSET,
146        parent: int | None | Unset = UNSET,
147        owner: int | None | Unset = UNSET,
148        set_permissions: SetPermissions | None | Unset = UNSET,
149    ) -> Tag:
150        """Partially update a tag (PATCH semantics).
151
152        Args:
153            id: Numeric ID of the tag to update.
154            name: Tag name.
155            color: Background colour as a CSS hex string.
156            is_inbox_tag: When ``True``, newly ingested documents get this tag.
157            match: Auto-matching pattern.
158            matching_algorithm: Controls how ``match`` is applied.
159                E.g. ``matching_algorithm=MatchingAlgorithm.REGEX`` for
160                regular-expression matching.
161            is_insensitive: When ``True``, ``match`` is case-insensitive.
162            parent: ID of parent tag.
163                Pass ``None`` to clear (make root tag).
164                Omit (or pass :data:`~easypaperless.UNSET`) to leave unchanged.
165            owner: Numeric user ID to assign as owner.
166                Pass ``None`` to clear the owner.
167                Omit (or pass :data:`~easypaperless.UNSET`) to leave unchanged.
168            set_permissions: Explicit view/change permission sets.
169                Pass ``None`` to clear all permissions (overwrite with empty).
170                Omit (or pass :data:`~easypaperless.UNSET`) to leave unchanged.
171
172        Returns:
173            The updated :class:`~easypaperless.models.tags.Tag`.
174        """
175        return cast(
176            Tag,
177            self._run(
178                self._async_tags.update(
179                    id,
180                    name=name,
181                    color=color,
182                    is_inbox_tag=is_inbox_tag,
183                    match=match,
184                    matching_algorithm=matching_algorithm,
185                    is_insensitive=is_insensitive,
186                    parent=parent,
187                    owner=owner,
188                    set_permissions=set_permissions,
189                )
190            ),
191        )
192
193    def delete(self, id: int) -> None:
194        """Delete a tag.
195
196        Args:
197            id: Numeric ID of the tag to delete.
198
199        Raises:
200            ~easypaperless.exceptions.NotFoundError: If no tag exists with
201                that ID.
202        """
203        self._run(self._async_tags.delete(id))
204
205    def bulk_delete(self, ids: List[int]) -> None:
206        """Permanently delete multiple tags in a single request.
207
208        Args:
209            ids: List of tag IDs to delete.
210        """
211        self._run(self._async_tags.bulk_delete(ids))
212
213    def bulk_set_permissions(
214        self,
215        ids: List[int],
216        *,
217        set_permissions: SetPermissions | Unset = UNSET,
218        owner: int | None | Unset = UNSET,
219        merge: bool = False,
220    ) -> None:
221        """Set permissions and/or owner on multiple tags.
222
223        Args:
224            ids: List of tag IDs to modify.
225            set_permissions: Explicit view/change permission sets.
226                Omit (or pass :data:`~easypaperless.UNSET`) to leave unchanged.
227            owner: Numeric user ID to assign as owner.
228                Pass ``None`` to clear the owner.
229                Omit (or pass :data:`~easypaperless.UNSET`) to leave unchanged.
230            merge: When ``True``, new permissions are merged with existing ones.
231        """
232        self._run(
233            self._async_tags.bulk_set_permissions(
234                ids, set_permissions=set_permissions, owner=owner, merge=merge
235            )
236        )

Sync accessor for tags: client.tags.

SyncTagsResource( async_tags: TagsResource, run: Any)
21    def __init__(self, async_tags: TagsResource, run: Any) -> None:
22        self._async_tags = async_tags
23        self._run = run
def list( self, *, ids: Optional[List[int]] = None, name_contains: str | None = None, name_exact: str | None = None, page: int | None = None, page_size: int | None = None, ordering: str | None = None, descending: bool = False) -> easypaperless.PagedResult[Tag]:
25    def list(
26        self,
27        *,
28        ids: List[int] | None = None,
29        name_contains: str | None = None,
30        name_exact: str | None = None,
31        page: int | None = None,
32        page_size: int | None = None,
33        ordering: str | None = None,
34        descending: bool = False,
35    ) -> PagedResult[Tag]:
36        """Return tags defined in paperless-ngx.
37
38        When ``page`` is ``None`` (the default), all pages are fetched
39        automatically and ``next`` / ``previous`` in the result are always
40        ``None``.  When ``page`` is set, only that page is fetched and
41        ``next`` / ``previous`` reflect the raw API values.
42
43        Args:
44            ids: Return only tags whose ID is in this list.
45            name_contains: Case-insensitive substring filter on tag name.
46            name_exact: Case-insensitive exact match on tag name.
47            page: Return only this specific page (1-based).
48            page_size: Number of results per page.
49            ordering: Field to sort by.
50            descending: When ``True``, reverses the sort direction.
51
52        Returns:
53            :class:`~easypaperless.models.paged_result.PagedResult` of
54            :class:`~easypaperless.models.tags.Tag` objects.
55        """
56        return cast(
57            PagedResult[Tag],
58            self._run(
59                self._async_tags.list(
60                    ids=ids,
61                    name_contains=name_contains,
62                    name_exact=name_exact,
63                    page=page,
64                    page_size=page_size,
65                    ordering=ordering,
66                    descending=descending,
67                )
68            ),
69        )

Return tags defined in paperless-ngx.

When page is None (the default), all pages are fetched automatically and next / previous in the result are always None. When page is set, only that page is fetched and next / previous reflect the raw API values.

Arguments:
  • ids: Return only tags whose ID is in this list.
  • name_contains: Case-insensitive substring filter on tag name.
  • name_exact: Case-insensitive exact match on tag name.
  • page: Return only this specific page (1-based).
  • page_size: Number of results per page.
  • ordering: Field to sort by.
  • descending: When True, reverses the sort direction.
Returns:

~easypaperless.models.paged_result.PagedResult of ~easypaperless.models.tags.Tag objects.

def get(self, id: int) -> easypaperless.Tag:
71    def get(self, id: int) -> Tag:
72        """Fetch a single tag by its ID.
73
74        Args:
75            id: Numeric tag ID.
76
77        Returns:
78            The :class:`~easypaperless.models.tags.Tag` with the given ID.
79
80        Raises:
81            ~easypaperless.exceptions.NotFoundError: If no tag exists with
82                that ID.
83        """
84        return cast(Tag, self._run(self._async_tags.get(id)))

Fetch a single tag by its ID.

Arguments:
  • id: Numeric tag ID.
Returns:

The ~easypaperless.models.tags.Tag with the given ID.

Raises:
def create( self, *, name: str, color: str | easypaperless.Unset = UNSET, is_inbox_tag: bool | easypaperless.Unset = UNSET, match: str | easypaperless.Unset = UNSET, matching_algorithm: easypaperless.MatchingAlgorithm | easypaperless.Unset = UNSET, is_insensitive: bool = True, parent: int | None | easypaperless.Unset = UNSET, owner: int | None | easypaperless.Unset = UNSET, set_permissions: easypaperless.SetPermissions | None | easypaperless.Unset = UNSET) -> easypaperless.Tag:
 86    def create(
 87        self,
 88        *,
 89        name: str,
 90        color: str | Unset = UNSET,
 91        is_inbox_tag: bool | Unset = UNSET,
 92        match: str | Unset = UNSET,
 93        matching_algorithm: MatchingAlgorithm | Unset = UNSET,
 94        is_insensitive: bool = True,
 95        parent: int | None | Unset = UNSET,
 96        owner: int | None | Unset = UNSET,
 97        set_permissions: SetPermissions | None | Unset = UNSET,
 98    ) -> Tag:
 99        """Create a new tag.
100
101        Args:
102            name: Tag name. Must be unique.
103            color: Background colour as a CSS hex string.
104            is_inbox_tag: When ``True``, newly ingested documents get this tag.
105            match: Auto-matching pattern.
106            matching_algorithm: Controls how ``match`` is applied.
107                E.g. ``matching_algorithm=MatchingAlgorithm.REGEX`` for
108                regular-expression matching.
109            is_insensitive: When ``True``, ``match`` is case-insensitive.
110                Defaults to ``True``, matching the paperless-ngx API default.
111            parent: ID of parent tag for hierarchical trees.
112            owner: Numeric user ID to assign as owner.
113            set_permissions: Explicit view/change permission sets.
114                Pass ``None`` to create with empty permissions.
115
116        Returns:
117            The newly created :class:`~easypaperless.models.tags.Tag`.
118        """
119        return cast(
120            Tag,
121            self._run(
122                self._async_tags.create(
123                    name=name,
124                    color=color,
125                    is_inbox_tag=is_inbox_tag,
126                    match=match,
127                    matching_algorithm=matching_algorithm,
128                    is_insensitive=is_insensitive,
129                    parent=parent,
130                    owner=owner,
131                    set_permissions=set_permissions,
132                )
133            ),
134        )

Create a new tag.

Arguments:
  • name: Tag name. Must be unique.
  • color: Background colour as a CSS hex string.
  • is_inbox_tag: When True, newly ingested documents get this tag.
  • match: Auto-matching pattern.
  • matching_algorithm: Controls how match is applied. E.g. matching_algorithm=MatchingAlgorithm.REGEX for regular-expression matching.
  • is_insensitive: When True, match is case-insensitive. Defaults to True, matching the paperless-ngx API default.
  • parent: ID of parent tag for hierarchical trees.
  • owner: Numeric user ID to assign as owner.
  • set_permissions: Explicit view/change permission sets. Pass None to create with empty permissions.
Returns:

The newly created ~easypaperless.models.tags.Tag.

def update( self, id: int, *, name: str | easypaperless.Unset = UNSET, color: str | easypaperless.Unset = UNSET, is_inbox_tag: bool | easypaperless.Unset = UNSET, match: str | easypaperless.Unset = UNSET, matching_algorithm: easypaperless.MatchingAlgorithm | easypaperless.Unset = UNSET, is_insensitive: bool | easypaperless.Unset = UNSET, parent: int | None | easypaperless.Unset = UNSET, owner: int | None | easypaperless.Unset = UNSET, set_permissions: easypaperless.SetPermissions | None | easypaperless.Unset = UNSET) -> easypaperless.Tag:
136    def update(
137        self,
138        id: int,
139        *,
140        name: str | Unset = UNSET,
141        color: str | Unset = UNSET,
142        is_inbox_tag: bool | Unset = UNSET,
143        match: str | Unset = UNSET,
144        matching_algorithm: MatchingAlgorithm | Unset = UNSET,
145        is_insensitive: bool | Unset = UNSET,
146        parent: int | None | Unset = UNSET,
147        owner: int | None | Unset = UNSET,
148        set_permissions: SetPermissions | None | Unset = UNSET,
149    ) -> Tag:
150        """Partially update a tag (PATCH semantics).
151
152        Args:
153            id: Numeric ID of the tag to update.
154            name: Tag name.
155            color: Background colour as a CSS hex string.
156            is_inbox_tag: When ``True``, newly ingested documents get this tag.
157            match: Auto-matching pattern.
158            matching_algorithm: Controls how ``match`` is applied.
159                E.g. ``matching_algorithm=MatchingAlgorithm.REGEX`` for
160                regular-expression matching.
161            is_insensitive: When ``True``, ``match`` is case-insensitive.
162            parent: ID of parent tag.
163                Pass ``None`` to clear (make root tag).
164                Omit (or pass :data:`~easypaperless.UNSET`) to leave unchanged.
165            owner: Numeric user ID to assign as owner.
166                Pass ``None`` to clear the owner.
167                Omit (or pass :data:`~easypaperless.UNSET`) to leave unchanged.
168            set_permissions: Explicit view/change permission sets.
169                Pass ``None`` to clear all permissions (overwrite with empty).
170                Omit (or pass :data:`~easypaperless.UNSET`) to leave unchanged.
171
172        Returns:
173            The updated :class:`~easypaperless.models.tags.Tag`.
174        """
175        return cast(
176            Tag,
177            self._run(
178                self._async_tags.update(
179                    id,
180                    name=name,
181                    color=color,
182                    is_inbox_tag=is_inbox_tag,
183                    match=match,
184                    matching_algorithm=matching_algorithm,
185                    is_insensitive=is_insensitive,
186                    parent=parent,
187                    owner=owner,
188                    set_permissions=set_permissions,
189                )
190            ),
191        )

Partially update a tag (PATCH semantics).

Arguments:
  • id: Numeric ID of the tag to update.
  • name: Tag name.
  • color: Background colour as a CSS hex string.
  • is_inbox_tag: When True, newly ingested documents get this tag.
  • match: Auto-matching pattern.
  • matching_algorithm: Controls how match is applied. E.g. matching_algorithm=MatchingAlgorithm.REGEX for regular-expression matching.
  • is_insensitive: When True, match is case-insensitive.
  • parent: ID of parent tag. Pass None to clear (make root tag). Omit (or pass ~easypaperless.UNSET) to leave unchanged.
  • owner: Numeric user ID to assign as owner. Pass None to clear the owner. Omit (or pass ~easypaperless.UNSET) to leave unchanged.
  • set_permissions: Explicit view/change permission sets. Pass None to clear all permissions (overwrite with empty). Omit (or pass ~easypaperless.UNSET) to leave unchanged.
Returns:

The updated ~easypaperless.models.tags.Tag.

def delete(self, id: int) -> None:
193    def delete(self, id: int) -> None:
194        """Delete a tag.
195
196        Args:
197            id: Numeric ID of the tag to delete.
198
199        Raises:
200            ~easypaperless.exceptions.NotFoundError: If no tag exists with
201                that ID.
202        """
203        self._run(self._async_tags.delete(id))

Delete a tag.

Arguments:
  • id: Numeric ID of the tag to delete.
Raises:
def bulk_delete(self, ids: List[int]) -> None:
205    def bulk_delete(self, ids: List[int]) -> None:
206        """Permanently delete multiple tags in a single request.
207
208        Args:
209            ids: List of tag IDs to delete.
210        """
211        self._run(self._async_tags.bulk_delete(ids))

Permanently delete multiple tags in a single request.

Arguments:
  • ids: List of tag IDs to delete.
def bulk_set_permissions( self, ids: List[int], *, set_permissions: easypaperless.SetPermissions | easypaperless.Unset = UNSET, owner: int | None | easypaperless.Unset = UNSET, merge: bool = False) -> None:
213    def bulk_set_permissions(
214        self,
215        ids: List[int],
216        *,
217        set_permissions: SetPermissions | Unset = UNSET,
218        owner: int | None | Unset = UNSET,
219        merge: bool = False,
220    ) -> None:
221        """Set permissions and/or owner on multiple tags.
222
223        Args:
224            ids: List of tag IDs to modify.
225            set_permissions: Explicit view/change permission sets.
226                Omit (or pass :data:`~easypaperless.UNSET`) to leave unchanged.
227            owner: Numeric user ID to assign as owner.
228                Pass ``None`` to clear the owner.
229                Omit (or pass :data:`~easypaperless.UNSET`) to leave unchanged.
230            merge: When ``True``, new permissions are merged with existing ones.
231        """
232        self._run(
233            self._async_tags.bulk_set_permissions(
234                ids, set_permissions=set_permissions, owner=owner, merge=merge
235            )
236        )

Set permissions and/or owner on multiple tags.

Arguments:
  • ids: List of tag IDs to modify.
  • set_permissions: Explicit view/change permission sets. Omit (or pass ~easypaperless.UNSET) to leave unchanged.
  • owner: Numeric user ID to assign as owner. Pass None to clear the owner. Omit (or pass ~easypaperless.UNSET) to leave unchanged.
  • merge: When True, new permissions are merged with existing ones.
class UsersResource:
 20class UsersResource:
 21    """Accessor for users: ``client.users``."""
 22
 23    def __init__(self, core: _ClientCore) -> None:
 24        self._core = core
 25
 26    async def list(
 27        self,
 28        *,
 29        username_contains: str | Unset = UNSET,
 30        username_exact: str | Unset = UNSET,
 31        ordering: str | Unset = UNSET,
 32        page: int | Unset = UNSET,
 33        page_size: int | Unset = UNSET,
 34    ) -> PagedResult[User]:
 35        """Return users defined in paperless-ngx.
 36
 37        When ``page`` is ``UNSET`` (the default), all pages are fetched
 38        automatically and ``next`` / ``previous`` in the result are always
 39        ``None``.  When ``page`` is set, only that page is fetched and
 40        ``next`` / ``previous`` reflect the raw API values.
 41
 42        Args:
 43            username_contains: Case-insensitive substring filter on username.
 44            username_exact: Case-insensitive exact match on username.
 45            ordering: Field to sort by.
 46            page: Return only this specific page (1-based).
 47            page_size: Number of results per page.
 48
 49        Returns:
 50            :class:`~easypaperless.models.paged_result.PagedResult` of
 51            :class:`~easypaperless.models.users.User` objects.
 52        """
 53        logger.info("Listing users")
 54        params: dict[str, Any] = {}
 55        if not isinstance(username_contains, Unset):
 56            params["username__icontains"] = username_contains
 57        if not isinstance(username_exact, Unset):
 58            params["username__iexact"] = username_exact
 59        if not isinstance(ordering, Unset):
 60            params["ordering"] = ordering
 61        if not isinstance(page, Unset):
 62            params["page"] = page
 63        if not isinstance(page_size, Unset):
 64            params["page_size"] = page_size
 65        return cast(
 66            PagedResult[User],
 67            await self._core._list_resource("users", User, params or None),
 68        )
 69
 70    async def get(self, id: int) -> User:
 71        """Fetch a single user by their ID.
 72
 73        Args:
 74            id: Numeric user ID.
 75
 76        Returns:
 77            The :class:`~easypaperless.models.users.User` with the given ID.
 78
 79        Raises:
 80            ~easypaperless.exceptions.NotFoundError: If no user exists with
 81                that ID.
 82        """
 83        logger.info("Getting user id=%d", id)
 84        return cast(User, await self._core._get_resource("users", id, User))
 85
 86    async def create(
 87        self,
 88        *,
 89        username: str,
 90        email: str | Unset = UNSET,
 91        password: str | Unset = UNSET,
 92        first_name: str | Unset = UNSET,
 93        last_name: str | Unset = UNSET,
 94        date_joined: datetime | Unset = UNSET,
 95        is_staff: bool | Unset = UNSET,
 96        is_active: bool | Unset = UNSET,
 97        is_superuser: bool | Unset = UNSET,
 98        groups: List[int] | Unset = UNSET,
 99        user_permissions: List[str] | Unset = UNSET,
100    ) -> User:
101        """Create a new user.
102
103        Args:
104            username: Login username. Must be unique.
105            email: Email address.
106            password: Password for the new account.
107            first_name: Given name.
108            last_name: Family name.
109            date_joined: Account creation timestamp.
110            is_staff: Grant staff (admin UI) access.
111            is_active: Whether the account is active.
112            is_superuser: Grant unrestricted superuser access.
113            groups: IDs of groups to assign the user to.
114            user_permissions: Directly assigned permission codenames, without
115                the app label (e.g. ``["view_document"]``).  The app-labelled
116                form ``"documents.view_document"`` is rejected by paperless-ngx
117                with a :exc:`~easypaperless.exceptions.BadRequestError`.
118
119        Returns:
120            The newly created :class:`~easypaperless.models.users.User`.
121        """
122        logger.info("Creating user username=%r", username)
123        return cast(
124            User,
125            await self._core._create_resource(
126                "users",
127                User,
128                username=username,
129                email=email,
130                password=password,
131                first_name=first_name,
132                last_name=last_name,
133                date_joined=date_joined,
134                is_staff=is_staff,
135                is_active=is_active,
136                is_superuser=is_superuser,
137                groups=groups,
138                user_permissions=user_permissions,
139            ),
140        )
141
142    async def update(
143        self,
144        id: int,
145        *,
146        username: str | Unset = UNSET,
147        email: str | Unset = UNSET,
148        password: str | Unset = UNSET,
149        first_name: str | Unset = UNSET,
150        last_name: str | Unset = UNSET,
151        date_joined: datetime | Unset = UNSET,
152        is_staff: bool | Unset = UNSET,
153        is_active: bool | Unset = UNSET,
154        is_superuser: bool | Unset = UNSET,
155        groups: List[int] | Unset = UNSET,
156        user_permissions: List[str] | Unset = UNSET,
157    ) -> User:
158        """Partially update a user (PATCH semantics).
159
160        Only fields with a non-:data:`~easypaperless.UNSET` value are included
161        in the request body.  Omit a parameter (or pass
162        :data:`~easypaperless.UNSET`) to leave it unchanged.
163
164        Args:
165            id: Numeric ID of the user to update.
166            username: Login username.
167            email: Email address.
168            password: New password.
169            first_name: Given name.
170            last_name: Family name.
171            date_joined: Account creation timestamp.
172            is_staff: Grant or revoke staff access.
173            is_active: Activate or deactivate the account.
174            is_superuser: Grant or revoke superuser access.
175            groups: IDs of groups to assign the user to.
176            user_permissions: Directly assigned permission codenames, without
177                the app label (e.g. ``["view_document"]``).  The app-labelled
178                form ``"documents.view_document"`` is rejected by paperless-ngx
179                with a :exc:`~easypaperless.exceptions.BadRequestError`.
180
181        Returns:
182            The updated :class:`~easypaperless.models.users.User`.
183        """
184        logger.info("Updating user id=%d", id)
185        return cast(
186            User,
187            await self._core._update_resource(
188                "users",
189                id,
190                User,
191                username=username,
192                email=email,
193                password=password,
194                first_name=first_name,
195                last_name=last_name,
196                date_joined=date_joined,
197                is_staff=is_staff,
198                is_active=is_active,
199                is_superuser=is_superuser,
200                groups=groups,
201                user_permissions=user_permissions,
202            ),
203        )
204
205    async def delete(self, id: int) -> None:
206        """Delete a user.
207
208        Args:
209            id: Numeric ID of the user to delete.
210
211        Raises:
212            ~easypaperless.exceptions.NotFoundError: If no user exists with
213                that ID.
214        """
215        logger.info("Deleting user id=%d", id)
216        await self._core._delete_resource("users", id)

Accessor for users: client.users.

UsersResource(core: easypaperless.client._ClientCore)
23    def __init__(self, core: _ClientCore) -> None:
24        self._core = core
async def list( self, *, username_contains: str | easypaperless.Unset = UNSET, username_exact: str | easypaperless.Unset = UNSET, ordering: str | easypaperless.Unset = UNSET, page: int | easypaperless.Unset = UNSET, page_size: int | easypaperless.Unset = UNSET) -> easypaperless.PagedResult[User]:
26    async def list(
27        self,
28        *,
29        username_contains: str | Unset = UNSET,
30        username_exact: str | Unset = UNSET,
31        ordering: str | Unset = UNSET,
32        page: int | Unset = UNSET,
33        page_size: int | Unset = UNSET,
34    ) -> PagedResult[User]:
35        """Return users defined in paperless-ngx.
36
37        When ``page`` is ``UNSET`` (the default), all pages are fetched
38        automatically and ``next`` / ``previous`` in the result are always
39        ``None``.  When ``page`` is set, only that page is fetched and
40        ``next`` / ``previous`` reflect the raw API values.
41
42        Args:
43            username_contains: Case-insensitive substring filter on username.
44            username_exact: Case-insensitive exact match on username.
45            ordering: Field to sort by.
46            page: Return only this specific page (1-based).
47            page_size: Number of results per page.
48
49        Returns:
50            :class:`~easypaperless.models.paged_result.PagedResult` of
51            :class:`~easypaperless.models.users.User` objects.
52        """
53        logger.info("Listing users")
54        params: dict[str, Any] = {}
55        if not isinstance(username_contains, Unset):
56            params["username__icontains"] = username_contains
57        if not isinstance(username_exact, Unset):
58            params["username__iexact"] = username_exact
59        if not isinstance(ordering, Unset):
60            params["ordering"] = ordering
61        if not isinstance(page, Unset):
62            params["page"] = page
63        if not isinstance(page_size, Unset):
64            params["page_size"] = page_size
65        return cast(
66            PagedResult[User],
67            await self._core._list_resource("users", User, params or None),
68        )

Return users defined in paperless-ngx.

When page is UNSET (the default), all pages are fetched automatically and next / previous in the result are always None. When page is set, only that page is fetched and next / previous reflect the raw API values.

Arguments:
  • username_contains: Case-insensitive substring filter on username.
  • username_exact: Case-insensitive exact match on username.
  • ordering: Field to sort by.
  • page: Return only this specific page (1-based).
  • page_size: Number of results per page.
Returns:

~easypaperless.models.paged_result.PagedResult of ~easypaperless.models.users.User objects.

async def get(self, id: int) -> easypaperless.User:
70    async def get(self, id: int) -> User:
71        """Fetch a single user by their ID.
72
73        Args:
74            id: Numeric user ID.
75
76        Returns:
77            The :class:`~easypaperless.models.users.User` with the given ID.
78
79        Raises:
80            ~easypaperless.exceptions.NotFoundError: If no user exists with
81                that ID.
82        """
83        logger.info("Getting user id=%d", id)
84        return cast(User, await self._core._get_resource("users", id, User))

Fetch a single user by their ID.

Arguments:
  • id: Numeric user ID.
Returns:

The ~easypaperless.models.users.User with the given ID.

Raises:
async def create( self, *, username: str, email: str | easypaperless.Unset = UNSET, password: str | easypaperless.Unset = UNSET, first_name: str | easypaperless.Unset = UNSET, last_name: str | easypaperless.Unset = UNSET, date_joined: datetime.datetime | easypaperless.Unset = UNSET, is_staff: bool | easypaperless.Unset = UNSET, is_active: bool | easypaperless.Unset = UNSET, is_superuser: bool | easypaperless.Unset = UNSET, groups: Union[List[int], easypaperless.Unset] = UNSET, user_permissions: Union[List[str], easypaperless.Unset] = UNSET) -> easypaperless.User:
 86    async def create(
 87        self,
 88        *,
 89        username: str,
 90        email: str | Unset = UNSET,
 91        password: str | Unset = UNSET,
 92        first_name: str | Unset = UNSET,
 93        last_name: str | Unset = UNSET,
 94        date_joined: datetime | Unset = UNSET,
 95        is_staff: bool | Unset = UNSET,
 96        is_active: bool | Unset = UNSET,
 97        is_superuser: bool | Unset = UNSET,
 98        groups: List[int] | Unset = UNSET,
 99        user_permissions: List[str] | Unset = UNSET,
100    ) -> User:
101        """Create a new user.
102
103        Args:
104            username: Login username. Must be unique.
105            email: Email address.
106            password: Password for the new account.
107            first_name: Given name.
108            last_name: Family name.
109            date_joined: Account creation timestamp.
110            is_staff: Grant staff (admin UI) access.
111            is_active: Whether the account is active.
112            is_superuser: Grant unrestricted superuser access.
113            groups: IDs of groups to assign the user to.
114            user_permissions: Directly assigned permission codenames, without
115                the app label (e.g. ``["view_document"]``).  The app-labelled
116                form ``"documents.view_document"`` is rejected by paperless-ngx
117                with a :exc:`~easypaperless.exceptions.BadRequestError`.
118
119        Returns:
120            The newly created :class:`~easypaperless.models.users.User`.
121        """
122        logger.info("Creating user username=%r", username)
123        return cast(
124            User,
125            await self._core._create_resource(
126                "users",
127                User,
128                username=username,
129                email=email,
130                password=password,
131                first_name=first_name,
132                last_name=last_name,
133                date_joined=date_joined,
134                is_staff=is_staff,
135                is_active=is_active,
136                is_superuser=is_superuser,
137                groups=groups,
138                user_permissions=user_permissions,
139            ),
140        )

Create a new user.

Arguments:
  • username: Login username. Must be unique.
  • email: Email address.
  • password: Password for the new account.
  • first_name: Given name.
  • last_name: Family name.
  • date_joined: Account creation timestamp.
  • is_staff: Grant staff (admin UI) access.
  • is_active: Whether the account is active.
  • is_superuser: Grant unrestricted superuser access.
  • groups: IDs of groups to assign the user to.
  • user_permissions: Directly assigned permission codenames, without the app label (e.g. ["view_document"]). The app-labelled form "documents.view_document" is rejected by paperless-ngx with a ~easypaperless.exceptions.BadRequestError.
Returns:

The newly created ~easypaperless.models.users.User.

async def update( self, id: int, *, username: str | easypaperless.Unset = UNSET, email: str | easypaperless.Unset = UNSET, password: str | easypaperless.Unset = UNSET, first_name: str | easypaperless.Unset = UNSET, last_name: str | easypaperless.Unset = UNSET, date_joined: datetime.datetime | easypaperless.Unset = UNSET, is_staff: bool | easypaperless.Unset = UNSET, is_active: bool | easypaperless.Unset = UNSET, is_superuser: bool | easypaperless.Unset = UNSET, groups: Union[List[int], easypaperless.Unset] = UNSET, user_permissions: Union[List[str], easypaperless.Unset] = UNSET) -> easypaperless.User:
142    async def update(
143        self,
144        id: int,
145        *,
146        username: str | Unset = UNSET,
147        email: str | Unset = UNSET,
148        password: str | Unset = UNSET,
149        first_name: str | Unset = UNSET,
150        last_name: str | Unset = UNSET,
151        date_joined: datetime | Unset = UNSET,
152        is_staff: bool | Unset = UNSET,
153        is_active: bool | Unset = UNSET,
154        is_superuser: bool | Unset = UNSET,
155        groups: List[int] | Unset = UNSET,
156        user_permissions: List[str] | Unset = UNSET,
157    ) -> User:
158        """Partially update a user (PATCH semantics).
159
160        Only fields with a non-:data:`~easypaperless.UNSET` value are included
161        in the request body.  Omit a parameter (or pass
162        :data:`~easypaperless.UNSET`) to leave it unchanged.
163
164        Args:
165            id: Numeric ID of the user to update.
166            username: Login username.
167            email: Email address.
168            password: New password.
169            first_name: Given name.
170            last_name: Family name.
171            date_joined: Account creation timestamp.
172            is_staff: Grant or revoke staff access.
173            is_active: Activate or deactivate the account.
174            is_superuser: Grant or revoke superuser access.
175            groups: IDs of groups to assign the user to.
176            user_permissions: Directly assigned permission codenames, without
177                the app label (e.g. ``["view_document"]``).  The app-labelled
178                form ``"documents.view_document"`` is rejected by paperless-ngx
179                with a :exc:`~easypaperless.exceptions.BadRequestError`.
180
181        Returns:
182            The updated :class:`~easypaperless.models.users.User`.
183        """
184        logger.info("Updating user id=%d", id)
185        return cast(
186            User,
187            await self._core._update_resource(
188                "users",
189                id,
190                User,
191                username=username,
192                email=email,
193                password=password,
194                first_name=first_name,
195                last_name=last_name,
196                date_joined=date_joined,
197                is_staff=is_staff,
198                is_active=is_active,
199                is_superuser=is_superuser,
200                groups=groups,
201                user_permissions=user_permissions,
202            ),
203        )

Partially update a user (PATCH semantics).

Only fields with a non-~easypaperless.UNSET value are included in the request body. Omit a parameter (or pass ~easypaperless.UNSET) to leave it unchanged.

Arguments:
  • id: Numeric ID of the user to update.
  • username: Login username.
  • email: Email address.
  • password: New password.
  • first_name: Given name.
  • last_name: Family name.
  • date_joined: Account creation timestamp.
  • is_staff: Grant or revoke staff access.
  • is_active: Activate or deactivate the account.
  • is_superuser: Grant or revoke superuser access.
  • groups: IDs of groups to assign the user to.
  • user_permissions: Directly assigned permission codenames, without the app label (e.g. ["view_document"]). The app-labelled form "documents.view_document" is rejected by paperless-ngx with a ~easypaperless.exceptions.BadRequestError.
Returns:

The updated ~easypaperless.models.users.User.

async def delete(self, id: int) -> None:
205    async def delete(self, id: int) -> None:
206        """Delete a user.
207
208        Args:
209            id: Numeric ID of the user to delete.
210
211        Raises:
212            ~easypaperless.exceptions.NotFoundError: If no user exists with
213                that ID.
214        """
215        logger.info("Deleting user id=%d", id)
216        await self._core._delete_resource("users", id)

Delete a user.

Arguments:
  • id: Numeric ID of the user to delete.
Raises:
class SyncUsersResource:
 17class SyncUsersResource:
 18    """Sync accessor for users: ``client.users``."""
 19
 20    def __init__(self, async_users: UsersResource, run: Any) -> None:
 21        self._async_users = async_users
 22        self._run = run
 23
 24    def list(
 25        self,
 26        *,
 27        username_contains: str | Unset = UNSET,
 28        username_exact: str | Unset = UNSET,
 29        ordering: str | Unset = UNSET,
 30        page: int | Unset = UNSET,
 31        page_size: int | Unset = UNSET,
 32    ) -> PagedResult[User]:
 33        """Return users defined in paperless-ngx.
 34
 35        When ``page`` is ``UNSET`` (the default), all pages are fetched
 36        automatically and ``next`` / ``previous`` in the result are always
 37        ``None``.  When ``page`` is set, only that page is fetched and
 38        ``next`` / ``previous`` reflect the raw API values.
 39
 40        Args:
 41            username_contains: Case-insensitive substring filter on username.
 42            username_exact: Case-insensitive exact match on username.
 43            ordering: Field to sort by.
 44            page: Return only this specific page (1-based).
 45            page_size: Number of results per page.
 46
 47        Returns:
 48            :class:`~easypaperless.models.paged_result.PagedResult` of
 49            :class:`~easypaperless.models.users.User` objects.
 50        """
 51        return cast(
 52            PagedResult[User],
 53            self._run(
 54                self._async_users.list(
 55                    username_contains=username_contains,
 56                    username_exact=username_exact,
 57                    ordering=ordering,
 58                    page=page,
 59                    page_size=page_size,
 60                )
 61            ),
 62        )
 63
 64    def get(self, id: int) -> User:
 65        """Fetch a single user by their ID.
 66
 67        Args:
 68            id: Numeric user ID.
 69
 70        Returns:
 71            The :class:`~easypaperless.models.users.User` with the given ID.
 72
 73        Raises:
 74            ~easypaperless.exceptions.NotFoundError: If no user exists with
 75                that ID.
 76        """
 77        return cast(User, self._run(self._async_users.get(id)))
 78
 79    def create(
 80        self,
 81        *,
 82        username: str,
 83        email: str | Unset = UNSET,
 84        password: str | Unset = UNSET,
 85        first_name: str | Unset = UNSET,
 86        last_name: str | Unset = UNSET,
 87        date_joined: datetime | Unset = UNSET,
 88        is_staff: bool | Unset = UNSET,
 89        is_active: bool | Unset = UNSET,
 90        is_superuser: bool | Unset = UNSET,
 91        groups: List[int] | Unset = UNSET,
 92        user_permissions: List[str] | Unset = UNSET,
 93    ) -> User:
 94        """Create a new user.
 95
 96        Args:
 97            username: Login username. Must be unique.
 98            email: Email address.
 99            password: Password for the new account.
100            first_name: Given name.
101            last_name: Family name.
102            date_joined: Account creation timestamp.
103            is_staff: Grant staff (admin UI) access.
104            is_active: Whether the account is active.
105            is_superuser: Grant unrestricted superuser access.
106            groups: IDs of groups to assign the user to.
107            user_permissions: Directly assigned permission codenames, without
108                the app label (e.g. ``["view_document"]``).  The app-labelled
109                form ``"documents.view_document"`` is rejected by paperless-ngx
110                with a :exc:`~easypaperless.exceptions.BadRequestError`.
111
112        Returns:
113            The newly created :class:`~easypaperless.models.users.User`.
114        """
115        return cast(
116            User,
117            self._run(
118                self._async_users.create(
119                    username=username,
120                    email=email,
121                    password=password,
122                    first_name=first_name,
123                    last_name=last_name,
124                    date_joined=date_joined,
125                    is_staff=is_staff,
126                    is_active=is_active,
127                    is_superuser=is_superuser,
128                    groups=groups,
129                    user_permissions=user_permissions,
130                )
131            ),
132        )
133
134    def update(
135        self,
136        id: int,
137        *,
138        username: str | Unset = UNSET,
139        email: str | Unset = UNSET,
140        password: str | Unset = UNSET,
141        first_name: str | Unset = UNSET,
142        last_name: str | Unset = UNSET,
143        date_joined: datetime | Unset = UNSET,
144        is_staff: bool | Unset = UNSET,
145        is_active: bool | Unset = UNSET,
146        is_superuser: bool | Unset = UNSET,
147        groups: List[int] | Unset = UNSET,
148        user_permissions: List[str] | Unset = UNSET,
149    ) -> User:
150        """Partially update a user (PATCH semantics).
151
152        Only fields with a non-:data:`~easypaperless.UNSET` value are included
153        in the request body.  Omit a parameter (or pass
154        :data:`~easypaperless.UNSET`) to leave it unchanged.
155
156        Args:
157            id: Numeric ID of the user to update.
158            username: Login username.
159            email: Email address.
160            password: New password.
161            first_name: Given name.
162            last_name: Family name.
163            date_joined: Account creation timestamp.
164            is_staff: Grant or revoke staff access.
165            is_active: Activate or deactivate the account.
166            is_superuser: Grant or revoke superuser access.
167            groups: IDs of groups to assign the user to.
168            user_permissions: Directly assigned permission codenames, without
169                the app label (e.g. ``["view_document"]``).  The app-labelled
170                form ``"documents.view_document"`` is rejected by paperless-ngx
171                with a :exc:`~easypaperless.exceptions.BadRequestError`.
172
173        Returns:
174            The updated :class:`~easypaperless.models.users.User`.
175        """
176        return cast(
177            User,
178            self._run(
179                self._async_users.update(
180                    id,
181                    username=username,
182                    email=email,
183                    password=password,
184                    first_name=first_name,
185                    last_name=last_name,
186                    date_joined=date_joined,
187                    is_staff=is_staff,
188                    is_active=is_active,
189                    is_superuser=is_superuser,
190                    groups=groups,
191                    user_permissions=user_permissions,
192                )
193            ),
194        )
195
196    def delete(self, id: int) -> None:
197        """Delete a user.
198
199        Args:
200            id: Numeric ID of the user to delete.
201
202        Raises:
203            ~easypaperless.exceptions.NotFoundError: If no user exists with
204                that ID.
205        """
206        self._run(self._async_users.delete(id))

Sync accessor for users: client.users.

SyncUsersResource( async_users: UsersResource, run: Any)
20    def __init__(self, async_users: UsersResource, run: Any) -> None:
21        self._async_users = async_users
22        self._run = run
def list( self, *, username_contains: str | easypaperless.Unset = UNSET, username_exact: str | easypaperless.Unset = UNSET, ordering: str | easypaperless.Unset = UNSET, page: int | easypaperless.Unset = UNSET, page_size: int | easypaperless.Unset = UNSET) -> easypaperless.PagedResult[User]:
24    def list(
25        self,
26        *,
27        username_contains: str | Unset = UNSET,
28        username_exact: str | Unset = UNSET,
29        ordering: str | Unset = UNSET,
30        page: int | Unset = UNSET,
31        page_size: int | Unset = UNSET,
32    ) -> PagedResult[User]:
33        """Return users defined in paperless-ngx.
34
35        When ``page`` is ``UNSET`` (the default), all pages are fetched
36        automatically and ``next`` / ``previous`` in the result are always
37        ``None``.  When ``page`` is set, only that page is fetched and
38        ``next`` / ``previous`` reflect the raw API values.
39
40        Args:
41            username_contains: Case-insensitive substring filter on username.
42            username_exact: Case-insensitive exact match on username.
43            ordering: Field to sort by.
44            page: Return only this specific page (1-based).
45            page_size: Number of results per page.
46
47        Returns:
48            :class:`~easypaperless.models.paged_result.PagedResult` of
49            :class:`~easypaperless.models.users.User` objects.
50        """
51        return cast(
52            PagedResult[User],
53            self._run(
54                self._async_users.list(
55                    username_contains=username_contains,
56                    username_exact=username_exact,
57                    ordering=ordering,
58                    page=page,
59                    page_size=page_size,
60                )
61            ),
62        )

Return users defined in paperless-ngx.

When page is UNSET (the default), all pages are fetched automatically and next / previous in the result are always None. When page is set, only that page is fetched and next / previous reflect the raw API values.

Arguments:
  • username_contains: Case-insensitive substring filter on username.
  • username_exact: Case-insensitive exact match on username.
  • ordering: Field to sort by.
  • page: Return only this specific page (1-based).
  • page_size: Number of results per page.
Returns:

~easypaperless.models.paged_result.PagedResult of ~easypaperless.models.users.User objects.

def get(self, id: int) -> easypaperless.User:
64    def get(self, id: int) -> User:
65        """Fetch a single user by their ID.
66
67        Args:
68            id: Numeric user ID.
69
70        Returns:
71            The :class:`~easypaperless.models.users.User` with the given ID.
72
73        Raises:
74            ~easypaperless.exceptions.NotFoundError: If no user exists with
75                that ID.
76        """
77        return cast(User, self._run(self._async_users.get(id)))

Fetch a single user by their ID.

Arguments:
  • id: Numeric user ID.
Returns:

The ~easypaperless.models.users.User with the given ID.

Raises:
def create( self, *, username: str, email: str | easypaperless.Unset = UNSET, password: str | easypaperless.Unset = UNSET, first_name: str | easypaperless.Unset = UNSET, last_name: str | easypaperless.Unset = UNSET, date_joined: datetime.datetime | easypaperless.Unset = UNSET, is_staff: bool | easypaperless.Unset = UNSET, is_active: bool | easypaperless.Unset = UNSET, is_superuser: bool | easypaperless.Unset = UNSET, groups: Union[List[int], easypaperless.Unset] = UNSET, user_permissions: Union[List[str], easypaperless.Unset] = UNSET) -> easypaperless.User:
 79    def create(
 80        self,
 81        *,
 82        username: str,
 83        email: str | Unset = UNSET,
 84        password: str | Unset = UNSET,
 85        first_name: str | Unset = UNSET,
 86        last_name: str | Unset = UNSET,
 87        date_joined: datetime | Unset = UNSET,
 88        is_staff: bool | Unset = UNSET,
 89        is_active: bool | Unset = UNSET,
 90        is_superuser: bool | Unset = UNSET,
 91        groups: List[int] | Unset = UNSET,
 92        user_permissions: List[str] | Unset = UNSET,
 93    ) -> User:
 94        """Create a new user.
 95
 96        Args:
 97            username: Login username. Must be unique.
 98            email: Email address.
 99            password: Password for the new account.
100            first_name: Given name.
101            last_name: Family name.
102            date_joined: Account creation timestamp.
103            is_staff: Grant staff (admin UI) access.
104            is_active: Whether the account is active.
105            is_superuser: Grant unrestricted superuser access.
106            groups: IDs of groups to assign the user to.
107            user_permissions: Directly assigned permission codenames, without
108                the app label (e.g. ``["view_document"]``).  The app-labelled
109                form ``"documents.view_document"`` is rejected by paperless-ngx
110                with a :exc:`~easypaperless.exceptions.BadRequestError`.
111
112        Returns:
113            The newly created :class:`~easypaperless.models.users.User`.
114        """
115        return cast(
116            User,
117            self._run(
118                self._async_users.create(
119                    username=username,
120                    email=email,
121                    password=password,
122                    first_name=first_name,
123                    last_name=last_name,
124                    date_joined=date_joined,
125                    is_staff=is_staff,
126                    is_active=is_active,
127                    is_superuser=is_superuser,
128                    groups=groups,
129                    user_permissions=user_permissions,
130                )
131            ),
132        )

Create a new user.

Arguments:
  • username: Login username. Must be unique.
  • email: Email address.
  • password: Password for the new account.
  • first_name: Given name.
  • last_name: Family name.
  • date_joined: Account creation timestamp.
  • is_staff: Grant staff (admin UI) access.
  • is_active: Whether the account is active.
  • is_superuser: Grant unrestricted superuser access.
  • groups: IDs of groups to assign the user to.
  • user_permissions: Directly assigned permission codenames, without the app label (e.g. ["view_document"]). The app-labelled form "documents.view_document" is rejected by paperless-ngx with a ~easypaperless.exceptions.BadRequestError.
Returns:

The newly created ~easypaperless.models.users.User.

def update( self, id: int, *, username: str | easypaperless.Unset = UNSET, email: str | easypaperless.Unset = UNSET, password: str | easypaperless.Unset = UNSET, first_name: str | easypaperless.Unset = UNSET, last_name: str | easypaperless.Unset = UNSET, date_joined: datetime.datetime | easypaperless.Unset = UNSET, is_staff: bool | easypaperless.Unset = UNSET, is_active: bool | easypaperless.Unset = UNSET, is_superuser: bool | easypaperless.Unset = UNSET, groups: Union[List[int], easypaperless.Unset] = UNSET, user_permissions: Union[List[str], easypaperless.Unset] = UNSET) -> easypaperless.User:
134    def update(
135        self,
136        id: int,
137        *,
138        username: str | Unset = UNSET,
139        email: str | Unset = UNSET,
140        password: str | Unset = UNSET,
141        first_name: str | Unset = UNSET,
142        last_name: str | Unset = UNSET,
143        date_joined: datetime | Unset = UNSET,
144        is_staff: bool | Unset = UNSET,
145        is_active: bool | Unset = UNSET,
146        is_superuser: bool | Unset = UNSET,
147        groups: List[int] | Unset = UNSET,
148        user_permissions: List[str] | Unset = UNSET,
149    ) -> User:
150        """Partially update a user (PATCH semantics).
151
152        Only fields with a non-:data:`~easypaperless.UNSET` value are included
153        in the request body.  Omit a parameter (or pass
154        :data:`~easypaperless.UNSET`) to leave it unchanged.
155
156        Args:
157            id: Numeric ID of the user to update.
158            username: Login username.
159            email: Email address.
160            password: New password.
161            first_name: Given name.
162            last_name: Family name.
163            date_joined: Account creation timestamp.
164            is_staff: Grant or revoke staff access.
165            is_active: Activate or deactivate the account.
166            is_superuser: Grant or revoke superuser access.
167            groups: IDs of groups to assign the user to.
168            user_permissions: Directly assigned permission codenames, without
169                the app label (e.g. ``["view_document"]``).  The app-labelled
170                form ``"documents.view_document"`` is rejected by paperless-ngx
171                with a :exc:`~easypaperless.exceptions.BadRequestError`.
172
173        Returns:
174            The updated :class:`~easypaperless.models.users.User`.
175        """
176        return cast(
177            User,
178            self._run(
179                self._async_users.update(
180                    id,
181                    username=username,
182                    email=email,
183                    password=password,
184                    first_name=first_name,
185                    last_name=last_name,
186                    date_joined=date_joined,
187                    is_staff=is_staff,
188                    is_active=is_active,
189                    is_superuser=is_superuser,
190                    groups=groups,
191                    user_permissions=user_permissions,
192                )
193            ),
194        )

Partially update a user (PATCH semantics).

Only fields with a non-~easypaperless.UNSET value are included in the request body. Omit a parameter (or pass ~easypaperless.UNSET) to leave it unchanged.

Arguments:
  • id: Numeric ID of the user to update.
  • username: Login username.
  • email: Email address.
  • password: New password.
  • first_name: Given name.
  • last_name: Family name.
  • date_joined: Account creation timestamp.
  • is_staff: Grant or revoke staff access.
  • is_active: Activate or deactivate the account.
  • is_superuser: Grant or revoke superuser access.
  • groups: IDs of groups to assign the user to.
  • user_permissions: Directly assigned permission codenames, without the app label (e.g. ["view_document"]). The app-labelled form "documents.view_document" is rejected by paperless-ngx with a ~easypaperless.exceptions.BadRequestError.
Returns:

The updated ~easypaperless.models.users.User.

def delete(self, id: int) -> None:
196    def delete(self, id: int) -> None:
197        """Delete a user.
198
199        Args:
200            id: Numeric ID of the user to delete.
201
202        Raises:
203            ~easypaperless.exceptions.NotFoundError: If no user exists with
204                that ID.
205        """
206        self._run(self._async_users.delete(id))

Delete a user.

Arguments:
  • id: Numeric ID of the user to delete.
Raises:
class GroupsResource:
 20class GroupsResource:
 21    """Accessor for groups: ``client.groups``."""
 22
 23    def __init__(self, core: _ClientCore) -> None:
 24        self._core = core
 25
 26    async def list(
 27        self,
 28        *,
 29        name_contains: str | Unset = UNSET,
 30        name_exact: str | Unset = UNSET,
 31        ordering: str | Unset = UNSET,
 32        page: int | Unset = UNSET,
 33        page_size: int | Unset = UNSET,
 34    ) -> PagedResult[Group]:
 35        """Return groups defined in paperless-ngx.
 36
 37        When ``page`` is ``UNSET`` (the default), all pages are fetched
 38        automatically and ``next`` / ``previous`` in the result are always
 39        ``None``.  When ``page`` is set, only that page is fetched and
 40        ``next`` / ``previous`` reflect the raw API values.
 41
 42        Args:
 43            name_contains: Case-insensitive substring filter on the group name.
 44            name_exact: Case-insensitive exact match on the group name.
 45            ordering: Field to sort by.
 46            page: Return only this specific page (1-based).
 47            page_size: Number of results per page.
 48
 49        Returns:
 50            :class:`~easypaperless.models.paged_result.PagedResult` of
 51            :class:`~easypaperless.models.groups.Group` objects.
 52        """
 53        logger.info("Listing groups")
 54        params: dict[str, Any] = {}
 55        if not isinstance(name_contains, Unset):
 56            params["name__icontains"] = name_contains
 57        if not isinstance(name_exact, Unset):
 58            params["name__iexact"] = name_exact
 59        if not isinstance(ordering, Unset):
 60            params["ordering"] = ordering
 61        if not isinstance(page, Unset):
 62            params["page"] = page
 63        if not isinstance(page_size, Unset):
 64            params["page_size"] = page_size
 65        return cast(
 66            PagedResult[Group],
 67            await self._core._list_resource("groups", Group, params or None),
 68        )
 69
 70    async def get(self, id: int) -> Group:
 71        """Fetch a single group by its ID.
 72
 73        Args:
 74            id: Numeric group ID.
 75
 76        Returns:
 77            The :class:`~easypaperless.models.groups.Group` with the given ID.
 78
 79        Raises:
 80            ~easypaperless.exceptions.NotFoundError: If no group exists with
 81                that ID.
 82        """
 83        logger.info("Getting group id=%d", id)
 84        return cast(Group, await self._core._get_resource("groups", id, Group))
 85
 86    async def create(
 87        self,
 88        *,
 89        name: str,
 90        permissions: builtins.list[str] | Unset = UNSET,
 91    ) -> Group:
 92        """Create a new group.
 93
 94        Args:
 95            name: Group name. Must be unique.
 96            permissions: Permission codenames to grant the group, without
 97                the app label (e.g. ``["view_document", "add_note"]``).
 98                paperless-ngx rejects the app-labelled form
 99                ``"documents.view_document"`` with a
100                :exc:`~easypaperless.exceptions.BadRequestError`.  When
101                omitted, ``[]`` is sent (paperless-ngx requires the field),
102                so the group starts without permissions.
103
104        Returns:
105            The newly created :class:`~easypaperless.models.groups.Group`.
106        """
107        logger.info("Creating group name=%r", name)
108        return cast(
109            Group,
110            await self._core._create_resource(
111                "groups",
112                Group,
113                name=name,
114                # paperless-ngx answers 400 "This field is required." without it.
115                permissions=[] if isinstance(permissions, Unset) else permissions,
116            ),
117        )
118
119    async def update(
120        self,
121        id: int,
122        *,
123        name: str | Unset = UNSET,
124        permissions: builtins.list[str] | Unset = UNSET,
125    ) -> Group:
126        """Partially update a group (PATCH semantics).
127
128        Only fields with a non-:data:`~easypaperless.UNSET` value are included
129        in the request body.  Omit a parameter (or pass
130        :data:`~easypaperless.UNSET`) to leave it unchanged.
131
132        Args:
133            id: Numeric ID of the group to update.
134            name: New group name.
135            permissions: Replacement list of permission codenames, without
136                the app label (e.g. ``["view_document"]``).  Pass ``[]`` to
137                remove all permissions.
138
139        Returns:
140            The updated :class:`~easypaperless.models.groups.Group`.
141        """
142        logger.info("Updating group id=%d", id)
143        return cast(
144            Group,
145            await self._core._update_resource(
146                "groups",
147                id,
148                Group,
149                name=name,
150                permissions=permissions,
151            ),
152        )
153
154    async def delete(self, id: int) -> None:
155        """Delete a group.
156
157        Args:
158            id: Numeric ID of the group to delete.
159
160        Raises:
161            ~easypaperless.exceptions.NotFoundError: If no group exists with
162                that ID.
163        """
164        logger.info("Deleting group id=%d", id)
165        await self._core._delete_resource("groups", id)

Accessor for groups: client.groups.

GroupsResource(core: easypaperless.client._ClientCore)
23    def __init__(self, core: _ClientCore) -> None:
24        self._core = core
async def list( self, *, name_contains: str | easypaperless.Unset = UNSET, name_exact: str | easypaperless.Unset = UNSET, ordering: str | easypaperless.Unset = UNSET, page: int | easypaperless.Unset = UNSET, page_size: int | easypaperless.Unset = UNSET) -> easypaperless.PagedResult[Group]:
26    async def list(
27        self,
28        *,
29        name_contains: str | Unset = UNSET,
30        name_exact: str | Unset = UNSET,
31        ordering: str | Unset = UNSET,
32        page: int | Unset = UNSET,
33        page_size: int | Unset = UNSET,
34    ) -> PagedResult[Group]:
35        """Return groups defined in paperless-ngx.
36
37        When ``page`` is ``UNSET`` (the default), all pages are fetched
38        automatically and ``next`` / ``previous`` in the result are always
39        ``None``.  When ``page`` is set, only that page is fetched and
40        ``next`` / ``previous`` reflect the raw API values.
41
42        Args:
43            name_contains: Case-insensitive substring filter on the group name.
44            name_exact: Case-insensitive exact match on the group name.
45            ordering: Field to sort by.
46            page: Return only this specific page (1-based).
47            page_size: Number of results per page.
48
49        Returns:
50            :class:`~easypaperless.models.paged_result.PagedResult` of
51            :class:`~easypaperless.models.groups.Group` objects.
52        """
53        logger.info("Listing groups")
54        params: dict[str, Any] = {}
55        if not isinstance(name_contains, Unset):
56            params["name__icontains"] = name_contains
57        if not isinstance(name_exact, Unset):
58            params["name__iexact"] = name_exact
59        if not isinstance(ordering, Unset):
60            params["ordering"] = ordering
61        if not isinstance(page, Unset):
62            params["page"] = page
63        if not isinstance(page_size, Unset):
64            params["page_size"] = page_size
65        return cast(
66            PagedResult[Group],
67            await self._core._list_resource("groups", Group, params or None),
68        )

Return groups defined in paperless-ngx.

When page is UNSET (the default), all pages are fetched automatically and next / previous in the result are always None. When page is set, only that page is fetched and next / previous reflect the raw API values.

Arguments:
  • name_contains: Case-insensitive substring filter on the group name.
  • name_exact: Case-insensitive exact match on the group name.
  • ordering: Field to sort by.
  • page: Return only this specific page (1-based).
  • page_size: Number of results per page.
Returns:

~easypaperless.models.paged_result.PagedResult of ~easypaperless.models.groups.Group objects.

async def get(self, id: int) -> easypaperless.Group:
70    async def get(self, id: int) -> Group:
71        """Fetch a single group by its ID.
72
73        Args:
74            id: Numeric group ID.
75
76        Returns:
77            The :class:`~easypaperless.models.groups.Group` with the given ID.
78
79        Raises:
80            ~easypaperless.exceptions.NotFoundError: If no group exists with
81                that ID.
82        """
83        logger.info("Getting group id=%d", id)
84        return cast(Group, await self._core._get_resource("groups", id, Group))

Fetch a single group by its ID.

Arguments:
  • id: Numeric group ID.
Returns:

The ~easypaperless.models.groups.Group with the given ID.

Raises:
async def create( self, *, name: str, permissions: list[str] | easypaperless.Unset = UNSET) -> easypaperless.Group:
 86    async def create(
 87        self,
 88        *,
 89        name: str,
 90        permissions: builtins.list[str] | Unset = UNSET,
 91    ) -> Group:
 92        """Create a new group.
 93
 94        Args:
 95            name: Group name. Must be unique.
 96            permissions: Permission codenames to grant the group, without
 97                the app label (e.g. ``["view_document", "add_note"]``).
 98                paperless-ngx rejects the app-labelled form
 99                ``"documents.view_document"`` with a
100                :exc:`~easypaperless.exceptions.BadRequestError`.  When
101                omitted, ``[]`` is sent (paperless-ngx requires the field),
102                so the group starts without permissions.
103
104        Returns:
105            The newly created :class:`~easypaperless.models.groups.Group`.
106        """
107        logger.info("Creating group name=%r", name)
108        return cast(
109            Group,
110            await self._core._create_resource(
111                "groups",
112                Group,
113                name=name,
114                # paperless-ngx answers 400 "This field is required." without it.
115                permissions=[] if isinstance(permissions, Unset) else permissions,
116            ),
117        )

Create a new group.

Arguments:
  • name: Group name. Must be unique.
  • permissions: Permission codenames to grant the group, without the app label (e.g. ["view_document", "add_note"]). paperless-ngx rejects the app-labelled form "documents.view_document" with a ~easypaperless.exceptions.BadRequestError. When omitted, [] is sent (paperless-ngx requires the field), so the group starts without permissions.
Returns:

The newly created ~easypaperless.models.groups.Group.

async def update( self, id: int, *, name: str | easypaperless.Unset = UNSET, permissions: list[str] | easypaperless.Unset = UNSET) -> easypaperless.Group:
119    async def update(
120        self,
121        id: int,
122        *,
123        name: str | Unset = UNSET,
124        permissions: builtins.list[str] | Unset = UNSET,
125    ) -> Group:
126        """Partially update a group (PATCH semantics).
127
128        Only fields with a non-:data:`~easypaperless.UNSET` value are included
129        in the request body.  Omit a parameter (or pass
130        :data:`~easypaperless.UNSET`) to leave it unchanged.
131
132        Args:
133            id: Numeric ID of the group to update.
134            name: New group name.
135            permissions: Replacement list of permission codenames, without
136                the app label (e.g. ``["view_document"]``).  Pass ``[]`` to
137                remove all permissions.
138
139        Returns:
140            The updated :class:`~easypaperless.models.groups.Group`.
141        """
142        logger.info("Updating group id=%d", id)
143        return cast(
144            Group,
145            await self._core._update_resource(
146                "groups",
147                id,
148                Group,
149                name=name,
150                permissions=permissions,
151            ),
152        )

Partially update a group (PATCH semantics).

Only fields with a non-~easypaperless.UNSET value are included in the request body. Omit a parameter (or pass ~easypaperless.UNSET) to leave it unchanged.

Arguments:
  • id: Numeric ID of the group to update.
  • name: New group name.
  • permissions: Replacement list of permission codenames, without the app label (e.g. ["view_document"]). Pass [] to remove all permissions.
Returns:

The updated ~easypaperless.models.groups.Group.

async def delete(self, id: int) -> None:
154    async def delete(self, id: int) -> None:
155        """Delete a group.
156
157        Args:
158            id: Numeric ID of the group to delete.
159
160        Raises:
161            ~easypaperless.exceptions.NotFoundError: If no group exists with
162                that ID.
163        """
164        logger.info("Deleting group id=%d", id)
165        await self._core._delete_resource("groups", id)

Delete a group.

Arguments:
  • id: Numeric ID of the group to delete.
Raises:
class SyncGroupsResource:
 17class SyncGroupsResource:
 18    """Sync accessor for groups: ``client.groups``."""
 19
 20    def __init__(self, async_groups: GroupsResource, run: Any) -> None:
 21        self._async_groups = async_groups
 22        self._run = run
 23
 24    def list(
 25        self,
 26        *,
 27        name_contains: str | Unset = UNSET,
 28        name_exact: str | Unset = UNSET,
 29        ordering: str | Unset = UNSET,
 30        page: int | Unset = UNSET,
 31        page_size: int | Unset = UNSET,
 32    ) -> PagedResult[Group]:
 33        """Return groups defined in paperless-ngx.
 34
 35        When ``page`` is ``UNSET`` (the default), all pages are fetched
 36        automatically and ``next`` / ``previous`` in the result are always
 37        ``None``.  When ``page`` is set, only that page is fetched and
 38        ``next`` / ``previous`` reflect the raw API values.
 39
 40        Args:
 41            name_contains: Case-insensitive substring filter on the group name.
 42            name_exact: Case-insensitive exact match on the group name.
 43            ordering: Field to sort by.
 44            page: Return only this specific page (1-based).
 45            page_size: Number of results per page.
 46
 47        Returns:
 48            :class:`~easypaperless.models.paged_result.PagedResult` of
 49            :class:`~easypaperless.models.groups.Group` objects.
 50        """
 51        return cast(
 52            PagedResult[Group],
 53            self._run(
 54                self._async_groups.list(
 55                    name_contains=name_contains,
 56                    name_exact=name_exact,
 57                    ordering=ordering,
 58                    page=page,
 59                    page_size=page_size,
 60                )
 61            ),
 62        )
 63
 64    def get(self, id: int) -> Group:
 65        """Fetch a single group by its ID.
 66
 67        Args:
 68            id: Numeric group ID.
 69
 70        Returns:
 71            The :class:`~easypaperless.models.groups.Group` with the given ID.
 72
 73        Raises:
 74            ~easypaperless.exceptions.NotFoundError: If no group exists with
 75                that ID.
 76        """
 77        return cast(Group, self._run(self._async_groups.get(id)))
 78
 79    def create(
 80        self,
 81        *,
 82        name: str,
 83        permissions: builtins.list[str] | Unset = UNSET,
 84    ) -> Group:
 85        """Create a new group.
 86
 87        Args:
 88            name: Group name. Must be unique.
 89            permissions: Permission codenames to grant the group, without
 90                the app label (e.g. ``["view_document", "add_note"]``).
 91                paperless-ngx rejects the app-labelled form
 92                ``"documents.view_document"`` with a
 93                :exc:`~easypaperless.exceptions.BadRequestError`.  When
 94                omitted, ``[]`` is sent (paperless-ngx requires the field),
 95                so the group starts without permissions.
 96
 97        Returns:
 98            The newly created :class:`~easypaperless.models.groups.Group`.
 99        """
100        return cast(
101            Group,
102            self._run(self._async_groups.create(name=name, permissions=permissions)),
103        )
104
105    def update(
106        self,
107        id: int,
108        *,
109        name: str | Unset = UNSET,
110        permissions: builtins.list[str] | Unset = UNSET,
111    ) -> Group:
112        """Partially update a group (PATCH semantics).
113
114        Only fields with a non-:data:`~easypaperless.UNSET` value are included
115        in the request body.  Omit a parameter (or pass
116        :data:`~easypaperless.UNSET`) to leave it unchanged.
117
118        Args:
119            id: Numeric ID of the group to update.
120            name: New group name.
121            permissions: Replacement list of permission codenames, without
122                the app label (e.g. ``["view_document"]``).  Pass ``[]`` to
123                remove all permissions.
124
125        Returns:
126            The updated :class:`~easypaperless.models.groups.Group`.
127        """
128        return cast(
129            Group,
130            self._run(self._async_groups.update(id, name=name, permissions=permissions)),
131        )
132
133    def delete(self, id: int) -> None:
134        """Delete a group.
135
136        Args:
137            id: Numeric ID of the group to delete.
138
139        Raises:
140            ~easypaperless.exceptions.NotFoundError: If no group exists with
141                that ID.
142        """
143        self._run(self._async_groups.delete(id))

Sync accessor for groups: client.groups.

SyncGroupsResource( async_groups: GroupsResource, run: Any)
20    def __init__(self, async_groups: GroupsResource, run: Any) -> None:
21        self._async_groups = async_groups
22        self._run = run
def list( self, *, name_contains: str | easypaperless.Unset = UNSET, name_exact: str | easypaperless.Unset = UNSET, ordering: str | easypaperless.Unset = UNSET, page: int | easypaperless.Unset = UNSET, page_size: int | easypaperless.Unset = UNSET) -> easypaperless.PagedResult[Group]:
24    def list(
25        self,
26        *,
27        name_contains: str | Unset = UNSET,
28        name_exact: str | Unset = UNSET,
29        ordering: str | Unset = UNSET,
30        page: int | Unset = UNSET,
31        page_size: int | Unset = UNSET,
32    ) -> PagedResult[Group]:
33        """Return groups defined in paperless-ngx.
34
35        When ``page`` is ``UNSET`` (the default), all pages are fetched
36        automatically and ``next`` / ``previous`` in the result are always
37        ``None``.  When ``page`` is set, only that page is fetched and
38        ``next`` / ``previous`` reflect the raw API values.
39
40        Args:
41            name_contains: Case-insensitive substring filter on the group name.
42            name_exact: Case-insensitive exact match on the group name.
43            ordering: Field to sort by.
44            page: Return only this specific page (1-based).
45            page_size: Number of results per page.
46
47        Returns:
48            :class:`~easypaperless.models.paged_result.PagedResult` of
49            :class:`~easypaperless.models.groups.Group` objects.
50        """
51        return cast(
52            PagedResult[Group],
53            self._run(
54                self._async_groups.list(
55                    name_contains=name_contains,
56                    name_exact=name_exact,
57                    ordering=ordering,
58                    page=page,
59                    page_size=page_size,
60                )
61            ),
62        )

Return groups defined in paperless-ngx.

When page is UNSET (the default), all pages are fetched automatically and next / previous in the result are always None. When page is set, only that page is fetched and next / previous reflect the raw API values.

Arguments:
  • name_contains: Case-insensitive substring filter on the group name.
  • name_exact: Case-insensitive exact match on the group name.
  • ordering: Field to sort by.
  • page: Return only this specific page (1-based).
  • page_size: Number of results per page.
Returns:

~easypaperless.models.paged_result.PagedResult of ~easypaperless.models.groups.Group objects.

def get(self, id: int) -> easypaperless.Group:
64    def get(self, id: int) -> Group:
65        """Fetch a single group by its ID.
66
67        Args:
68            id: Numeric group ID.
69
70        Returns:
71            The :class:`~easypaperless.models.groups.Group` with the given ID.
72
73        Raises:
74            ~easypaperless.exceptions.NotFoundError: If no group exists with
75                that ID.
76        """
77        return cast(Group, self._run(self._async_groups.get(id)))

Fetch a single group by its ID.

Arguments:
  • id: Numeric group ID.
Returns:

The ~easypaperless.models.groups.Group with the given ID.

Raises:
def create( self, *, name: str, permissions: list[str] | easypaperless.Unset = UNSET) -> easypaperless.Group:
 79    def create(
 80        self,
 81        *,
 82        name: str,
 83        permissions: builtins.list[str] | Unset = UNSET,
 84    ) -> Group:
 85        """Create a new group.
 86
 87        Args:
 88            name: Group name. Must be unique.
 89            permissions: Permission codenames to grant the group, without
 90                the app label (e.g. ``["view_document", "add_note"]``).
 91                paperless-ngx rejects the app-labelled form
 92                ``"documents.view_document"`` with a
 93                :exc:`~easypaperless.exceptions.BadRequestError`.  When
 94                omitted, ``[]`` is sent (paperless-ngx requires the field),
 95                so the group starts without permissions.
 96
 97        Returns:
 98            The newly created :class:`~easypaperless.models.groups.Group`.
 99        """
100        return cast(
101            Group,
102            self._run(self._async_groups.create(name=name, permissions=permissions)),
103        )

Create a new group.

Arguments:
  • name: Group name. Must be unique.
  • permissions: Permission codenames to grant the group, without the app label (e.g. ["view_document", "add_note"]). paperless-ngx rejects the app-labelled form "documents.view_document" with a ~easypaperless.exceptions.BadRequestError. When omitted, [] is sent (paperless-ngx requires the field), so the group starts without permissions.
Returns:

The newly created ~easypaperless.models.groups.Group.

def update( self, id: int, *, name: str | easypaperless.Unset = UNSET, permissions: list[str] | easypaperless.Unset = UNSET) -> easypaperless.Group:
105    def update(
106        self,
107        id: int,
108        *,
109        name: str | Unset = UNSET,
110        permissions: builtins.list[str] | Unset = UNSET,
111    ) -> Group:
112        """Partially update a group (PATCH semantics).
113
114        Only fields with a non-:data:`~easypaperless.UNSET` value are included
115        in the request body.  Omit a parameter (or pass
116        :data:`~easypaperless.UNSET`) to leave it unchanged.
117
118        Args:
119            id: Numeric ID of the group to update.
120            name: New group name.
121            permissions: Replacement list of permission codenames, without
122                the app label (e.g. ``["view_document"]``).  Pass ``[]`` to
123                remove all permissions.
124
125        Returns:
126            The updated :class:`~easypaperless.models.groups.Group`.
127        """
128        return cast(
129            Group,
130            self._run(self._async_groups.update(id, name=name, permissions=permissions)),
131        )

Partially update a group (PATCH semantics).

Only fields with a non-~easypaperless.UNSET value are included in the request body. Omit a parameter (or pass ~easypaperless.UNSET) to leave it unchanged.

Arguments:
  • id: Numeric ID of the group to update.
  • name: New group name.
  • permissions: Replacement list of permission codenames, without the app label (e.g. ["view_document"]). Pass [] to remove all permissions.
Returns:

The updated ~easypaperless.models.groups.Group.

def delete(self, id: int) -> None:
133    def delete(self, id: int) -> None:
134        """Delete a group.
135
136        Args:
137            id: Numeric ID of the group to delete.
138
139        Raises:
140            ~easypaperless.exceptions.NotFoundError: If no group exists with
141                that ID.
142        """
143        self._run(self._async_groups.delete(id))

Delete a group.

Arguments:
  • id: Numeric ID of the group to delete.
Raises:
class TrashResource:
19class TrashResource:
20    """Accessor for the trash bin: ``client.trash``."""
21
22    def __init__(self, core: _ClientCore) -> None:
23        self._core = core
24
25    async def list(
26        self,
27        *,
28        page: int | Unset = UNSET,
29        page_size: int | Unset = UNSET,
30    ) -> PagedResult[Document]:
31        """Return all documents currently in the trash.
32
33        When ``page`` is ``UNSET`` (the default), all pages are fetched
34        automatically and ``next`` / ``previous`` in the result are always
35        ``None``.  When ``page`` is set, only that page is fetched and
36        ``next`` / ``previous`` reflect the raw API values.
37
38        Args:
39            page: Return only this specific page (1-based).
40            page_size: Number of results per page.
41
42        Returns:
43            :class:`~easypaperless.models.paged_result.PagedResult` of
44            :class:`~easypaperless.models.documents.Document` objects currently
45            in the trash.
46        """
47        logger.info("Listing trashed documents")
48        params: dict[str, Any] = {}
49        if not isinstance(page, Unset):
50            params["page"] = page
51        if not isinstance(page_size, Unset):
52            params["page_size"] = page_size
53        return cast(
54            PagedResult[Document],
55            await self._core._list_resource("trash", Document, params or None),
56        )
57
58    async def restore(self, document_ids: List[int]) -> None:
59        """Restore trashed documents back to active status.
60
61        Args:
62            document_ids: List of numeric document IDs to restore.
63        """
64        logger.info("Restoring %d trashed document(s)", len(document_ids))
65        await self._core._session.post(
66            "/trash/",
67            json={"documents": document_ids, "action": "restore"},
68        )
69
70    async def empty(self, document_ids: List[int]) -> None:
71        """Permanently delete trashed documents.
72
73        .. warning::
74            **This operation is irreversible and cannot be undone.**
75            The documents will be permanently removed and cannot be recovered.
76
77        Args:
78            document_ids: List of numeric document IDs to permanently delete.
79        """
80        logger.info("Permanently deleting %d trashed document(s)", len(document_ids))
81        await self._core._session.post(
82            "/trash/",
83            json={"documents": document_ids, "action": "empty"},
84        )

Accessor for the trash bin: client.trash.

TrashResource(core: easypaperless.client._ClientCore)
22    def __init__(self, core: _ClientCore) -> None:
23        self._core = core
async def list( self, *, page: int | easypaperless.Unset = UNSET, page_size: int | easypaperless.Unset = UNSET) -> easypaperless.PagedResult[Document]:
25    async def list(
26        self,
27        *,
28        page: int | Unset = UNSET,
29        page_size: int | Unset = UNSET,
30    ) -> PagedResult[Document]:
31        """Return all documents currently in the trash.
32
33        When ``page`` is ``UNSET`` (the default), all pages are fetched
34        automatically and ``next`` / ``previous`` in the result are always
35        ``None``.  When ``page`` is set, only that page is fetched and
36        ``next`` / ``previous`` reflect the raw API values.
37
38        Args:
39            page: Return only this specific page (1-based).
40            page_size: Number of results per page.
41
42        Returns:
43            :class:`~easypaperless.models.paged_result.PagedResult` of
44            :class:`~easypaperless.models.documents.Document` objects currently
45            in the trash.
46        """
47        logger.info("Listing trashed documents")
48        params: dict[str, Any] = {}
49        if not isinstance(page, Unset):
50            params["page"] = page
51        if not isinstance(page_size, Unset):
52            params["page_size"] = page_size
53        return cast(
54            PagedResult[Document],
55            await self._core._list_resource("trash", Document, params or None),
56        )

Return all documents currently in the trash.

When page is UNSET (the default), all pages are fetched automatically and next / previous in the result are always None. When page is set, only that page is fetched and next / previous reflect the raw API values.

Arguments:
  • page: Return only this specific page (1-based).
  • page_size: Number of results per page.
Returns:

~easypaperless.models.paged_result.PagedResult of ~easypaperless.models.documents.Document objects currently in the trash.

async def restore(self, document_ids: List[int]) -> None:
58    async def restore(self, document_ids: List[int]) -> None:
59        """Restore trashed documents back to active status.
60
61        Args:
62            document_ids: List of numeric document IDs to restore.
63        """
64        logger.info("Restoring %d trashed document(s)", len(document_ids))
65        await self._core._session.post(
66            "/trash/",
67            json={"documents": document_ids, "action": "restore"},
68        )

Restore trashed documents back to active status.

Arguments:
  • document_ids: List of numeric document IDs to restore.
async def empty(self, document_ids: List[int]) -> None:
70    async def empty(self, document_ids: List[int]) -> None:
71        """Permanently delete trashed documents.
72
73        .. warning::
74            **This operation is irreversible and cannot be undone.**
75            The documents will be permanently removed and cannot be recovered.
76
77        Args:
78            document_ids: List of numeric document IDs to permanently delete.
79        """
80        logger.info("Permanently deleting %d trashed document(s)", len(document_ids))
81        await self._core._session.post(
82            "/trash/",
83            json={"documents": document_ids, "action": "empty"},
84        )

Permanently delete trashed documents.

This operation is irreversible and cannot be undone. The documents will be permanently removed and cannot be recovered.

Arguments:
  • document_ids: List of numeric document IDs to permanently delete.
class SyncTrashResource:
16class SyncTrashResource:
17    """Sync accessor for the trash bin: ``client.trash``."""
18
19    def __init__(self, async_trash: TrashResource, run: Any) -> None:
20        self._async_trash = async_trash
21        self._run = run
22
23    def list(
24        self,
25        *,
26        page: int | Unset = UNSET,
27        page_size: int | Unset = UNSET,
28    ) -> PagedResult[Document]:
29        """Return all documents currently in the trash.
30
31        When ``page`` is ``UNSET`` (the default), all pages are fetched
32        automatically and ``next`` / ``previous`` in the result are always
33        ``None``.  When ``page`` is set, only that page is fetched and
34        ``next`` / ``previous`` reflect the raw API values.
35
36        Args:
37            page: Return only this specific page (1-based).
38            page_size: Number of results per page.
39
40        Returns:
41            :class:`~easypaperless.models.paged_result.PagedResult` of
42            :class:`~easypaperless.models.documents.Document` objects currently
43            in the trash.
44        """
45        return cast(
46            PagedResult[Document],
47            self._run(self._async_trash.list(page=page, page_size=page_size)),
48        )
49
50    def restore(self, document_ids: List[int]) -> None:
51        """Restore trashed documents back to active status.
52
53        Args:
54            document_ids: List of numeric document IDs to restore.
55        """
56        self._run(self._async_trash.restore(document_ids))
57
58    def empty(self, document_ids: List[int]) -> None:
59        """Permanently delete trashed documents.
60
61        .. warning::
62            **This operation is irreversible and cannot be undone.**
63            The documents will be permanently removed and cannot be recovered.
64
65        Args:
66            document_ids: List of numeric document IDs to permanently delete.
67        """
68        self._run(self._async_trash.empty(document_ids))

Sync accessor for the trash bin: client.trash.

SyncTrashResource( async_trash: TrashResource, run: Any)
19    def __init__(self, async_trash: TrashResource, run: Any) -> None:
20        self._async_trash = async_trash
21        self._run = run
def list( self, *, page: int | easypaperless.Unset = UNSET, page_size: int | easypaperless.Unset = UNSET) -> easypaperless.PagedResult[Document]:
23    def list(
24        self,
25        *,
26        page: int | Unset = UNSET,
27        page_size: int | Unset = UNSET,
28    ) -> PagedResult[Document]:
29        """Return all documents currently in the trash.
30
31        When ``page`` is ``UNSET`` (the default), all pages are fetched
32        automatically and ``next`` / ``previous`` in the result are always
33        ``None``.  When ``page`` is set, only that page is fetched and
34        ``next`` / ``previous`` reflect the raw API values.
35
36        Args:
37            page: Return only this specific page (1-based).
38            page_size: Number of results per page.
39
40        Returns:
41            :class:`~easypaperless.models.paged_result.PagedResult` of
42            :class:`~easypaperless.models.documents.Document` objects currently
43            in the trash.
44        """
45        return cast(
46            PagedResult[Document],
47            self._run(self._async_trash.list(page=page, page_size=page_size)),
48        )

Return all documents currently in the trash.

When page is UNSET (the default), all pages are fetched automatically and next / previous in the result are always None. When page is set, only that page is fetched and next / previous reflect the raw API values.

Arguments:
  • page: Return only this specific page (1-based).
  • page_size: Number of results per page.
Returns:

~easypaperless.models.paged_result.PagedResult of ~easypaperless.models.documents.Document objects currently in the trash.

def restore(self, document_ids: List[int]) -> None:
50    def restore(self, document_ids: List[int]) -> None:
51        """Restore trashed documents back to active status.
52
53        Args:
54            document_ids: List of numeric document IDs to restore.
55        """
56        self._run(self._async_trash.restore(document_ids))

Restore trashed documents back to active status.

Arguments:
  • document_ids: List of numeric document IDs to restore.
def empty(self, document_ids: List[int]) -> None:
58    def empty(self, document_ids: List[int]) -> None:
59        """Permanently delete trashed documents.
60
61        .. warning::
62            **This operation is irreversible and cannot be undone.**
63            The documents will be permanently removed and cannot be recovered.
64
65        Args:
66            document_ids: List of numeric document IDs to permanently delete.
67        """
68        self._run(self._async_trash.empty(document_ids))

Permanently delete trashed documents.

This operation is irreversible and cannot be undone. The documents will be permanently removed and cannot be recovered.

Arguments:
  • document_ids: List of numeric document IDs to permanently delete.
class TasksResource:
 23class TasksResource:
 24    """Accessor for paperless-ngx background tasks: ``client.tasks``."""
 25
 26    def __init__(self, core: _ClientCore) -> None:
 27        self._core = core
 28
 29    async def list(
 30        self,
 31        *,
 32        task_id: str | Unset = UNSET,
 33        status: TaskStatus | str | Unset = UNSET,
 34        task_name: str | Unset = UNSET,
 35        type: str | Unset = UNSET,
 36        acknowledged: bool | Unset = UNSET,
 37    ) -> PagedResult[Task]:
 38        """Return background tasks, optionally filtered.
 39
 40        paperless-ngx returns the task list as a plain JSON array (not
 41        paginated); it is wrapped into a
 42        :class:`~easypaperless.models.paged_result.PagedResult` with
 43        ``next`` / ``previous`` set to ``None``.  A paginated response is
 44        accepted as well, and all its pages are fetched.
 45
 46        Args:
 47            task_id: Only the task with this Celery task ID (UUID string).
 48            status: Only tasks with this status, e.g. ``TaskStatus.FAILURE``
 49                or ``"FAILURE"``.
 50            task_name: Only tasks with this name: ``"consume_file"``,
 51                ``"train_classifier"``, ``"check_sanity"`` or
 52                ``"index_optimize"``.
 53            type: Only tasks of this type: ``"auto_task"``,
 54                ``"scheduled_task"`` or ``"manual_task"``.
 55            acknowledged: ``False`` for tasks not yet acknowledged (as shown
 56                in the paperless-ngx UI), ``True`` for acknowledged ones.
 57
 58        Returns:
 59            :class:`~easypaperless.models.paged_result.PagedResult` of
 60            :class:`~easypaperless.models.tasks.Task` objects.
 61
 62        Raises:
 63            ~easypaperless.exceptions.BadRequestError: If ``status``,
 64                ``task_name`` or ``type`` is not one of paperless-ngx's values.
 65                These filters are case-sensitive (``"success"`` is rejected).
 66        """
 67        logger.info("Listing tasks")
 68        filters = {
 69            "task_id": task_id,
 70            "status": status,
 71            "task_name": task_name,
 72            "type": type,
 73            "acknowledged": acknowledged,
 74        }
 75        params: dict[str, Any] = {k: v for k, v in filters.items() if not isinstance(v, Unset)}
 76        raw = await self._core._session.get_list("/tasks/", params=params or None)
 77        return PagedResult(
 78            count=raw.count,
 79            all=raw.all_ids,
 80            results=[Task.model_validate(item) for item in raw.items],
 81        )
 82
 83    async def get(self, task_id: str) -> Task:
 84        """Fetch a single task by its Celery task ID.
 85
 86        Args:
 87            task_id: The task's UUID string, e.g. as returned by
 88                ``documents.upload(wait=False)``.
 89
 90        Returns:
 91            The :class:`~easypaperless.models.tasks.Task`.
 92
 93        Raises:
 94            ~easypaperless.exceptions.NotFoundError: If paperless-ngx does not
 95                know a task with this ID.
 96        """
 97        logger.info("Getting task task_id=%r", task_id)
 98        task = await self._fetch(task_id)
 99        if task is None:
100            raise NotFoundError(f"Task {task_id!r} not found")
101        return task
102
103    async def wait(
104        self,
105        task_id: str,
106        *,
107        poll_interval: float | None = None,
108        poll_timeout: float | None = None,
109    ) -> Task:
110        """Poll a task until it reaches a terminal state and return it.
111
112        Use this to resume waiting for an upload started with
113        ``documents.upload(wait=False)``, or after a
114        :exc:`~easypaperless.exceptions.TaskTimeoutError`.  A task that
115        paperless-ngx does not list yet (right after an upload) is polled
116        again rather than treated as missing.  The task is checked at least
117        once, even with ``poll_timeout=0``.  A status this library does not
118        know is treated as not finished yet.  An unknown ``task_id`` therefore
119        keeps being polled until ``poll_timeout`` and then raises
120        :exc:`~easypaperless.exceptions.TaskTimeoutError`.
121
122        Args:
123            task_id: The task's UUID string, e.g. as returned by
124                ``documents.upload(wait=False)``.
125            poll_interval: Seconds between status checks.  When omitted, falls
126                back to the client-level ``poll_interval`` (``2.0`` s unless
127                changed at construction).
128            poll_timeout: Maximum seconds to wait.  When omitted, falls back to
129                the client-level ``poll_timeout`` (``60.0`` s unless changed at
130                construction).
131
132        Returns:
133            The final :class:`~easypaperless.models.tasks.Task` with status
134            ``SUCCESS``.
135
136        Raises:
137            ~easypaperless.exceptions.UploadError: If the task reports
138                ``FAILURE`` or ``REVOKED``; ``err.task`` holds the task with
139                paperless-ngx's ``status`` and ``result`` unaltered.
140            ~easypaperless.exceptions.TaskTimeoutError: If the task does not
141                finish within ``poll_timeout`` seconds; ``err.task_id`` and
142                ``err.timeout`` are set so the caller can wait again.
143        """
144        interval = poll_interval if poll_interval is not None else self._core._poll_interval
145        timeout = poll_timeout if poll_timeout is not None else self._core._poll_timeout
146        logger.info("Waiting for task task_id=%r (timeout=%.1fs)", task_id, timeout)
147        start = time.monotonic()
148        deadline = start + timeout
149        while True:
150            task = await self._fetch(task_id)
151            elapsed = time.monotonic() - start
152            status = task.status if task is not None else None
153            logger.debug(
154                "Polling task %r (status=%s, elapsed=%.1fs)",
155                task_id,
156                status if status is not None else "unknown",
157                elapsed,
158            )
159            if task is not None and status == TaskStatus.SUCCESS:
160                logger.info("Task %r succeeded", task_id)
161                return task
162            if task is not None and status == TaskStatus.FAILURE:
163                logger.warning("Task %r failed: %s", task_id, task.result)
164                raise UploadError(f"Document processing failed: {task.result}", task=task)
165            if task is not None and status == TaskStatus.REVOKED:
166                logger.warning("Task %r was revoked", task_id)
167                raise UploadError(f"Task {task_id!r} was revoked", task=task)
168            if time.monotonic() >= deadline:
169                break
170            await asyncio.sleep(interval)
171
172        logger.warning("Task %r timed out after %.1fs", task_id, time.monotonic() - start)
173        raise TaskTimeoutError(
174            f"Task {task_id!r} did not complete within {timeout}s",
175            task_id=task_id,
176            timeout=timeout,
177        )
178
179    async def acknowledge(self, ids: builtins.list[int]) -> int:
180        """Mark tasks as acknowledged, as the paperless-ngx UI's "Dismiss" does.
181
182        Args:
183            ids: Numeric task IDs (:attr:`Task.id
184                <easypaperless.models.tasks.Task.id>`, not the UUID
185                ``task_id``).
186
187        Returns:
188            The number of tasks paperless-ngx acknowledged.
189        """
190        logger.info("Acknowledging %d task(s)", len(ids))
191        resp = await self._core._session.post("/tasks/acknowledge/", json={"tasks": ids})
192        body = resp.json()
193        result = body.get("result") if isinstance(body, dict) else None
194        return result if isinstance(result, int) else len(ids)
195
196    async def _fetch(self, task_id: str) -> Task | None:
197        """Return the task with ``task_id``, or ``None`` if paperless has none."""
198        raw = await self._core._session.get_list(
199            "/tasks/", params={"task_id": task_id}, all_pages=False
200        )
201        if not raw.items:
202            return None
203        return Task.model_validate(raw.items[0])

Accessor for paperless-ngx background tasks: client.tasks.

TasksResource(core: easypaperless.client._ClientCore)
26    def __init__(self, core: _ClientCore) -> None:
27        self._core = core
async def list( self, *, task_id: str | easypaperless.Unset = UNSET, status: easypaperless.TaskStatus | str | easypaperless.Unset = UNSET, task_name: str | easypaperless.Unset = UNSET, type: str | easypaperless.Unset = UNSET, acknowledged: bool | easypaperless.Unset = UNSET) -> easypaperless.PagedResult[Task]:
29    async def list(
30        self,
31        *,
32        task_id: str | Unset = UNSET,
33        status: TaskStatus | str | Unset = UNSET,
34        task_name: str | Unset = UNSET,
35        type: str | Unset = UNSET,
36        acknowledged: bool | Unset = UNSET,
37    ) -> PagedResult[Task]:
38        """Return background tasks, optionally filtered.
39
40        paperless-ngx returns the task list as a plain JSON array (not
41        paginated); it is wrapped into a
42        :class:`~easypaperless.models.paged_result.PagedResult` with
43        ``next`` / ``previous`` set to ``None``.  A paginated response is
44        accepted as well, and all its pages are fetched.
45
46        Args:
47            task_id: Only the task with this Celery task ID (UUID string).
48            status: Only tasks with this status, e.g. ``TaskStatus.FAILURE``
49                or ``"FAILURE"``.
50            task_name: Only tasks with this name: ``"consume_file"``,
51                ``"train_classifier"``, ``"check_sanity"`` or
52                ``"index_optimize"``.
53            type: Only tasks of this type: ``"auto_task"``,
54                ``"scheduled_task"`` or ``"manual_task"``.
55            acknowledged: ``False`` for tasks not yet acknowledged (as shown
56                in the paperless-ngx UI), ``True`` for acknowledged ones.
57
58        Returns:
59            :class:`~easypaperless.models.paged_result.PagedResult` of
60            :class:`~easypaperless.models.tasks.Task` objects.
61
62        Raises:
63            ~easypaperless.exceptions.BadRequestError: If ``status``,
64                ``task_name`` or ``type`` is not one of paperless-ngx's values.
65                These filters are case-sensitive (``"success"`` is rejected).
66        """
67        logger.info("Listing tasks")
68        filters = {
69            "task_id": task_id,
70            "status": status,
71            "task_name": task_name,
72            "type": type,
73            "acknowledged": acknowledged,
74        }
75        params: dict[str, Any] = {k: v for k, v in filters.items() if not isinstance(v, Unset)}
76        raw = await self._core._session.get_list("/tasks/", params=params or None)
77        return PagedResult(
78            count=raw.count,
79            all=raw.all_ids,
80            results=[Task.model_validate(item) for item in raw.items],
81        )

Return background tasks, optionally filtered.

paperless-ngx returns the task list as a plain JSON array (not paginated); it is wrapped into a ~easypaperless.models.paged_result.PagedResult with next / previous set to None. A paginated response is accepted as well, and all its pages are fetched.

Arguments:
  • task_id: Only the task with this Celery task ID (UUID string).
  • status: Only tasks with this status, e.g. TaskStatus.FAILURE or "FAILURE".
  • task_name: Only tasks with this name: "consume_file", "train_classifier", "check_sanity" or "index_optimize".
  • type: Only tasks of this type: "auto_task", "scheduled_task" or "manual_task".
  • acknowledged: False for tasks not yet acknowledged (as shown in the paperless-ngx UI), True for acknowledged ones.
Returns:

~easypaperless.models.paged_result.PagedResult of ~easypaperless.models.tasks.Task objects.

Raises:
async def get(self, task_id: str) -> easypaperless.Task:
 83    async def get(self, task_id: str) -> Task:
 84        """Fetch a single task by its Celery task ID.
 85
 86        Args:
 87            task_id: The task's UUID string, e.g. as returned by
 88                ``documents.upload(wait=False)``.
 89
 90        Returns:
 91            The :class:`~easypaperless.models.tasks.Task`.
 92
 93        Raises:
 94            ~easypaperless.exceptions.NotFoundError: If paperless-ngx does not
 95                know a task with this ID.
 96        """
 97        logger.info("Getting task task_id=%r", task_id)
 98        task = await self._fetch(task_id)
 99        if task is None:
100            raise NotFoundError(f"Task {task_id!r} not found")
101        return task

Fetch a single task by its Celery task ID.

Arguments:
  • task_id: The task's UUID string, e.g. as returned by documents.upload(wait=False).
Returns:

The ~easypaperless.models.tasks.Task.

Raises:
async def wait( self, task_id: str, *, poll_interval: float | None = None, poll_timeout: float | None = None) -> easypaperless.Task:
103    async def wait(
104        self,
105        task_id: str,
106        *,
107        poll_interval: float | None = None,
108        poll_timeout: float | None = None,
109    ) -> Task:
110        """Poll a task until it reaches a terminal state and return it.
111
112        Use this to resume waiting for an upload started with
113        ``documents.upload(wait=False)``, or after a
114        :exc:`~easypaperless.exceptions.TaskTimeoutError`.  A task that
115        paperless-ngx does not list yet (right after an upload) is polled
116        again rather than treated as missing.  The task is checked at least
117        once, even with ``poll_timeout=0``.  A status this library does not
118        know is treated as not finished yet.  An unknown ``task_id`` therefore
119        keeps being polled until ``poll_timeout`` and then raises
120        :exc:`~easypaperless.exceptions.TaskTimeoutError`.
121
122        Args:
123            task_id: The task's UUID string, e.g. as returned by
124                ``documents.upload(wait=False)``.
125            poll_interval: Seconds between status checks.  When omitted, falls
126                back to the client-level ``poll_interval`` (``2.0`` s unless
127                changed at construction).
128            poll_timeout: Maximum seconds to wait.  When omitted, falls back to
129                the client-level ``poll_timeout`` (``60.0`` s unless changed at
130                construction).
131
132        Returns:
133            The final :class:`~easypaperless.models.tasks.Task` with status
134            ``SUCCESS``.
135
136        Raises:
137            ~easypaperless.exceptions.UploadError: If the task reports
138                ``FAILURE`` or ``REVOKED``; ``err.task`` holds the task with
139                paperless-ngx's ``status`` and ``result`` unaltered.
140            ~easypaperless.exceptions.TaskTimeoutError: If the task does not
141                finish within ``poll_timeout`` seconds; ``err.task_id`` and
142                ``err.timeout`` are set so the caller can wait again.
143        """
144        interval = poll_interval if poll_interval is not None else self._core._poll_interval
145        timeout = poll_timeout if poll_timeout is not None else self._core._poll_timeout
146        logger.info("Waiting for task task_id=%r (timeout=%.1fs)", task_id, timeout)
147        start = time.monotonic()
148        deadline = start + timeout
149        while True:
150            task = await self._fetch(task_id)
151            elapsed = time.monotonic() - start
152            status = task.status if task is not None else None
153            logger.debug(
154                "Polling task %r (status=%s, elapsed=%.1fs)",
155                task_id,
156                status if status is not None else "unknown",
157                elapsed,
158            )
159            if task is not None and status == TaskStatus.SUCCESS:
160                logger.info("Task %r succeeded", task_id)
161                return task
162            if task is not None and status == TaskStatus.FAILURE:
163                logger.warning("Task %r failed: %s", task_id, task.result)
164                raise UploadError(f"Document processing failed: {task.result}", task=task)
165            if task is not None and status == TaskStatus.REVOKED:
166                logger.warning("Task %r was revoked", task_id)
167                raise UploadError(f"Task {task_id!r} was revoked", task=task)
168            if time.monotonic() >= deadline:
169                break
170            await asyncio.sleep(interval)
171
172        logger.warning("Task %r timed out after %.1fs", task_id, time.monotonic() - start)
173        raise TaskTimeoutError(
174            f"Task {task_id!r} did not complete within {timeout}s",
175            task_id=task_id,
176            timeout=timeout,
177        )

Poll a task until it reaches a terminal state and return it.

Use this to resume waiting for an upload started with documents.upload(wait=False), or after a ~easypaperless.exceptions.TaskTimeoutError. A task that paperless-ngx does not list yet (right after an upload) is polled again rather than treated as missing. The task is checked at least once, even with poll_timeout=0. A status this library does not know is treated as not finished yet. An unknown task_id therefore keeps being polled until poll_timeout and then raises ~easypaperless.exceptions.TaskTimeoutError.

Arguments:
  • task_id: The task's UUID string, e.g. as returned by documents.upload(wait=False).
  • poll_interval: Seconds between status checks. When omitted, falls back to the client-level poll_interval (2.0 s unless changed at construction).
  • poll_timeout: Maximum seconds to wait. When omitted, falls back to the client-level poll_timeout (60.0 s unless changed at construction).
Returns:

The final ~easypaperless.models.tasks.Task with status SUCCESS.

Raises:
async def acknowledge(self, ids: list[int]) -> int:
179    async def acknowledge(self, ids: builtins.list[int]) -> int:
180        """Mark tasks as acknowledged, as the paperless-ngx UI's "Dismiss" does.
181
182        Args:
183            ids: Numeric task IDs (:attr:`Task.id
184                <easypaperless.models.tasks.Task.id>`, not the UUID
185                ``task_id``).
186
187        Returns:
188            The number of tasks paperless-ngx acknowledged.
189        """
190        logger.info("Acknowledging %d task(s)", len(ids))
191        resp = await self._core._session.post("/tasks/acknowledge/", json={"tasks": ids})
192        body = resp.json()
193        result = body.get("result") if isinstance(body, dict) else None
194        return result if isinstance(result, int) else len(ids)

Mark tasks as acknowledged, as the paperless-ngx UI's "Dismiss" does.

Arguments:
Returns:

The number of tasks paperless-ngx acknowledged.

class SyncTasksResource:
 17class SyncTasksResource:
 18    """Sync accessor for paperless-ngx background tasks: ``client.tasks``."""
 19
 20    def __init__(self, async_tasks: TasksResource, run: Any) -> None:
 21        self._async_tasks = async_tasks
 22        self._run = run
 23
 24    def list(
 25        self,
 26        *,
 27        task_id: str | Unset = UNSET,
 28        status: TaskStatus | str | Unset = UNSET,
 29        task_name: str | Unset = UNSET,
 30        type: str | Unset = UNSET,
 31        acknowledged: bool | Unset = UNSET,
 32    ) -> PagedResult[Task]:
 33        """Return background tasks, optionally filtered.
 34
 35        paperless-ngx returns the task list as a plain JSON array (not
 36        paginated); it is wrapped into a
 37        :class:`~easypaperless.models.paged_result.PagedResult` with
 38        ``next`` / ``previous`` set to ``None``.  A paginated response is
 39        accepted as well, and all its pages are fetched.
 40
 41        Args:
 42            task_id: Only the task with this Celery task ID (UUID string).
 43            status: Only tasks with this status, e.g. ``TaskStatus.FAILURE``
 44                or ``"FAILURE"``.
 45            task_name: Only tasks with this name: ``"consume_file"``,
 46                ``"train_classifier"``, ``"check_sanity"`` or
 47                ``"index_optimize"``.
 48            type: Only tasks of this type: ``"auto_task"``,
 49                ``"scheduled_task"`` or ``"manual_task"``.
 50            acknowledged: ``False`` for tasks not yet acknowledged (as shown
 51                in the paperless-ngx UI), ``True`` for acknowledged ones.
 52
 53        Returns:
 54            :class:`~easypaperless.models.paged_result.PagedResult` of
 55            :class:`~easypaperless.models.tasks.Task` objects.
 56
 57        Raises:
 58            ~easypaperless.exceptions.BadRequestError: If ``status``,
 59                ``task_name`` or ``type`` is not one of paperless-ngx's values.
 60                These filters are case-sensitive (``"success"`` is rejected).
 61        """
 62        return cast(
 63            PagedResult[Task],
 64            self._run(
 65                self._async_tasks.list(
 66                    task_id=task_id,
 67                    status=status,
 68                    task_name=task_name,
 69                    type=type,
 70                    acknowledged=acknowledged,
 71                )
 72            ),
 73        )
 74
 75    def get(self, task_id: str) -> Task:
 76        """Fetch a single task by its Celery task ID.
 77
 78        Args:
 79            task_id: The task's UUID string, e.g. as returned by
 80                ``documents.upload(wait=False)``.
 81
 82        Returns:
 83            The :class:`~easypaperless.models.tasks.Task`.
 84
 85        Raises:
 86            ~easypaperless.exceptions.NotFoundError: If paperless-ngx does not
 87                know a task with this ID.
 88        """
 89        return cast(Task, self._run(self._async_tasks.get(task_id)))
 90
 91    def wait(
 92        self,
 93        task_id: str,
 94        *,
 95        poll_interval: float | None = None,
 96        poll_timeout: float | None = None,
 97    ) -> Task:
 98        """Poll a task until it reaches a terminal state and return it.
 99
100        Use this to resume waiting for an upload started with
101        ``documents.upload(wait=False)``, or after a
102        :exc:`~easypaperless.exceptions.TaskTimeoutError`.  A task that
103        paperless-ngx does not list yet (right after an upload) is polled
104        again rather than treated as missing.  The task is checked at least
105        once, even with ``poll_timeout=0``.  A status this library does not
106        know is treated as not finished yet.  An unknown ``task_id`` therefore
107        keeps being polled until ``poll_timeout`` and then raises
108        :exc:`~easypaperless.exceptions.TaskTimeoutError`.
109
110        Args:
111            task_id: The task's UUID string, e.g. as returned by
112                ``documents.upload(wait=False)``.
113            poll_interval: Seconds between status checks.  When omitted, falls
114                back to the client-level ``poll_interval`` (``2.0`` s unless
115                changed at construction).
116            poll_timeout: Maximum seconds to wait.  When omitted, falls back to
117                the client-level ``poll_timeout`` (``60.0`` s unless changed at
118                construction).
119
120        Returns:
121            The final :class:`~easypaperless.models.tasks.Task` with status
122            ``SUCCESS``.
123
124        Raises:
125            ~easypaperless.exceptions.UploadError: If the task reports
126                ``FAILURE`` or ``REVOKED``; ``err.task`` holds the task with
127                paperless-ngx's ``status`` and ``result`` unaltered.
128            ~easypaperless.exceptions.TaskTimeoutError: If the task does not
129                finish within ``poll_timeout`` seconds; ``err.task_id`` and
130                ``err.timeout`` are set so the caller can wait again.
131        """
132        return cast(
133            Task,
134            self._run(
135                self._async_tasks.wait(
136                    task_id, poll_interval=poll_interval, poll_timeout=poll_timeout
137                )
138            ),
139        )
140
141    def acknowledge(self, ids: builtins.list[int]) -> int:
142        """Mark tasks as acknowledged, as the paperless-ngx UI's "Dismiss" does.
143
144        Args:
145            ids: Numeric task IDs (:attr:`Task.id
146                <easypaperless.models.tasks.Task.id>`, not the UUID
147                ``task_id``).
148
149        Returns:
150            The number of tasks paperless-ngx acknowledged.
151        """
152        return cast(int, self._run(self._async_tasks.acknowledge(ids)))

Sync accessor for paperless-ngx background tasks: client.tasks.

SyncTasksResource( async_tasks: TasksResource, run: Any)
20    def __init__(self, async_tasks: TasksResource, run: Any) -> None:
21        self._async_tasks = async_tasks
22        self._run = run
def list( self, *, task_id: str | easypaperless.Unset = UNSET, status: easypaperless.TaskStatus | str | easypaperless.Unset = UNSET, task_name: str | easypaperless.Unset = UNSET, type: str | easypaperless.Unset = UNSET, acknowledged: bool | easypaperless.Unset = UNSET) -> easypaperless.PagedResult[Task]:
24    def list(
25        self,
26        *,
27        task_id: str | Unset = UNSET,
28        status: TaskStatus | str | Unset = UNSET,
29        task_name: str | Unset = UNSET,
30        type: str | Unset = UNSET,
31        acknowledged: bool | Unset = UNSET,
32    ) -> PagedResult[Task]:
33        """Return background tasks, optionally filtered.
34
35        paperless-ngx returns the task list as a plain JSON array (not
36        paginated); it is wrapped into a
37        :class:`~easypaperless.models.paged_result.PagedResult` with
38        ``next`` / ``previous`` set to ``None``.  A paginated response is
39        accepted as well, and all its pages are fetched.
40
41        Args:
42            task_id: Only the task with this Celery task ID (UUID string).
43            status: Only tasks with this status, e.g. ``TaskStatus.FAILURE``
44                or ``"FAILURE"``.
45            task_name: Only tasks with this name: ``"consume_file"``,
46                ``"train_classifier"``, ``"check_sanity"`` or
47                ``"index_optimize"``.
48            type: Only tasks of this type: ``"auto_task"``,
49                ``"scheduled_task"`` or ``"manual_task"``.
50            acknowledged: ``False`` for tasks not yet acknowledged (as shown
51                in the paperless-ngx UI), ``True`` for acknowledged ones.
52
53        Returns:
54            :class:`~easypaperless.models.paged_result.PagedResult` of
55            :class:`~easypaperless.models.tasks.Task` objects.
56
57        Raises:
58            ~easypaperless.exceptions.BadRequestError: If ``status``,
59                ``task_name`` or ``type`` is not one of paperless-ngx's values.
60                These filters are case-sensitive (``"success"`` is rejected).
61        """
62        return cast(
63            PagedResult[Task],
64            self._run(
65                self._async_tasks.list(
66                    task_id=task_id,
67                    status=status,
68                    task_name=task_name,
69                    type=type,
70                    acknowledged=acknowledged,
71                )
72            ),
73        )

Return background tasks, optionally filtered.

paperless-ngx returns the task list as a plain JSON array (not paginated); it is wrapped into a ~easypaperless.models.paged_result.PagedResult with next / previous set to None. A paginated response is accepted as well, and all its pages are fetched.

Arguments:
  • task_id: Only the task with this Celery task ID (UUID string).
  • status: Only tasks with this status, e.g. TaskStatus.FAILURE or "FAILURE".
  • task_name: Only tasks with this name: "consume_file", "train_classifier", "check_sanity" or "index_optimize".
  • type: Only tasks of this type: "auto_task", "scheduled_task" or "manual_task".
  • acknowledged: False for tasks not yet acknowledged (as shown in the paperless-ngx UI), True for acknowledged ones.
Returns:

~easypaperless.models.paged_result.PagedResult of ~easypaperless.models.tasks.Task objects.

Raises:
def get(self, task_id: str) -> easypaperless.Task:
75    def get(self, task_id: str) -> Task:
76        """Fetch a single task by its Celery task ID.
77
78        Args:
79            task_id: The task's UUID string, e.g. as returned by
80                ``documents.upload(wait=False)``.
81
82        Returns:
83            The :class:`~easypaperless.models.tasks.Task`.
84
85        Raises:
86            ~easypaperless.exceptions.NotFoundError: If paperless-ngx does not
87                know a task with this ID.
88        """
89        return cast(Task, self._run(self._async_tasks.get(task_id)))

Fetch a single task by its Celery task ID.

Arguments:
  • task_id: The task's UUID string, e.g. as returned by documents.upload(wait=False).
Returns:

The ~easypaperless.models.tasks.Task.

Raises:
def wait( self, task_id: str, *, poll_interval: float | None = None, poll_timeout: float | None = None) -> easypaperless.Task:
 91    def wait(
 92        self,
 93        task_id: str,
 94        *,
 95        poll_interval: float | None = None,
 96        poll_timeout: float | None = None,
 97    ) -> Task:
 98        """Poll a task until it reaches a terminal state and return it.
 99
100        Use this to resume waiting for an upload started with
101        ``documents.upload(wait=False)``, or after a
102        :exc:`~easypaperless.exceptions.TaskTimeoutError`.  A task that
103        paperless-ngx does not list yet (right after an upload) is polled
104        again rather than treated as missing.  The task is checked at least
105        once, even with ``poll_timeout=0``.  A status this library does not
106        know is treated as not finished yet.  An unknown ``task_id`` therefore
107        keeps being polled until ``poll_timeout`` and then raises
108        :exc:`~easypaperless.exceptions.TaskTimeoutError`.
109
110        Args:
111            task_id: The task's UUID string, e.g. as returned by
112                ``documents.upload(wait=False)``.
113            poll_interval: Seconds between status checks.  When omitted, falls
114                back to the client-level ``poll_interval`` (``2.0`` s unless
115                changed at construction).
116            poll_timeout: Maximum seconds to wait.  When omitted, falls back to
117                the client-level ``poll_timeout`` (``60.0`` s unless changed at
118                construction).
119
120        Returns:
121            The final :class:`~easypaperless.models.tasks.Task` with status
122            ``SUCCESS``.
123
124        Raises:
125            ~easypaperless.exceptions.UploadError: If the task reports
126                ``FAILURE`` or ``REVOKED``; ``err.task`` holds the task with
127                paperless-ngx's ``status`` and ``result`` unaltered.
128            ~easypaperless.exceptions.TaskTimeoutError: If the task does not
129                finish within ``poll_timeout`` seconds; ``err.task_id`` and
130                ``err.timeout`` are set so the caller can wait again.
131        """
132        return cast(
133            Task,
134            self._run(
135                self._async_tasks.wait(
136                    task_id, poll_interval=poll_interval, poll_timeout=poll_timeout
137                )
138            ),
139        )

Poll a task until it reaches a terminal state and return it.

Use this to resume waiting for an upload started with documents.upload(wait=False), or after a ~easypaperless.exceptions.TaskTimeoutError. A task that paperless-ngx does not list yet (right after an upload) is polled again rather than treated as missing. The task is checked at least once, even with poll_timeout=0. A status this library does not know is treated as not finished yet. An unknown task_id therefore keeps being polled until poll_timeout and then raises ~easypaperless.exceptions.TaskTimeoutError.

Arguments:
  • task_id: The task's UUID string, e.g. as returned by documents.upload(wait=False).
  • poll_interval: Seconds between status checks. When omitted, falls back to the client-level poll_interval (2.0 s unless changed at construction).
  • poll_timeout: Maximum seconds to wait. When omitted, falls back to the client-level poll_timeout (60.0 s unless changed at construction).
Returns:

The final ~easypaperless.models.tasks.Task with status SUCCESS.

Raises:
def acknowledge(self, ids: list[int]) -> int:
141    def acknowledge(self, ids: builtins.list[int]) -> int:
142        """Mark tasks as acknowledged, as the paperless-ngx UI's "Dismiss" does.
143
144        Args:
145            ids: Numeric task IDs (:attr:`Task.id
146                <easypaperless.models.tasks.Task.id>`, not the UUID
147                ``task_id``).
148
149        Returns:
150            The number of tasks paperless-ngx acknowledged.
151        """
152        return cast(int, self._run(self._async_tasks.acknowledge(ids)))

Mark tasks as acknowledged, as the paperless-ngx UI's "Dismiss" does.

Arguments:
Returns:

The number of tasks paperless-ngx acknowledged.