Audit | Python SDK
The audit API is designed for recording a trail of application-based user activity in a scalable, tamper-proof log.
download-file
Audit.download_file()Download search results
Audit.download_results(result_id, format)Get all search results as a compressed (gzip) CSV file.
response = audit.download_results(
result_id="pas_[...]",
format=DownloadFormat.JSON,
)
Log an entry
Audit.log(message, actor, action, new, old, source, status, target, timestamp, verify, sign_local, verbose, tenant_id)Create a log entry in the Secure Audit Log.
log_response = audit.log(
message="hello world",
verbose=True,
)
Log multiple entries
Audit.log_bulk(events, sign_local, verbose)Create multiple log entries in the Secure Audit Log.
log_response = audit.log_bulk(
events=[{"message": "hello world"}],
verbose=True,
)
Log multiple entries asynchronously
Audit.log_bulk_async(events, sign_local, verbose)Asynchronously create multiple log entries in the Secure Audit Log.
log_response = audit.log_bulk_async(
events=[{"message": "hello world"}],
verbose=True,
)
Log an entry
Audit.log_event(event, verify, sign_local, verbose)Create a log entry in the Secure Audit Log.
try:
log_response = audit.log({"message": "hello world"}, verbose=True)
print(f"Response. Hash: {log_response.result.hash}")
except pe.PangeaAPIException as e:
print(f"Request Error: {e.response.summary}")
for err in e.errors:
print(f"\t{err.detail} \n")
Poll result
Audit.poll_result(exception)Returns request's result that has been accepted by the server
response = service.poll_result(exception)
Results of a search
Audit.results(id, limit, offset, verify_consistency, verify_events)Fetch paginated results of a previously executed search.
response = audit.results(
id="pas_sqilrhruwu54uggihqj3aie24wrctakr",
limit=10,
offset=0,
)
Tamperproof verification
Audit.root(tree_size)Returns current root hash and consistency proof.
response = audit.root(tree_size=7)
Search the log
Audit.search(query, order, order_by, last, start, end, limit, max_results, search_restriction, verbose, verify_consistency, verify_events)Search for events that match the provided search criteria.
response = audit.search(
query="message:test",
search_restriction={'source': ["monitor"]},
limit=1,
verify_consistency=True,
verify_events=True,
)