def get_resources(): query, sort, limit, query_time = parse_fields(request) resources = db.get_resources(query=query, sort=sort, limit=limit) total = db.get_count( query=query) # TODO(nsatterl): possible race condition? found = 0 resource_details = list() if len(resources) > 0: last_time = None for resource in resources: resource_details.append(resource) found += 1 if not last_time: last_time = resource['lastReceiveTime'] elif resource['lastReceiveTime'] > last_time: last_time = resource['lastReceiveTime'] return jsonify( response={ "resources": { "resourceDetails": resource_details, "lastTime": last_time, }, "status": "ok", "total": found, "more": total > limit }) else: return jsonify( response={ "resources": { "resourceDetails": list(), "lastTime": query_time, }, "status": "ok", "message": "not found", "total": 0, "more": False, })
def get_resources(): query, sort, limit, query_time = parse_fields(request) resources = db.get_resources(query=query, sort=sort, limit=limit) total = db.get_count(query=query) # TODO(nsatterl): possible race condition? found = 0 resource_details = list() if len(resources) > 0: last_time = None for resource in resources: resource_details.append(resource) found += 1 if not last_time: last_time = resource['lastReceiveTime'] elif resource['lastReceiveTime'] > last_time: last_time = resource['lastReceiveTime'] return jsonify(response={ "resources": { "resourceDetails": resource_details, "lastTime": last_time, }, "status": "ok", "total": found, "more": total > limit }) else: return jsonify(response={ "resources": { "resourceDetails": list(), "lastTime": query_time, }, "status": "ok", "message": "not found", "total": 0, "more": False, })
def get_alerts(): try: query, sort, limit, query_time = parse_fields(request) except Exception, e: return jsonify(response={"status": "error", "message": str(e)})