Yield each cursor page; follow ``next_cursor`` until exhausted. Works over both ``MachineList`` (next_cursor + has_more) and ``ScheduleRunList`` (next_cursor only).
(
self,
fetch_page: Callable[[str | None], Awaitable[Any]],
)
| 55 | # -- pagination helpers ------------------------------------------------ |
| 56 | |
| 57 | async def _paginate_cursor( |
| 58 | self, |
| 59 | fetch_page: Callable[[str | None], Awaitable[Any]], |
| 60 | ) -> AsyncIterator[Any]: |
| 61 | """Yield each cursor page; follow ``next_cursor`` until exhausted. |
| 62 | |
| 63 | Works over both ``MachineList`` (next_cursor + has_more) and |
| 64 | ``ScheduleRunList`` (next_cursor only). |
| 65 | """ |
| 66 | cursor: str | None = None |
| 67 | while True: |
| 68 | page = await fetch_page(cursor) |
| 69 | yield page |
| 70 | next_cursor = getattr(page, "next_cursor", "") or None |
| 71 | if not next_cursor: |
| 72 | return |
| 73 | # has_more is only present on MachineList; absent (truthy default) elsewhere. |
| 74 | has_more_field = page.DESCRIPTOR.fields_by_name.get("has_more") |
| 75 | if has_more_field is not None and not getattr(page, "has_more", True): |
| 76 | return |
| 77 | cursor = next_cursor |
| 78 | |
| 79 | async def _paginate_offset( |
| 80 | self, |
no test coverage detected