{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/digitraffic-fi/json-schema/digitraffic-fi-spatial-track-work-notification-schema.json",
  "title": "SpatialTrackWorkNotification",
  "description": "Describes planned, in-progress or finished track work",
  "x-generated": "2026-11-11",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/digitraffic-fi-rail-api-openapi.yml#/components/schemas/SpatialTrackWorkNotification",
  "required": [
    "created",
    "electricitySafetyPlan",
    "id",
    "location",
    "organization",
    "personInChargePlan",
    "speedLimitPlan",
    "speedLimitRemovalPlan",
    "state",
    "trafficSafetyPlan",
    "version",
    "workParts"
  ],
  "type": "object",
  "properties": {
    "id": {
      "type": "string",
      "description": "Id"
    },
    "state": {
      "type": "string",
      "description": "State",
      "enum": [
        "ACTIVE",
        "PASSIVE",
        "FINISHED",
        "SENT",
        "DRAFT",
        "REMOVED",
        "REJECTED"
      ]
    },
    "organization": {
      "type": "string",
      "description": "Which organization created this notification"
    },
    "created": {
      "type": "string",
      "description": "When this notification was created",
      "format": "date-time"
    },
    "modified": {
      "type": "string",
      "description": "When this notification last modified",
      "format": "date-time"
    },
    "trafficSafetyPlan": {
      "type": "boolean",
      "description": "Does the notification contain a traffic safety plan"
    },
    "speedLimitRemovalPlan": {
      "type": "boolean",
      "description": "Does the notification contain a speed limit removal plan"
    },
    "electricitySafetyPlan": {
      "type": "boolean",
      "description": "Does the notification contain a electricity safety plan"
    },
    "speedLimitPlan": {
      "type": "boolean",
      "description": "Does the notification contain a speed limit plan"
    },
    "personInChargePlan": {
      "type": "boolean",
      "description": "Does the notification contain a plan for persons in charge"
    },
    "location": {
      "type": "object",
      "description": "Approximate location"
    },
    "workParts": {
      "type": "array",
      "description": "Work parts",
      "items": {
        "$ref": "#/$defs/TrackWorkPart"
      }
    },
    "version": {
      "type": "integer",
      "description": "Version",
      "format": "int64"
    }
  },
  "$defs": {
    "RumaLocation": {
      "title": "RumaLocation",
      "required": [
        "locationType",
        "notificationId",
        "workPartIndex"
      ],
      "type": "object",
      "properties": {
        "notificationId": {
          "type": "string",
          "description": "Notification identifier"
        },
        "workPartIndex": {
          "type": "integer",
          "description": "Track work part index",
          "format": "int64"
        },
        "locationType": {
          "type": "string",
          "description": "Type",
          "enum": [
            "WORK",
            "FIREWORK",
            "SPEED_LIMIT"
          ]
        },
        "operatingPointId": {
          "type": "string",
          "description": "Identifier of operating point, required if section is not present"
        },
        "sectionBetweenOperatingPointsId": {
          "type": "string",
          "description": "Identifier of section between operating points, required if operating point is not present"
        }
      },
      "description": "Location of work, either an operating point or a section between operating points"
    },
    "TrackWorkPart": {
      "title": "TrackWorkPart",
      "required": [
        "containsFireWork",
        "locations",
        "partIndex",
        "permissionMinimumDuration",
        "startDay"
      ],
      "type": "object",
      "properties": {
        "partIndex": {
          "type": "integer",
          "description": "Index number",
          "format": "int64"
        },
        "startDay": {
          "type": "string",
          "description": "Planned (not necessarily actual) start day",
          "format": "date"
        },
        "permissionMinimumDuration": {
          "type": "string",
          "description": "Requested minimum duration for work permission in ISO 8601 format, e.g. PT30M"
        },
        "containsFireWork": {
          "type": "boolean",
          "description": "Contains fire work"
        },
        "plannedWorkingGap": {
          "type": "string",
          "description": "Planned working gap in local time with no time zone, e.g. 11:43:00"
        },
        "advanceNotifications": {
          "type": "array",
          "description": "Related advance notifications",
          "items": {
            "type": "string",
            "description": "Related advance notifications"
          }
        },
        "locations": {
          "uniqueItems": true,
          "type": "array",
          "description": "Locations",
          "items": {
            "$ref": "#/$defs/RumaLocation"
          }
        }
      },
      "description": "A logical part of a track work"
    }
  }
}