Skip to content

Commit e90ee8e

Browse files
committed
fix: commented out the wrong endpoint
1 parent 6ef7264 commit e90ee8e

File tree

1 file changed

+56
-56
lines changed

1 file changed

+56
-56
lines changed

cumulus_lambda_functions/uds_api/granules_api.py

Lines changed: 56 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -214,33 +214,33 @@ async def get_granules_dapa(request: Request, collection_id: str, limit: Union[i
214214
raise HTTPException(status_code=granules_result['statusCode'], detail=granules_result['body'])
215215

216216

217-
# @router.get("/{collection_id}/items/{granule_id}")
218-
# @router.get("/{collection_id}/items/{granule_id}/")
219-
# async def get_single_granule_dapa(request: Request, collection_id: str, granule_id: str):
220-
# authorizer: UDSAuthorizorAbstract = UDSAuthorizerFactory() \
221-
# .get_instance(UDSAuthorizerFactory.cognito,
222-
# es_url=os.getenv('ES_URL'),
223-
# es_port=int(os.getenv('ES_PORT', '443'))
224-
# )
225-
# auth_info = FastApiUtils.get_authorization_info(request)
226-
# collection_identifier = UdsCollections.decode_identifier(collection_id)
227-
# if not authorizer.is_authorized_for_collection(DBConstants.read, collection_id,
228-
# auth_info['ldap_groups'],
229-
# collection_identifier.tenant,
230-
# collection_identifier.venue):
231-
# LOGGER.debug(f'user: {auth_info["username"]} is not authorized for {collection_id}')
232-
# raise HTTPException(status_code=403, detail=json.dumps({
233-
# 'message': 'not authorized to execute this action'
234-
# }))
235-
# try:
236-
# api_base_prefix = FastApiUtils.get_api_base_prefix()
237-
# pg_link_generator = PaginationLinksGenerator(request)
238-
# granules_dapa_query = GranulesDapaQueryEs(collection_id, 1, None, None, filter, None, f'{pg_link_generator.base_url}/{api_base_prefix}')
239-
# granules_result = granules_dapa_query.get_single_granule(granule_id)
240-
# except Exception as e:
241-
# LOGGER.exception('failed during get_granules_dapa')
242-
# raise HTTPException(status_code=500, detail=str(e))
243-
# return granules_result
217+
@router.get("/{collection_id}/items/{granule_id}")
218+
@router.get("/{collection_id}/items/{granule_id}/")
219+
async def get_single_granule_dapa(request: Request, collection_id: str, granule_id: str):
220+
authorizer: UDSAuthorizorAbstract = UDSAuthorizerFactory() \
221+
.get_instance(UDSAuthorizerFactory.cognito,
222+
es_url=os.getenv('ES_URL'),
223+
es_port=int(os.getenv('ES_PORT', '443'))
224+
)
225+
auth_info = FastApiUtils.get_authorization_info(request)
226+
collection_identifier = UdsCollections.decode_identifier(collection_id)
227+
if not authorizer.is_authorized_for_collection(DBConstants.read, collection_id,
228+
auth_info['ldap_groups'],
229+
collection_identifier.tenant,
230+
collection_identifier.venue):
231+
LOGGER.debug(f'user: {auth_info["username"]} is not authorized for {collection_id}')
232+
raise HTTPException(status_code=403, detail=json.dumps({
233+
'message': 'not authorized to execute this action'
234+
}))
235+
try:
236+
api_base_prefix = FastApiUtils.get_api_base_prefix()
237+
pg_link_generator = PaginationLinksGenerator(request)
238+
granules_dapa_query = GranulesDapaQueryEs(collection_id, 1, None, None, filter, None, f'{pg_link_generator.base_url}/{api_base_prefix}')
239+
granules_result = granules_dapa_query.get_single_granule(granule_id)
240+
except Exception as e:
241+
LOGGER.exception('failed during get_granules_dapa')
242+
raise HTTPException(status_code=500, detail=str(e))
243+
return granules_result
244244

245245
@router.delete("/{collection_id}/items/{granule_id}")
246246
@router.delete("/{collection_id}/items/{granule_id}/")
@@ -288,35 +288,35 @@ async def delete_single_granule_dapa_actual(request: Request, collection_id: str
288288
return {}
289289

290290

291-
@router.delete("/{collection_id}/items/{granule_id}")
292-
@router.delete("/{collection_id}/items/{granule_id}/")
293-
async def delete_single_granule_dapa_facade(request: Request, collection_id: str, granule_id: str, response: Response, response_class=JSONResponse):
294-
authorizer: UDSAuthorizorAbstract = UDSAuthorizerFactory() \
295-
.get_instance(UDSAuthorizerFactory.cognito,
296-
es_url=os.getenv('ES_URL'),
297-
es_port=int(os.getenv('ES_PORT', '443'))
298-
)
299-
auth_info = FastApiUtils.get_authorization_info(request)
300-
collection_identifier = UdsCollections.decode_identifier(collection_id)
301-
if not authorizer.is_authorized_for_collection(DBConstants.delete, collection_id,
302-
auth_info['ldap_groups'],
303-
collection_identifier.tenant,
304-
collection_identifier.venue):
305-
LOGGER.debug(f'user: {auth_info["username"]} is not authorized for {collection_id}')
306-
raise HTTPException(status_code=403, detail=json.dumps({
307-
'message': 'not authorized to execute this action'
308-
}))
309-
try:
310-
LOGGER.debug(f'deleting granule: {granule_id}')
311-
granules_dapa_query = GranulesDapaQueryEs(collection_id, -1, -1, None, None, None, '')
312-
delete_prep_result = granules_dapa_query.delete_facade(request.url, request.headers.get('Authorization', ''))
313-
except Exception as e:
314-
LOGGER.exception('failed during delete_single_granule_dapa')
315-
raise HTTPException(status_code=500, detail=str(e))
316-
if delete_prep_result['statusCode'] < 300:
317-
response.status_code = delete_prep_result['statusCode']
318-
return delete_prep_result['body']
319-
raise HTTPException(status_code=delete_prep_result['statusCode'], detail=delete_prep_result['body'])
291+
# @router.delete("/{collection_id}/items/{granule_id}")
292+
# @router.delete("/{collection_id}/items/{granule_id}/")
293+
# async def delete_single_granule_dapa_facade(request: Request, collection_id: str, granule_id: str, response: Response, response_class=JSONResponse):
294+
# authorizer: UDSAuthorizorAbstract = UDSAuthorizerFactory() \
295+
# .get_instance(UDSAuthorizerFactory.cognito,
296+
# es_url=os.getenv('ES_URL'),
297+
# es_port=int(os.getenv('ES_PORT', '443'))
298+
# )
299+
# auth_info = FastApiUtils.get_authorization_info(request)
300+
# collection_identifier = UdsCollections.decode_identifier(collection_id)
301+
# if not authorizer.is_authorized_for_collection(DBConstants.delete, collection_id,
302+
# auth_info['ldap_groups'],
303+
# collection_identifier.tenant,
304+
# collection_identifier.venue):
305+
# LOGGER.debug(f'user: {auth_info["username"]} is not authorized for {collection_id}')
306+
# raise HTTPException(status_code=403, detail=json.dumps({
307+
# 'message': 'not authorized to execute this action'
308+
# }))
309+
# try:
310+
# LOGGER.debug(f'deleting granule: {granule_id}')
311+
# granules_dapa_query = GranulesDapaQueryEs(collection_id, -1, -1, None, None, None, '')
312+
# delete_prep_result = granules_dapa_query.delete_facade(request.url, request.headers.get('Authorization', ''))
313+
# except Exception as e:
314+
# LOGGER.exception('failed during delete_single_granule_dapa')
315+
# raise HTTPException(status_code=500, detail=str(e))
316+
# if delete_prep_result['statusCode'] < 300:
317+
# response.status_code = delete_prep_result['statusCode']
318+
# return delete_prep_result['body']
319+
# raise HTTPException(status_code=delete_prep_result['statusCode'], detail=delete_prep_result['body'])
320320

321321

322322
@router.put("/{collection_id}/archive/{granule_id}")

0 commit comments

Comments
 (0)