{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/open-plant-data/json-schema/open-plant-data-internal-data-batch-response-schema.json",
  "title": "InternalDataBatchResponse",
  "x-generated": "2026-12-04",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/open-plant-data-openapi.json#/components/schemas/InternalDataBatchResponse",
  "required": [
    "summary",
    "results"
  ],
  "properties": {
    "summary": {
      "required": [
        "total",
        "succeeded",
        "failed"
      ],
      "properties": {
        "total": {
          "type": "integer"
        },
        "succeeded": {
          "type": "integer"
        },
        "failed": {
          "type": "integer"
        }
      },
      "type": "object"
    },
    "results": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/InternalDataBatchResult"
      }
    }
  },
  "type": "object",
  "$defs": {
    "InternalDataBatchResult": {
      "required": [
        "index",
        "status",
        "outcome"
      ],
      "properties": {
        "index": {
          "description": "Zero-based position in the submitted records array; always present, even for malformed records.",
          "type": "integer",
          "minimum": 0
        },
        "data_id": {
          "description": "Echoed input ID, or null when its type is invalid; omitted for non-object records.",
          "type": [
            "integer",
            "null"
          ]
        },
        "internal_id": {
          "type": [
            "string",
            "null"
          ]
        },
        "action": {
          "type": [
            "string",
            "null"
          ]
        },
        "status": {
          "description": "Per-record status: 200 updated/unchanged/deleted, 201 created, 404 delete target not found (counted as failed), 409 ambiguous existing mappings, 422 invalid record or unavailable plant, 500 failed write (retry).",
          "type": "integer",
          "enum": [
            200,
            201,
            404,
            409,
            422,
            500
          ]
        },
        "outcome": {
          "type": "string",
          "enum": [
            "created",
            "updated",
            "unchanged",
            "deleted",
            "not_found",
            "error"
          ]
        },
        "record": {
          "$ref": "#/$defs/InternalDataRecord"
        },
        "errors": {
          "$ref": "#/$defs/InternalDataErrors"
        }
      },
      "type": "object"
    },
    "InternalDataErrors": {
      "description": "Field names mapped to arrays of error messages.",
      "type": "object",
      "additionalProperties": {
        "type": "array",
        "items": {
          "type": "string"
        }
      }
    },
    "InternalDataRecord": {
      "required": [
        "data_id",
        "internal_id",
        "internal_name",
        "price",
        "old_price",
        "product_url"
      ],
      "properties": {
        "data_id": {
          "type": "integer"
        },
        "internal_id": {
          "type": "string"
        },
        "internal_name": {
          "type": [
            "string",
            "null"
          ]
        },
        "price": {
          "type": [
            "string",
            "null"
          ]
        },
        "old_price": {
          "type": [
            "string",
            "null"
          ]
        },
        "product_url": {
          "type": [
            "string",
            "null"
          ]
        }
      },
      "type": "object"
    }
  }
}