schema:
  type: object
  title: Minimum Groundtime
  description: Minimum groundtime data from snapshots with filtering
  version: "1.0.0"
  properties:
    iata_ap_code:
      description: IATA Airport Code (supports regex pattern)
      title: IATA Airport Code
      type: string
      examples:
        - "HKG"
      maxLength: 3
      coercion: coerce_to_string
      validations:
        pattern:
          regex: "^[A-Z]{3}$"
        max_length:
          threshold: 3
        non_empty_string: null
    day_of_origin:
      description: Day of origin (Date component of flight identifier) in ISO format
      title: Day of Origin
      type: string
      format: date-time
      examples:
        - "2025-09-01T00:00:00Z"
      coercion: coerce_to_datetime
      validations:
        non_empty_string: null
    minimum_groundtime:
      description: Minimum ground time in minutes
      title: Minimum Groundtime
      type: integer
      coercion: coerce_to_integer
      validations:
        greater_than_or_equal_to:
          threshold: 0
    aircraft_type:
      description: Aircraft type code
      title: Aircraft Type
      type: string
      maxLength: 10
      coercion: coerce_to_nullable_string
    flight_carrier:
      description: Flight carrier code
      title: Flight Carrier
      type: string
      maxLength: 3
      coercion: coerce_to_nullable_string
    flight_number:
      description: Flight number
      title: Flight Number
      type: integer
      coercion: coerce_to_nullable_integer
    effective_date:
      description: Date when the minimum groundtime becomes effective
      title: Effective Date
      type: string
      format: date-time
      coercion: coerce_to_datetime
    expiry_date:
      description: Date when the minimum groundtime expires
      title: Expiry Date
      type: string
      format: date-time
      coercion: coerce_to_nullable_datetime
    record_id:
      description: Unique identifier for the record
      title: Record ID
      type: integer
      coercion: coerce_to_integer
      validations:
        greater_than_or_equal_to:
          threshold: 0
    last_updated:
      description: Timestamp of last update
      title: Last Updated
      type: string
      format: date-time
      coercion: coerce_to_datetime
  required:
    - iata_ap_code
    - day_of_origin
    - minimum_groundtime
    - effective_date
    - record_id

metadata:
  version: 1.0.0
  description: Minimum groundtime data from snapshots with filtering for operational configuration
  created: '2025-01-15'
  last_updated: '2025-01-15'
  title: Minimum Groundtime
  status: active
  type: object
  validation_title: Minimum Groundtime
  created_at: '2025-01-15T00:00:00+00:00'
  updated_at: '2025-01-15T00:00:00+00:00'
  created_by: spicoc@cathaypacific.com
  updated_by: spicoc@cathaypacific.com
  data_feed_association:
    - title: Minimum Groundtime
      type: Operational
  pulls_from:
    - "NetlineOpsReplica"
  pushes_to:
    - "SCR"
    - "Fleetwise"
  system_sources:
    - "NetlineBase"
  dependencies:
    - "Airport"
    - "Flight"
    - "Aircraft"
  business_owners:
    - "andrew_baird@cathaypacific.com"
  bu_sme:
    - "lincoln_mak@cathaypacific.com"
  it_application_owners:
    - "ken_tong@cathaypacific.com"
  it_sme:
    - "mimi_chu@cathaypacific.com"
  domain: "IOC"
  ownership:
    owner: andrew_baird@cathaypacific.com
    team: data-engineering
    contact: andrew_baird@cathaypacific.com
  data_quality:
    accuracy: 0.0
    monitoring_enabled: false
    sla: null
    total_records: 0
    last_updated: '2024-01-01T00:00:00'
  governance_rules:
    data_retention:
      days: 2555
      reason: Regulatory compliance for minimum groundtime records
    pii_fields:
      fields: []
    sensitivity: Internal
    access_control:
      read:
        - operations-team
        - data-team
      write:
        - operations-team
  business_rules:
    validity_period:
      description: effective_date must be before expiry_date if expiry_date is set
      enforced: true
    groundtime_consistency:
      description: minimum_groundtime must be a positive value
      enforced: true
  serve:
    api:
      type: GET
      endpoint: "/ioc-de-api/v1/snapshots/operational-configs/minimum-groundtime"
      rate_limit: "120/min"
      cache_ttl: 3600
      confluence_page: "https://cathaypacific-prod.atlassian.net/wiki/spaces/DEN/pages/MinimumGroundtime"
      params:
        - name: "iata_ap_code"
          in: query
          required: false
          description: IATA Airport Code (supports regex pattern)
          schema:
            type: "string"
          example: "HKG"
        - name: "day_of_origin"
          in: query
          required: true
          description: Day of origin (Date component of flight identifier) in ISO format
          schema:
            type: string
            format: date-time
          example: "2025-09-01T00:00:00Z"
  indexes:
    - cluster: ioc-de-{env}
      database: internal
      collection: minimum_groundtime
      indexes:
        - minimum_groundtime_unique_index:
            iata_ap_code: 1
            day_of_origin: 1
            aircraft_type: 1
            flight_carrier: 1
            flight_number: 1
          unique: true
          background: true

coercion_rules:
  version: "1.0.0"
  rules:
    iata_ap_code: coerce_to_string
    day_of_origin: coerce_to_datetime
    minimum_groundtime: coerce_to_integer
    aircraft_type: coerce_to_nullable_string
    flight_carrier: coerce_to_nullable_string
    flight_number: coerce_to_nullable_integer
    effective_date: coerce_to_datetime
    expiry_date: coerce_to_nullable_datetime
    record_id: coerce_to_integer
    last_updated: coerce_to_datetime

validation_rules:
  version: "1.0.0"
  rules:
    iata_ap_code:
      pattern:
        regex: "^[A-Z]{3}$"
      max_length:
        threshold: 3
      non_empty_string: null
    day_of_origin:
      non_empty_string: null
    minimum_groundtime:
      greater_than_or_equal_to:
        threshold: 0
    aircraft_type:
      max_length:
        threshold: 10
    flight_carrier:
      max_length:
        threshold: 3
    flight_number:
      greater_than_or_equal_to:
        threshold: 0
    record_id:
      greater_than_or_equal_to:
        threshold: 0

versions:
  schema: "1.0.0"
  coercion_rules: "1.0.0"
  validation_rules: "1.0.0"
  metadata: "1.0.0"

