Skip to content

Commit

Permalink
add version and path to sns attrs (#138)
Browse files Browse the repository at this point in the history
* add version and path to sns attrs

* black the file

* make retrieving path robust

Co-authored-by: Emma Ai <[email protected]>
  • Loading branch information
emmaai and Emma Ai authored Mar 3, 2022
1 parent 2917841 commit 56758a4
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions datacube_alchemist/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ def _stac_to_sns(sns_arn, stac):
Publish our STAC document to an SNS
"""
bbox = stac["bbox"]
link_ref = next(
filter(lambda x: x.get("rel", "") == "self", get_in(["links"], stac, [])), {}
).get("href", "")

product_name = get_in(["properties", "odc:product"], stac, None)
if product_name is None:
product_name = stac.get("collection", None)
Expand All @@ -116,6 +120,14 @@ def _stac_to_sns(sns_arn, stac):
"DataType": "String",
"StringValue": product_name,
},
"version": {
"DataType": "String",
"StringValue": str(get_in(["properties", "odc:dataset_version"], stac, "")),
},
"path": {
"DataType": "String",
"StringValue": link_ref,
},
"bbox.ll_lon": {"DataType": "Number", "StringValue": str(bbox[0])},
"bbox.ll_lat": {"DataType": "Number", "StringValue": str(bbox[1])},
"bbox.ur_lon": {"DataType": "Number", "StringValue": str(bbox[2])},
Expand Down

0 comments on commit 56758a4

Please sign in to comment.