Skip to content
Merged
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
c9dd83f
breaking: using latest uds-lib + update docker
wphyojpl Oct 28, 2024
d803e28
feat: use latest uds-lib
wphyojpl Oct 28, 2024
9df22f5
Merge branch 'develop' of github.com:unity-sds/unity-data-services in…
wphyojpl Nov 4, 2024
db5833f
Merge branch 'develop' of github.com:unity-sds/unity-data-services in…
wphyojpl Nov 4, 2024
2368a4c
chore: merge from develop
wphyojpl Nov 4, 2024
ebaaab5
Merge branch 'develop' of github.com:unity-sds/unity-data-services in…
wphyojpl Dec 3, 2024
84cfda4
Merge branch 'develop' of github.com:unity-sds/unity-data-services in…
wphyojpl Dec 8, 2024
3345c13
Merge branch 'develop' of github.com:unity-sds/unity-data-services in…
wphyojpl Dec 9, 2024
bc7a4cf
Merge branch 'develop' of github.com:unity-sds/unity-data-services in…
wphyojpl Dec 9, 2024
dd500cb
Merge branch 'develop' of github.com:unity-sds/unity-data-services in…
wphyojpl Dec 16, 2024
e02e045
Merge branch 'develop' of github.com:unity-sds/unity-data-services in…
wphyojpl Dec 17, 2024
b8bf96c
Merge branch 'develop' of github.com:unity-sds/unity-data-services in…
wphyojpl Dec 20, 2024
5fa73a4
chore: allow local ES
wphyojpl Dec 20, 2024
790969b
fix: add es type
wphyojpl Jan 7, 2025
4ff56d3
Merge branch 'develop' of github.com:unity-sds/unity-data-services in…
wphyojpl Jan 17, 2025
3bd1a0b
fix: adding a no-ssl option
wphyojpl Jan 17, 2025
2fb799f
feat: optionally omitting cumulus in collection creation
wphyojpl Jan 21, 2025
d7d8fc2
feat: split archive api to a different file to simplify documentation
wphyojpl Jan 21, 2025
a977826
feat: move one more archive api
wphyojpl Jan 21, 2025
0fc4b18
fix: add granule addition (w/o cumulus)
wphyojpl Jan 21, 2025
532c164
feat: allow cross collection query + bbox
wphyojpl Jan 30, 2025
1513652
Merge branch 'develop' of github.com:unity-sds/unity-data-services in…
wphyojpl Jan 31, 2025
640e9b7
feat: Api documentation (#522)
wphyojpl Jan 31, 2025
54b6a14
fix: boto3 s3 transfer lib issue
wphyojpl Jan 31, 2025
e593288
Merge branch 'local.es' of github.com:unity-sds/unity-data-services i…
wphyojpl Jan 31, 2025
d7549b8
Merge branch 'develop' of github.com:unity-sds/unity-data-services in…
wphyojpl Jan 31, 2025
6c75f52
feat: add sort by argument
wphyojpl Feb 1, 2025
8d93869
update keyword to match ogc
wphyojpl Feb 1, 2025
23e18fb
Merge branch 'develop' into local.es
wphyojpl Feb 6, 2025
f7a62b9
Merge branch 'local.es' of github.com:unity-sds/unity-data-services i…
wphyojpl Feb 6, 2025
18152fc
fix: bbox need to check for None type
wphyojpl Feb 6, 2025
1213bec
chore: dummy
wphyojpl Feb 6, 2025
e51b576
Merge branch 'develop' into sort-by-time
wphyojpl Feb 10, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ Questions about our project? Please see our: [FAQ]([INSERT LINK TO FAQ / DISCUSS
1. Question 1
- Answer to question 1.
2. Question 2
- Answer to question 2
- Answer to question 2.
-->

<!-- example FAQ inline with no questions yet>
Expand Down
3 changes: 2 additions & 1 deletion cumulus_lambda_functions/cumulus_es_setup/es_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ def __init__(self):
required_env = ['ES_URL']
if not all([k in os.environ for k in required_env]):
raise EnvironmentError(f'one or more missing env: {required_env}')
self.__es: ESAbstract = ESFactory().get_instance('AWS',
self.__es: ESAbstract = ESFactory().get_instance(os.getenv('ES_TYPE', 'AWS'),
index=DBConstants.collections_index,
base_url=os.getenv('ES_URL'),
use_ssl=os.getenv('ES_USE_SSL', 'TRUE').strip() is True,
port=int(os.getenv('ES_PORT', '443'))
)

Expand Down
34 changes: 34 additions & 0 deletions cumulus_lambda_functions/cumulus_wrapper/query_granules.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,40 @@ def query_direct_to_private_api(self, private_api_prefix: str, transform=True):
return {'server_error': f'error while invoking:{str(e)}'}
return {'results': stac_list}

def add_entry(self, private_api_prefix: str, new_granule: dict):
raise NotImplementedError(f'Please implement adding granules to Cumulus')
# https://nasa.github.io/cumulus-api/v18.4.0/#create-granule
# payload = {
# 'httpMethod': 'POST',
# 'resource': '/{proxy+}',
# 'path': f'/{self.__collections_key}',
# 'headers': {
# 'Content-Type': 'application/json',
# },
# 'body': json.dumps(new_granule)
# }
# LOGGER.debug(f'payload: {payload}')
# try:
# query_result = self._invoke_api(payload, private_api_prefix)
# """
# {'statusCode': 500, 'body': '', 'headers': {}}
# """
# if query_result['statusCode'] >= 500:
# LOGGER.error(f'server error status code: {query_result["statusCode"]}. details: {query_result}')
# return {'server_error': query_result}
# if query_result['statusCode'] >= 400:
# LOGGER.error(f'client error status code: {query_result["statusCode"]}. details: {query_result}')
# return {'client_error': query_result}
# query_result = json.loads(query_result['body'])
# LOGGER.debug(f'json query_result: {query_result}')
# if 'message' not in query_result:
# return {'server_error': f'invalid response: {query_result}'}
# except Exception as e:
# LOGGER.exception('error while invoking')
# return {'server_error': f'error while invoking:{str(e)}'}
# return {'status': query_result['message']}
return

def delete_entry(self, private_api_prefix: str, granule_id: str):
payload = {
'httpMethod': 'DELETE',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
class DaacArchiverLogic:
def __init__(self):
self.__es_url, self.__es_port = os.getenv('ES_URL'), int(os.getenv('ES_PORT', '443'))
self.__archive_index_logic = UdsArchiveConfigIndex(self.__es_url, self.__es_port)
self.__archive_index_logic = UdsArchiveConfigIndex(self.__es_url, self.__es_port, os.getenv('ES_TYPE', 'AWS'), os.getenv('ES_USE_SSL', 'TRUE').strip() is True)
self.__granules_index = GranulesDbIndex()
self.__sns = AwsSns()
self.__s3 = AwsS3()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def __init__(self):
if 'UNITY_DEFAULT_PROVIDER' not in os.environ:
raise ValueError(f'missing UNITY_DEFAULT_PROVIDER')
self.__default_provider = os.environ.get('UNITY_DEFAULT_PROVIDER')
self.__uds_collection = UdsCollections(es_url=os.getenv('ES_URL'), es_port=int(os.getenv('ES_PORT', '443')))
self.__uds_collection = UdsCollections(es_url=os.getenv('ES_URL'), es_port=int(os.getenv('ES_PORT', '443')), es_type=os.getenv('ES_TYPE', 'AWS'))

@property
def successful_features_json(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@

class UDSAuthorizorEsIdentityPool(UDSAuthorizorAbstract):

def __init__(self, es_url: str, es_port=443) -> None:
def __init__(self, es_url: str, es_port=443, es_type='AWS', use_ssl=True) -> None:
super().__init__()
self.__es: ESAbstract = ESFactory().get_instance('AWS',
self.__es: ESAbstract = ESFactory().get_instance(es_type,
index=DBConstants.authorization_index,
base_url=es_url,
use_ssl=use_ssl,
port=es_port)

def add_authorized_group(self, action: [str], resource: [str], tenant: str, venue: str, ldap_group_name: str):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
import os

from mdps_ds_lib.lib.utils.factory_abstract import FactoryAbstract


class UDSAuthorizerFactory(FactoryAbstract):
cognito = 'COGNITO'

def get_instance(self, class_type, **kwargs):
if 'use_ssl' not in kwargs:
kwargs['use_ssl'] = os.getenv('ES_USE_SSL', 'TRUE').strip() is True
if 'es_type' not in kwargs:
kwargs['es_type'] = os.getenv('ES_TYPE', 'AWS')
if class_type == self.cognito:
from cumulus_lambda_functions.lib.authorization.uds_authorizer_es_identity_pool import \
UDSAuthorizorEsIdentityPool
return UDSAuthorizorEsIdentityPool(kwargs['es_url'], kwargs['es_port'])
return UDSAuthorizorEsIdentityPool(kwargs['es_url'], kwargs['es_port'], kwargs['es_type'], kwargs['use_ssl'])
raise ValueError(f'class_type: {class_type} not implemented')
6 changes: 4 additions & 2 deletions cumulus_lambda_functions/lib/uds_db/archive_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@ class UdsArchiveConfigIndex:
'archiving_types': {'type': 'array', 'items': {'type': 'object'}},
}
}
def __init__(self, es_url, es_port=443):
self.__es: ESAbstract = ESFactory().get_instance('AWS',

def __init__(self, es_url, es_port=443, es_type='AWS', use_ssl=True):
self.__es: ESAbstract = ESFactory().get_instance(es_type,
index='TODO',
base_url=es_url,
use_ssl=use_ssl,
port=es_port)
self.__tenant, self.__venue = '', ''

Expand Down
8 changes: 6 additions & 2 deletions cumulus_lambda_functions/lib/uds_db/granules_db_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ def __init__(self):
required_env = ['ES_URL']
if not all([k in os.environ for k in required_env]):
raise EnvironmentError(f'one or more missing env: {required_env}')
self.__es: ESAbstract = ESFactory().get_instance('AWS',
self.__es: ESAbstract = ESFactory().get_instance(os.getenv('ES_TYPE', 'AWS'),
index=DBConstants.collections_index,
base_url=os.getenv('ES_URL'),
port=int(os.getenv('ES_PORT', '443'))
port=int(os.getenv('ES_PORT', '443')),
use_ssl=os.getenv('ES_USE_SSL', 'TRUE').strip() is True,
)
# self.__default_fields = {
# "granule_id": {"type": "keyword"},
Expand All @@ -36,8 +37,11 @@ def __init__(self):
def to_es_bbox(bbox_array):
# lon = x, lat = y
# lon, lat, lon, lat
# -180, -90, 180, 90
# x can be 170 to -170
# 170, 0, -170, 10
# latitude must be between -90.0 and 90.0
# longitude must be between -180.0 and 180.0
minX, minY, maxX, maxY = bbox_array

# Ensure the values are properly sorted
Expand Down
5 changes: 3 additions & 2 deletions cumulus_lambda_functions/lib/uds_db/uds_collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@ class UdsCollections:
start_time = 'start_time'
end_time = 'end_time'

def __init__(self, es_url, es_port=443):
self.__es: ESAbstract = ESFactory().get_instance('AWS',
def __init__(self, es_url, es_port=443, es_type='AWS', use_ssl=True):
self.__es: ESAbstract = ESFactory().get_instance(es_type,
index=DBConstants.collections_index,
base_url=es_url,
use_ssl=use_ssl,
port=es_port)

@staticmethod
Expand Down
2 changes: 1 addition & 1 deletion cumulus_lambda_functions/uds_api/auth_admin_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

router = APIRouter(
prefix=f'/{WebServiceConstants.ADMIN}/auth',
tags=["Admin Records CRUD", "Admins-Only"],
tags=["Admin Records CRUD (Admins-Only)"],
responses={404: {"description": "Not found"}},
)

Expand Down
2 changes: 1 addition & 1 deletion cumulus_lambda_functions/uds_api/catalog_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ async def get_catalog(request: Request, limit: Union[int, None] = 10, offset: Un
)
auth_info = FastApiUtils.get_authorization_info(request)
uds_collections = UdsCollections(es_url=os.getenv('ES_URL'),
es_port=int(os.getenv('ES_PORT', '443')))
es_port=int(os.getenv('ES_PORT', '443')), es_type=os.getenv('ES_TYPE', 'AWS'))
collection_regexes = authorizer.get_authorized_collections(DBConstants.read, auth_info['ldap_groups'])
LOGGER.info(f'collection_regexes: {collection_regexes}')
authorized_collections = uds_collections.get_collections(collection_regexes)
Expand Down
5 changes: 3 additions & 2 deletions cumulus_lambda_functions/uds_api/collections_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ async def create_new_collection(request: Request, new_collection: CumulusCollect


@router.post("/actual")
@router.post("/actual/")
async def create_new_collection_real(request: Request, new_collection: CumulusCollectionModel):
"""
Actual endpoint to create a new Cumulus Collection
Expand Down Expand Up @@ -192,7 +193,7 @@ async def get_single_collection(request: Request, collection_id: str, limit: Uni
)
auth_info = FastApiUtils.get_authorization_info(request)
uds_collections = UdsCollections(es_url=os.getenv('ES_URL'),
es_port=int(os.getenv('ES_PORT', '443')))
es_port=int(os.getenv('ES_PORT', '443')), es_type=os.getenv('ES_TYPE', 'AWS'))
if collection_id is None or collection_id == '':
raise HTTPException(status_code=500, detail=f'missing or invalid collection_id: {collection_id}')
collection_identifier = uds_collections.decode_identifier(collection_id)
Expand Down Expand Up @@ -237,7 +238,7 @@ async def query_collections(request: Request, collection_id: Union[str, None] =
)
auth_info = FastApiUtils.get_authorization_info(request)
uds_collections = UdsCollections(es_url=os.getenv('ES_URL'),
es_port=int(os.getenv('ES_PORT', '443')))
es_port=int(os.getenv('ES_PORT', '443')), es_type=os.getenv('ES_TYPE', 'AWS'))
if collection_id is not None:
collection_identifier = uds_collections.decode_identifier(collection_id)
if not authorizer.is_authorized_for_collection(DBConstants.read, collection_id,
Expand Down
8 changes: 4 additions & 4 deletions cumulus_lambda_functions/uds_api/custom_meta_admin_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

@router.put("/custom_metadata/{tenant}")
@router.put("/custom_metadata/{tenant}/")
async def es_granules_index_setup(request: Request, tenant: str, venue: Union[str, None] = None, request_body: dict = {}):
async def custom_metadata_add(request: Request, tenant: str, venue: Union[str, None] = None, request_body: dict = {}):
LOGGER.debug(f'started es_granules_index_setup')
auth_info = FastApiUtils.get_authorization_info(request)
query_body = {
Expand All @@ -40,7 +40,7 @@ async def es_granules_index_setup(request: Request, tenant: str, venue: Union[st

@router.get("/custom_metadata/{tenant}")
@router.get("/custom_metadata/{tenant}/")
async def es_granules_index_setup(request: Request, tenant: str, venue: Union[str, None] = None):
async def custom_metadata_get(request: Request, tenant: str, venue: Union[str, None] = None):
LOGGER.debug(f'started es_granules_index_setup')
auth_info = FastApiUtils.get_authorization_info(request)
query_body = {
Expand All @@ -61,7 +61,7 @@ async def es_granules_index_setup(request: Request, tenant: str, venue: Union[st

@router.delete("/custom_metadata/{tenant}/destroy")
@router.delete("/custom_metadata/{tenant}/destroy/")
async def es_granules_index_setup(request: Request, tenant: str, venue: Union[str, None] = None):
async def custom_metadata_destroy(request: Request, tenant: str, venue: Union[str, None] = None):
LOGGER.debug(f'started es_granules_index_setup')
auth_info = FastApiUtils.get_authorization_info(request)
query_body = {
Expand All @@ -82,7 +82,7 @@ async def es_granules_index_setup(request: Request, tenant: str, venue: Union[st

@router.delete("/custom_metadata/{tenant}")
@router.delete("/custom_metadata/{tenant}/")
async def es_granules_index_delete_setup(request: Request, tenant: str, venue: Union[str, None] = None):
async def custom_metadata_delete(request: Request, tenant: str, venue: Union[str, None] = None):
LOGGER.debug(f'started es_granules_index_delete_setup')
auth_info = FastApiUtils.get_authorization_info(request)
query_body = {
Expand Down
2 changes: 1 addition & 1 deletion cumulus_lambda_functions/uds_api/dapa/auth_crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def __init__(self, authorization_info, request_body):
self.__authorizer: UDSAuthorizorAbstract = UDSAuthorizerFactory() \
.get_instance(UDSAuthorizerFactory.cognito,
es_url=self.__es_url,
es_port=self.__es_port
es_port=self.__es_port, es_type=os.getenv('ES_TYPE', 'AWS')
)

def is_admin(self):
Expand Down
Loading
Loading