(self, request, tenant_id)
return json.dumps({'metadata': metadata, 'values': audits})
Gets the user's audit logs.
Gets the user's audit logs.
Gets the user s audit logs .
def list_audits(self, request, tenant_id):
        """
        Gets the user's audit logs.
        """
        ordering = -1 if request.args.get(b'reverse', False) else 1
        all_audits = self._entity_cache_for_tenant(
            tenant_id).audits_list[::ordering]
        page_limit = min(int(request.args.get(b'limit', [100])[0]), 1000)
        offset = 0
        current_marker = request.args.get(b'marker', [None])[0]
        if current_marker is not None:
            current_marker = current_marker.decode("utf-8")
            try:
                offset = all_audits.index(
                    Matcher(lambda audit: audit['id'] == current_marker))
            except ValueError:
                offset = 0

        audits = all_audits[offset:offset + page_limit]
        next_marker = None
        if offset + page_limit < len(all_audits):
            next_marker = all_audits[offset + page_limit]['id']

        metadata = {
            'count': len(audits),
            'marker': current_marker,
            'next_marker': next_marker,
            'limit': page_limit,
            'next_href': None
        }
        request.setResponseCode(200)
        return json.dumps({'metadata': metadata, 'values': audits})
def list_audits ( self , request , tenant_id ) : ordering = - 1 if request . args . get ( b'reverse' , False ) else 1 all_audits = self . _entity_cache_for_tenant ( tenant_id ) . audits_list [ : : ordering ] page_limit = min ( int ( request . args . get ( b'limit' , [ 100 ] ) [ 0 ] ) , 1000 ) offset = 0 current_marker = request . args . get ( b'marker' , [ None ] ) [ 0 ] if current_marker is not None : current_marker = current_marker . decode ( "utf-8" ) try : offset = all_audits . index ( Matcher ( lambda audit : audit [ 'id' ] == current_marker ) ) except ValueError : offset = 0 audits = all_audits [ offset : offset + page_limit ] next_marker = None if offset + page_limit < len ( all_audits ) : next_marker = all_audits [ offset + page_limit ] [ 'id' ] metadata = { 'count' : len ( audits ) , 'marker' : current_marker , 'next_marker' : next_marker , 'limit' : page_limit , 'next_href' : None } request . setResponseCode ( 200 ) return json . dumps ( { 'metadata' : metadata , 'values' : audits } )