{
    "id"     :"topology_v2.json",
    "$schema": "http://json-schema.org/draft-04/schema#",
    "$ref" : "#/definitions/topology",
    "links" : [
	{
	    "title" : "gets the topologies list, which contains only the description",
	    "href" : "/topologies",
	    "method" : "GET",
	    "schema" : {
		"type" : "array",
		"items" : {"$ref" : "#/definitions/topology"}
	    }
	},
	{
	    "title" : "gets all Live state.",
	    "href" : "/{topologyIndex}",
	    "method" : "GET",
	    "rel" : "self",
	    "schema" : {"$ref" : "#/definitions/topology"}
	},
	{
	    "title" : "node information",
	    "href" : "/{topologyIndex}/nodes/",
	    "schema" : {"$ref" : "node_v2.json#/definitions/nodeList"}
	},
        {"title" : "get SSE notification stream", "href" : "/{topologyIndex}/stream","method" : "GET"},
	{
	    "title" : "links topology information",
	    "href" : "/{topologyIndex}/links/",
	    "schema" : {"$ref" : "link_v2.json#/definitions/linkList"}
	},
	{
	    "title" : "te-lsps",
	    "href" : "/{topologyIndex}/te-lsps/",
	    "schema" : {"$ref" : "lsp.json#/definitions/lspList"}
	},
        {
	    "title" : "P2MP groups",
	    "href" : "/{topologyIndex}/p2mp/",
	    "schema" : {"$ref" : "p2mp.json#/definitions/p2mpList"}
	},
        {
	    "title" : "facilities",
	    "href" : "/{topologyIndex}/facilities/",
	    "schema" : {"$ref" : "facilities.json#/definitions/facilityList"}
	},
        {
	    "title" : "interfaces",
	    "href" : "/{topologyIndex}/interfaces/",
	    "schema" : {"$ref" : "interfaceSchema_v2.json#/definitions/interfaceList"}
	},
        {
	    "title" : "Maintenances",
	    "href" : "/{topologyIndex}/maintenances/",
	    "schema" : {"$ref" : "maintenance.json#/definitions/maintenanceList"}
	},
        {
	    "title" : "TE++ Containers",
	    "href" : "/{topologyIndex}/te-container/",
	    "schema" : {"$ref" : "lsp-containers.json#/definitions/containerList"}
	},
        {
	    "title" : "VRFs ",
	    "href" : "/{topologyIndex}/vrfs/",
	    "schema" : {"$ref" : "vrfs.json#/definitions/vrfSummaryList"}
	},
        {
	    "title" : "anycastGroups",
	    "href" : "/{topologyIndex}/anycastGroups/",
	    "schema" : {"$ref" : "anycast.json#/definitions/anycastGroupList"}
	},
	{
	    "title" : "topology acquisition status",
	    "href" : "/{topologyIndex}/status/topologyAcquisition",
	    "method" : "GET",
	    "rel" : "self",
	    "schema" : {"$ref" : "#/definitions/componentStatus"}
	},
	{
	    "title" : "PCE status",
	    "href" : "/{topologyIndex}/status/pce",
	    "method" : "GET",
	    "rel" : "self",
	    "schema" : {"$ref" : "#/definitions/componentStatus"}
	},
        {
	    "title" : "path computation server status",
	    "href" : "/{topologyIndex}/status/pathComputationServer",
	    "method" : "GET",
	    "rel" : "self",
	    "schema" : {"$ref" : "#/definitions/componentStatus"}
	},
        {
	    "title" : "transport topology acquisition status",
	    "href" : "/{topologyIndex}/status/multilayerTopology",
	    "method" : "GET",
	    "rel" : "self",
	    "schema" : {"$ref" : "#/definitions/componentStatus"}
	},
        {
	    "title" : "Analytics data collection component status",
	    "href" : "/{topologyIndex}/status/analyticsCollection",
	    "method" : "GET",
	    "rel" : "self",
	    "schema" : {"$ref" : "#/definitions/componentStatus"}
	},
        {
	    "title" : "Analytics database component status",
	    "href" : "/{topologyIndex}/status/analyticsDatabase",
	    "method" : "GET",
	    "rel" : "self",
	    "schema" : {"$ref" : "#/definitions/componentStatus"}
	},
        {
	    "title" : "NorthStar components status",
	    "href" : "/{topologyIndex}/status",
	    "method" : "GET",
	    "rel" : "self",
	    "schema" : {"$ref" : "#/definitions/componentStatusList"}
	},
        {
	    "title" : "path computation requests RPC",
	    "href" : "/{topologyIndex}/pathComputation",
	    "method" : "POST",
	    "rel" : "self",
            "schema"       : {"$ref" : "pathComputation.json#/definitions/pathComputationRequests"},
            "targetSchema" : {"$ref" : "pathComputation.json#/definitions/pathComputationResponses"}
	}
    ],
    "definitions" : {
        "componentStatusList" : {
            "type":"array",
            "items": {"$ref" : "#/definitions/componentStatus"}
        },
        "subComponentStatus" : {
            "type" : "object",
	    "description" : "status of a sub-component without restriction on the component part",
	    "additionalProperties" : false,
            "properties" : {
		"component" : {"type" :"string"},
		"status" : {"type" :"string"},
		"statusTimestamp" : {"type" :"integer"},
                "statusTimestampTime" : {"type" : "string","description" : "ISO 8101 timestamp","format" : "datetime"},
                "sessions" : {
                    "type":"array",
                    "items": {"$ref" : "#/definitions/sessionsStatus"}
                }
	    }
        },
        "sessionsStatus" : {
            "type" : "object",
            "description" : "Provide the session information, if the component has such information available",
            "properties" : {
                "remotePeer"     : {"type" : "string", "format" : "ipv4", "description" : "remove peer Ipv4 address"},
                "remoteHostname" : {"type" : "string",  "description" : "remove peer hostname"},
                "protocol"       : {"type" : "string", "description" : "Protocol used for that session, for instance http, PCEP,...etc"},
                "operationalStatus" : {"$ref" : "common.json#/definitions/operStatus"},
                "id"             : {"type" : "string", "description" : "id of the session"}
            }
        },
	"componentStatus" : {
	    "type" : "object",
	    "description" : "indicates the status of the topology and LSP data acquisition sources",
	    "additionalProperties" : false,
            "properties" : {
		"component" : {"type" :"string", "enum" : ["Topology acquisition","PCE","Path Computation Server","Transport Topology acquisition","Analytics data collection","Analytics database"]},
		"status" : {"type" :"string"},
                "childs" : {
                    "type":"array",
                    "items": {"$ref" : "#/definitions/subComponentStatus"}
                },
                "sessions" : {
                    "type":"array",
                    "items": {"$ref" : "#/definitions/sessionsStatus"}
                },
		"statusTimestamp" : {"type" :"integer"},
                "statusTimestampTime" : {"type" : "string","description" : "ISO 8101 timestamp","format" : "datetime"}
	    }
	},
	"topologyIndex" : {
	    "description" : "topology index, for now only one is supported",
	    "$ref" : "common.json#/definitions/index"
	},
	"topology" : {
	    "type" : "object",
	    "required" : ["topologyIndex","topoObjectType"],
	    "properties" : {
		"topologyIndex" : { "$ref" : "#/definitions/topologyIndex"},
		"topoObjectType" : {"type" : "string","enum" : ["topology"]},
		"description" : {
		    "description" : "topology description",
		    "type" : "string",
		    "enum" : [ "default Topology" ]
		},
		"nodes" : {
		    "description" : "all nodes",
		    "$ref" : "node_v2.json#/definitions/nodeList"
		},
		"links" : {
		    "description" : "all nodes",
		    "$ref" : "link_v2.json#/definitions/linkList"
		},
                "facilities" : {
                    "description" : "facilities",
                    "$ref" : "facilities.json#/definitions/facilityList"
                }
	    }
	},
        "notification" : {
            "type" : "object",
            "required": [ "notificationType" ],
            "oneOf": [
                { "$ref": "#/definitions/linkNotification" },
                { "$ref": "#/definitions/nodeNotification" },
                { "$ref": "#/definitions/lspNotification" },
                { "$ref": "#/definitions/demandNotification" },
                { "$ref": "#/definitions/p2mpGroupNotification"},
                { "$ref": "#/definitions/haHostNotification"},
                { "$ref": "#/definitions/facilityNotification"},
                { "$ref": "#/definitions/statusComponentNotification"},
                { "$ref": "#/definitions/maintenanceNotification"},
                { "$ref": "#/definitions/topologyNotification"},
                { "$ref": "#/definitions/containerNotification"},
                { "$ref": "#/definitions/lspTopologyEvent"},
                { "$ref": "#/definitions/ipePolicyNotification"},
                { "$ref": "#/definitions/anycastGroupNotification"}
            ]
        },
        "linkNotification" : {
            "type": "object",
            "properties" : {
                "notificationType" : {"type" :"string","enum":["link"]},
                "action"           : {"$ref" : "common.json#/definitions/notificationAction"},
                "object"           : {"$ref" : "link_v2.json#/definitions/link"}
            }
        },
        "nodeNotification" : {
            "type": "object",
            "properties" : {
                "notificationType" : {"type" :"string","enum":["node"]},
                "action"           : {"$ref" : "common.json#/definitions/notificationAction"},
                "object"           : {"$ref" : "node_v2.json#/definitions/node"}
            }
        },
        "lspNotification" : {
            "type": "object",
            "properties" : {
                "notificationType" : {"type" :"string","enum":["lsp"]},
                "action"           : {"$ref" : "common.json#/definitions/notificationAction"},
                "object"           : {"$ref" : "lsp.json#/definitions/lsp"}
            }
        },
        "demandNotification" : {
            "type": "object",
            "properties" : {
                "notificationType" : {"type" :"string","enum":["demand"]},
                "action"           : {"$ref" : "common.json#/definitions/notificationAction"},
                "object"           : {"$ref" : "demands.json#/definitions/demand"}
            }
        },
        "p2mpGroupNotification" : {
            "type": "object",
            "properties" : {
                "notificationType" : {"type" :"string","enum":["p2mpGroup"]},
                "action"           : {"$ref" : "common.json#/definitions/notificationAction"},
                "object"           : {"$ref" : "p2mp.json#/definitions/p2mpGroup"}
            }
        },
        "haHostNotification" : {
            "type": "object",
            "properties" : {
                "notificationType" : {"type" :"string","enum":["host"]},
                "action"           : {"$ref" : "common.json#/definitions/notificationAction"},
                "object"           : {"$ref" : "ha.json#/definitions/host"}
            }
        },
        "facilityNotification" : {
            "type": "object",
            "properties" : {
                "notificationType" : {"type" :"string","enum":["facility"]},
                "action"           : {"$ref" : "common.json#/definitions/notificationAction"},
                "object"           : {"$ref" : "facilities.json#/definitions/facility"}
            }
        },
        "maintenanceNotification" : {
            "type": "object",
            "properties" : {
                "notificationType" : {"type" :"string","enum":["maintenance"]},
                "action"           : {"$ref" : "common.json#/definitions/notificationAction"},
                "object"           : {"$ref" : "maintenance.json#/definitions/maintenance"}
            }
        },
        "containerNotification" : {
            "description" : "Notification containing a container. On update/add the full object is present, on remove only the containerIndex is present",
            "oneOf" : [
                {
                    "type": "object",
                    "properties" : {
                        "notificationType" : {"type" :"string","enum":["te-container"]},
                        "action"           : {"$ref" : "common.json#/definitions/notificationActionUpdates"},
                        "object"           : {"$ref" : "lsp-containers.json#/definitions/container"}
                    }
                },
                {
                    "type": "object",
                    "properties" : {
                        "notificationType" : {"type" :"string","enum":["te-container"]},
                        "action"           : {"$ref" : "common.json#/definitions/notificationActionRemove"},
                        "object"           : {"$ref" : "lsp-containers.json#/definitions/containerReferenceIndex"}
                    }
                }
            ]
        },
        "healthNotificationProcessMessage" : {
            "type": "object",
            "required" : ["node","processName"],
            "properties" : {
                "node"        : {"type": "string","description" : "Indicates on which node the event was originated."},
                "processName" : {"type": "string","description" : "process name"},
                "status"      : {"type": "string","description" : "process status"},
                "pid"         : {
                    "oneOf" : [                        
                        {"type": "string","description" : "process pid, encoded in a string"},
                        {"type": "integer","description" : "process pid"}
                    ]},
                "prevStatus"  : {"type": "string","description" : "previous process status"}
            }
        },
        "healthNotificationTimeDiff" : {
            "type": "object",
            "required" : ["node","timeDiff"],
            "properties" : {
                "node"        : {"type": "string","description" : "Indicates on which node the event was originated."},
                "timeDiff"    : {"type": "integer","description" : "Time difference between the master and node"}
            }
        },
        "healthNotificationDiskThreshold" : {
            "type": "object",
            "required" : ["node","partition"],
            "properties" : {
                "node"        : {"type": "string","description" : "Indicates on which node the event was originated."},
                "partition"   : {"type": "string","description" : "Partition"},
                "usage"       : {"type": "integer","description" : "Current usage"},
                "threshold"   : {"$ref" : "health.json#/definitions/diskThreshold"}
            }
        },
        "healthNotificationLicense" : {
            "type": "object",
            "required" : ["node_status"],
            "properties" : {
                "node_status"  : {"type": "string","description" : "License status on the node."},
                "node_limit"   : {"type": "integer","description" : "Number of nodes allowed by the license."},
                "node_count"   : {"type": "integer","description" : "Number of nodes in the network."},
                "expiry"       : {"type": "string","description" : "Expiration date of the license, in the format Year-Month-Day"}
            }
        },
        "healthNotification" : {
            "type": "object",
            "description" : "indicates that health monitoring hresholds are crossed",
            "properties" : {
                "id"               : {"type" :"integer","description" :"timestamp"},
                "type"             : {"type" :"string","enum":["license","process","diskThreshold","time"]},
                "object"           : {
                    "type" : "object",
                    "properties": {
                        "severity": {"type": "string", "enum": ["info", "warning", "critical"]},
                        "timestamp": { "type": "integer"},
                        "message"  : {
                            "oneOf" : [
                                {"$ref" : "#/definitions/healthNotificationProcessMessage"},
                                {"$ref" : "#/definitions/healthNotificationTimeDiff"},
                                {"$ref" : "#/definitions/healthNotificationDiskThreshold"},
                                {"$ref" : "#/definitions/healthNotificationLicense"}
                            ]                                                            
                        }
                    }
                }
            }
        },
        "statusComponentNotification" : {
            "type": "object",
            "properties" : {
                "notificationType" : { 
                    "type" :"string", 
                    "enum":["componentStatus"]},
                "action" :  { 
                    "$ref" :  "common.json#/definitions/notificationAction"},
                "object" : {
                    "$ref" : "topology_v2.json#/definitions/componentStatus"}
            }
        },
        "lspTopologyEvent" : {            		
            "type": "object",
            "description": "This notification is sent to indicate that all LSPs have been updated. This may happen in high-load situation where the notification rate is too big (northstar.cfg lsp_state_refresh_threshold). The payload only indicates which topology is affected.",
            "properties" : {
                "notificationType" : {"type" :"string","enum":["lspTopology","demandTopology"]},
                "action"           : {"$ref" : "common.json#/definitions/notificationAction"},
                "object"           : {
                    "type" : "object", "properties" : {"topologyIndex" : { "$ref" : "#/definitions/topologyIndex"}}
                }
            }
        },        
        "topologyNotification" : {
            "type": "object",
            "description": "This notification is sent on topology-wide event. The notification sent at the moment are: 1. add with empty topology indicating that the Topology has been re-synched or reseted.\n  2. update and Topology with only node or link set: Indicates that the complete node (resp. link) should be re-synched. This may happen in high-load situation where the notification rate is too big (northstar.cfg *_state_refresh_threshold)",
            "properties" : {
                "notificationType" : {"type" :"string","enum":["topology"]},
                "action"           : {"$ref" : "common.json#/definitions/notificationAction"},
                "object"           : {"$ref" : "#/definitions/topology"}
            }
        },
        "ipePolicyNotification" : {
            "type": "object",
            "properties" : {
                "notificationType" : {"type" :"string","enum":["ipePolicy"]},
                "action"           : {"$ref" : "common.json#/definitions/notificationAction"},
                "object"           : {"$ref" : "ipe.json#/definitions/IPEPolicy"}
            }
        },
        "anycastGroupNotification" : {
            "type": "object",
            "properties" : {
                "notificationType" : {"type" :"string","enum":["anycastGroup"]},
                "action"           : {"$ref" : "common.json#/definitions/notificationAction"},
                "object"           : {"$ref" : "anycast.json#/definitions/anycastGroup"}
            }
        }
    }
}
