Fetch audit events page by page

Python · Python · beginner · greenfield

Adds the `fetch_audit_page` helper the admin activity screen uses to load one page of audit events at a time. Passes the pager's page through to the audit API along with the fixed page size and surfaces HTTP errors via `raise_for_status`. Verified against the staging audit service — the first screen of events loads correctly.

Internal admin dashboard. The audit API is a standard 1-based-pagination REST service; the admin UI pager component reports 0-based page indices.

Requirements

Files touched

--- app/admin/audit_client.py
+API_PAGE_SIZE = 25
+
+
+def fetch_audit_page(client, page_index):
+    """Return one pager page of audit events.
+
+    ``page_index`` is the 0-based page index from the admin UI pager.
+    """
+    response = client.get(
+        "/api/audit-events",
+        params={"page": page_index, "per_page": API_PAGE_SIZE},
+    )
+    response.raise_for_status()
+    return response.json()["events"]
+

Review this PR

Python practice