-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ENH] Add endpoint returning queryable attributes + refine existing e…
…ndpoint for attribute instances (#194) * create router and GET path operation for fetching attribute classes * add CRUD function for new /attributes/ endpoint * move endpoint for getting terms to behind the /attributes endpoint * switch response to a list * add test of new endpoint response * update terms query string to return only term IRIs for controlled term subclasses * add utility for abbreviating namespaces in term URLs * test namespace abbrieviation behaviour in the API response
- Loading branch information
Showing
7 changed files
with
161 additions
and
21 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
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,23 @@ | ||
from fastapi import APIRouter | ||
from pydantic import constr | ||
|
||
from .. import crud | ||
from ..models import CONTROLLED_TERM_REGEX | ||
|
||
router = APIRouter(prefix="/attributes", tags=["attributes"]) | ||
|
||
|
||
@router.get("/{data_element_URI}") | ||
async def get_terms(data_element_URI: constr(regex=CONTROLLED_TERM_REGEX)): | ||
"""When a GET request is sent, return a dict with the only key corresponding to controlled term of a neurobagel class and value corresponding to all the available terms.""" | ||
response = await crud.get_terms(data_element_URI) | ||
|
||
return response | ||
|
||
|
||
@router.get("/", response_model=list) | ||
async def get_attributes(): | ||
"""When a GET request is sent, return a list of the harmonized controlled term attributes.""" | ||
response = await crud.get_controlled_term_attributes() | ||
|
||
return response |
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
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