@@ -6,8 +6,25 @@ class Audit(Construct):
6
6
Class for accessing a workspace audit log
7
7
"""
8
8
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