aboutsummaryrefslogtreecommitdiff
path: root/wqflask
diff options
context:
space:
mode:
authorzsloan2019-05-24 17:01:02 -0500
committerzsloan2019-05-24 17:01:02 -0500
commit8e1a22002278e79f1a0bc828e5ed5bba9aa8280d (patch)
tree0b724c6d99eaa602206deb89fa5d4fc989080fbf /wqflask
parent850d2ba6f885226869080e071fe1f8ddf17808ad (diff)
downloadgenenetwork2-8e1a22002278e79f1a0bc828e5ed5bba9aa8280d.tar.gz
Added status to error messages
Diffstat (limited to 'wqflask')
-rw-r--r--wqflask/wqflask/api/router.py27
1 files changed, 14 insertions, 13 deletions
diff --git a/wqflask/wqflask/api/router.py b/wqflask/wqflask/api/router.py
index 22d16e30..845873a0 100644
--- a/wqflask/wqflask/api/router.py
+++ b/wqflask/wqflask/api/router.py
@@ -93,7 +93,7 @@ def get_groups_list(species_name=None):
return flask.jsonify(groups_list)
else:
- return return_error(source=request.url_rule.rule, title="No Results", details="")
+ return return_error(code=204, source=request.url_rule.rule, title="No Results", details="")
@app.route("/api/v_{}/group/<path:group_name>".format(version))
@app.route("/api/v_{}/group/<path:group_name>.<path:file_format>".format(version))
@@ -136,7 +136,7 @@ def get_group_info(group_name, species_name = None, file_format = "json"):
return flask.jsonify(group_dict)
else:
- return return_error(source=request.url_rule.rule, title="No Results", details="")
+ return return_error(code=204, source=request.url_rule.rule, title="No Results", details="")
@app.route("/api/v_{}/datasets/<path:group_name>".format(version))
@app.route("/api/v_{}/datasets/<path:species_name>/<path:group_name>".format(version))
@@ -188,7 +188,7 @@ def get_datasets_for_group(group_name, species_name=None):
return flask.jsonify(datasets_list)
else:
- return return_error(source=request.url_rule.rule, title="No Results", details="")
+ return return_error(code=204, source=request.url_rule.rule, title="No Results", details="")
@app.route("/api/v_{}/dataset/<path:dataset_name>".format(version))
@app.route("/api/v_{}/dataset/<path:dataset_name>.<path:file_format>".format(version))
@@ -288,7 +288,7 @@ def get_dataset_info(dataset_name, group_name = None, file_format="json"):
elif len(datasets_list) == 1:
return flask.jsonify(dataset_dict)
else:
- return return_error(source=request.url_rule.rule, title="No Results", details="")
+ return return_error(code=204, source=request.url_rule.rule, title="No Results", details="")
@app.route("/api/v_{}/sample_data/<path:dataset_name>".format(version))
@@ -382,9 +382,9 @@ def all_sample_data(dataset_name, file_format = "csv"):
output.headers["Content-type"] = "text/csv"
return output
else:
- return return_error(source=request.url_rule.rule, title="No Results", details="")
+ return return_error(code=204, source=request.url_rule.rule, title="No Results", details="")
else:
- return return_error(source=request.url_rule.rule, title="No Results", details="")
+ return return_error(code=204, source=request.url_rule.rule, title="No Results", details="")
@app.route("/api/v_{}/sample_data/<path:dataset_name>/<path:trait_name>".format(version))
@app.route("/api/v_{}/sample_data/<path:dataset_name>/<path:trait_name>.<path:file_format>".format(version))
@@ -473,7 +473,7 @@ def trait_sample_data(dataset_name, trait_name, file_format = "json"):
return flask.jsonify(sample_list)
else:
- return return_error(source=request.url_rule.rule, title="No Results", details="")
+ return return_error(code=204, source=request.url_rule.rule, title="No Results", details="")
@app.route("/api/v_{}/trait/<path:dataset_name>/<path:trait_name>".format(version))
@app.route("/api/v_{}/trait/<path:dataset_name>/<path:trait_name>.<path:file_format>".format(version))
@@ -544,7 +544,7 @@ def get_trait_info(dataset_name, trait_name, file_format = "json"):
return flask.jsonify(trait_dict)
else:
- return return_error(source=request.url_rule.rule, title="No Results", details="")
+ return return_error(code=204, source=request.url_rule.rule, title="No Results", details="")
@app.route("/api/v_{}/correlation".format(version), methods=('GET',))
def get_corr_results():
@@ -553,7 +553,7 @@ def get_corr_results():
if len(results) > 0:
return flask.jsonify(results) #ZS: I think flask.jsonify expects a dict/list instead of JSON
else:
- return return_error(source=request.url_rule.rule, title="No Results", details="")
+ return return_error(code=204, source=request.url_rule.rule, title="No Results", details="")
@app.route("/api/v_{}/mapping".format(version), methods=('GET',))
def get_mapping_results():
@@ -571,7 +571,7 @@ def get_mapping_results():
return output
else:
- return return_error(source=request.url_rule.rule, title="No Results", details="")
+ return return_error(code=204, source=request.url_rule.rule, title="No Results", details="")
@app.route("/api/v_{}/genotypes/<path:group_name>".format(version))
@app.route("/api/v_{}/genotypes/<path:group_name>.<path:file_format>".format(version))
@@ -591,7 +591,7 @@ def get_genotypes(group_name, file_format="csv"):
csv_writer = csv.writer(si, delimiter = '\t', escapechar = "\\", quoting = csv.QUOTE_NONE)
else:
- return return_error(source=request.url_rule.rule, title="No Results", details="")
+ return return_error(code=204, source=request.url_rule.rule, title="No Results", details="")
else:
filename = group_name + ".bimbam"
@@ -603,7 +603,7 @@ def get_genotypes(group_name, file_format="csv"):
csv_writer = csv.writer(si, delimiter = ',')
else:
- return return_error(source=request.url_rule.rule, title="No Results", details="")
+ return return_error(code=204, source=request.url_rule.rule, title="No Results", details="")
csv_writer.writerows(output_lines)
output = make_response(si.getvalue())
@@ -619,9 +619,10 @@ def get_traits(dataset_name, file_format = "json"):
NotImplemented
-def return_error(source, title, details):
+def return_error(code, source, title, details):
json_ob = {"errors": [
{
+ "status": code,
"source": { "pointer": source },
"title" : title,
"detail": details