@@ -388,26 +388,29 @@ def get_audit_actions(self, date_modified, offset=0, page_length=100):
388388 )
389389 result = self .parse_json (response .content ) if response .status_code == requests .codes .ok else None
390390 self .log_http_status (response .status_code , 'GET actions' )
391- if result is None or None in [result .get ('count' ), result .get ('offset' ), result .get ('total' )]:
391+ if result is None or None in [result .get ('count' ), result .get ('offset' ), result .get ('total' ), result . get ( 'actions' ) ]:
392392 return None
393393 return self .get_page_of_actions (logger , date_modified , result , offset , page_length )
394394
395- def get_page_of_actions (self , logger , date_modified , result , offset = 0 , page_length = 100 ):
395+ def get_page_of_actions (self , logger , date_modified , previous_page , offset = 0 , page_length = 100 ):
396396 """
397397 Returns a page of action search results
398398
399399 :param logger: the logger
400400 :param date_modified: fetch from that date onwards
401- :param result : a page of action search results
401+ :param previous_page : a page of action search results
402402 :param offset: the index to start retrieving actions from
403403 :param page_length: the number of actions to return on the search page (max 100)
404404 :return: Array of action objects
405405 """
406- if result ['count' ] + result ['offset' ] < result ['total' ]:
407- logger .info ('Paging Actions. Offset: ' + str (offset + page_length ) + '. Total: ' + str (result ['total' ]))
408- return self .get_audit_actions (date_modified , offset + page_length ) + result ['actions' ]
409- elif result ['count' ] + result ['offset' ] == result ['total' ]:
410- return result ['actions' ]
406+ if previous_page ['count' ] + previous_page ['offset' ] < previous_page ['total' ]:
407+ logger .info ('Paging Actions. Offset: ' + str (offset + page_length ) + '. Total: ' + str (previous_page ['total' ]))
408+ next_page = self .get_audit_actions (date_modified , offset + page_length )
409+ if next_page is None :
410+ return None
411+ return next_page + previous_page ['actions' ]
412+ elif previous_page ['count' ] + previous_page ['offset' ] == previous_page ['total' ]:
413+ return previous_page ['actions' ]
411414
412415 def get_audit (self , audit_id ):
413416 """
@@ -431,7 +434,6 @@ def log_http_status(status_code, message):
431434 :param status_code: http status code to log
432435 :param message: to describe where the status code was obtained
433436 """
434-
435437 logger = logging .getLogger ('sp_logger' )
436438 status_description = requests .status_codes ._codes [status_code ][0 ]
437439 log_string = str (status_code ) + ' [' + status_description + '] status received ' + message
0 commit comments