{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://paulkov.github.io/dpone/schemas/gitops/selected-safe-sample-report.schema.json",
  "title": "dpone GitOps selected safe sample report",
  "type": "object",
  "required": [
    "schema",
    "passed",
    "exit_code",
    "selection",
    "results",
    "unscheduled",
    "errors"
  ],
  "additionalProperties": false,
  "properties": {
    "schema": {
      "const": "dpone.selected-safe-sample-report.v1"
    },
    "passed": {
      "type": "boolean"
    },
    "exit_code": {
      "type": "integer",
      "minimum": 0,
      "maximum": 5
    },
    "sample": {
      "type": [
        "integer",
        "null"
      ],
      "minimum": 1
    },
    "target": {
      "type": [
        "string",
        "null"
      ],
      "enum": [
        "temporary",
        null
      ]
    },
    "environment": {
      "type": "string",
      "minLength": 1
    },
    "selection": {
      "anyOf": [
        {
          "type": "null"
        },
        {
          "type": "object",
          "required": [
            "schema",
            "selection_fingerprint"
          ],
          "properties": {
            "schema": {
              "const": "dpone.selection-report.v1"
            },
            "selection_fingerprint": {
              "type": "string",
              "pattern": "^sha256:[0-9a-f]{64}$"
            }
          },
          "additionalProperties": true
        }
      ]
    },
    "results": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/result"
      }
    },
    "unscheduled": {
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 1
      },
      "uniqueItems": true
    },
    "errors": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/error"
      }
    }
  },
  "$defs": {
    "result": {
      "type": "object",
      "required": [
        "workload_id",
        "source",
        "run_id",
        "passed",
        "status",
        "exit_code",
        "errors",
        "evidence_path"
      ],
      "properties": {
        "workload_id": {
          "type": "string",
          "minLength": 1
        },
        "source": {
          "type": "string",
          "minLength": 1
        },
        "run_id": {
          "type": "string"
        },
        "passed": {
          "type": "boolean"
        },
        "status": {
          "type": "string",
          "minLength": 1
        },
        "exit_code": {
          "type": "integer",
          "minimum": 0,
          "maximum": 5
        },
        "errors": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/error"
          }
        },
        "evidence_path": {
          "anyOf": [
            {
              "type": "null"
            },
            {
              "type": "string",
              "minLength": 1
            }
          ]
        }
      },
      "additionalProperties": false
    },
    "error": {
      "type": "object",
      "required": [
        "code",
        "message"
      ],
      "properties": {
        "schema": {
          "const": "dpone.error.v1"
        },
        "code": {
          "type": "string",
          "pattern": "^DPONE_[A-Z0-9_]+$"
        },
        "stage": {
          "type": "string",
          "minLength": 1
        },
        "severity": {
          "enum": [
            "info",
            "warning",
            "error"
          ]
        },
        "message": {
          "type": "string",
          "minLength": 1
        },
        "entity": {
          "type": "object"
        },
        "fixes": {
          "type": "array"
        },
        "docs_url": {
          "type": "string",
          "minLength": 1
        },
        "trace_id": {
          "type": "string",
          "minLength": 1
        }
      },
      "additionalProperties": true
    }
  }
}
