25 lines
839 B
Python
25 lines
839 B
Python
from flask import Blueprint, request, jsonify
|
|
import auth
|
|
import config_utils
|
|
|
|
bp = Blueprint('api_apply_health', __name__)
|
|
|
|
|
|
@bp.route('/api/apply-health')
|
|
@auth.require_level('viewer')
|
|
def apply_health():
|
|
entry_uuid = request.args.get('uuid', '')
|
|
if not entry_uuid:
|
|
return jsonify({'status': 'unknown'})
|
|
|
|
if entry_uuid in config_utils._load_done_set():
|
|
return jsonify({'status': 'complete'})
|
|
|
|
if config_utils._is_locked():
|
|
mtime = config_utils._lock_mtime()
|
|
entry_ts = config_utils._entry_ts_from_queue(entry_uuid)
|
|
if mtime and entry_ts is not None and entry_ts < mtime:
|
|
return jsonify({'status': 'running'})
|
|
return jsonify({'status': 'pending', 'next_in': None})
|
|
|
|
return jsonify({'status': 'pending', 'next_in': config_utils._seconds_until_next_run()})
|