{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://hupe1980.github.io/imsys/contracts/events/v1/de.imsys.gateway.read.superseded.json",
  "title": "de.imsys.gateway.read.superseded",
  "description": "An operator replaced a pending read after the gateway's target changed. The successor's outcome follows as its own event. Personal data: confidential, GDPR, standard.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "job",
    "gateway",
    "window",
    "successor",
    "reason"
  ],
  "properties": {
    "client_reference": {
      "description": "The submitter's reference for the read, byte for byte; mirrored in the event's subject (REF-2). A successor inherits its predecessor's.",
      "type": "string",
      "pattern": "^[\\x21-\\x7e]{1,128}$"
    },
    "job": {
      "description": "The desk's read ID.",
      "type": "integer",
      "minimum": 1
    },
    "gateway": {
      "description": "The gateway's wake-up recipient, 18 lowercase hex digits.",
      "type": "string",
      "pattern": "^[0-9a-f]{18}$"
    },
    "metering_point": {
      "description": "The metering point bound to the gateway when the read was submitted (Messlokation or Marktlokation ID). Absent when none was bound.",
      "type": "string",
      "pattern": "\\S",
      "maxLength": 160
    },
    "window": {
      "description": "The three quarter-hour slots requested.",
      "type": "object",
      "additionalProperties": false,
      "required": [
        "start",
        "end",
        "period_seconds"
      ],
      "properties": {
        "start": {
          "type": "string",
          "format": "date-time",
          "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$",
          "description": "First slot, inclusive."
        },
        "end": {
          "type": "string",
          "format": "date-time",
          "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$",
          "description": "End of the last slot, exclusive."
        },
        "period_seconds": {
          "const": 900
        }
      }
    },
    "successor": {
      "description": "The successor read's ID.",
      "type": "integer",
      "minimum": 1
    },
    "reason": {
      "description": "The operator's reason.",
      "type": "string",
      "pattern": "\\S",
      "maxLength": 256
    }
  }
}
