def retrieveAlertsCountWithType():
""" Retrieve number of alerts in timeframe (GET-Parameter time as decimal or "day") and divide into honypot types"""
# get result from cache
getCacheResult = getCache(request.url, "url")
if getCacheResult is not False:
return jsonify(getCacheResult)
# query ES
else:
# Retrieve Number of Alerts from ElasticSearch and return as xml / json
if not request.args.get('time'):
app.logger.error('No time GET-parameter supplied in retrieveAlertsCountWithType. Must be decimal number (in minutes) or string "day"')
return app.config['DEFAULTRESPONSE']
else:
returnResult = formatAlertsCountWithType(queryAlertsCountWithType(request.args.get('time'), checkCommunityIndex(request)))
setCache(request.url, returnResult, 13, "url")
app.logger.debug('UNCACHED %s' % str(request.url))
return jsonify(returnResult)
评论列表
文章目录