diff --git a/icepyx/core/harmony.py b/icepyx/core/harmony.py index cc812b00..33274a5a 100644 --- a/icepyx/core/harmony.py +++ b/icepyx/core/harmony.py @@ -2,13 +2,22 @@ import harmony +from icepyx.core.auth import EarthdataAuthMixin -def get_capabilities(concept_id: str) -> dict[str, Any]: - capabilities_request = harmony.CapabilitiesRequest(concept_id=concept_id) - # TODO: This will work if the user has a .netrc file available but the other - # auth options might fail. We might need to add harmony client auth to the - # icepyx auth package. - harmony_client = harmony.Client() - response = harmony_client.submit(capabilities_request) - return response +class HarmonyApi(EarthdataAuthMixin): + def __init__(self): + # initialize authentication properties + EarthdataAuthMixin.__init__(self) + self.harmony_client = harmony.Client( + auth=( + self.auth.username, + self.auth.password, + ), + ) + + def get_capabilities(self, concept_id: str) -> dict[str, Any]: + capabilities_request = harmony.CapabilitiesRequest(concept_id=concept_id) + response = self.harmony_client.submit(capabilities_request) + + return response