{       
    "id" : "node.json",
    "title" : "API to access the nodes",
    "$schema": "http://json-schema.org/draft-04/schema#",
    "$ref" : "#/definitions/node",
    "links" : [
	{
	    "title" : "get all nodes",
	    "href" : "/",
	    "method" : "GET",
	    "rel" : "instances",
	    "schema" : {"$ref" : "#/definitions/nodeList"}
	},
	{
	    "title" : "get node based on filter",
	    "href" : "/search?name={nameFilter}&AS={ASNumber}&queryType=OR",
	    "method" : "GET",
	    "rel" : "search",
	    "schema" : {"$ref" : "#/definitions/nodeList"}
	},
	{
	    "title" : "get a node",
	    "href" : "/{nodeIndex}",
	    "method" : "GET",
	    "rel" : "self",
	    "schema" : {"$ref" : "#/definitions/node"}
	},
	{
	    "title" : "get a node event history",
	    "href" : "/{nodeIndex}/history?start={startTimeStamp}&end={endTimeStamp}",
	    "description" : "Provide the history of events for the Node, it can be optionally filtered by start (inclusive) and end (exclusive) timestamp",
	    "method" : "GET",
	    "rel" : "self",
	    "schema" : {"$ref" : "#/definitions/nodeHistoryEventList"}
	},

	{
	    "title" : "create a new node",
	    "description" : "Create a new node, schema on request is #/definitions/createNode",
	    "href" : "/",
	    "method" : "POST",
	    "rel" : "create",
	    "schema" : {
		"$ref" : "#/definitions/node",
		"required" : ["name"]
	    }
	},
	{
	    "title" : "update a node",
	    "href" : "/{nodeIndex}",
	    "description" : "Update an existing node, schema on request is #/definitions/updateNode",
	    "method" : "PUT",
	    "rel" : "self",	    
	    "schema" : {"$ref" : "#/definitions/node"}
	},
	{
	    "title" : "delete a node",
	    "href" : "/{nodeIndex}",	    
	    "method" : "DELETE"
	}
    ],
    "definitions" : {
	"nodeHistoryEventList" : {
	    "type" : "array",
	    "items" : { "$ref" : "#/definitions/nodeHistoryEvent"}	    
	},
	"nodeHistoryEvent" : {
	    "description" : "An entry in the history of an Node. The history consists of the information received from Topology acquisition",
            "type" :"object",
            "properties" : {
		"timestamp" : {
		    "description" :"Event Timestamp.",
		    "type" : "integer"
		}		
            },
	    "oneOf" : [
		{"$ref" :"#/definitions/node"}
            ]
	},
        "mgmtProtocols" : {            
            "description" : "Management Protocol information schema",
            "type" : "object",
            "properties" : {
                "address" : {
                    "description" : "management IP address",
                    "type" : "string",
                    "format" : "ipv4"
                },
                "operatingSystem" :  {
                    "type" : "string",
                    "maxLength" : 31,
                    "description" : "operating system information"
                },
                "vendor" :  {
                    "type" : "string",
                    "maxLength" : 31,
                    "description" : "Vendor"
                }
            }                  
        },
	"updateNode" : {
	    "description" : "Set of properties that can used to update a planned Node. Other properties can be set, but they will be ignored.",
	    "type" : "object",
            "additionalProperties" : true,
	    "required" : ["topologyIndex","topoObjectType","nodeIndex"],
            "properties": {
		"topoObjectType" : {"type" : "string","enum" : ["node"]},
		"topologyIndex" : { "$ref" : "topology.json#/definitions/topologyIndex"},
                "nodeIndex": { 
                    "description": "Program ID for node",
		    "$ref" : "common.json#/definitions/index"
                },                              
                "name": {
                    "description": "Identifier of the node. This parameter is fixed on creation and cannot be updated. For Nodes created from BGP-LS, this defaults to the node router-id",
                    "$ref" : "common.json#/definitions/name255"},
                "hostName": {
                    "description": " hostname of the node",
                    "type": "string",
                    "maxLength" : 255,
                    "minLength" : 1
                },
		"pseudoNode" : {
		    "description" : "indicates if the node is a pseudo node created by the underlying IGP protocol",
		    "type" : "boolean",
		    "default" : false
		},
                "nodeType": {
                    "description": "Hardware node type (any user string)",
                    "type": "string"
                },
                "protocols": {
                    "description" : "Protocols configuration and information on the node",
                    "type" : "object",
                    "properties" : {
			"management" : {"$ref" : "#/definitions/mgmtProtocols"}
                    }
                },
                "topology": {
                    "type": "object",
                    "additionalProperties" :false,
                    "properties" : {
                        "coordinates": { 
                            "description" : "A GeoJSON Point, allowing crs and bbox",
                            "type" : "object",
                            "required": [ "type" ],
                            "properties": {"type": { "enum": [ "Point" ] }},
			    "$ref" : "geojson.json#"
                       }
                    }
                },            
                "layer" : {
                    "description": " Layer of the node",
                    "type" : "string"
                },
                "AutonomousSystem": {
		    "description": "Correlated AS Number, may be present even if the node is not a BGP speaker",
		    "$ref" : "common.json#/definitions/ASNumber"
		},
                "site": {
                    "description" : "Site ID of the node",
                    "type"        : "string"
                }, 
                "design": {                
                    "description": "User defined design properties",
                    "type" : "object",
                    "properties" : {
                        "simulation": {
                            "type":"object",
                            "properties" : {
                                "canFail": {"type" :"boolean" }
                            }
                        },
                        "delay" : {
                            "description" : "Node delay in millisecond",
                            "type" : "integer"
                        },
                        "trafficRerouteThreshold" : {"type" : "integer","description" : "the percentage of utilization that trigger a reroute based on analytics","minimum":0,"maximum":100},
                        "userCost":	{"type" : "integer","description" : "User metric"}

                    }                                      
                },
                "comment"           : {"description" : "Comment" , "type" : "string"},
                "extraIpAddresses" : {
                    "type":"array",
                    "items":{"$ref" : "link.json#/definitions/ipv4TaggedAddress"}
                }
            }
	},
	"createNode" : {
	    "description" : "Set of properties that can used for planned node creation",
	    "type" : "object",
            "additionalProperties" : false,
	    "required" : ["topologyIndex","topoObjectType","name"],
            "properties": {
		"topoObjectType" : {"type" : "string","enum" : ["node"]},
		"topologyIndex" : { "$ref" : "topology.json#/definitions/topologyIndex"},
                "name": {
                    "description": "Identifier of the node. This parameter is fixed on creation and cannot be updated. For Nodes created from BGP-LS, this defaults to the node router-id",
                    "$ref" : "common.json#/definitions/name255"},
                "hostName": {
                    "description": " hostname of the node",
                    "type": "string",
                    "maxLength" : 255,
                    "minLength" : 1
                },
                "nodeType": {
                    "description": "Hardware node type (any user string)",
                    "type": "string"
                },
                "nodeType": {
                    "description": "Hardware node type (any user string)",
                    "type": "string"
                },
                "protocols": {
                    "description" : "Protocols configuration and information on the node",
                    "type" : "object",
                    "properties" : {
			"management" : {"$ref" : "#/definitions/mgmtProtocols"}
                    }
                },
		"pseudoNode" : {
		    "description" : "indicates if the node is a pseudo node created by the underlying IGP protocol",
		    "type" : "boolean",
		    "default" : false
		},
                "topology": {
                    "type": "object",
                    "additionalProperties" :false,
                    "properties" : {
                        "coordinates": { 
                            "description" : "A GeoJSON Point, allowing crs and bbox",
                            "type" : "object",
                            "required": [ "type" ],
                            "properties": {"type": { "enum": [ "Point" ] }},
			    "$ref" : "geojson.json#"
                       }
                    }
                },            
                "layer" : {
                    "description": " Layer of the node",
                    "type" : "string"
                },
                "AutonomousSystem": {
		    "description": "Correlated AS Number, may be present even if the node is not a BGP speaker",
		    "$ref" : "common.json#/definitions/ASNumber"
		},
                "site": {
                    "description" : "Site ID of the node",
                    "type"        : "string"
                }, 
                "design": {                
                    "description": "User defined design properties",
                    "type" : "object",
                    "properties" : {
                        "simulation": {
                            "type":"object",
                            "properties" : {
                                "canFail": {"type" :"boolean" }
                            }
                        },
                        "delay" : {
                            "description" : "Node delay in millisecond",
                            "type" : "integer"
                        },
                        "userCost" : {"type" : "integer","description" : "User metric"}
                    }
                },
                "comment"           : {"description" : "Comment" , "type" : "string"},
                "extraIpAddresses" : {
                    "type":"array",
                    "items":{"$ref" : "link.json#/definitions/ipv4TaggedAddress"}
                }
            }	    
	},
        "node" : {
            "description" : "Represent a single node",
	    "name" : "node",
            "type" : "object",
	    "required" : ["topologyIndex","topoObjectType"],
            "properties": {
		"topoObjectType" : {"type" : "string","enum" : ["node"]},
		"topologyIndex" : { "$ref" : "topology.json#/definitions/topologyIndex"},
                "name": {
                    "description": "Identifier of the node. This parameter is fixed on creation and cannot be updated. For Nodes created from BGP-LS, this defaults to the node router-id",
                    "$ref" : "common.json#/definitions/name255"},
                "hostName": {
                    "description": " hostname of the node",
                    "type": "string",
                    "maxLength" : 255,
                    "minLength" : 1
                },
                "nodeIndex": { 
                    "description": "Program ID for node",
		    "$ref" : "common.json#/definitions/index"
                },                              
                "nodeType": {
                    "description": "Hardware node type (any user string)",
                    "type": "string"
                },
		"pseudoNode" : {
		    "description" : "indicates if the node is a pseudo node created by the underlying IGP protocol",
		    "type" : "boolean",
		    "default" : false
		},
                "routerId"     : {"type" : "string","format" : "ipv4","description":"router ID derived from protocols or device collection, read only"},
                "routerIdIPv6" : {"type" : "string","format" : "ipv6","description":"IPv6 router ID derived from  device collection, read only"},
                "protocols": {
                    "description" : "Protocols configuration and information on the node",
                    "type" : "object",
                    "properties" : {
			"management" : {"$ref" : "#/definitions/mgmtProtocols"},
                        "OSPF": {
                            "type" : "object",
                            "additionalProperties" : false,
                            "properties": {
                                "routerId"   : {"type" : "string","format" : "ipv4"},
                                "TERouterId" : {"type" : "string","format" : "ipv4"},
                                "overloadBit"   : {"type" :"boolean", "description" : "OSPF overload bit set (from device collection)"},
                                "referenceBw": {"type" :"number", "description" : "OSPF reference bandwidth (read-only,from device collection)"} 
                            }
                        },
                        "ISIS": {
                            "type" : "object",
                            "additionalProperties" : false,
                            "properties": {
				"isoAddress" : {"type" :"string"},
                                "routerId": {"type" :"string","format" : "ipv6"},
                                "TERouterId": {"type" :"string","format" : "ipv6"},
                                "area": {"type" :"string"},
                                "overloadBit"   : {"type" :"boolean", "description" : "ISIS overload bit set (from device collection)"}
                            }
                        },    
                        "BGP": {
                            "type" : "object",
                            "additionalProperties" : false,
                            "properties": {
                                "id": {"type" :"string"},
                                "AutonomousSystem": {
				    "description" : "default AS",
				    "$ref" : "common.json#/definitions/ASNumber"
				}
                            }
                        },
                        "PCEP": {
                            "type": "object",
                            "additionalProperties" : false,
                            "properties" : {
                                "operationalStatus" : {
                                    "description" : "PCEP protocol operational status, Either Up or Down",
		                    "$ref" : "common.json#/definitions/operStatus"
                                },
                                "peerStatefullCapabilities" : {
                                    "type" : "object",
                                    "description" : "This represent the remote peer advertized capabilites",
                                    "properties" : {
                                        "lspUpdate"         : {"type" :"boolean", "description" : "Stateful PCE LSP Update "},
                                        "lspInstantiation"  : {"type" :"boolean", "description" : "Stateful PCE LSP Create"},
                                        "p2mp"              : {"type" :"boolean", "description" : "Stateful PCE P2MP LSP reporting"},
                                        "p2mpUpdate"        : {"type" :"boolean", "description" : "Stateful PCE P2MP LSP Update"},
                                        "p2mpInstantiation" : {"type" :"boolean", "description" : "Stateful PCE P2MP LSP Create"},
                                        "SRCapability"      : {"type" :"boolean", "description" : "Segment Routing capability"}
                                        
                                    }
                                },
                                "sessionParameters" : {
                                    "type" : "object",
                                    "description" : "This represent the remote peer pcep session parameters",
                                    "properties" : {
                                        "keepalive"  : {"type" :"integer", "description" : "PCEP session keepalive time, in seconds"},
                                        "deadtimer"  : {"type" :"integer", "description" : "PCEP session DeadTimer time, in seconds"},
                                        "maximumStackDepth" : {"type":"integer","description":"The SR maximum Stack Depth (MSD) reported by the PCC"}
                                    }
                                },
                                "extensions" : {
                                    "type" : "object",
                                    "description" : "Force NorthStar support of specific extensions",
                                    "properties" : {
                                        "lsp-association-protection"         : {"type" :"boolean", "description" : "Support for Primary/Secondary LSP using draft-ananthakrishnan-pce-stateful-path-protection-00. "}
                                    }
                                },
                                "pccAddress": {
                                    "description": " Ipv4 address of pcc in xx.xx.xx.xx",
                                    "type": "string",
                                    "format" : "ipv4"
                                }
                            }
                        },
                        "SR" : {
                            "type" : "object",
                            "description" : "Represent the node Segment Routing (SR) parameters",
                            "properties" : {
                                "nodeCapabilities" : {"type":"integer","description" : "The Node capabilities, as defined in draft-ietf-isis-segment-routing-extensions-07#section-3, draft-ietf-ospf-ospfv3-segment-routing-extensions-05#section-3.3 "},
                                "SRGBs"            : {
                                    "description" : "List of SRG Ranges",
                                    "type" : "array",
	                            "items" : {
                                        "type" : "object",
                                        "description" : "One range",
                                        "properties" : {
                                            "start":{"type":"integer"},
                                            "range":{"type":"integer"}
                                        }                                        
                                    }
                                },
                                "enabled" : {"type" :"boolean","description" : "If true the node can be used to route SR Tunnels. This flag is set to true if the node has SRGB and a node index (Prefix with routerId role and SR properties)"}
                            }
                        }
                    }                    
                },
                "prefixes" : {
                    "type" : "array",
	            "items" : {
                        "type" : "object",
                        "properties" :{
	                    "role"    : {"type" : "string", "description" : "indicate the role of the address when its derived from a particular protocol, for instance routerID, teRouterID, ipv6address,..etc "},
                            "SR"      : {
                                "type" : "object",
                                "properties" : {
                                    "index" : {"type":"number", "description" : "Index of the prefix in the global SR tables"},
                                    "algo"  : {"type":"number", "description" : "Spring Algorithm (0 for ECMP-aware CSPF, 1 for strict ECMP aware CSPF)"},
                                    "flags" : {"type":"number", "description" : "Flags associated to this prefix, see draft-ietf-isis-segment-routing-extensions-07#section-2.1, Flags not defined for OSPF are 0"}
                                }
                            }   
	                },
	                "oneOf" : [
                            {"$ref" : "common.json#/definitions/ipv4Prefix"},
                            {"$ref" : "common.json#/definitions/ipv6Prefix"}                            
                        ]
                    }
                },
                "topology": {
                    "type": "object",
                    "additionalProperties" :false,
                    "properties" : {
                        "coordinates": { 
                            "description" : "A GeoJSON Point, allowing crs and bbox",
                            "type" : "object",
                            "required": [ "type" ],
                            "properties": {"type": { "enum": [ "Point" ] }},
			    "$ref" : "geojson.json#"
                       }                      
                    }
                },            
                "layer" : {
                    "description": " Layer of the node",
                    "type" : "string"
                },
                "AutonomousSystem": {
		    "description": "Correlated AS Number, may be present even if the node is not a BGP speaker",
		    "$ref" : "common.json#/definitions/ASNumber"
		},
                "site": {
                    "description" : "Site ID of the node",
                    "type"        : "string"
                }, 
                "design": {                
                    "description": "User defined design properties",
                    "type" : "object",
                    "properties" : {
                        "simulation": {
                            "type":"object",
                            "properties" : {
                                "canFail": {"type" :"boolean" }
                            }
                        },
                        "delay" : {
                            "description" : "Node delay in millisecond",
                            "type" : "integer"
                        }
                    }                                      
                },
                "comment"           : {"description" : "Comment" , "type" : "string"},
                "extraIpAddresses" : {
                    "type":"array",
                    "items":{"$ref" : "link.json#/definitions/ipv4TaggedAddress"}
                }
            }
        },
	"nodeList" : {
	    "type" : "array",
	    "items" : {"$ref" : "#/definitions/node"}	    
	}
    }  
}
