{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://paulkov.github.io/dpone/schemas/gitops/airflow-connection-bridge-plan.schema.json",
  "title": "dpone GitOps Airflow connection bridge plan contract",
  "type": "object",
  "required": [
    "kind",
    "schema_version",
    "producer",
    "artifact_dir",
    "output_path",
    "runtime_profile_path",
    "pod_contract_path",
    "mode",
    "runtime_mode",
    "required_connection_ids",
    "env",
    "artifacts"
  ],
  "properties": {
    "kind": {
      "const": "gitops.airflow_connection_bridge_plan"
    },
    "schema_version": {
      "type": "string"
    },
    "producer": {
      "type": "string"
    },
    "artifact_dir": {
      "type": "string"
    },
    "output_path": {
      "type": "string"
    },
    "runtime_profile_path": {
      "type": "string"
    },
    "pod_contract_path": {
      "type": "string"
    },
    "mode": {
      "type": "string"
    },
    "runtime_mode": {
      "type": "string"
    },
    "secret_name": {
      "type": [
        "string",
        "null"
      ],
      "pattern": "^[a-z0-9]([-a-z0-9]*[a-z0-9])?$",
      "maxLength": 63
    },
    "required_connection_ids": {
      "type": "array",
      "items": {
        "type": "string",
        "pattern": "^[A-Za-z0-9_.-]+$"
      }
    },
    "env": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": true,
        "required": [
          "connection_id",
          "env_name"
        ],
        "properties": {
          "connection_id": {
            "type": "string",
            "pattern": "^[A-Za-z0-9_.-]+$"
          },
          "env_name": {
            "type": "string",
            "pattern": "^AIRFLOW_CONN_[A-Z0-9_]+$"
          },
          "secret_ref": {
            "type": "object",
            "additionalProperties": true,
            "required": [
              "name",
              "key"
            ],
            "properties": {
              "name": {
                "type": "string",
                "pattern": "^[a-z0-9]([-a-z0-9]*[a-z0-9])?$",
                "maxLength": 63
              },
              "key": {
                "type": "string",
                "pattern": "^AIRFLOW_CONN_[A-Z0-9_]+$"
              }
            }
          }
        }
      }
    },
    "artifacts": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": true,
        "required": [
          "path",
          "kind",
          "required",
          "exists",
          "reason"
        ],
        "properties": {
          "path": {
            "type": "string"
          },
          "kind": {
            "type": "string"
          },
          "required": {
            "type": "boolean"
          },
          "exists": {
            "type": "boolean"
          },
          "reason": {
            "type": "string"
          }
        }
      }
    },
    "warnings": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/issue"
      }
    },
    "blockers": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/issue"
      }
    }
  },
  "$defs": {
    "issue": {
      "type": "object",
      "additionalProperties": true,
      "required": [
        "code",
        "message",
        "path",
        "source"
      ],
      "properties": {
        "code": {
          "type": "string"
        },
        "message": {
          "type": "string"
        },
        "path": {
          "type": "string"
        },
        "source": {
          "type": "string"
        }
      }
    }
  },
  "additionalProperties": true
}
