summaryrefslogtreecommitdiff
path: root/apirouters/customize_ship.py
blob: ca3ef839bf9b85be098d482d2ee748e45269222a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
from typing import Annotated
from fastapi import APIRouter, Depends
from pydantic import BaseModel

from ..modules import ships
from ..entities.ship import Ship

router = APIRouter()


class RenameBody(BaseModel):
    name: str


@router.post("/customize_ship/{ship_symbol}/rename")
async def rename(ship_symbol: str, rename_body: RenameBody, ship: Annotated[Ship, Depends(ships.get_ship)]):
    ship.rename(rename_body.name)
    return ship.get_data()