{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://hwlab.pikastech.local/protocol/schemas/wiring-config.schema.json",
  "title": "HWLAB Wiring Config",
  "type": "object",
  "required": [
    "wiringConfigId",
    "projectId",
    "gatewaySessionId",
    "status",
    "connections",
    "createdAt",
    "updatedAt"
  ],
  "properties": {
    "wiringConfigId": {
      "$ref": "common.json#/$defs/id"
    },
    "projectId": {
      "$ref": "common.json#/$defs/id"
    },
    "gatewaySessionId": {
      "$ref": "common.json#/$defs/id"
    },
    "name": {
      "type": "string",
      "maxLength": 160
    },
    "status": {
      "type": "string",
      "enum": ["draft", "valid", "active", "rejected", "retired"]
    },
    "connections": {
      "type": "array",
      "minItems": 1,
      "items": {
        "$ref": "#/$defs/connection"
      }
    },
    "constraints": {
      "$ref": "common.json#/$defs/jsonObject"
    },
    "createdAt": {
      "$ref": "common.json#/$defs/timestamp"
    },
    "updatedAt": {
      "$ref": "common.json#/$defs/timestamp"
    }
  },
  "additionalProperties": false,
  "$defs": {
    "endpoint": {
      "type": "object",
      "required": ["resourceId", "port"],
      "properties": {
        "resourceId": {
          "$ref": "common.json#/$defs/id"
        },
        "port": {
          "type": "string",
          "minLength": 1,
          "maxLength": 128
        },
        "capabilityId": {
          "$ref": "common.json#/$defs/id"
        }
      },
      "additionalProperties": false
    },
    "connection": {
      "type": "object",
      "required": ["from", "to"],
      "properties": {
        "from": {
          "$ref": "#/$defs/endpoint"
        },
        "to": {
          "$ref": "#/$defs/endpoint"
        },
        "mode": {
          "type": "string",
          "enum": ["exclusive", "shared", "monitor"]
        }
      },
      "additionalProperties": false
    }
  }
}
