-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patholcf-s3m-token.py
More file actions
executable file
·46 lines (36 loc) · 1.33 KB
/
olcf-s3m-token.py
File metadata and controls
executable file
·46 lines (36 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env python3
import argparse
from os import getenv
from olcf_s3m_api.client import OLCFAPIClient
from olcf_s3m_api.token import TokenService
def info(service : TokenService):
print('++++ OLCF S3M - Token Management ++++ Querying Token Details')
success, token_info = service.get_token_info()
msg = token_info.msg()
if success:
print(msg)
print('\n\n')
def revoke(service : TokenService):
print('++++ OLCF S3M - Token Management ++++ Revoking Token')
service.revoke_token()
print('\n\n')
def show(service : TokenService):
print('++++ OLCF S3M - Token Management ++++ Displaying Token')
hash = service.get_token_hash()
print(f'OLCF S3M API Token: {hash}')
print('\n\n')
def main(args):
my_api_client = OLCFAPIClient(api_token=getenv("olcf_s3m_api_TOKEN", "InvalidToken"))
my_token_service = TokenService(api_client=my_api_client)
if args.info:
info(my_token_service)
elif args.revoke:
revoke(my_token_service)
else:
show(my_token_service)
if __name__ == '__main__':
parser = argparse.ArgumentParser('olcf-s3m-token')
parser.add_argument('-i', '--info', help='get token details', action='store_true')
parser.add_argument('-r', '--revoke', help='revoke current token', action='store_true')
args = parser.parse_args()
main(args)