syntax = "proto3";

package worldmonitor.military.v1;

import "buf/validate/validate.proto";
import "sebuf/http/annotations.proto";

// WingbitsLiveFlight contains real-time flight position data from the Wingbits ECS network.
message WingbitsLiveFlight {
  // ICAO 24-bit hex address.
  string icao24 = 1;
  // Live callsign.
  string callsign = 2;
  // Latitude in decimal degrees.
  double lat = 3;
  // Longitude in decimal degrees.
  double lon = 4;
  // Altitude in feet.
  double altitude = 5;
  // Ground speed in knots.
  double speed = 6;
  // Track/heading in degrees.
  double heading = 7;
  // Vertical rate in feet per minute (positive = climb, negative = descent).
  double vertical_rate = 8;
  // Aircraft registration number.
  string registration = 9;
  // Aircraft model (e.g. "PC-12/45").
  string model = 10;
  // Operator name.
  string operator = 11;
  // True if the aircraft is on the ground.
  bool on_ground = 12;
  // Unix timestamp of the last position update.
  int64 last_seen = 13;

  // Schedule — from ecs-api.wingbits.com/v1/flights/schedule/{callsign}
  // Departure airport IATA code (e.g. "FJR").
  string dep_iata = 14;
  // Arrival airport IATA code (e.g. "BOM").
  string arr_iata = 15;
  // Scheduled departure time UTC (ISO 8601).
  string dep_time_utc = 16;
  // Scheduled arrival time UTC (ISO 8601).
  string arr_time_utc = 17;
  // Estimated departure time UTC (ISO 8601).
  string dep_estimated_utc = 18;
  // Estimated arrival time UTC (ISO 8601).
  string arr_estimated_utc = 19;
  // Departure delay in minutes (negative = early).
  int32 dep_delayed_min = 20;
  // Arrival delay in minutes (negative = early).
  int32 arr_delayed_min = 21;
  // Flight status string (e.g. "en-route", "landed", "scheduled").
  string flight_status = 22;
  // Scheduled flight duration in minutes.
  int32 flight_duration_min = 23;
  // Arrival terminal (e.g. "2").
  string arr_terminal = 24;

  // Photo — from api.planespotters.net/pub/photos/hex/{icao24}
  // Aircraft photo URL (large thumbnail ~497x280).
  string photo_url = 25;
  // Permalink to the photo page on planespotters.net.
  string photo_link = 26;
  // Photographer credit name.
  string photo_credit = 27;

  // Airline — resolved server-side from the ICAO callsign prefix.
  // IATA-equivalent callsign (e.g. "EK528" for ICAO "UAE528"). Empty if no mapping.
  string callsign_iata = 28;
  // Airline name (e.g. "Emirates"). Empty if no mapping.
  string airline_name = 29;
}

// GetWingbitsLiveFlightRequest fetches live Wingbits ECS data for a single aircraft.
message GetWingbitsLiveFlightRequest {
  // ICAO 24-bit hex address (lowercase, 6 characters).
  string icao24 = 1 [
    (buf.validate.field).required = true,
    (buf.validate.field).string.min_len = 1,
    (sebuf.http.query) = {name: "icao24"}
  ];
}

// GetWingbitsLiveFlightResponse contains the live flight data, if available.
message GetWingbitsLiveFlightResponse {
  // Live flight position data; absent if Wingbits has no current signal for this aircraft.
  WingbitsLiveFlight flight = 1;
}
