diff options
author | Roberto Hueso Gómez <rhueso@soleta.eu> | 2020-06-19 13:10:14 +0200 |
---|---|---|
committer | Roberto Hueso Gómez <rhueso@soleta.eu> | 2020-06-19 13:10:14 +0200 |
commit | be18d619e69755ee836175d414dada7b6b3cf13e (patch) | |
tree | 41b2de6cb7054cecafa881ddaa41e34e8d04d00b /ogcli/ogcli.py | |
parent | 36c61158555b6a59b28fa1d3c07f15adddffabc9 (diff) |
Add list scopes command
This is consistent with HTTP GET /scopes
Diffstat (limited to 'ogcli/ogcli.py')
-rw-r--r-- | ogcli/ogcli.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/ogcli/ogcli.py b/ogcli/ogcli.py index 37fb2e0..d628bfd 100644 --- a/ogcli/ogcli.py +++ b/ogcli/ogcli.py @@ -1,4 +1,5 @@ from ogcli.objects.og_client import OgClient +from ogcli.objects.og_scopes import OgScope import argparse import requests import sys @@ -10,7 +11,7 @@ class OgREST(): def get(self, path): try: - r = requests.get(f'{self.URL}/clients', + r = requests.get(f'{self.URL}{path}', headers=self.HEADERS) if r.status_code != 200: sys.exit(f"Cannot connect to ogServer: " @@ -24,9 +25,12 @@ class OgCLI(): self.rest = OgREST(cfg['ip'], cfg['port'], cfg['api_token']) def list(self, args): + choices = ['clients', 'scopes'] parser = argparse.ArgumentParser() - parser.add_argument('item', choices=['clients']) + parser.add_argument('item', choices=choices) args = parser.parse_args(args) if args.item == 'clients': OgClient.list_clients(self.rest) + elif args.item == 'scopes': + OgScope.list_scopes(self.rest) |