Documentation Index
Fetch the complete documentation index at: https://developer.kodexa.ai/llms.txt
Use this file to discover all available pages before exploring further.
The audit trail provides a comprehensive history of all changes made to data objects, data attributes, and tags within a document. Each modification is recorded as part of a revision, enabling you to track who changed what and when.
Overview
The audit system records:
- Revisions: Snapshots representing a set of related changes
- Data Object Audits: Creation, modification, and deletion of data objects
- Data Attribute Audits: Changes to attribute values and properties
- Tag Audits: Changes to content node tags
Accessing Audit Data
List Revisions
from kodexa_document import Document
with Document.from_kddb("processed.kddb") as doc:
# List all revisions
revisions = doc.audit.list_revisions()
for rev in revisions:
print(f"Revision {rev['id']}")
print(f" Created: {rev.get('createdAt')}")
print(f" Actor: {rev.get('actorUri')}")
print(f" Comment: {rev.get('comment')}")
Get Revision Details
with Document.from_kddb("processed.kddb") as doc:
# Get details for a specific revision
details = doc.audit.get_revision_details(revision_id=1)
if details:
print(f"Revision: {details}")
# Get a single revision
rev = doc.audit.get_revision(revision_id=1)
if rev:
print(f"Revision {rev['id']}: {rev.get('comment')}")
Entity History
Data Object History
Track all changes to a specific data object across revisions:
with Document.from_kddb("processed.kddb") as doc:
# Get the full history of a data object
history = doc.audit.get_data_object_history(data_object_id=1)
for entry in history:
print(f"Action: {entry.get('action')}")
print(f" Revision: {entry.get('revisionId')}")
print(f" Timestamp: {entry.get('createdAt')}")
Data Attribute History
Track changes to a specific data attribute:
with Document.from_kddb("processed.kddb") as doc:
# Get the full history of a data attribute
history = doc.audit.get_data_attribute_history(data_attribute_id=1)
for entry in history:
print(f"Action: {entry.get('action')}")
print(f" Old Value: {entry.get('oldValue')}")
print(f" New Value: {entry.get('newValue')}")
Tag History
Track changes to content node tags:
with Document.from_kddb("processed.kddb") as doc:
# Get the full history of a tag
history = doc.audit.get_tag_history(tag_id=1)
for entry in history:
print(f"Action: {entry.get('action')}")
print(f" Revision: {entry.get('revisionId')}")
Revision-Based Queries
Get all changes of a specific type for a given revision:
with Document.from_kddb("processed.kddb") as doc:
revisions = doc.audit.list_revisions()
for rev in revisions:
rev_id = rev['id']
# Get all data object changes in this revision
obj_audits = doc.audit.get_data_object_audits_by_revision(rev_id)
# Get all data attribute changes in this revision
attr_audits = doc.audit.get_data_attribute_audits_by_revision(rev_id)
# Get all tag changes in this revision
tag_audits = doc.audit.get_tag_audits_by_revision(rev_id)
print(f"Revision {rev_id}: "
f"{len(obj_audits)} object changes, "
f"{len(attr_audits)} attribute changes, "
f"{len(tag_audits)} tag changes")
API Reference
AuditAccessor Methods
| Method (Python) | Method (TypeScript) | Description |
|---|
list_revisions() | listRevisions() | List all revisions |
get_revision(id) | getRevision(id) | Get a specific revision |
get_revision_details(id) | getRevisionDetails(id) | Get detailed revision info |
get_data_object_history(id) | getDataObjectHistory(id) | History of a data object |
get_data_attribute_history(id) | getDataAttributeHistory(id) | History of a data attribute |
get_tag_history(id) | getTagHistory(id) | History of a tag |
get_data_object_audits_by_revision(id) | getDataObjectAuditsByRevision(id) | Object changes in revision |
get_data_attribute_audits_by_revision(id) | getDataAttributeAuditsByRevision(id) | Attribute changes in revision |
get_tag_audits_by_revision(id) | getTagAuditsByRevision(id) | Tag changes in revision |