From 2120ef6f78a49235611be84f3a79f5dbb3d268d4 Mon Sep 17 00:00:00 2001 From: OpenGnSys Support Team Date: Thu, 18 Jun 2020 13:53:09 +0200 Subject: First commit Add basic OgCLI structure. --- ogcli/__init__.py | 1 + ogcli/ogcli.py | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 ogcli/__init__.py create mode 100644 ogcli/ogcli.py (limited to 'ogcli') diff --git a/ogcli/__init__.py b/ogcli/__init__.py new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/ogcli/__init__.py @@ -0,0 +1 @@ + diff --git a/ogcli/ogcli.py b/ogcli/ogcli.py new file mode 100644 index 0000000..d383e2d --- /dev/null +++ b/ogcli/ogcli.py @@ -0,0 +1,18 @@ +import requests + +class OgCLI(): + def __init__(self, cfg): + self.api_token = cfg['api_token'] + + def client_list(self): + headers = {'Authorization' : self.api_token} + try: + r = requests.get('http://127.0.0.1:8888/clients', + headers=headers) + if r.status_code != 200: + sys.exit(f"Cannot connect to ogServer: " + f"{r.status_code} HTTP status code") + except IOError as e: + sys.exit(f"Cannot connect to ogServer: {e}") + + print(r.json()) -- cgit v1.2.3-18-g5258