from abc import ABC, abstractmethod
from typing import AsyncIterator
from fastapi import UploadFile

from models.api import (
    FlightCreateRequest,
    FlightResponse,
    FlightDetailResponse,
    FlightStatusResponse,
    DeleteResponse,
    UpdateResponse,
    BatchResponse,
    UserFixRequest,
    UserFixResponse,
    ObjectGPSResponse,
)
from models.core import GPSPoint


class FlightAPIBase(ABC):
    @abstractmethod
    async def create_flight(self, request: FlightCreateRequest) -> FlightResponse:
        pass

    @abstractmethod
    async def get_flight(self, flight_id: str) -> FlightDetailResponse:
        pass

    @abstractmethod
    async def get_flight_status(self, flight_id: str) -> FlightStatusResponse:
        pass

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

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

    @abstractmethod
    async def upload_batch(
        self,
        flight_id: str,
        files: list[UploadFile],
        start_sequence: int,
        end_sequence: int,
        batch_number: int,
    ) -> BatchResponse:
        pass

    @abstractmethod
    async def submit_user_fix(
        self, flight_id: str, request: UserFixRequest
    ) -> UserFixResponse:
        pass

    @abstractmethod
    async def get_object_gps(
        self, flight_id: str, frame_id: int, pixel: tuple[float, float]
    ) -> ObjectGPSResponse:
        pass

    @abstractmethod
    def stream_events(self, flight_id: str) -> AsyncIterator[dict]:
        pass

