{
  "$defs": {
    "item": {
      "additionalProperties": false,
      "allOf": [
        {
          "if": {
            "properties": {
              "deployment_id": {
                "type": "null"
              }
            },
            "required": [
              "deployment_id"
            ]
          },
          "then": {
            "properties": {
              "action": {
                "const": "skipped"
              },
              "reason": {
                "enum": [
                  "incomplete",
                  "invalid"
                ]
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "action": {
                "const": "deleted"
              }
            },
            "required": [
              "action"
            ]
          },
          "then": {
            "properties": {
              "deployment_id": {
                "$ref": "#/$defs/sha256"
              },
              "reason": {
                "const": "unreferenced"
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "reason": {
                "enum": [
                  "current",
                  "retention_evidence"
                ]
              }
            },
            "required": [
              "reason"
            ]
          },
          "then": {
            "properties": {
              "action": {
                "const": "skipped"
              }
            }
          }
        }
      ],
      "properties": {
        "action": {
          "enum": [
            "deleted",
            "skipped"
          ]
        },
        "deployment_id": {
          "anyOf": [
            {
              "$ref": "#/$defs/sha256"
            },
            {
              "type": "null"
            }
          ]
        },
        "error_code": {
          "pattern": "^DPONE_(CACHE|RELEASE|DEPLOYMENT|AIRFLOW)_[A-Z0-9_]+$",
          "type": "string"
        },
        "path": {
          "minLength": 1,
          "type": "string"
        },
        "reason": {
          "enum": [
            "current",
            "retention_evidence",
            "unreferenced",
            "incomplete",
            "invalid"
          ]
        }
      },
      "required": [
        "deployment_id",
        "action",
        "reason",
        "path"
      ],
      "type": "object"
    },
    "sha256": {
      "pattern": "^sha256:[0-9a-f]{64}$",
      "type": "string"
    }
  },
  "$id": "https://paulkov.github.io/dpone/schemas/gitops/deployment-cache-retention-apply-v3.schema.json",
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "additionalProperties": false,
  "allOf": [
    {
      "if": {
        "properties": {
          "deleted_deployment_ids": {
            "minItems": 1
          }
        },
        "required": [
          "deleted_deployment_ids"
        ]
      },
      "then": {
        "required": [
          "reviewed_plan_sha256",
          "activation_history_revision",
          "operation_id",
          "review_id",
          "receipt_revision",
          "transaction_status"
        ]
      }
    }
  ],
  "properties": {
    "activation_history_revision": {
      "pattern": "^sha256:[0-9a-f]{64}$",
      "type": "string"
    },
    "current_deployment_id": {
      "anyOf": [
        {
          "$ref": "#/$defs/sha256"
        },
        {
          "type": "null"
        }
      ]
    },
    "deleted_deployment_ids": {
      "items": {
        "$ref": "#/$defs/sha256"
      },
      "type": "array",
      "uniqueItems": true
    },
    "environment": {
      "minLength": 1,
      "type": "string"
    },
    "items": {
      "items": {
        "$ref": "#/$defs/item"
      },
      "type": "array"
    },
    "operation_id": {
      "pattern": "^sha256:[0-9a-f]{64}$",
      "type": "string"
    },
    "promoted_by": {
      "minLength": 1,
      "type": "string"
    },
    "receipt_revision": {
      "pattern": "^sha256:[0-9a-f]{64}$",
      "type": "string"
    },
    "review_id": {
      "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$",
      "type": "string"
    },
    "reviewed_plan_sha256": {
      "pattern": "^sha256:[0-9a-f]{64}$",
      "type": "string"
    },
    "schema": {
      "const": "dpone.deployment-cache-retention-apply.v3"
    },
    "skipped_deployment_ids": {
      "items": {
        "$ref": "#/$defs/sha256"
      },
      "type": "array",
      "uniqueItems": true
    },
    "transaction_status": {
      "const": "committed"
    }
  },
  "required": [
    "schema",
    "environment",
    "promoted_by",
    "current_deployment_id",
    "items",
    "deleted_deployment_ids",
    "skipped_deployment_ids"
  ],
  "title": "dpone GitOps deployment cache retention apply report with durable transaction receipt",
  "type": "object",
  "x-dpone-authoritative-field": "items"
}
