Add keyset pagination to Instance level audit events api
What does this MR do and why?
relates to: #367528 (closed)
The Audit Events interfaces do not currently have keyset pagination for the Instance level audit events API. This causes issues with large payloads
This changes implements keyset pagination, mirroring the addition of keyset pagination added to group audit events in this MR
Screenshots or screen recordings
example request 1 | example request 2 |
---|---|
![]() |
![]() |
How to set up and validate locally
-
I set things up locally as such:
user = User.find(1) group = Group.find(31) project = Project.find(7) 2.times { FactoryBot.create(:project_audit_event, target_project: project, user: user) } 2.times { FactoryBot.create(:group_audit_event, target_group: group, user: user) }
-
you will need a personal access token to use in the API requests.
-
Make an API query such as this (as an instance administrator)
curl -v \ --header "PRIVATE-TOKEN: $TOKEN" \ -H "Content-Type: application/json" \ -H "Accept: application/json, text/plain, */*" \ --url "localhost:3000/api/v4/audit_events?per_page=2&pagination=keyset&order_by=id" | json_pp
-
In the response headers, check the
Link
header which should be in this format:< Link: <http://127.0.0.1:3000/api/v4/projects/7/audit_events?cursor=eyJpZCI6IjYyMjAiLCJfa2QiOiJuIn0%3D&id=7&order_by=id&page=1&pagination=keyset&per_page=2>; rel="next"
-
Make the same request again, using the URL provided in the
LINK
headercurl -v \ --header "PRIVATE-TOKEN: $TOKEN" \ -H "Content-Type: application/json" \ -H "Accept: application/json, text/plain, */*" \ --url "http://127.0.0.1:3000/api/v4/audit_events?cursor=eyJpZCI6IjYyMjQiLCJfa2QiOiJuIn0%3D&order_by=id&page=1&pagination=keyset&per_page=2" | json_pp
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.