{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://aisa.ablera.com/contracts/configuration-change.schema.json",
  "title": "Existing-product configuration change v1",
  "x-status": "draft",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schema_version",
    "case_id",
    "request_ref",
    "selected_stages",
    "targets",
    "changes",
    "input_bindings",
    "skipped_stages",
    "templates",
    "obligation_refs",
    "execution_obligations_ref",
    "stage_edges"
  ],
  "properties": {
    "schema_version": {
      "const": 1
    },
    "case_id": {
      "type": "string",
      "minLength": 1
    },
    "request_ref": {
      "type": "string",
      "minLength": 1
    },
    "selected_stages": {
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 1
      },
      "uniqueItems": true,
      "minItems": 1
    },
    "targets": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "environment",
          "system",
          "baseline_ref",
          "schema_ref",
          "scope_ref"
        ],
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1
          },
          "environment": {
            "type": "string",
            "minLength": 1
          },
          "system": {
            "type": "string",
            "minLength": 1
          },
          "baseline_ref": {
            "type": "string",
            "minLength": 1
          },
          "schema_ref": {
            "type": "string",
            "minLength": 1
          },
          "scope_ref": {
            "type": "string",
            "minLength": 1
          }
        }
      }
    },
    "changes": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "stage",
          "target_id",
          "before_ref",
          "desired_ref",
          "assertion_refs",
          "shared"
        ],
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1
          },
          "stage": {
            "type": "string",
            "minLength": 1
          },
          "target_id": {
            "type": "string",
            "minLength": 1
          },
          "before_ref": {
            "type": "string",
            "minLength": 1
          },
          "desired_ref": {
            "type": "string",
            "minLength": 1
          },
          "assertion_refs": {
            "type": "array",
            "items": {
              "type": "string",
              "minLength": 1
            },
            "uniqueItems": true,
            "minItems": 1
          },
          "shared": {
            "type": "boolean"
          }
        }
      }
    },
    "input_bindings": {
      "type": "object",
      "additionalProperties": {
        "type": "string",
        "minLength": 1
      }
    },
    "skipped_stages": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "stage",
          "reason",
          "baseline_ref"
        ],
        "properties": {
          "stage": {
            "type": "string",
            "minLength": 1
          },
          "reason": {
            "type": "string",
            "minLength": 1
          },
          "baseline_ref": {
            "type": "string",
            "minLength": 1
          }
        }
      }
    },
    "templates": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "key",
          "selector_ref",
          "role_scope_ref",
          "effective_from",
          "product_spec_ref",
          "target_ids",
          "assertion_refs"
        ],
        "properties": {
          "key": {
            "type": "string",
            "minLength": 1
          },
          "selector_ref": {
            "type": "string",
            "minLength": 1
          },
          "role_scope_ref": {
            "type": "string",
            "minLength": 1
          },
          "effective_from": {
            "type": "string",
            "format": "date"
          },
          "product_spec_ref": {
            "type": "string",
            "minLength": 1
          },
          "target_ids": {
            "type": "array",
            "items": {
              "type": "string",
              "minLength": 1
            },
            "uniqueItems": true,
            "minItems": 1
          },
          "assertion_refs": {
            "type": "array",
            "items": {
              "type": "string",
              "minLength": 1
            },
            "uniqueItems": true,
            "minItems": 1
          }
        }
      }
    },
    "obligation_refs": {
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 1
      },
      "uniqueItems": true
    },
    "execution_obligations_ref": {
      "type": "string",
      "minLength": 1
    },
    "stage_edges": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "from",
          "to"
        ],
        "properties": {
          "from": {
            "type": "string"
          },
          "to": {
            "type": "string"
          }
        }
      }
    }
  }
}
