summaryrefslogtreecommitdiffstats
path: root/ogcp/og_server.py
diff options
context:
space:
mode:
Diffstat (limited to 'ogcp/og_server.py')
-rw-r--r--ogcp/og_server.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/ogcp/og_server.py b/ogcp/og_server.py
index 6242f02..08c9b08 100644
--- a/ogcp/og_server.py
+++ b/ogcp/og_server.py
@@ -1,3 +1,4 @@
+import requests
import json
class OGServer:
@@ -5,6 +6,7 @@ class OGServer:
self.ip = ip
self.port = port
self.api_token = api_token
+ self._prepare_requests()
def load_config(self, path):
with open(path, 'r') as f:
@@ -13,3 +15,20 @@ class OGServer:
self.ip = cfg['ip']
self.port = cfg['port']
self.api_token = cfg['api_token']
+ self._prepare_requests()
+
+ def _prepare_requests(self):
+ self.URL = f'http://{self.ip}:{self.port}'
+ self.HEADERS = {'Authorization' : self.api_token}
+
+ def get(self, path, payload=None):
+ r = requests.get(f'{self.URL}{path}',
+ headers=self.HEADERS,
+ json=payload)
+ return r
+
+ def post(self, path, payload):
+ r = requests.post(f'{self.URL}{path}',
+ headers=self.HEADERS,
+ json=payload)
+ return r