-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add concept_id cached property to Query class
We need this to talk to Harmony -- Harmony doesn't support the product version as a query parameter, so we need to look up the real unique identifier in advance.
- Loading branch information
Showing
2 changed files
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,29 @@ | ||
from typing import Final | ||
|
||
import requests | ||
|
||
from icepyx.core.urls import COLLECTION_SEARCH_BASE_URL | ||
from icepyx.uat import EDL_ACCESS_TOKEN | ||
|
||
CMR_PROVIDER: Final = "NSIDC_CUAT" | ||
# CMR_PROVIDER: Final = "NSIDC_CPRD" | ||
|
||
|
||
def get_concept_id(*, product: str, version: str) -> str: | ||
response = requests.get( | ||
COLLECTION_SEARCH_BASE_URL, | ||
headers={ | ||
"Authorization": f"Bearer {EDL_ACCESS_TOKEN}", | ||
}, | ||
params={ | ||
"short_name": product, | ||
"version": version, | ||
"provider": CMR_PROVIDER, | ||
}, | ||
) | ||
metadata = response.json()["feed"]["entry"] | ||
|
||
if len(metadata) != 1: | ||
raise RuntimeError(f"Expected 1 result from CMR, received {metadata}") | ||
|
||
return metadata[0]["id"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters