44
55from azure .core .credentials import AccessToken
66from azure .identity import ClientSecretCredential
7- from fastapi import APIRouter , Depends , Path , status
7+ from fastapi import APIRouter , Path , status
88from fastapi_cache .decorator import cache
99from httpx import AsyncClient
1010
11- from aind_sharepoint_service_server .configs import Settings , get_settings
11+ from aind_sharepoint_service_server .configs import settings
1212from aind_sharepoint_service_server .handler import SessionHandler
1313from aind_sharepoint_service_server .models .core import HealthCheck
1414from aind_sharepoint_service_server .models .las_2020 import Las2020List
1919
2020
2121@cache (expire = 3360 )
22- async def get_access_token (settings : Settings ) -> str :
22+ async def get_access_token () -> str :
2323 """
2424 Get access token from either Azure or cache. Token is valid for 60 minutes.
2525 We set cache lifespan to 56 minutes.
@@ -38,9 +38,9 @@ async def get_access_token(settings: Settings) -> str:
3838
3939
4040@cache (expire = 3600 )
41- async def get_las_2020_list (settings : Settings ) -> List [Dict [str , Any ]]:
41+ async def get_las_2020_list () -> List [Dict [str , Any ]]:
4242 """Get the LAS_2020 list items"""
43- bearer_token = await get_access_token (settings = settings )
43+ bearer_token = await get_access_token ()
4444 headers = {
4545 "Authorization" : f"Bearer { bearer_token } " ,
4646 "Content-Type" : "application/json" ,
@@ -58,11 +58,9 @@ async def get_las_2020_list(settings: Settings) -> List[Dict[str, Any]]:
5858
5959
6060# Not worthwhile to cache results for NSB lists
61- async def get_nsb_2019_list (
62- subject_id : str , settings : Settings
63- ) -> List [Dict [str , Any ]]:
61+ async def get_nsb_2019_list (subject_id : str ) -> List [Dict [str , Any ]]:
6462 """Get the NSB_2019 list items"""
65- bearer_token = await get_access_token (settings = settings )
63+ bearer_token = await get_access_token ()
6664 headers = {
6765 "Authorization" : f"Bearer { bearer_token } " ,
6866 "Content-Type" : "application/json" ,
@@ -79,11 +77,9 @@ async def get_nsb_2019_list(
7977 return list_items
8078
8179
82- async def get_nsb_2023_list (
83- subject_id : str , settings : Settings
84- ) -> List [Dict [str , Any ]]:
80+ async def get_nsb_2023_list (subject_id : str ) -> List [Dict [str , Any ]]:
8581 """Get the NSB_2023 list items"""
86- bearer_token = await get_access_token (settings = settings )
82+ bearer_token = await get_access_token ()
8783 headers = {
8884 "Authorization" : f"Bearer { bearer_token } " ,
8985 "Content-Type" : "application/json" ,
@@ -100,11 +96,9 @@ async def get_nsb_2023_list(
10096 return list_items
10197
10298
103- async def get_nsb_present_list (
104- subject_id : str , settings : Settings
105- ) -> List [Dict [str , Any ]]:
99+ async def get_nsb_present_list (subject_id : str ) -> List [Dict [str , Any ]]:
106100 """Get the NSB Present list items"""
107- bearer_token = await get_access_token (settings = settings )
101+ bearer_token = await get_access_token ()
108102 headers = {
109103 "Authorization" : f"Bearer { bearer_token } " ,
110104 "Content-Type" : "application/json" ,
@@ -153,14 +147,13 @@ async def get_las_2020(
153147 "value" : "805811" ,
154148 }
155149 },
156- ),
157- settings = Depends (get_settings ),
150+ )
158151):
159152 """
160153 # LAS 2020 Endpoint
161154 Retrieve information from the LAS 2020 list for a given subject ID.
162155 """
163- las_2020_list = await get_las_2020_list (settings = settings )
156+ las_2020_list = await get_las_2020_list ()
164157 las_2020_models = [
165158 Las2020List .model_validate (item ["fields" ])
166159 for item in las_2020_list
@@ -183,17 +176,14 @@ async def get_nsb_2019(
183176 "value" : "656374" ,
184177 }
185178 },
186- ),
187- settings = Depends (get_settings ),
179+ )
188180):
189181 """
190182 # NSB 2019 Endpoint
191183 Retrieve information from the NSB 2019 list for a given subject ID.
192184 """
193185
194- nsb_2019_list = await get_nsb_2019_list (
195- subject_id = subject_id , settings = settings
196- )
186+ nsb_2019_list = await get_nsb_2019_list (subject_id = subject_id )
197187 nsb_2019_models = [
198188 NSB2019List .model_validate (item ["fields" ]) for item in nsb_2019_list
199189 ]
@@ -214,17 +204,14 @@ async def get_nsb_2023(
214204 "value" : "657849" ,
215205 }
216206 },
217- ),
218- settings = Depends (get_settings ),
207+ )
219208):
220209 """
221210 # NSB 2023 Endpoint
222211 Retrieve information from the NSB 2023-Archive list for a given subject ID.
223212 """
224213
225- nsb_2023_list = await get_nsb_2023_list (
226- subject_id = subject_id , settings = settings
227- )
214+ nsb_2023_list = await get_nsb_2023_list (subject_id = subject_id )
228215 nsb_2023_models = [
229216 NSB2023List .model_validate (item ["fields" ]) for item in nsb_2023_list
230217 ]
@@ -245,17 +232,14 @@ async def get_nsb_present(
245232 "value" : "790025" ,
246233 }
247234 },
248- ),
249- settings = Depends (get_settings ),
235+ )
250236):
251237 """
252238 # NSB Present Endpoint
253239 Retrieve information from the NSB 2023-Present list for a given subject ID.
254240 """
255241
256- nsb_present_list = await get_nsb_present_list (
257- subject_id = subject_id , settings = settings
258- )
242+ nsb_present_list = await get_nsb_present_list (subject_id = subject_id )
259243 nsb_present_models = [
260244 NSB2023List .model_validate (item ["fields" ]) for item in nsb_present_list
261245 ]
0 commit comments