1- from datetime import datetime
21import json
32
43import os
5- from typing import Optional
64import dateparser
75
86import asf_search as asf
97from fastapi import Depends , FastAPI , Request , HTTPException , APIRouter , UploadFile
10- from fastapi .responses import RedirectResponse , Response , JSONResponse
8+ from fastapi .responses import Response , JSONResponse
119from fastapi .middleware .cors import CORSMiddleware
1210
1311from .log_router import LoggingRoute
@@ -228,17 +226,19 @@ async def file_to_wkt(files: list[UploadFile]):
228226 headers = constants .DEFAULT_HEADERS
229227 )
230228
231- # @router.get('/redirect/{shortName}')
232- # async def nisar_static_layer(shortName: str, granule_id: str, cmr_token: Optional[str], cmr_host: Optional[str]='uat'):
229+ # @router.get('/redirect/{short_name}/{granule_id}')
230+ # async def nisar_static_layer(environment: Literal['prod', 'test'], short_name: str, granule_id: str):
231+ # """
232+ # environment: 'prod' or 'test' (whether to search the cmr prod or uat record)
233+ # short_name: the CMR static layer collection short name to search
234+ # granule_id: the granule id of the product to find the static layer for
235+
236+ # returns: redirect to file url
237+ # """
233238# opts = asf.ASFSearchOptions()
234- # if cmr_token is not None:
235- # if cmr_host == 'uat':
236- # host = asf.INTERNAL.CMR_HOST_UAT
237- # else:
238- # host = asf.INTERNAL.CMR_HOST
239- # session = asf.ASFSession(cmr_host=host).auth_with_token(cmr_token)
240- # opts.session = session
241- # opts.host = host
239+ # if environment == 'test':
240+ # opts.host = asf.INTERNAL.CMR_HOST_UAT
241+
242242# try:
243243# granule = asf.search(
244244# granule_list=[granule_id],
@@ -247,7 +247,7 @@ async def file_to_wkt(files: list[UploadFile]):
247247# except IndexError:
248248# raise HTTPException(status_code=400, detail=f'Unable to find static layer, provided scene named "{granule_id}" not found in CMR record')
249249
250- # static_layer = granule.get_static_layer(opts=asf.ASFSearchOptions(shortName=shortName ))
250+ # static_layer = granule.get_static_layer(opts=asf.ASFSearchOptions(shortName=short_name ))
251251# if static_layer is None:
252252# raise HTTPException(status_code=500, detail=f'Static layer not found for scene named "{granule_id}"')
253253
0 commit comments