[Site Admin] Site admin audit log read API#5790
Open
carmenlau wants to merge 9 commits into
Open
Conversation
SiteAdminAuditLogStore queries _audit_log scoped to the portal app ID. Count/List/Get each build a Squirrel query with activity_type LIKE 'site_admin.%', an optional affected_app_id JSON path filter, and ORDER BY created_at DESC/ASC driven by the order parameter. SiteAdminAuditReadService wraps the store with a nil-DB guard and pagination normalisation (page defaults to 1, page_size clamped to 100, order defaults to desc when invalid). ref DEV-3549 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Define AuditLogsListService and AuditLogGetService narrow interfaces on the two handler structs. parseAuditLogsListParams reads page, page_size, affected_app_id, and order from the query string. ServeHTTP bodies are stubs (http.NotFound) pending DI wiring. ref DEV-3549 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add SiteAdminAuditReadDatabase interface binding (*auditdb.ReadHandle), SiteAdminAuditLogStoreIface binding, and transport bindings for AuditLogsListService and AuditLogGetService. Regenerate wire_gen.go. ref DEV-3549 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
AuditLogsListHandler calls ListAuditLogs and maps entries to SiteAdminAuditLog using the entryToSiteAdminAuditLog helper (defined in handler_audit_logs_list.go and shared with AuditLogGetHandler). AuditLogGetHandler calls GetAuditLog and returns SiteAdminAuditLogDetail including the raw data field. Add vettedpositions for r.Context() in both handlers. Apply make check-tidy formatting output. ref DEV-3549 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
ref DEV-3549 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Seed 3 known entries directly via custom_audit_sql fixture (seed_siteadmin_audit_logs.sql) using a dedicated app ID (e2e-audit-log-app) that no other test touches. Tests cover: - GET /api/v1/audit-logs: basic structure, affected_app_id filter, order=desc (newest first), order=asc (oldest first), pagination - GET /api/v1/audit-logs/:id: detail response with data field - GET /api/v1/audit-logs/non-existent: 404 ref DEV-3549 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ref DEV-3549
Add GET
/api/v1/audit-logsand GET/api/v1/audit-logs/:idendpoints to the site admin API for querying site admin audit log entries.