{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://paulkov.github.io/dpone/schemas/gitops/airflow-run-identity.schema.json",
  "title": "dpone GitOps Airflow run identity contract",
  "type": "object",
  "required": [
    "schema",
    "release_id",
    "deployment_id",
    "dag_spec",
    "workload_pack",
    "runtime_image_digest",
    "binding_set_ref",
    "connection_registry_ref",
    "credential_runtime_ref",
    "airflow_bundle"
  ],
  "additionalProperties": false,
  "properties": {
    "schema": {
      "const": "dpone.airflow-run-identity.v1"
    },
    "release_id": {
      "type": "string",
      "pattern": "^sha256:[0-9a-f]{64}$"
    },
    "deployment_id": {
      "type": "string",
      "pattern": "^sha256:[0-9a-f]{64}$"
    },
    "dag_spec": {
      "anyOf": [
        {
          "type": "object",
          "required": [
            "id",
            "sha256"
          ],
          "additionalProperties": false,
          "properties": {
            "id": {
              "type": "string",
              "minLength": 1
            },
            "sha256": {
              "type": "string",
              "pattern": "^sha256:[0-9a-f]{64}$"
            }
          }
        },
        {
          "type": "null"
        }
      ]
    },
    "workload_pack": {
      "type": "object",
      "required": [
        "id",
        "sha256"
      ],
      "additionalProperties": false,
      "properties": {
        "id": {
          "type": "string",
          "minLength": 1
        },
        "sha256": {
          "type": "string",
          "pattern": "^sha256:[0-9a-f]{64}$"
        }
      }
    },
    "runtime_image_digest": {
      "anyOf": [
        {
          "type": "string",
          "pattern": "^sha256:[0-9a-f]{64}$"
        },
        {
          "type": "null"
        }
      ]
    },
    "binding_set_ref": {
      "anyOf": [
        {
          "type": "string",
          "pattern": "^sha256:[0-9a-f]{64}$"
        },
        {
          "type": "null"
        }
      ]
    },
    "connection_registry_ref": {
      "anyOf": [
        {
          "type": "string",
          "pattern": "^sha256:[0-9a-f]{64}$"
        },
        {
          "type": "null"
        }
      ]
    },
    "credential_runtime_ref": {
      "anyOf": [
        {
          "type": "string",
          "pattern": "^sha256:[0-9a-f]{64}$"
        },
        {
          "type": "null"
        }
      ]
    },
    "airflow_bundle": {
      "anyOf": [
        {
          "type": "object",
          "required": [
            "backend",
            "ref",
            "versioned",
            "version",
            "snapshot_ref"
          ],
          "additionalProperties": false,
          "properties": {
            "backend": {
              "type": "string",
              "minLength": 1
            },
            "ref": {
              "type": "string",
              "minLength": 1,
              "pattern": "^\\S+$",
              "not": {
                "pattern": "(?:[?&](?:token|password|signature|credential|x-amz-signature|x-goog-signature)=|://[^/]*@)"
              }
            },
            "versioned": {
              "type": "boolean"
            },
            "version": {
              "anyOf": [
                {
                  "type": "string",
                  "minLength": 1
                },
                {
                  "type": "null"
                }
              ]
            },
            "snapshot_ref": {
              "anyOf": [
                {
                  "type": "string",
                  "pattern": "^sha256:[0-9a-f]{64}$"
                },
                {
                  "type": "null"
                }
              ]
            }
          },
          "allOf": [
            {
              "if": {
                "properties": {
                  "versioned": {
                    "const": true
                  }
                }
              },
              "then": {
                "properties": {
                  "version": {
                    "type": "string",
                    "minLength": 1
                  }
                }
              },
              "else": {
                "properties": {
                  "version": {
                    "type": "null"
                  }
                }
              }
            }
          ]
        },
        {
          "type": "null"
        }
      ]
    }
  }
}
