summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBotond Hende <nettingman@gmail.com>2024-08-19 13:46:32 +0200
committerBotond Hende <nettingman@gmail.com>2024-08-19 13:46:32 +0200
commit490db4316b3012e689b10f187d6c19042373fef4 (patch)
treebebc0d59ee26bedfb0f948fc2ea6232dcd8afa35
parentf888a02ed4a5b715557f679571e3bbb8ad9c0f17 (diff)
first api call
-rw-r--r--__init__.py0
-rw-r--r--__main__.py12
-rw-r--r--modules/__init__.py0
-rw-r--r--modules/daemon.py17
4 files changed, 29 insertions, 0 deletions
diff --git a/__init__.py b/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/__init__.py
diff --git a/__main__.py b/__main__.py
new file mode 100644
index 0000000..5cba034
--- /dev/null
+++ b/__main__.py
@@ -0,0 +1,12 @@
+import os.path
+from .modules import daemon
+
+AGENT_SYMBOL = "WAZUL"
+TOKEN_FILE_NAME = "sta.token"
+
+if __name__ == "__main__":
+ with open(os.path.join(os.path.dirname(__file__), TOKEN_FILE_NAME)) as f:
+ token = f.read().strip()
+
+ d = daemon.Daemon(AGENT_SYMBOL, token)
+ d.run()
diff --git a/modules/__init__.py b/modules/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/modules/__init__.py
diff --git a/modules/daemon.py b/modules/daemon.py
new file mode 100644
index 0000000..e5987d2
--- /dev/null
+++ b/modules/daemon.py
@@ -0,0 +1,17 @@
+import openapi_client
+
+class Daemon():
+
+ def __init__(self, agent_symbol, token):
+ config = openapi_client.Configuration(access_token = token)
+ self.api_client = openapi_client.ApiClient(config)
+ self.api_instance = openapi_client.AgentsApi(self.api_client)
+ self.agent_symbol = agent_symbol
+
+ def run(self):
+ try:
+ api_response = self.api_instance.get_agent(self.agent_symbol)
+ print("The response of AgentsApi->get_agent:\n")
+ print(api_response)
+ except Exception as e:
+ print("Exception when calling AgentsApi->get_agent: %s\n" % e)