{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://fdc3.finos.org/schemas/next/bridging/connectionStep6ConnectedAgentsUpdate.schema.json",
  "title": "ConnectionStep6ConnectedAgentsUpdate",
  "type": "object",
  "allOf": [
    {
      "$ref": "#/$defs/ConnectionStep6ConnectedAgentsUpdateBase"
    },
    {
      "$ref": "connectionStep.schema.json"
    }
  ],
  "$defs": {
    "ConnectionStep6ConnectedAgentsUpdateBase": {
      "type":"object",
      "title": "ConnectionStep6ConnectedAgentsUpdateBase",
      "description": "Message sent by Bridge to all Desktop Agent when an agent joins or leaves the bridge, includes the details of all agents, the change made and the expected channel state for all agents.",
      "properties": {
        "type": {
          "title": "Connection Step 6 Message Type",
          "const": "connectedAgentsUpdate"
        },
        "payload": {
          "title": "Connection Step 6 Payload",
          "type": "object",
          "properties": {
            "addAgent": {
              "title": "Agents To Add",
              "type": "string",
              "description": "Should be set when an agent first connects to the bridge and provide its assigned name."
            },
            "removeAgent": {
              "title": "Agents To Remove",
              "type": "string",
              "description": "Should be set when an agent disconnects from the bridge and provide the name that no longer is assigned."
            },
            "allAgents": {
              "title": "All Connected Agents",
              "type": "array",
              "description": "Desktop Agent Bridge implementation metadata of all connected agents.",
              "items": {
                "$ref": "common.schema.json#/$defs/DesktopAgentImplementationMetadata"
              }
            },
            "channelsState": {
              "title": "Channel State",
              "type": "object",
              "description": "The updated state of channels that should be adopted by the agents. Should only be set when an agent is connecting to the bridge.",
              "additionalProperties": {
                "type": "array",
                  "items": {
                    "$ref": "../context/context.schema.json"
                  }
              }
            }
          },
          "additionalProperties": false,
          "required": ["allAgents"]
        },
        "meta": {
          "title": "Connection Step 6 Metadata",
          "type": "object",
          "properties": {
            "requestUuid": {
              "$ref": "../api/common.schema.json#/$defs/RequestUuid"
            },
            "responseUuid": {
              "$ref": "../api/common.schema.json#/$defs/ResponseUuid"
            },
            "timestamp": {
              "$ref": "../api/common.schema.json#/$defs/Timestamp"
            }
          },
          "additionalProperties": false,
          "required": ["requestUuid", "responseUuid", "timestamp"]
        }
      },
      "required": ["type", "payload", "meta"],
      "additionalProperties": false
    }
  }
}