feat(audit): add internal audit API client#455
Merged
ngjunsiang merged 3 commits intoweeklyfrom Apr 10, 2026
Merged
Conversation
Add comprehensive unit tests for the audit HTTP client implementation: - test_interface.py: Tests for base resource classes (ResourceRoot, ResourceCollection, Resource) - test_client.py: Tests for AuditClient initialization - test_traces.py: Tests for Traces resource methods and nested classes These tests verify: - Path construction with proper URL prefixes - Client propagation from parent to child resources - Bracket access patterns for ID-based resources - Property access for named sub-resources - Standard verb methods (new, list, search, get) Co-Authored-By: Claude Opus 4.6 <[email protected]>
Fix AttributeError in Trace, Span, and Spans classes by calling super().__init__() to properly set self.parent and self.path attributes. Also fix make_path() in ResourceCollection to avoid path duplication when constructing URLs. Changes: - Trace.__init__(): Call super().__init__() instead of manually setting path - Span.__init__(): Call super().__init__() instead of manually setting path - Spans.make_path(): Override to properly nest under Trace parent path - ResourceCollection.make_path(): Use root.url_prefix directly instead of root.make_path() Co-Authored-By: Claude Opus 4.6 <[email protected]>
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.
Overview
Adds an internal HTTP client for the Campus audit service that follows Campus API schema conventions. This client enables
campus.authandcampus.apideployments to send trace spans tocampus.auditvia HTTP.Changes
Client Implementation
campus/audit/client/__init__.py-AuditCliententry point with environment-based URL resolutioncampus/audit/client/interface.py-ResourceRoot,ResourceCollection,Resourcebase classescampus/audit/client/v1/__init__.py- v1 API modulecampus/audit/client/v1/root.py-AuditRootresourcecampus/audit/client/v1/traces.py-Traces,Trace,Spans,Spanresources with nested class structureUnit Tests
tests/unit/audit/test_client.py- Client initialization teststests/unit/audit/test_interface.py- Base resource class teststests/unit/audit/test_traces.py- Traces resource testsAPI Usage
Design
Follows
campus-api-pythonstructure with:ResourceCollectionfor collectionsnew(),list(),search(),get()client.traces[trace_id]client.traces[trace_id].spansRelated Issues