22
33from typing import List , Optional
44
5- from fastapi import APIRouter , Depends , HTTPException , Query , status
5+ from fastapi import APIRouter , Depends , Query , status
66
77from aind_smartsheet_service_server .handler import SessionHandler
88from aind_smartsheet_service_server .models import (
@@ -41,14 +41,27 @@ async def get_health() -> HealthCheck:
4141 "/funding" ,
4242 response_model = List [FundingModel ],
4343)
44- async def get_funding (
44+ def get_funding (
4545 project_name : Optional [str ] = Query (
4646 default = None ,
47- examples = ["Discovery-Neuromodulator circuit dynamics during foraging" ],
47+ openapi_examples = {
48+ "default" : {
49+ "summary" : "A sample project name" ,
50+ "description" : "Example project name for smartsheet" ,
51+ "value" : "Discovery-Neuromodulator circuit dynamics"
52+ " during foraging" ,
53+ }
54+ },
4855 ),
4956 subproject : Optional [str ] = Query (
5057 default = None ,
51- examples = ["Subproject 2 Molecular Anatomy Cell Types" ],
58+ openapi_examples = {
59+ "default" : {
60+ "summary" : "A sample subproject" ,
61+ "description" : "Example subproject name" ,
62+ "value" : "Subproject 2 Molecular Anatomy Cell Types" ,
63+ }
64+ },
5265 ),
5366 session : SmartsheetClient = Depends (get_session ),
5467):
@@ -65,17 +78,14 @@ async def get_funding(
6578 content = SessionHandler (session = session ).get_project_funding_info (
6679 sheet_model = sheet , project_name = project_name , subproject = subproject
6780 )
68- if len (content ) == 0 :
69- raise HTTPException (status_code = 404 , detail = "Not found" )
70- else :
71- return content
81+ return content
7282
7383
7484@router .get (
7585 "/project_names" ,
7686 response_model = List [str ],
7787)
78- async def get_project_names (
88+ def get_project_names (
7989 session : SmartsheetClient = Depends (get_session ),
8090):
8191 """
@@ -91,25 +101,26 @@ async def get_project_names(
91101 content = SessionHandler (session = session ).get_project_names (
92102 sheet_model = sheet
93103 )
94- if len (content ) == 0 :
95- raise HTTPException (status_code = 404 , detail = "Not found" )
96- else :
97- return content
104+ return content
98105
99106
100107@router .get (
101108 "/protocols" ,
102109 response_model = List [ProtocolsModel ],
103110)
104- async def get_protocols (
111+ def get_protocols (
105112 protocol_name : Optional [str ] = Query (
106113 default = None ,
107- examples = [
108- (
109- "Tetrahydrofuran and Dichloromethane Delipidation of a Whole "
110- "Mouse Brain"
111- )
112- ],
114+ openapi_examples = {
115+ "default" : {
116+ "summary" : "A sample protocol name" ,
117+ "description" : "Example protocol name" ,
118+ "value" : (
119+ "Tetrahydrofuran and Dichloromethane Delipidation of a "
120+ "Whole Mouse Brain"
121+ ),
122+ }
123+ },
113124 ),
114125 session : SmartsheetClient = Depends (get_session ),
115126):
@@ -126,20 +137,23 @@ async def get_protocols(
126137 content = SessionHandler (session = session ).get_protocols_info (
127138 sheet_model = sheet , protocol_name = protocol_name
128139 )
129- if len (content ) == 0 :
130- raise HTTPException (status_code = 404 , detail = "Not found" )
131- else :
132- return content
140+ return content
133141
134142
135143@router .get (
136144 "/perfusions" ,
137145 response_model = List [PerfusionsModel ],
138146)
139- async def get_perfusions (
147+ def get_perfusions (
140148 subject_id : Optional [str ] = Query (
141149 default = None ,
142- examples = ["689418" ],
150+ openapi_examples = {
151+ "default" : {
152+ "summary" : "A sample subject id" ,
153+ "description" : "Example subject id" ,
154+ "value" : "689418" ,
155+ }
156+ },
143157 ),
144158 session : SmartsheetClient = Depends (get_session ),
145159):
@@ -156,7 +170,4 @@ async def get_perfusions(
156170 content = SessionHandler (session = session ).get_perfusions_info (
157171 sheet_model = sheet , subject_id = subject_id
158172 )
159- if len (content ) == 0 :
160- raise HTTPException (status_code = 404 , detail = "Not found" )
161- else :
162- return content
173+ return content
0 commit comments