blob: 085a7f68e4b272c31f873210b6cad28e5533dd80 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
import openapi_client
from fastapi import FastAPI
from pprint import pprint
fast_api = FastAPI()
class Daemon:
def __init__(self, agent_symbol, token):
config = openapi_client.Configuration(access_token=token)
self.api_client = openapi_client.ApiClient(config)
self.agents_api = openapi_client.AgentsApi(self.api_client)
self.fleet_api = openapi_client.FleetApi(self.api_client)
self.systems_api = openapi_client.SystemsApi(self.api_client)
self.agent_symbol = agent_symbol
@fast_api.get("/")
def foo(self):
return "hello"
def run(self):
try:
api_response = self.agents_api.get_agent(self.agent_symbol)
print("The response of AgentsApi->get_agent:\n")
print(api_response)
api_response = self.fleet_api.get_my_ships()
for elem in api_response.data:
print(elem.symbol, elem.nav.waypoint_symbol, elem.nav.status)
waypoint = self.systems_api.get_waypoint(elem.nav.system_symbol, elem.nav.waypoint_symbol).data
print(waypoint.symbol, waypoint.type)
except Exception as e:
print("Exception when calling AgentsApi->get_agent: %s\n" % e)
|