def status():

    if 'ignore-dependencies' in request.args:
        return jsonify(
            status="ok",
        ), 200

    version = current_app.config['VERSION']
    status = data_api_client.get_status()

    if status['status'] == "ok":
        return jsonify(
            status="ok",
            version=version,
            api_status=status,
            flags=get_flags(current_app)
        )

    return jsonify(
        status="error",
        version=version,
        api_status=status,
        message="Error connecting to the (Data) API.",
        flags=get_flags(current_app)
    ), 500
def status():

    if 'ignore-dependencies' in request.args:
        return jsonify(
            status="ok",
        ), 200

    result, status_code = status_for_all_indexes()
    version = current_app.config['VERSION']

    if status_code == 200:
        return jsonify(
            status="ok",
            version=version,
            es_status=result,
            flags=get_flags(current_app)
        )

    current_app.logger.exception("Error connecting to elasticsearch")

    return jsonify(
        status="error",
        version=version,
        message="Error connecting to elasticsearch",
        es_status={
            'status_code': status_code,
            'message': "{}".format(result),
        },
        flags=get_flags(current_app)
    ), 500
def status_no_db():

    if 'ignore-dependencies' in request.args:
        return jsonify(
            status="ok",
        ), 200

    version = current_app.config['VERSION']

    try:
        return jsonify(
            status="ok",
            version=version,
            db_version=utils.get_db_version(),
            flags=get_flags(current_app)
        )

    except SQLAlchemyError:
        current_app.logger.exception('Error connecting to database')
        return jsonify(
            status="error",
            version=version,
            message="Error connecting to database",
            flags=get_flags(current_app)
        ), 500
def status():

    if 'ignore-dependencies' in request.args:
        return jsonify(
            status="ok",
        ), 200

    version = current_app.config['VERSION']
    apis = [
        {
            'name': '(Data) API',
            'key': 'api_status',
            'status': data_api_client.get_status()
        }, {
            'name': 'Search API',
            'key': 'search_api_status',
            'status': search_api_client.get_status()
        }
    ]

    apis_with_errors = []

    for api in apis:
        if api['status'] is None or api['status']['status'] != "ok":
            apis_with_errors.append(api['name'])

    # if no errors found, return as is.  Else, return an error and a message
    if not apis_with_errors:
        return jsonify(
            {api['key']: api['status'] for api in apis},
            status="ok",
            version=version,
            flags=get_flags(current_app)
        )

    message = "Error connecting to the {}.".format(
        " and the ".join(apis_with_errors)
    )

    return jsonify(
        {api['key']: api['status'] for api in apis},
        status="error",
        version=version,
        message=message,
        flags=get_flags(current_app)
    ), 500
def status():

    api_status = data_api_client.get_status()
    version = current_app.config['VERSION']

    if api_status['status'] == "ok":
        return jsonify(
            status="ok",
            version=version,
            api_status=api_status,
            flags=get_flags(current_app)
        )

    return jsonify(
        status="error",
        version=version,
        api_status=api_status,
        message="Error connecting to the (Data) API.",
        flags=get_flags(current_app)
    ), 500
def status():

    if 'ignore-dependencies' in request.args:
        return jsonify(
            status="ok",
        ), 200

    version = current_app.config['VERSION']
    apis = [
        {
            'name': '(Data) API',
            'key': 'api_status',
            'status': data_api_client.get_status()
        },
    ]

    apis_with_errors = []

    for api in apis:
        if api['status'] is None or api['status']['status'] != "ok":
            apis_with_errors.append(api['name'])

    stats = {api['key']: api['status'] for api in apis}
    stats.update({
        'version': version,
        'flags': get_flags(current_app)
    })

    if apis_with_errors:
        stats['status'] = 'error'
        stats['message'] = 'Error connecting to the {}.'.format(
            ' and the '.join(apis_with_errors)
        )
        return jsonify(**stats), 500

    stats['status'] = 'ok'
    return jsonify(**stats), 200