from abc import ABC, abstractmethod
from typing import Optional

from models.flight import Flight, FlightState, Waypoint
from models.results import FrameResult
from models.chunks import ChunkHandle
from models.core import Pose


class FlightDatabaseBase(ABC):
    @abstractmethod
    async def create_flight(self, flight: Flight) -> str:
        pass

    @abstractmethod
    async def get_flight(self, flight_id: str) -> Optional[Flight]:
        pass

    @abstractmethod
    async def delete_flight(self, flight_id: str) -> bool:
        pass

    @abstractmethod
    async def update_flight_state(self, state: FlightState) -> bool:
        pass

    @abstractmethod
    async def get_flight_state(self, flight_id: str) -> Optional[FlightState]:
        pass

    @abstractmethod
    async def save_frame_result(self, flight_id: str, result: FrameResult) -> bool:
        pass

    @abstractmethod
    async def get_frame_result(
        self, flight_id: str, frame_id: int
    ) -> Optional[FrameResult]:
        pass

    @abstractmethod
    async def get_all_frame_results(self, flight_id: str) -> list[FrameResult]:
        pass

    @abstractmethod
    async def save_chunk(self, chunk: ChunkHandle) -> bool:
        pass

    @abstractmethod
    async def get_chunk(self, chunk_id: str) -> Optional[ChunkHandle]:
        pass

    @abstractmethod
    async def get_flight_chunks(self, flight_id: str) -> list[ChunkHandle]:
        pass

    @abstractmethod
    async def save_pose(self, flight_id: str, pose: Pose) -> bool:
        pass

    @abstractmethod
    async def get_poses(self, flight_id: str) -> list[Pose]:
        pass

    @abstractmethod
    async def update_waypoints(
        self, flight_id: str, waypoints: list[Waypoint]
    ) -> bool:
        pass

