Skip to content

Commit

Permalink
Add iterate override for tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
tb1337 committed Dec 19, 2023
1 parent eb9c84d commit 5c84e37
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pypaperless/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,15 @@ async def get(
res = await self._paperless.request("get", self._endpoint, params=kwargs)
return [dataclass_from_dict(self.endpoint_cls, item) for item in res]

async def iterate(
self,
**kwargs: dict[str, Any],
) -> Generator[Task, None, None]:
"""Iterate pages and yield every entity."""
res = await self.get(**kwargs)
for item in res:
yield item

async def one(self, idx: str) -> T:
"""Request exactly one entity by id."""
res = await self._paperless.request("get", self._endpoint, params={"task_id": idx})
Expand Down

0 comments on commit 5c84e37

Please sign in to comment.