-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
started with the query endpoint and request's errors
- Loading branch information
1 parent
f50ca56
commit cd7c7be
Showing
6 changed files
with
102 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
from .consent_codes import CONSENT_CODES | ||
from .variant_constants import CHROMOSOMES | ||
from .response_objs import MISSING_PARAMS_ERROR |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Error objects | ||
MISSING_PARAMS_ERROR = dict( | ||
error=dict( | ||
errorCode=400, | ||
errorMessage="Missing one or more mandatory parameters (referenceName, referenceBases, assemblyId)" | ||
) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# -*- coding: utf-8 -*- | ||
import logging | ||
from flask import request | ||
from cgbeacon2.constants import MISSING_PARAMS_ERROR | ||
|
||
LOG = logging.getLogger(__name__) | ||
|
||
def set_query(req): | ||
"""Create a a query dictionary from GET or POST requests sent to the query endpoint. | ||
Accepts: | ||
req(flask.request) | ||
Returns: | ||
query(dict) | ||
""" | ||
data = None | ||
query = {} | ||
if request.method == "GET": | ||
data = req.args | ||
else: # POST method | ||
data = req.data | ||
|
||
# check if the minimal required params were provided in query | ||
if None in [data.get("referenceName"), data.get("referenceBases"), data.get("assemblyId")]: | ||
# return a bad request 400 error with explanation message | ||
return MISSING_PARAMS_ERROR | ||
|
||
|
||
query = dict( | ||
|
||
) | ||
|
||
return data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters