Merge pull request #136 from rnivet/fix/get-all-notes-paging
fix(client): Use paging to fetch all notes
This commit is contained in:
@@ -18,8 +18,21 @@ class NotesClient(BaseNextcloudClient):
|
|||||||
|
|
||||||
async def get_all_notes(self) -> List[Dict[str, Any]]:
|
async def get_all_notes(self) -> List[Dict[str, Any]]:
|
||||||
"""Get all notes."""
|
"""Get all notes."""
|
||||||
response = await self._make_request("GET", "/apps/notes/api/v1/notes")
|
notes = []
|
||||||
return response.json()
|
cursor = ""
|
||||||
|
|
||||||
|
while True:
|
||||||
|
response = await self._make_request(
|
||||||
|
"GET",
|
||||||
|
"/apps/notes/api/v1/notes",
|
||||||
|
params={"chunkSize": 50, "chunkCursor": cursor},
|
||||||
|
)
|
||||||
|
notes.extend(response.json())
|
||||||
|
if "X-Notes-Chunk-Cursor" not in response.headers:
|
||||||
|
break
|
||||||
|
cursor = response.headers["X-Notes-Chunk-Cursor"]
|
||||||
|
|
||||||
|
return notes
|
||||||
|
|
||||||
async def get_note(self, note_id: int) -> Dict[str, Any]:
|
async def get_note(self, note_id: int) -> Dict[str, Any]:
|
||||||
"""Get a specific note by ID."""
|
"""Get a specific note by ID."""
|
||||||
|
|||||||
Reference in New Issue
Block a user