Skip to content

Commit

Permalink
Harmony api: use EarthdataAuthMixin
Browse files Browse the repository at this point in the history
  • Loading branch information
trey-stafford committed Nov 11, 2024
1 parent 192cee2 commit e7ff043
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions icepyx/core/harmony.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit e7ff043

Please sign in to comment.