Skip to main content

Retreiving an audit log

import decentriq_platform as dq
user_email = "@@ YOUR EMAIL HERE @@"
api_token = "@@ YOUR TOKEN HERE @@"

client = dq.create_client(user_email, api_token)
enclave_specs = dq.enclave_specifications.latest()

First, let's create a simple DCR to use as an example

import decentriq_platform as dq
from decentriq_platform.analytics import AnalyticsDcrBuilder

USER_EMAIL = "@@ YOUR EMAIL HERE @@"
API_TOKEN = "@@ YOUR TOKEN HERE @@"

client = dq.create_client(USER_EMAIL, API_TOKEN)

builder = AnalyticsDcrBuilder(client=client)
builder.\
with_name("My DCR").\
with_owner(USER_EMAIL).\
with_description("My test DCR")

dcr_definition = builder.build()
dcr = client.publish_analytics_dcr(dcr_definition)

DCR_ID = dcr.id

Retrieve Audit Log

Retrieve the tamper-proof audit log that stores information about each interaction with the DCR:

dcr = client.retrieve_analytics_dcr(DCR_ID)
audit_log = dcr.retrieve_audit_log()
print(audit_log)

Parse Audit Log

Here is some additional guidance for how to parse an audit log:

import datetime

dcr = client.retrieve_analytics_dcr(DCR_ID)
audit_log = dcr.retrieve_audit_log()
for entry in audit_log.split('\n'):
if entry:
timestamp, participant, notes, action, _ = entry.split(',')
timestamp_string = datetime.datetime.utcfromtimestamp(int(timestamp)/1000).strftime("%m/%d/%Y, %H:%M:%S")
print(f'{participant} made a {action} at {timestamp_string}: {notes}')