syntax = "proto3";

package worldmonitor.aviation.v1;

import "buf/validate/validate.proto";
import "sebuf/http/annotations.proto";
import "worldmonitor/aviation/v1/carrier.proto";

// GetCarrierOpsRequest specifies parameters for carrier operations metrics.
message GetCarrierOpsRequest {
  // IATA airport codes to aggregate carrier metrics from.
  repeated string airports = 1 [
    (sebuf.http.query) = { name: "airports" },
    (buf.validate.field).repeated.min_items = 1,
    (buf.validate.field).repeated.max_items = 20
  ];
  // Minimum number of flights required to include a carrier (default: 1).
  int32 min_flights = 2 [
    (sebuf.http.query) = { name: "min_flights" },
    (buf.validate.field).int32.gte = 0
  ];
}

// CarrierOpsSummary contains delay and cancellation metrics for a carrier at an airport.
message CarrierOpsSummary {
  // The airline carrier.
  Carrier carrier = 1;
  // Airport IATA code this summary applies to.
  string airport = 2;
  // Total flights observed.
  int32 total_flights = 3;
  // Number of delayed flights.
  int32 delayed_count = 4;
  // Number of cancelled flights.
  int32 cancelled_count = 5;
  // Average delay in minutes across delayed flights.
  int32 avg_delay_minutes = 6;
  // Delay percentage (0-100).
  double delay_pct = 7;
  // Cancellation rate (0-100).
  double cancellation_rate = 8;
  // Last update time as Unix epoch milliseconds.
  int64 updated_at = 9 [(sebuf.http.int64_encoding) = INT64_ENCODING_NUMBER];
}

// GetCarrierOpsResponse contains carrier operations metrics.
message GetCarrierOpsResponse {
  // Carrier operation summaries.
  repeated CarrierOpsSummary carriers = 1;
  // Data source identifier.
  string source = 2;
  // Last update time as Unix epoch milliseconds.
  int64 updated_at = 3 [(sebuf.http.int64_encoding) = INT64_ENCODING_NUMBER];
}
