{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://paulkov.github.io/dpone/schemas/gitops/selection-report.schema.json",
  "title": "dpone GitOps explainable workload selection report",
  "type": "object",
  "required": [
    "schema",
    "selection_fingerprint",
    "catalog_fingerprint",
    "state_fingerprint",
    "expressions",
    "selected",
    "excluded",
    "unmatched",
    "removed"
  ],
  "additionalProperties": false,
  "properties": {
    "schema": {
      "const": "dpone.selection-report.v1"
    },
    "selection_fingerprint": {
      "type": "string",
      "pattern": "^sha256:[0-9a-f]{64}$"
    },
    "catalog_fingerprint": {
      "type": "string",
      "pattern": "^sha256:[0-9a-f]{64}$"
    },
    "state_fingerprint": {
      "oneOf": [
        {
          "type": "string",
          "pattern": "^sha256:[0-9a-f]{64}$"
        },
        {
          "type": "null"
        }
      ]
    },
    "expressions": {
      "type": "object",
      "required": [
        "select",
        "exclude"
      ],
      "additionalProperties": false,
      "properties": {
        "select": {
          "$ref": "#/$defs/expression_list"
        },
        "exclude": {
          "$ref": "#/$defs/expression_list"
        }
      }
    },
    "selected": {
      "$ref": "#/$defs/entry_list"
    },
    "excluded": {
      "$ref": "#/$defs/entry_list"
    },
    "unmatched": {
      "$ref": "#/$defs/expression_list"
    },
    "removed": {
      "type": "array",
      "maxItems": 1000,
      "items": {
        "type": "string",
        "minLength": 1,
        "maxLength": 256
      }
    }
  },
  "$defs": {
    "sha256": {
      "type": "string",
      "pattern": "^sha256:[0-9a-f]{64}$"
    },
    "expression_list": {
      "type": "array",
      "maxItems": 1000,
      "items": {
        "type": "string",
        "minLength": 1,
        "maxLength": 256
      }
    },
    "entry_list": {
      "type": "array",
      "maxItems": 1000,
      "items": {
        "$ref": "#/$defs/entry"
      }
    },
    "entry": {
      "type": "object",
      "required": [
        "id",
        "source",
        "semantic_fingerprint",
        "graph_fingerprint",
        "domain",
        "owner",
        "tags",
        "sources",
        "sinks",
        "groups",
        "reasons"
      ],
      "additionalProperties": false,
      "properties": {
        "id": {
          "type": "string",
          "minLength": 1,
          "maxLength": 256
        },
        "source": {
          "type": "string",
          "minLength": 1,
          "maxLength": 256
        },
        "semantic_fingerprint": {
          "type": "string",
          "pattern": "^sha256:[0-9a-f]{64}$"
        },
        "graph_fingerprint": {
          "type": "string",
          "pattern": "^sha256:[0-9a-f]{64}$"
        },
        "domain": {
          "oneOf": [
            {
              "type": "string",
              "minLength": 1,
              "maxLength": 256
            },
            {
              "type": "null"
            }
          ]
        },
        "owner": {
          "oneOf": [
            {
              "type": "string",
              "minLength": 1,
              "maxLength": 256
            },
            {
              "type": "null"
            }
          ]
        },
        "tags": {
          "type": "array",
          "maxItems": 1000,
          "items": {
            "type": "string",
            "minLength": 1,
            "maxLength": 256
          }
        },
        "sources": {
          "type": "array",
          "maxItems": 1000,
          "items": {
            "type": "string",
            "minLength": 1,
            "maxLength": 256
          }
        },
        "sinks": {
          "type": "array",
          "maxItems": 1000,
          "items": {
            "type": "string",
            "minLength": 1,
            "maxLength": 256
          }
        },
        "groups": {
          "type": "array",
          "maxItems": 1000,
          "items": {
            "type": "string",
            "minLength": 1,
            "maxLength": 256
          }
        },
        "reasons": {
          "type": "array",
          "minItems": 1,
          "maxItems": 1000,
          "items": {
            "$ref": "#/$defs/reason"
          }
        }
      }
    },
    "reason": {
      "type": "object",
      "required": [
        "kind",
        "expression",
        "root",
        "path"
      ],
      "additionalProperties": false,
      "properties": {
        "kind": {
          "enum": [
            "all_by_default",
            "direct",
            "named",
            "state",
            "ancestor",
            "descendant"
          ]
        },
        "expression": {
          "type": "string",
          "minLength": 1,
          "maxLength": 256
        },
        "root": {
          "type": "string",
          "minLength": 1,
          "maxLength": 256
        },
        "path": {
          "type": "array",
          "minItems": 1,
          "maxItems": 1000,
          "items": {
            "type": "string",
            "minLength": 1,
            "maxLength": 256
          }
        }
      }
    }
  }
}
