Skip to content
This repository was archived by the owner on Jan 28, 2025. It is now read-only.

Commit 1680a73

Browse files
authored
Merge pull request #32 from ghrcdaac/mlh0079-5352-private-api-lambda
Mlh0079 5352 private api lambda
2 parents 51cd318 + 88fab10 commit 1680a73

File tree

3 files changed

+22
-15
lines changed

3 files changed

+22
-15
lines changed

pylot/plugins/cumulus_api/main.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,10 @@ def generate_parser(subparsers, action_target_dict):
7373
action_subparsers = cumulus_api_parser.add_subparsers(title='actions', dest='action', required=True)
7474
for action_k, target_v in action_target_dict.items():
7575
action_parser = action_subparsers.add_parser(
76-
action_k, help=f'{action_k} action for the cumulus API',
77-
usage=f'{action_k} <target> ',
78-
description=f'{action_k} action for the cumulus API'
79-
)
76+
action_k, help=f'{action_k} action for the cumulus API',
77+
usage=f'{action_k} <target> ',
78+
description=f'{action_k} action for the cumulus API'
79+
)
8080
target_subparsers = action_parser.add_subparsers(title='target', dest='target', required=True)
8181
for target_k, argument_v in target_v.items():
8282
plural = ''

pylot/plugins/helpers/pylot_helpers.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,21 @@ def get_hash_token_file():
3131
@classmethod
3232
def get_cumulus_api_instance(cls):
3333
""" Get Cumulus instance with cached token"""
34-
get_hashed_file_name = cls.get_hash_token_file()
35-
token: str
36-
tempfile = f'{mkdtemp()}/{get_hashed_file_name}'
37-
if not os.path.isfile(tempfile):
38-
with open(tempfile, 'w', encoding='utf-8') as _file:
39-
cml = CumulusApi()
40-
_file.write(cml.TOKEN)
34+
if 'PRIVATE_API_LAMBDA_ARN' in os.environ:
35+
print('getting non-token instance')
36+
cml = CumulusApi()
37+
pass
4138
else:
42-
with open(tempfile, 'r', encoding='utf-8') as _file:
43-
token = _file.readline()
44-
cml = CumulusApi(token=token)
39+
print('getting token instance')
40+
get_hashed_file_name = cls.get_hash_token_file()
41+
token: str
42+
tempfile = f'{mkdtemp()}/{get_hashed_file_name}'
43+
if not os.path.isfile(tempfile):
44+
with open(tempfile, 'w', encoding='utf-8') as _file:
45+
cml = CumulusApi()
46+
_file.write(cml.TOKEN)
47+
else:
48+
with open(tempfile, 'r', encoding='utf-8') as _file:
49+
token = _file.readline()
50+
cml = CumulusApi(token=token)
4551
return cml

requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
cumulus-api @ https://github.com/ghrcdaac/cumulus-api/archive/refs/tags/v2.0.0.zip
1+
2+
cumulus-api @ https://github.com/ghrcdaac/cumulus-api/archive/refs/tags/v2.2.0.zip
23
boto3==1.24.28

0 commit comments

Comments
 (0)