|
| 1 | +from datetime import datetime |
1 | 2 | import json |
2 | 3 |
|
3 | 4 | import os |
|
6 | 7 |
|
7 | 8 | import asf_search as asf |
8 | 9 | from fastapi import Depends, FastAPI, Request, HTTPException, APIRouter, UploadFile |
9 | | -from fastapi.responses import Response, JSONResponse |
| 10 | +from fastapi.responses import RedirectResponse, Response, JSONResponse |
10 | 11 | from fastapi.middleware.cors import CORSMiddleware |
11 | 12 |
|
12 | 13 | from .log_router import LoggingRoute |
@@ -227,6 +228,31 @@ async def file_to_wkt(files: list[UploadFile]): |
227 | 228 | headers=constants.DEFAULT_HEADERS |
228 | 229 | ) |
229 | 230 |
|
| 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'): |
| 233 | +# 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 |
| 242 | +# try: |
| 243 | +# granule = asf.search( |
| 244 | +# granule_list=[granule_id], |
| 245 | +# opts=opts |
| 246 | +# )[0] |
| 247 | +# except IndexError: |
| 248 | +# raise HTTPException(status_code=400, detail=f'Unable to find static layer, provided scene named "{granule_id}" not found in CMR record') |
| 249 | + |
| 250 | +# static_layer = granule.get_static_layer(opts=asf.ASFSearchOptions(shortName=shortName)) |
| 251 | +# if static_layer is None: |
| 252 | +# raise HTTPException(status_code=500, detail=f'Static layer not found for scene named "{granule_id}"') |
| 253 | + |
| 254 | +# return RedirectResponse(static_layer.properties['url']) |
| 255 | + |
230 | 256 |
|
231 | 257 | def validate_wkt(wkt: str): |
232 | 258 | try: |
|
0 commit comments