blob: 4a6d0d6f441a254fb0f63b5b5bae11907ee88843 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
from typing import Annotated
from fastapi import Depends, HTTPException
from ..apirouters import auth
from ..entities.agent import Agent
from ..entities.ship import Ship
async def get_ship(ship_symbol: str, agent: Annotated[Agent, Depends(auth.auth_agent)]) -> Ship:
for ship in agent.ships.values():
if ship.symbol == ship_symbol:
return ship
raise HTTPException(status_code=400, detail="Unknown ship symbol.")
|