示例#1
0
def hipposcoreService():
    logger.info('hipposcore service requested')
    if not request.json:
        logger.error('no JSON request sent to hipposcore')
        abort(400)
    if not checkES():
        logger.error('elasticsearch not available')
        return jsonify({'error': 'elasticsearch not available'}), 500
    if not checkData(['sourceType']):
        #ES type source is needed to retrieve source's score
        logger.error('no data')
        return jsonify({'error': 'no data available'}), 500
    logger.info('more for hipposcore started')
    result = more.main(request.json)

    #check if there's error in more response
    for requested in result.values():
        if 'error' in requested:
            logger.error('more for hipposcore failed')
            return jsonify(result), 500
    else:
        hippodict = hipposcore.calcHipposcore(result)
        if 'error' in hippodict:
            #hippodict looks like {'error': '<error_name>'}
            logger.error('hipposcore failed')
            return jsonify(hippodict), 500
        else:
            return jsonify(hippodict), 200
示例#2
0
def shadowbookService():
    logger.info('shadowbook service requested')
    if not checkES():
        logger.error('elasticsearch not available')
        return jsonify({'error': 'elasticsearch not available'}), 500
    reportJob = shadowbook.initJob()

    if 'error' in reportJob:
        logger.error('shadowbook failed')
        return jsonify(reportJob), 500
    else:
        threading.Thread(target=shadowbook.manageJob).start()
        return jsonify(reportJob), 200
示例#3
0
def typeIntelService():
    logger.info('type service requested')
    if not checkES():
        logger.error('elasticsearch not available')
        return jsonify({'error': 'elasticsearch not available'}), 500
    if not checkData([]):
        logger.error('no data')
        return jsonify({'error': 'no data available'}), 500
    result = typeIntel.main()
    if 'error' in result:
        logger.error('type service failed')
        return jsonify(result), 500
    else:
        return jsonify(result), 200
示例#4
0
def hipposchedService():
    logger.info('hipposched service requested')
    if not request.json:
        logger.error('no JSON request sent to hipposched')
        abort(400)
    if not checkES():
        logger.error('elasticsearch not available')
        return jsonify({'error': 'elasticsearch not available'}), 500
    report = hipposched.main(request.json)
    if 'error' in report:
        logger.error('hipposched failed')
        return jsonify(report), 500
    else:
        return jsonify(report), 202
示例#5
0
def sizeByTypeService():
    logger.info('sizeByType service requested')
    if not checkES():
        logger.error('elasticsearch not available')
        return jsonify({'error': 'elasticsearch not available'}), 500
    if not checkData(['sourceType']):
        #need to retrieve all sources
        logger.error('no data')
        return jsonify({'error': 'no data available'}), 500
    result = sizeByType.main()
    if 'error' in result:
        logger.error('sizeByType failed')
        return jsonify(result), 500
    else:
        return jsonify(result), 200
示例#6
0
def lastQueryService():
    logger.info('lastQuery service requested')
    if not checkES():
        logger.error('elasticsearch not available')
        return jsonify({'error': 'elasticsearch not available'}), 500
    if not checkData(['sourceType']):
        #lastQuery is in source
        logger.error('no data')
        return jsonify({'error': 'no data available'}), 500
    result = lastQuery.main()
    if 'error' in result:
        logger.error('lastQuery failed')
        return jsonify(result), 500
    else:
        return jsonify(result), 200
示例#7
0
def schedReportService():
    logger.info('schedReport service requested')
    if not checkES():
        logger.error('elasticsearch not available')
        return jsonify({'error': 'elasticsearch not available'}), 500
    if not checkData(['sourceType']):
        #ES type source needed to determine if threshold is respected
        logger.error('no data')
        return jsonify({'error': 'no data available'}), 500
    result = schedReport.main()
    if 'error' in result:
        logger.error('schedReport failed')
        return jsonify(result), 500
    else:
        return jsonify(result), 200
示例#8
0
def freshnessService():
    logger.info('freshness service requested')
    if not checkES():
        logger.error('elasticsearch not available')
        return jsonify({'error': 'elasticsearch not available'}), 500
    if not checkData(['sourceType']):
        #ES type source needed to calc freshness
        logger.error('no data')
        return jsonify({'error': 'no data available'}), 500
    result = freshness.main()
    if 'error' in result:
        logger.error('freshness failed')
        return jsonify(result), 500
    else:
        return jsonify(result), 200
示例#9
0
def newService():
    logger.info('new service requested')
    if not checkES():
        logger.error('elasticsearch not available')
        return jsonify({'error': 'elasticsearch not available'}), 500
    if not checkData(['newType']):
        logger.error('no data')
        return jsonify({'error': 'no data available'}), 500
    result = new.main()
    #result is a list of new intelligence, never seen before
    if 'error' in result:
        logger.error('new failed')
        return jsonify(response), 500
    else:
        return jsonify(result), 200
示例#10
0
def distinctService():
    logger.info('distinct service requested')
    if not request.json:
        logger.error('no JSON request sent to distinct')
        abort(400)
    if not checkES():
        logger.error('elasticsearch not available')
        return jsonify({'error': 'elasticsearch not available'}), 500
    if not checkData([]):
        logger.error('no data')
        return jsonify({'error': 'no data available'}), 500
    result = distinct.main(request.json)
    if 'error' in result:
        logger.error('distinct failed')
        return jsonify(result), 500
    else:
        return jsonify(result), 200