{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://paulkov.github.io/dpone/schemas/gitops/airflow-connection-secret-gc-plan.schema.json",
  "title": "dpone GitOps Airflow Connection Secret GC plan",
  "type": "object",
  "required": [
    "schema",
    "status",
    "namespace",
    "observed_at",
    "minimum_age_seconds",
    "page_size",
    "inventory",
    "items",
    "delete_candidates"
  ],
  "additionalProperties": false,
  "properties": {
    "schema": {
      "const": "dpone.airflow-connection-secret-gc-plan.v1"
    },
    "status": {
      "enum": [
        "ok",
        "needs_cleanup",
        "needs_attention"
      ]
    },
    "namespace": {
      "type": "string",
      "minLength": 1
    },
    "observed_at": {
      "type": "string",
      "format": "date-time"
    },
    "minimum_age_seconds": {
      "type": "integer",
      "minimum": 300,
      "maximum": 2592000
    },
    "page_size": {
      "type": "integer",
      "minimum": 1,
      "maximum": 1000
    },
    "inventory": {
      "$ref": "#/$defs/inventory"
    },
    "items": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/plan_item"
      }
    },
    "delete_candidates": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/sha256"
      },
      "uniqueItems": true
    }
  },
  "$defs": {
    "sha256": {
      "type": "string",
      "pattern": "^sha256:[0-9a-f]{64}$"
    },
    "inventory": {
      "type": "object",
      "required": [
        "managed_secrets",
        "managed_pods",
        "active_references",
        "orphan_pod_references",
        "quarantined"
      ],
      "additionalProperties": false,
      "properties": {
        "managed_secrets": {
          "type": "integer",
          "minimum": 0
        },
        "managed_pods": {
          "type": "integer",
          "minimum": 0
        },
        "active_references": {
          "type": "integer",
          "minimum": 0
        },
        "orphan_pod_references": {
          "type": "integer",
          "minimum": 0
        },
        "quarantined": {
          "type": "integer",
          "minimum": 0
        }
      }
    },
    "plan_item": {
      "type": "object",
      "required": [
        "secret_ref",
        "attempt_ref",
        "action",
        "reason",
        "cleanup_policy",
        "age_seconds"
      ],
      "additionalProperties": false,
      "properties": {
        "secret_ref": {
          "$ref": "#/$defs/sha256"
        },
        "attempt_ref": {
          "anyOf": [
            {
              "$ref": "#/$defs/sha256"
            },
            {
              "type": "null"
            }
          ]
        },
        "action": {
          "enum": [
            "protect",
            "delete",
            "quarantine"
          ]
        },
        "reason": {
          "enum": [
            "active_pod",
            "minimum_age",
            "retained_expired",
            "synchronous_cleanup_orphaned",
            "invalid_metadata",
            "future_timestamp"
          ]
        },
        "cleanup_policy": {
          "type": [
            "string",
            "null"
          ],
          "enum": [
            "retain",
            "after_execute",
            null
          ]
        },
        "age_seconds": {
          "type": [
            "integer",
            "null"
          ]
        }
      }
    }
  }
}
