events
Audit event models and type definitions for the append-only audit trail.
AuditOperation
Bases: StrEnum
CRUD operations captured by the audit log.
Source code in src/horde_model_reference/audit/events.py
AuditFieldChange
Bases: BaseModel
Represents a field-level delta for update operations.
Source code in src/horde_model_reference/audit/events.py
AuditPayload
Bases: BaseModel
Payload recorded with an audit event (full snapshots or deltas).
Source code in src/horde_model_reference/audit/events.py
before
class-attribute
instance-attribute
before: dict[str, Any] | None = Field(
default=None,
description="Full record state prior to the change",
)
after
class-attribute
instance-attribute
after: dict[str, Any] | None = Field(
default=None,
description="Full record state after the change",
)
delta
class-attribute
instance-attribute
delta: dict[str, AuditFieldChange] | None = Field(
default=None,
description="Sparse representation of changed fields for updates",
)
from_create
staticmethod
Build payload for create operations using the new record snapshot.
from_delete
staticmethod
Build payload for delete operations using the removed record snapshot.
from_update
staticmethod
Build payload for update operations using a sparse delta representation.
Source code in src/horde_model_reference/audit/events.py
AuditEvent
Bases: BaseModel
Single append-only audit event.
Source code in src/horde_model_reference/audit/events.py
timestamp
class-attribute
instance-attribute
logical_user_id
class-attribute
instance-attribute
request_id
class-attribute
instance-attribute
request_id: str | None = Field(
default=None,
description="Optional idempotency or tracing identifier",
)
payload
class-attribute
instance-attribute
new
staticmethod
new(
*,
event_id: int,
domain: CanonicalFormat,
category: str,
model_name: str,
operation: AuditOperation,
logical_user_id: str,
timestamp: int | None = None,
request_id: str | None = None,
payload: AuditPayload | None = None,
) -> AuditEvent
Create an audit event while filling defaults such as timestamp.