{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://paulkov.github.io/dpone/schemas/gitops/airflow-connection-secret-gc-apply.schema.json",
  "title": "dpone GitOps Airflow Connection Secret GC apply report",
  "type": "object",
  "required": [
    "schema",
    "status",
    "namespace",
    "actor",
    "observed_at",
    "minimum_age_seconds",
    "max_delete_count",
    "items",
    "deleted_secret_refs",
    "skipped_secret_refs",
    "failed_secret_refs"
  ],
  "additionalProperties": false,
  "properties": {
    "schema": {
      "const": "dpone.airflow-connection-secret-gc-apply.v1"
    },
    "status": {
      "enum": [
        "ok",
        "partial",
        "failed"
      ]
    },
    "namespace": {
      "type": "string",
      "minLength": 1
    },
    "actor": {
      "type": "string",
      "minLength": 1
    },
    "observed_at": {
      "type": "string",
      "format": "date-time"
    },
    "minimum_age_seconds": {
      "type": "integer",
      "minimum": 300,
      "maximum": 2592000
    },
    "max_delete_count": {
      "type": "integer",
      "minimum": 1,
      "maximum": 1000
    },
    "items": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/apply_item"
      }
    },
    "deleted_secret_refs": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/sha256"
      },
      "uniqueItems": true
    },
    "skipped_secret_refs": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/sha256"
      },
      "uniqueItems": true
    },
    "failed_secret_refs": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/sha256"
      },
      "uniqueItems": true
    }
  },
  "$defs": {
    "sha256": {
      "type": "string",
      "pattern": "^sha256:[0-9a-f]{64}$"
    },
    "apply_item": {
      "type": "object",
      "required": [
        "secret_ref",
        "attempt_ref",
        "action",
        "reason"
      ],
      "additionalProperties": false,
      "properties": {
        "secret_ref": {
          "$ref": "#/$defs/sha256"
        },
        "attempt_ref": {
          "anyOf": [
            {
              "$ref": "#/$defs/sha256"
            },
            {
              "type": "null"
            }
          ]
        },
        "action": {
          "enum": [
            "deleted",
            "skipped",
            "failed"
          ]
        },
        "reason": {
          "enum": [
            "retained_expired",
            "synchronous_cleanup_orphaned",
            "already_absent",
            "changed_since_plan",
            "delete_failed",
            "batch_limit",
            "not_attempted_after_failure",
            "invalid_metadata",
            "future_timestamp"
          ]
        },
        "error_code": {
          "enum": [
            "DPONE_AIRFLOW_SECRET_GC_ACCESS_DENIED",
            "DPONE_AIRFLOW_SECRET_GC_DELETE_FAILED"
          ]
        },
        "http_status": {
          "type": "integer",
          "minimum": 100,
          "maximum": 599
        }
      }
    }
  }
}
