Skip to content

Add audit-events CLI command and docs#30

Open
rodchristiansen wants to merge 3 commits into
audit-events-corefrom
audit-events-cli
Open

Add audit-events CLI command and docs#30
rodchristiansen wants to merge 3 commits into
audit-events-corefrom
audit-events-cli

Conversation

@rodchristiansen

Copy link
Copy Markdown
Owner

Summary

Adds the audit-events CLI subcommand on top of the core Audit Events support, plus README docs. Stacked on #29 — review/merge that first; this PR's base is audit-events-core and will retarget to main once #29 merges.

What's included

  • audit-events command (Commands.swift, registered in Entry.swift) — required --start/--end ISO8601 UTC timestamps, optional single --type / --subject-id / --actor-id filters, --events-per-page (1–1000) and --total-limit, pretty JSON on stdout with an event count on stderr.
  • README — API 2.0 feature bullet and a documented command section framed around migration verification.

Usage

asbmutil audit-events --start 2026-06-01T00:00:00Z --end 2026-06-14T23:59:59Z --type DEVICE_ASSIGNED_TO_SERVER

Testing

  • swift build clean (full workspace).
  • Verified arg parsing: required --start/--end enforced, --events-per-page bounds validated, missing-credentials path fails gracefully (no crash).
  • Live-API verification still pending (needs tenant credentials).

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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-events subcommand in the CLI entrypoint.
  • Implement audit-events command options (time range + optional filters), pagination/limit validation, and JSON output.
  • Update README.md with 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants