{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://raw.githubusercontent.com/api-evangelist/viridi-parente/main/json-schema/viridi-parente-rule-chain-data-schema.json",
  "title": "RuleChainData",
  "description": "A JSON value representing the rule chains.",
  "x-generated": "2026-10-20",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/viridi-parente-rule-chain-controller-api-openapi.yml#/components/schemas/RuleChainData",
  "properties": {
    "ruleChains": {
      "type": "array",
      "description": "List of the Rule Chain objects.",
      "items": {
        "$ref": "#/$defs/RuleChain"
      },
      "readOnly": true
    },
    "metadata": {
      "type": "array",
      "description": "List of the Rule Chain metadata objects.",
      "items": {
        "$ref": "#/$defs/RuleChainMetaData"
      },
      "readOnly": true
    }
  },
  "required": [
    "metadata",
    "ruleChains"
  ],
  "$defs": {
    "JsonNode": {
      "description": "A value representing the any type (object or primitive)"
    },
    "NodeConnectionInfo": {
      "properties": {
        "fromIndex": {
          "type": "integer",
          "format": "int32",
          "description": "Index of rule node in the 'nodes' array of the RuleChainMetaData. Indicates the 'from' part of the connection."
        },
        "toIndex": {
          "type": "integer",
          "format": "int32",
          "description": "Index of rule node in the 'nodes' array of the RuleChainMetaData. Indicates the 'to' part of the connection."
        },
        "type": {
          "type": "string",
          "description": "Type of the relation. Typically indicated the result of processing by the 'from' rule node. For example, 'Success' or 'Failure'"
        }
      },
      "required": [
        "fromIndex",
        "toIndex",
        "type"
      ]
    },
    "RuleChain": {
      "description": "A JSON value representing the rule chain.",
      "properties": {
        "id": {
          "$ref": "#/$defs/RuleChainId",
          "description": "JSON object with the Rule Chain Id. Specify this field to update the Rule Chain. Referencing non-existing Rule Chain Id will cause error. Omit this field to create new rule chain."
        },
        "createdTime": {
          "type": "integer",
          "format": "int64",
          "description": "Timestamp of the rule chain creation, in milliseconds",
          "readOnly": true
        },
        "tenantId": {
          "$ref": "#/$defs/TenantId",
          "description": "JSON object with Tenant Id.",
          "readOnly": true
        },
        "name": {
          "type": "string",
          "description": "Rule Chain name"
        },
        "type": {
          "type": "string",
          "description": "Rule Chain type. 'EDGE' rule chains are processing messages on the edge devices only.",
          "enum": [
            "CORE",
            "EDGE"
          ]
        },
        "firstRuleNodeId": {
          "$ref": "#/$defs/RuleNodeId",
          "description": "JSON object with Rule Chain Id. Pointer to the first rule node that should receive all messages pushed to this rule chain."
        },
        "root": {
          "type": "boolean",
          "description": "Indicates root rule chain. The root rule chain process messages from all devices and entities by default. User may configure default rule chain per device profile."
        },
        "debugMode": {
          "type": "boolean",
          "description": "Reserved for future usage."
        },
        "configuration": {
          "$ref": "#/$defs/JsonNode"
        },
        "additionalInfo": {
          "$ref": "#/$defs/JsonNode"
        }
      },
      "required": [
        "name",
        "tenantId"
      ]
    },
    "RuleChainConnectionInfo": {
      "properties": {
        "fromIndex": {
          "type": "integer",
          "format": "int32",
          "description": "Index of rule node in the 'nodes' array of the RuleChainMetaData. Indicates the 'from' part of the connection."
        },
        "targetRuleChainId": {
          "$ref": "#/$defs/RuleChainId",
          "description": "JSON object with the Rule Chain Id."
        },
        "additionalInfo": {
          "$ref": "#/$defs/JsonNode",
          "description": "JSON object with the additional information about the connection."
        },
        "type": {
          "type": "string",
          "description": "Type of the relation. Typically indicated the result of processing by the 'from' rule node. For example, 'Success' or 'Failure'"
        }
      },
      "required": [
        "additionalInfo",
        "fromIndex",
        "targetRuleChainId",
        "type"
      ]
    },
    "RuleChainId": {
      "properties": {
        "id": {
          "type": "string",
          "format": "uuid",
          "description": "ID of the entity, time-based UUID v1"
        },
        "entityType": {
          "type": "string",
          "description": "string",
          "enum": [
            "RULE_CHAIN"
          ]
        }
      },
      "required": [
        "entityType",
        "id"
      ]
    },
    "RuleChainMetaData": {
      "description": "A JSON value representing the rule chain metadata.",
      "properties": {
        "ruleChainId": {
          "$ref": "#/$defs/RuleChainId",
          "description": "JSON object with Rule Chain Id.",
          "readOnly": true
        },
        "firstNodeIndex": {
          "type": "integer",
          "format": "int32",
          "description": "Index of the first rule node in the 'nodes' list"
        },
        "nodes": {
          "type": "array",
          "description": "List of rule node JSON objects",
          "items": {
            "$ref": "#/$defs/RuleNode"
          }
        },
        "connections": {
          "type": "array",
          "description": "List of JSON objects that represent connections between rule nodes",
          "items": {
            "$ref": "#/$defs/NodeConnectionInfo"
          }
        },
        "ruleChainConnections": {
          "type": "array",
          "description": "List of JSON objects that represent connections between rule nodes and other rule chains.",
          "items": {
            "$ref": "#/$defs/RuleChainConnectionInfo"
          }
        }
      },
      "required": [
        "connections",
        "firstNodeIndex",
        "nodes",
        "ruleChainConnections",
        "ruleChainId"
      ]
    },
    "RuleNode": {
      "properties": {
        "id": {
          "$ref": "#/$defs/RuleNodeId",
          "description": "JSON object with the Rule Node Id. Specify this field to update the Rule Node. Referencing non-existing Rule Node Id will cause error. Omit this field to create new rule node."
        },
        "createdTime": {
          "type": "integer",
          "format": "int64",
          "description": "Timestamp of the rule node creation, in milliseconds",
          "readOnly": true
        },
        "ruleChainId": {
          "$ref": "#/$defs/RuleChainId",
          "description": "JSON object with the Rule Chain Id. ",
          "readOnly": true
        },
        "type": {
          "type": "string",
          "description": "Full Java Class Name of the rule node implementation. "
        },
        "name": {
          "type": "string",
          "description": "User defined name of the rule node. Used on UI and for logging. "
        },
        "debugMode": {
          "type": "boolean",
          "description": "Enable/disable debug. "
        },
        "singletonMode": {
          "type": "boolean",
          "description": "Enable/disable singleton mode. "
        },
        "queueName": {
          "type": "string",
          "description": "Queue name. "
        },
        "configurationVersion": {
          "type": "integer",
          "format": "int32",
          "description": "Version of rule node configuration. "
        },
        "externalId": {
          "$ref": "#/$defs/RuleNodeId"
        },
        "configuration": {
          "$ref": "#/$defs/JsonNode"
        },
        "additionalInfo": {
          "$ref": "#/$defs/JsonNode",
          "description": "Additional parameters of the rule node. Contains 'layoutX' and 'layoutY' properties for visualization."
        }
      }
    },
    "RuleNodeId": {
      "properties": {
        "id": {
          "type": "string",
          "format": "uuid",
          "description": "ID of the entity, time-based UUID v1"
        },
        "entityType": {
          "type": "string",
          "description": "string",
          "enum": [
            "RULE_NODE"
          ]
        }
      },
      "required": [
        "entityType",
        "id"
      ]
    },
    "TenantId": {
      "properties": {
        "id": {
          "type": "string",
          "format": "uuid",
          "description": "ID of the entity, time-based UUID v1"
        },
        "entityType": {
          "type": "string",
          "description": "string",
          "enum": [
            "TENANT"
          ]
        }
      },
      "required": [
        "entityType",
        "id"
      ]
    }
  }
}