Add audit-events CLI command and docs#30
Open
rodchristiansen wants to merge 3 commits into
Open
Conversation
Expose APIClient.listAuditEvents as an audit-events subcommand: required --start/--end ISO8601 timestamps, optional single --type/--subject-id/--actor-id filters, --events-per-page and --total-limit, and pretty JSON output with a count on stderr. Document it in the README, framed around verifying an MDM server migration via DEVICE_ASSIGNED_TO_SERVER events.
There was a problem hiding this comment.
Pull request overview
Adds a new audit-events CLI subcommand (built on the Audit Events core client/models from stacked PR #29) and documents the feature/usage in the README to support audit-log based verification workflows (e.g., MDM migration validation).
Changes:
- Register a new
audit-eventssubcommand in the CLI entrypoint. - Implement
audit-eventscommand options (time range + optional filters), pagination/limit validation, and JSON output. - Update
README.mdwith API 2.0 feature bullet and an “Audit Events” usage section.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| Sources/cli/Entry.swift | Registers the new AuditEvents subcommand with the CLI. |
| Sources/cli/Commands.swift | Implements the audit-events command, arguments, validation, and output. |
| README.md | Documents the new API 2.0 audit-events capability and provides example invocations. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+641
to
+652
| func validate() throws { | ||
| if let eventsPerPage { | ||
| guard eventsPerPage > 0 && eventsPerPage <= 1000 else { | ||
| throw ValidationError("Events per page must be between 1 and 1000") | ||
| } | ||
| } | ||
| if let totalLimit { | ||
| guard totalLimit > 0 else { | ||
| throw ValidationError("Total limit must be greater than 0") | ||
| } | ||
| } | ||
| } |
The audit-events command targets the Apple Business API (2.1+). Apple School Manager (still 1.5) does not expose /v1/auditEvents, so the command now guards against School tenants. Note the requirement in the README feature list and command section.
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.
Summary
Adds the
audit-eventsCLI subcommand on top of the core Audit Events support, plus README docs. Stacked on #29 — review/merge that first; this PR's base isaudit-events-coreand will retarget tomainonce #29 merges.What's included
audit-eventscommand (Commands.swift, registered inEntry.swift) — required--start/--endISO8601 UTC timestamps, optional single--type/--subject-id/--actor-idfilters,--events-per-page(1–1000) and--total-limit, pretty JSON on stdout with an event count on stderr.Usage
Testing
swift buildclean (full workspace).--start/--endenforced,--events-per-pagebounds validated, missing-credentials path fails gracefully (no crash).