def handleMakeCube(): global cubes keyspace=flask.request.args.get('keyspace','') table=flask.request.args.get('tablename','') if not table or not keyspace: perr("Invalid request") return jsonify({"status":"failed","error":"No tablename or keyspace"}) newcubename=(dollarAdd(dollarEscape(keyspace),table)) if cubes.has_key(newcubename): return jsonify({"status":"failed","error":"Cube already exists"}) cubes[newcubename]=ElandraCube(keyspace=keyspace, tablename=table) return jsonify({"status":"success"})
def handleInsert(): keyspace=flask.request.args.get('keyspace','') table=flask.request.args.get('tablename','') data=json.loads(flask.request.get_data(as_text=True)) if not table or not keyspace: perr("Invalid request") return jsonify({"status":"failed","error":"No tablename or keyspace"}) cubename=(dollarAdd(dollarEscape(keyspace),table)) if(cubes.has_key(cubename)): ecobj=cubes[cubename] if ecobj.insert(data): return jsonify({"status":"ok"}) return jsonify({"status":"failed","error":"Unknown error in ElandraCube insert"}) else: return jsonify({"status":"failed","error":"Cube does not exist"})
def query(): keyspace=flask.request.args.get('keyspace','') table=flask.request.args.get('tablename','') data=json.loads(flask.request.get_data(as_text=True)) if not table or not keyspace: perr("Invalid request") return jsonify({"status":"failed","error":"No tablename or keyspace"}) cubename=(dollarAdd(dollarEscape(keyspace),table)) if(cubes.has_key(cubename)): ecobj=cubes[cubename] queryret=ecobj.query(data); if queryret: return (json.dumps(queryret)) return jsonify({"status":"failed","error":"Your Search %s did not match any index"%(json.dumps(data))}) else: return jsonify({"status":"failed","error":"Cube does not exist"})