Skip to content

Commit

Permalink
Merge pull request #747 from asfadmin/feature-s3-urls
Browse files Browse the repository at this point in the history
NISAR S3 & Additional Urls
  • Loading branch information
SpicyGarlicAlbacoreRoll authored Apr 1, 2024
2 parents e520313 + ba3bd35 commit 5664c24
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 1 deletion.
9 changes: 8 additions & 1 deletion SearchAPI/CMR/Output/jsonlite.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ def req_fields_jsonlite():
'subswath',
'pgeVersion',
'operaBurstID',
'additionalUrls'
'additionalUrls',
's3Urls'
]
return fields

Expand Down Expand Up @@ -186,4 +187,10 @@ def getItem(self, p):
if p.get('validityStartDate'):
result['opera']['validityStartDate'] = p.get('validityStartDate')

if p.get('platform') == 'NISAR':
result['nisar'] = {
'additionalUrls': p.get('additionalUrls', []),
's3Urls': p.get('s3Urls', [])
}

return result
3 changes: 3 additions & 0 deletions SearchAPI/CMR/Output/jsonlite2.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,7 @@ def getItem(self, p):
if p.get('opera') is not None:
result['s1o'] = p['opera']

if p.get('nisar') is not None:
result['nsr'] = p['nisar']

return result
1 change: 1 addition & 0 deletions SearchAPI/CMR/Translate/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ def get_field_paths():
'track': attr_path('PATH_NUMBER'),
'pgeVersion': "./PGEVersionClass/PGEVersion",
'additionalUrls': "./OnlineAccessURLs",
's3Urls': "./OnlineAccessURLs",

# BURST FIELDS
'absoluteBurstID': attr_path('BURST_ID_ABSOLUTE'),
Expand Down
16 changes: 16 additions & 0 deletions SearchAPI/CMR/Translate/parse_cmr_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,23 @@ def float_or_none(a):

if 'STATIC' in result['processingLevel']:
result['validityStartDate'] = get_val('./Temporal/SingleDateTime')
if result.get('platform', '') == 'NISAR':
accessUrls = [url for url in get_all_vals('./OnlineAccessURLs/OnlineAccessURL/URL') if not url.endswith('.md5') and not url.startswith('s3://') and not 's3credentials' in url]
OnlineResources = [url for url in get_all_vals('./OnlineResources/OnlineResource/URL') if not url.endswith('.md5') and not url.startswith('s3://') and not 's3credentials' in url]
result['additionalUrls'] = list(set([*accessUrls, *OnlineResources]))

accessUrls = get_all_vals('./OnlineAccessURLs/OnlineAccessURL/URL')
if accessUrls is None:
accessUrls = []
resourceUrls = get_all_vals('./OnlineResources/OnlineResource/URL')
if resourceUrls is None:
resourceUrls = []

result['s3Urls'] = list(set(
[*[url for url in accessUrls if not url.endswith('.md5') and (url.startswith('s3://') or 's3credentials' in url)],
*[url for url in resourceUrls if not url.endswith('.md5') and (url.startswith('s3://') or 's3credentials' in url)]
]
))
return result


Expand Down

0 comments on commit 5664c24

Please sign in to comment.