Skip to content

Commit 32d0377

Browse files
Feat: add publications endpoint to retrieve data from VCell API
1 parent 4d24a3d commit 32d0377

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

backend/app/controllers/vcelldb_controller.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
get_diagram_url,
1111
get_diagram_image,
1212
fetch_biomodel_applications_files,
13+
fetch_publications,
1314
)
1415

1516

@@ -132,3 +133,24 @@ async def get_biomodel_applications_files_controller(biomodel_id: str) -> dict:
132133
)
133134
except Exception as e:
134135
raise HTTPException(status_code=500, detail=str(e))
136+
137+
138+
async def get_publications_controller() -> List[dict]:
139+
"""
140+
Controller function to fetch publications from the VCell API.
141+
Raises:
142+
HTTPException: If the VCell API request fails.
143+
"""
144+
try:
145+
publications = await fetch_publications()
146+
return publications
147+
except httpx.HTTPStatusError as e:
148+
raise HTTPException(
149+
status_code=e.response.status_code, detail="Error fetching publications."
150+
)
151+
except httpx.RequestError as e:
152+
raise HTTPException(
153+
status_code=500, detail="Error communicating with VCell API."
154+
)
155+
except Exception as e:
156+
raise HTTPException(status_code=500, detail=str(e))

backend/app/routes/vcelldb_router.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
get_diagram_url_controller,
1010
get_diagram_image_controller,
1111
get_biomodel_applications_files_controller,
12+
get_publications_controller,
1213
)
1314

1415
router = APIRouter()
@@ -89,3 +90,14 @@ async def get_biomodel_applications_files(biomodel_id: str):
8990
return await get_biomodel_applications_files_controller(biomodel_id)
9091
except HTTPException as e:
9192
raise e
93+
94+
95+
@router.get("/publications", response_model=List[dict])
96+
async def get_publications():
97+
"""
98+
Endpoint to retrieve publications from the VCell API.
99+
"""
100+
try:
101+
return await get_publications_controller()
102+
except HTTPException as e:
103+
raise e

0 commit comments

Comments
 (0)