def list_archives(): """ GET /archives :return: """ try: with session_scope() as session: imgs = db_archived_images.summarize(session) or [] rules = (session.query(ArchiveTransitionRule).filter_by( account=ApiRequestContextProxy.namespace()).all() or []) rule_count = len(rules) newest = None if rule_count > 0: newest = epoch_to_rfc3339( max(map(lambda x: x.last_updated, rules))) return { "images": imgs, "rules": { "count": rule_count, "last_updated": newest } } except Exception as ex: logger.exception("Failed to list archives") return make_response_error(ex, in_httpcode=500), 500
def get_image_analysis_archive(): """ GET /archives/images :return: """ try: with session_scope() as session: response_obj = db_archived_images.summarize(session) return response_obj, 200 except Exception as ex: return make_response_error(ex, in_httpcode=500), 500
def list_archives(): """ GET /archives :return: """ try: with session_scope() as session: imgs = db_archived_images.summarize(session) rules = session.query(ArchiveTransitionRule).filter_by(account=ApiRequestContextProxy.namespace()).all() rule_count = len(rules) newest = max(map(lambda x: x.last_updated, rules)) return { 'images': imgs, 'rules': { 'count': rule_count, 'last_updated': epoch_to_rfc3339(newest) } } except Exception as ex: return make_response_error(ex, in_httpcode=500), 500