{
  "$schema": "http://json-schema.org/draft/2019-09/schema#",
  "title": "API Request Validation Schema",
  "description": "Validates the structure of the reports sent to the Managed Servers API",
  "type": "object",
  "properties": {
    "service": {
      "type": "string",
      "enum": [
        "disk_root",
        "disk_backup",
        "cpu_load",
        "puppet",
        "smtp",
        "spamd",
        "memory",
        "imap",
        "pop",
        "csf",
        "cp_license",
        "dns_query",
        "ftp",
        "backup_age",
        "swap"
      ],
      "description": "Service codename identifying which service is being checked"
    },
    "auto_fix_status": {
      "type": ["string"],
      "enum": ["success", "failure", "N/A", "api_side_fix", "no_auto_fix"],
      "description": "Status of the automatic fix attempt"
    },
    "payload": {
      "type": "object",
      "description": "Service-specific check results from bash scripts"
    },
    "client_notified": {
      "type": ["boolean", "null"],
      "description": "Cannot be true here since emails are only sent by the backend. If absent, no email will be sent automatically."
    },
    "acknowledged": {
      "type": ["null"],
      "description": "Whether the issue has been acknowledged. Is always null."
    }
  },
  "required": ["service", "payload"],
  "additionalProperties": false,
  "$defs": {
    "payload_common_fields": {
      "type": "object",
      "properties": {
        "service_status": {
          "type": "string",
          "enum": [
            "ok",
            "warning",
            "critical",
            "down",
            "disabled",
            "backup_in_progress",
            "backup_started"
          ]
        },
        "monitoring_comment": {
          "type": "string",
          "description": "Additional data to add to the acknowledgement comment in Icinga"
        },
        "acknowledge_expiry_timestamp": {
          "type": "integer",
          "description": "Unix timestamp when temporary acknowledgment expires"
        },
        "service_data": {
          "type": "string",
          "description": "Short service status for the email creation"
        },
        "details": {
          "type": "string",
          "description": "Additional details (statistics, logs, etc.) for the email creation"
        },
        "recommendations": {
          "type": "string",
          "description": "Troubleshooting recommendations for the email creation"
        },
        "error": {
          "type": "string",
          "description": "Error message if script execution failed"
        }
      }
    }
  }
}
