paperap.models.task.model module
Task model module for interacting with Paperless-NgX tasks.
This module provides the Task model class for representing and interacting with background tasks in the Paperless-NgX system.
- class paperap.models.task.model.Task(**data)[source]
Bases:
StandardModel
Represents a background task in Paperless-NgX.
Tasks are used for tracking long-running operations in Paperless-NgX, such as document processing, OCR, classification, and bulk operations. This model provides access to task status, progress, and results.
- task_id
Unique identifier for the task in the task queue system.
- task_file_name
Name of the file being processed, if applicable.
- task_name
Human-readable name of the task type.
- date_created
When the task was created.
- date_started
When the task started execution.
- date_done
When the task completed (successfully or with error).
- type
The type of task being performed.
- status
Current status of the task (pending, running, success, failure).
- result
Result data from the task, often a JSON string.
- acknowledged
Whether the task has been acknowledged by a user.
ID of the document related to this task, if any.
Examples
>>> # Get a specific task >>> task = client.tasks.get(5) >>> print(f"Task status: {task.status}") >>> >>> # Wait for a task to complete >>> document = client.tasks.wait_for_task(task.task_id) >>> print(f"Document {document.id} ready")
- Parameters:
data (
Any
)
- task_id: str
- task_file_name: str | None
- task_name: TaskNameType | None
- date_created: datetime | None
- date_started: datetime | None
- date_done: datetime | None
- type: TaskTypeType | None
- status: TaskStatusType | None
- result: str | None
- acknowledged: bool
- related_document: int | None
- class Meta(model)[source]
Bases:
Meta
Metadata for the Task model.
Defines the queryset class to use for task queries.
- Parameters:
model (type[_Self])
- queryset
alias of
TaskQuerySet
- blacklist_filtering_params: ClassVar[set[str]] = {}
- field_map: dict[str, str] = {}
- filtering_disabled: ClassVar[set[str]] = {}
- filtering_fields: ClassVar[set[str]] = {'_resource', 'acknowledged', 'date_created', 'date_done', 'date_started', 'id', 'related_document', 'result', 'status', 'task_file_name', 'task_id', 'task_name', 'type'}
- read_only_fields: ClassVar[set[str]] = {'id'}
- supported_filtering_params: ClassVar[set[str]] = {'id', 'id__in', 'limit'}
- model: type[_Self]
- name: str
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'extra': 'ignore', 'populate_by_name': True, 'use_enum_values': True, 'validate_assignment': True, 'validate_default': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_post_init(context: Any, /) None
We need to both initialize private attributes and call the user-defined model_post_init method.
- id: int