"""Data types and operations from Remote ID Display Data Observation 0.0.2 OpenAPI"""

# This file is autogenerated; do not modify manually!

from __future__ import annotations

from enum import Enum
from typing import Dict, List, Optional

from uas_standards import Operation

from implicitdict import ImplicitDict


API_VERSION = "0.0.2"
"""Version of Remote ID Display Data Observation OpenAPI specification from which the objects in this package were generated."""

class UAS(ImplicitDict):
    """UAS information"""

    id: Optional[str]
    """Observed arbitrary and format agnostic (string) identification of a UAS."""


class RIDOperationalStatus(str, Enum):
    """Indicates operational status of associated aircraft."""

    Undeclared = "Undeclared"
    Ground = "Ground"
    Airborne = "Airborne"
    Emergency = "Emergency"
    RemoteIDSystemFailure = "RemoteIDSystemFailure"


RIDTrack = float
"""Direction of flight expressed as a "True North-based" ground track angle.  This value is provided in degrees East of North with a minimum resolution of 1 degree."""


RIDSpeed = float
"""Ground speed of flight in meters per second."""


Longitude = float
"""Degrees of longitude east of the Prime Meridian, with reference to the WGS84 ellipsoid."""


Latitude = float
"""Degrees of latitude north of the equator, with reference to the WGS84 ellipsoid."""


class OperatorAltitudeAltitudeType(str, Enum):
    """Source of data for the altitude field."""

    Takeoff = "Takeoff"
    Dynamic = "Dynamic"
    Fixed = "Fixed"


Altitude = float
"""An altitude, in meters, above the WGS84 ellipsoid."""


class RIDHeightReference(str, Enum):
    """The reference datum above which the height is reported."""

    TakeoffLocation = "TakeoffLocation"
    GroundLevel = "GroundLevel"


class RIDHeight(ImplicitDict):
    """A relative altitude for the purposes of remote ID."""

    distance: float
    """Distance above reference datum.  This value is provided in meters and must have a minimum resolution of 1 meter."""

    reference: RIDHeightReference
    """The reference datum above which the height is reported."""


class CurrentState(ImplicitDict):
    """Current state of an aircraft."""

    timestamp: Optional[str]
    """Time at which the message containing the current state information was generated by the display provider."""

    operational_status: Optional[RIDOperationalStatus]

    track: Optional[RIDTrack]

    speed: Optional[RIDSpeed]


class Position(ImplicitDict):
    """A position on Earth."""

    lat: Latitude

    lng: Longitude

    alt: Optional[Altitude]

    height: Optional[RIDHeight]


class Path(ImplicitDict):
    """Path followed by a flight."""

    positions: List[Position]
    """Sequential positions available for a flight."""


class LatLngPoint(ImplicitDict):
    """Point on the earth's surface."""

    lng: Longitude

    lat: Latitude


class OperatorAltitude(ImplicitDict):
    """Altitude associated with the Remote Pilot"""

    altitude: Optional[Altitude]

    altitude_type: Optional[OperatorAltitudeAltitudeType]
    """Source of data for the altitude field."""


class Flight(ImplicitDict):
    id: str
    """Identifier of flight that may be used to obtain details about the flight. This is not necessarily the UTM/flight ID in the remote ID system."""

    current_state: Optional[CurrentState]

    most_recent_position: Optional[Position]
    """Most recent position known for the flight."""

    recent_paths: Optional[List[Path]]
    """Paths the flight recently traveled, if available."""


class Operator(ImplicitDict):
    """Operator's information"""

    id: Optional[str]
    """CAA-issued registration/license ID for the remote pilot or operator."""

    location: Optional[LatLngPoint]

    altitude: Optional[OperatorAltitude]


class Cluster(ImplicitDict):
    """A general area containing one or more flight."""

    corners: List[Position]
    """Two opposite corners of a rectangular lat-lng box bounding the cluster."""

    area_sqm: float
    """Area of the cluster in square meters."""

    number_of_flights: int
    """Number of flights within the cluster."""


class GetDisplayDataResponse(ImplicitDict):
    """Response to a request for current data that would be visualized by a Display Application."""

    flights: Optional[List[Flight]] = []
    """Current information for set of discovered flights whose precise locations are known."""

    clusters: Optional[List[Cluster]] = []
    """Current information for sets of discovered flights whose precise locations are not known."""


class GetDetailsResponse(ImplicitDict):
    """Response to a request to get details about a flight."""

    operator: Optional[Operator]

    uas: Optional[UAS]


class OperationID(str, Enum):
    GetDisplayData = "getDisplayData"
    GetDetails = "getDetails"


OPERATIONS: Dict[OperationID, Operation] = {
    OperationID.GetDisplayData: Operation(
        id="getDisplayData",
        path="/display_data",
        verb="GET",
        request_body_type=None,
        response_body_type={
            200: GetDisplayDataResponse,
        }
    ),
    OperationID.GetDetails: Operation(
        id="getDetails",
        path="/display_data/{id}",
        verb="GET",
        request_body_type=None,
        response_body_type={
            200: GetDetailsResponse,
            404: None,
        }
    ),
}
