Skip to content

Commit 56db012

Browse files
author
Saimon Michelson
committed
support list audit trail events
1 parent 733bd1c commit 56db012

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

papi/constructs/audit.py

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,25 @@ class Audit(Construct):
66
Class for accessing a workspace audit log
77
"""
88

9-
# use custom get function with additional headers
10-
# https://api.segmentapis.com/docs/admin/audit-trail/#list-audit-events
11-
def all(self, start_time, end_time, resource_id, resource_type):
12-
print(self, start_time, end_time, resource_id, resource_type)
13-
# return self._segment.iterator('/audit-events', 'events')
9+
def all(self, start_time=None, end_time=None, resource_id=None, resource_type=None):
10+
"""
11+
List audit trail events
12+
13+
:param datetime.datetime,optional start_time: Filter response to events that happened after this time
14+
:param datetime.datetime,optional end_time: Filter response to events that happened before this time, defaults to the current time.
15+
:param str resource_id: Filter response to events that affect a specific resource
16+
:param str resource_type: Filter response to events that affect a specific type
17+
:returns: List of audit trail events
18+
:rtype: papi.common.common.Object
19+
"""
20+
# https://api.segmentapis.com/docs/admin/audit-trail/#list-audit-events
21+
params = {}
22+
if start_time:
23+
params['startTime'] = start_time.isoformat()
24+
if end_time:
25+
params['endTime'] = end_time.isoformat()
26+
if resource_id:
27+
params['resourceId'] = resource_id
28+
if resource_type:
29+
params['resourceType'] = resource_type
30+
return self._segment.iterator('/audit-trails', params).events

0 commit comments

Comments
 (0)