mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-08 21:03:11 -04:00
49 lines
1.7 KiB
Python
49 lines
1.7 KiB
Python
from flask import current_app, jsonify, request
|
|
from notifications_python_client.errors import HTTPError
|
|
|
|
from app import status_api_client, version
|
|
from app.status import status
|
|
|
|
|
|
@status.route('/_status', methods=['GET'])
|
|
def show_status():
|
|
if request.args.get('elb', None) or request.args.get('simple', None):
|
|
return jsonify(status="ok"), 200
|
|
else:
|
|
try:
|
|
api_status = status_api_client.get_status()
|
|
except HTTPError as e:
|
|
current_app.logger.exception("API failed to respond")
|
|
return jsonify(status="error", message=str(e.message)), 500
|
|
return jsonify(
|
|
status="ok",
|
|
api=api_status,
|
|
git_commit=version.__git_commit__,
|
|
build_time=version.__time__), 200
|
|
|
|
@status.route('/_status/servicecounts', methods=['GET'])
|
|
def get_counts():
|
|
try:
|
|
orgs_status = status_api_client.get_count_of_live_services_and_organisations()
|
|
except HTTPError as e:
|
|
current_app.logger.exception("API failed to respond")
|
|
return jsonify(status="error", message=str(e.message)), 500
|
|
return jsonify(
|
|
status="ok",
|
|
api=orgs_status,
|
|
git_commit=version.__git_commit__,
|
|
build_time=version.__time__), 200
|
|
|
|
@status.route('/_status/services', methods=['GET'])
|
|
def get_services():
|
|
try:
|
|
services = status_api_client.get_services()
|
|
except HTTPError as e:
|
|
current_app.logger.exception("API failed to respond")
|
|
return jsonify(status="error", message=str(e.message)), 500
|
|
return jsonify(
|
|
status="ok",
|
|
api=services,
|
|
git_commit=version.__git_commit__,
|
|
build_time=version.__time__), 200
|