From 1638f40eccc4a1321ee1bf19e3756157b6c965e1 Mon Sep 17 00:00:00 2001 From: Botond Hende Date: Mon, 2 Sep 2024 00:21:13 +0200 Subject: refactored code, use get_ship dependency for ship related calls --- apirouters/agents.py | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) (limited to 'apirouters/agents.py') diff --git a/apirouters/agents.py b/apirouters/agents.py index 1b927e7..49d3740 100644 --- a/apirouters/agents.py +++ b/apirouters/agents.py @@ -1,30 +1,17 @@ from enum import Enum from typing import Annotated, Dict -import openapi_client from fastapi import APIRouter, Depends, Response, HTTPException from fastapi.security import OAuth2PasswordBearer, OAuth2PasswordRequestForm -from ..modules import task_types from ..modules.database import cursor, conn -from ..modules.ships import Ship +from ..entities import task_types +from ..entities.agent import Agent +from ..entities.ship import Ship router = APIRouter() oauth2_scheme = OAuth2PasswordBearer(tokenUrl="token") -agents: Dict[str, 'Agent'] = {} - - -class Agent: - 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 - self.ships: Dict[str, Ship] = {} +agents: Dict[str, Agent] = {} @router.post("/token") -- cgit v1.2.3-70-g09d2