tb1337 / paperless-api

Little api client for paperless(-ngx).
https://pypi.org/p/pypaperless/
MIT License
24 stars 5 forks source link

[Feature request] `/api/acknowledge_tasks` endpoint #210

Open madduck opened 1 month ago

madduck commented 1 month ago

PNGX has an undocumented API endpoint to acknowledge tasks: /api/acknowledge_tasks/. It takes a POSTed list tasks with the IDs (not UUIDs) of Task objects, e.g.:

curl 'https://dms.example.org/api/acknowledge_tasks/' -X POST --data-raw '{"tasks":[539,537,536,535,534]}'

Since it allows for bulk acknowledgement, something like this would be good:

await paperless.acknowledge_tasks([539,537,536,535,534])

It would be great to also have this exposed as a method of the Task class/model for single-task acknowledgement, enabling e.g.:

task = await paperless.tasks("a57a3bea-4c89-4b4c-921b-011c5d6c34c7")
assert task.acknowledged == False
if task.status == TaskStatusType.SUCCESS:
    assert await task.acknowledge()
madduck commented 1 month ago

This can be used in the meantime:

resp = await paperless.request_json(
    "POST", "/api/acknowledge_tasks/", json=dict(tasks=[task.id])
)
tb1337 commented 2 weeks ago

I will think about that as I try to avoid endpoints for the Paperless frontend. Could you describe your use-case a little?

madduck commented 2 weeks ago

I mass-import files, and when an automatic import has been successful, I want to acknowledge the task automatically.

It's okay though to use the generic request_json function for this if you don't want to abstract the functionality…