{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://xyte-io.github.io/xyte-cli/schemas/edge-params-update-batch.v1.schema.json",
  "title": "Xyte CLI Edge Params Update Batch Result",
  "type": "object",
  "required": ["schemaVersion", "generatedAtUtc", "tenantId", "mode", "runId", "totals", "rows"],
  "properties": {
    "schemaVersion": {
      "const": "xyte.edge.params-update-batch.v1"
    },
    "generatedAtUtc": {
      "type": "string"
    },
    "tenantId": {
      "type": "string",
      "minLength": 1
    },
    "mode": {
      "enum": ["plan", "apply"]
    },
    "runId": {
      "type": "string",
      "minLength": 1
    },
    "reportPath": {
      "type": "string"
    },
    "resumePath": {
      "type": "string"
    },
    "totals": {
      "type": "object",
      "required": ["rows", "planned", "succeeded", "failed", "rejected", "skipped"],
      "properties": {
        "rows": {
          "type": "number"
        },
        "planned": {
          "type": "number"
        },
        "succeeded": {
          "type": "number"
        },
        "failed": {
          "type": "number"
        },
        "rejected": {
          "type": "number"
        },
        "skipped": {
          "type": "number"
        }
      },
      "additionalProperties": true
    },
    "rows": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/outcome"
      }
    }
  },
  "$defs": {
    "outcome": {
      "type": "object",
      "required": ["device_id", "disposition"],
      "properties": {
        "rowIndex": {
          "type": "number"
        },
        "device_id": {
          "type": "string"
        },
        "disposition": {
          "enum": ["planned", "succeeded", "failed", "rejected", "skipped"]
        },
        "detail": {
          "type": "string"
        },
        "rejectReason": {
          "type": "string"
        },
        "plan": {
          "type": "object",
          "required": [
            "device_id",
            "model_id",
            "set",
            "current_custom_parameters",
            "merged_custom_parameters",
            "requestBody",
            "supportedParameters"
          ],
          "properties": {
            "device_id": {
              "type": "string"
            },
            "model_id": {
              "type": "string"
            },
            "model_name": {
              "type": "string"
            },
            "set": {
              "type": "object"
            },
            "current_custom_parameters": {
              "type": "object"
            },
            "merged_custom_parameters": {
              "type": "object"
            },
            "requestBody": {
              "type": "object",
              "required": ["custom_parameters"],
              "properties": {
                "custom_parameters": {
                  "type": "object"
                }
              },
              "additionalProperties": true
            },
            "supportedParameters": {
              "type": "array",
              "items": {
                "$ref": "#/$defs/modelParameter"
              }
            }
          },
          "additionalProperties": true
        },
        "response": true,
        "verification": {
          "type": "object",
          "required": ["ok", "mismatches"],
          "properties": {
            "ok": {
              "type": "boolean"
            },
            "mismatches": {
              "type": "array",
              "items": {
                "type": "object",
                "required": ["key"],
                "properties": {
                  "key": {
                    "type": "string"
                  },
                  "expected": true,
                  "actual": true
                },
                "additionalProperties": true
              }
            }
          },
          "additionalProperties": true
        }
      },
      "additionalProperties": true
    },
    "modelParameter": {
      "type": "object",
      "required": ["name"],
      "properties": {
        "name": { "type": "string" },
        "type": { "type": "string" },
        "required": { "type": "boolean" }
      },
      "additionalProperties": true
    }
  },
  "additionalProperties": true
}
