summaryrefslogtreecommitdiffstats
path: root/ogcli/ogcli.py
diff options
context:
space:
mode:
authorOpenGnSys Support Team <soporte-og@soleta.eu>2020-06-18 13:53:09 +0200
committerOpenGnSys Support Team <soporte-og@soleta.eu>2020-06-18 16:44:08 +0200
commit2120ef6f78a49235611be84f3a79f5dbb3d268d4 (patch)
tree66a9a88787089853fbfb1ae3ab44f4f132cd3590 /ogcli/ogcli.py
First commit
Add basic OgCLI structure.
Diffstat (limited to 'ogcli/ogcli.py')
-rw-r--r--ogcli/ogcli.py18
1 files changed, 18 insertions, 0 deletions
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())