{	
    "id" : "common.json",
    "$schema": "http://json-schema.org/draft-04/schema#",
    "definitions" : {
        "Bandwidth" : {
            "description": " Bandwidth value in from 0 - 10,000,000,000[bBKkMmGg]",
	    "OneOf" : [
          {"type": "string",
           "pattern" : "([0-9][0-9\\.]{0,9}|10000000000)[bBKkMmGg]?",
           "default" : "0"},
          {"type" : "integer"}
	    ]
        },
	"unreservedBw": {
	    "description" : "Unreserved bandwidth array",
	    "type" : "array",
	    "minItem" : 8,
	    "maxItem" : 8,
	    "items" : {"$ref" : "#/definitions/Bandwidth"}
	},
	"maintenanceName" : {
        "description" : "object name for maintenance event name, string without space, comma",
        "type"        : "string",
	    "pattern" : "^[a-zA-Z0-9_\\-\\.\\:\\>\\<\\@\\/]*$"	   	   
	},
	"name" : {
            "description" : "object name, string without space, comma",
            "type"        : "string",
	    "pattern" : "^[a-zA-Z0-9_\\-\\.\\:\\>\\<]*$"	   	   
	},
        "name64" : {
            "description" : "object name, string without space, comma, limited to 64 chars (repeated due to some validator handling of references)",
            "type"        : "string",
	    "pattern" : "^[a-zA-Z0-9_\\-\\.\\:\\>\\<\\/]*$",
   	    "maxLength" : 64,
            "minLength" : 1
	},
	"name255" : {
            "description" : "object name, string without space, comma, limited to 64 chars (repeated due to some validator handling of references)",
            "type"        : "string",
    	    "pattern" : "^[a-zA-Z0-9_\\-\\.\\:\\>\\<]*$",
   	        "maxLength" : 255,
            "minLength" : 1
	},
    "hostHostnameOrIp": {
        "description": "String field for either host name or IP address",
        "anyOf" : [
          {"type": "string", "format": "hostname"},
          {"type": "string", "format": "ipv4"},
          {"type": "string", "format": "ipv6"}
        ]
    },
        "demandName" : {
            "description" : "object name, string without space, comma, limited to 64 chars (repeated due to some validator handling of references)",
            "type"        : "string",
	    "pattern" : "^[a-zA-Z0-9_\\-\\.\\:\\>\\<\\/]*$",
   	    "maxLength" : 255,
            "minLength" : 1
	},
        "tag" : {
            "description" : "a string contaning a tag or list of tag",
            "type"        : "string",
            "maxLength"   : 255
	},
        "index" : {
            "description" : "Application Server index",
            "type"        : "integer" 
        },
        "adminStatus" : {
            "description" : "Interface administrative status",
            "type" : "string",
            "enum" : ["Up","Down","Unknown","Planned", "Shutdown"]
        },
	"SID": {
            "description" : "Segment Identifier",
            "type"        : "integer",
            "minimum"     : 0,
            "maximum"     : 1048575
        },
        "operStatus" : {
            "description" : "Operational status",
            "type" : "string",	
            "enum" : ["Up","Down","Unknown","Empty"]
        },
        "operStatusAndPlanned" : {
	    "description" : "Extends the operational status to planned elements like nodes and links",
	    "oneOf" :[
		{"$ref" : "common.json#/definitions/operStatus"},
		{
		    "type" : "string",	
		    "enum" : ["Planned"]
		}
	    ]
	},
        "calendarSchema" : {
            "description" : "Description of an event",
            "type" : "object",
            "required" : ["startTime","endTime"],
            "additionalProperties" : false,
            "properties" : {
                "startTime":  {"description" : "start time" , "$ref" : "#/definitions/dateTime"},
                "endTime"  :  {"description" : "end time" ,  "$ref" : "#/definitions/dateTime"},
                "recurrence" : {
                    "description" : "optional recurence description",
                    "required" : [ "FREQ" ],
		    "additionalProperties" : false,
                    "properties" : {
                        "FREQ" : {
                            "description" : "Frequency, possibly one of SECONDLY MINUTELY HOURLY DAILY WEEKLY MONTHLY YEARLY, however actual support is restricted to DAILY",
                            "type" : "string",
                            "enum" : ["DAILY"]
                        },
                        "UNTIL" : {"$ref" : "#/definitions/dateTime"},
                        "INTERVAL"   : {"description" : "Only daily, every day recurence is supported",
					"type" : "integer",
					"enum" : [1]
				       }
                    }
                }
            }            
            
        },
        "dateTime" : {"type" : "string" ,
                      "description" : "RFC5545 section 3.3.5 date-time, also ISO.8601.2004"
                  },
        "srlg":{"id" : "#/definitions/srlg",
		"title" :"SRLG","type":"object",
		"additionalProperties":false,"properties":{"srlgValue":{"type":"integer"},"srlgName":{"type":"string"}}},
	"srlgList" : {
	    "type" : "array",
	    "items" : {"$ref" : "#/definitions/srlg"}
	},
        "site":{"id" : "#/definitions/site","title" :"site","type":"object","required":["siteName"],"additionalProperties":false,"properties":{"siteName":{"type":"string"}}},
	"ASNumber" : {"id" : "#/definitions/asNumber","title" :"siteAS Number","type":"object","required":["asNumber"],"additionalProperties":false,
		      "properties":{"asNumber": {
			  "anyOf": [
			      {"type":"integer"},
			      {"type":"null"}
			      ]
		      }}},
	"credentials" : {
	    "type" : "object",
	    "description" : "User crendentials used to connect to a device",
	    "properties" : {
		"userName" : {"type" :"string"},
		"password" : {"type" :"string","description" :"Write-Only password, this parameter is not returned on GET responses"},
		"token"    : {"type" :"string"},
		"keys" : {
		    "type" : "array",
		    "items" : {
			"type" : "object",
			"properties" : {
			    "applicableProtocols" : {
				"description" : "list of protocols where the key can be used",
				"type" :"array",
				"items" : {"type" : "string"}
				
			    },
			    "keyType" : {"type" : "string","enum" : ["rsa","dsa"]},
			    "publicKey" : {"type" : "string"},
			    "privateKey" : {"type" : "string"}
			}			
		    }		    
		}
	    }	
	},
	"APILinkList" : {
            "description" : "Contains the linked information",
            "type" :"array",
            "items" : {"$ref" : "#/definitions/APILink"}
        },
        "APILink" : {
            "type" : "object",
            "requiredProperties" : ["href"],
            "properties" : {
                "href" : {"type" : "string"},
                "rel"  : {"type" : "string"},
                "type"   : {"type" : "string"},
                "schema" : {
                    "description" : "Optional schema information.",
                    "oneOf" :[
		        {"type" : "object"},
		        {"type" : "string"}
	    ]} 
            }
        },
        "lspColor": {
          "anyOf": [
            { "type": "string", "maxLength": 10 },
            { "type": "number", "minimum": 0 }
          ],
          "description": "LSP color, as per draft-filsfils-spring-segment-routing-policy"
        },
        "notificationAction" : {
            "description": "Indicate what is the action on the object beeing notified",
            "comment" : "Split into two subtypes for notifications with different schema on object state change and remove",
            "oneOf": [
                {"$ref" : "#/definitions/notificationActionUpdates"},
                {"$ref" : "#/definitions/notificationActionRemove"}
            ]
        },
        "notificationActionRemove" : {
            "type" : "string",
            "description": "Indicate what is the action on the object beeing notified",
            "enum" : ["remove"]
        },
        "notificationActionUpdates" : {
            "type" : "string",
            "description": "Indicate what is the action on the object beeing notified",
            "enum" : ["add","update"]
        },
        "prefixWithSR" :{
            "type" : "object",
            "description" : "Prefix with optional SR information",
            "properties" :{
                "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" : "#/definitions/ipv4Prefix"},
                {"$ref" : "#/definitions/ipv6Prefix"}                            
            ]
            
        },
        "ipv4Prefix" : {
            "type" : "object",
            "description": "IP Prefix",
            "required" : ["address"],
            "properties" : {
              "topoObjectType" : {"type" : "string","enum" : ["prefix"]},
              "address" : {"type" : "string","format":"ipv4"},
              "length"  : {"type" : "number","description":"prefix length"}
            }
        },
        "vpnIdentifier": {
            "type": "object",
            "description": "VPN identifier on a PE, either the name of a routing instance or a route-distinguisher",
            "oneOf": [
                { "required": ["topoObjectType", "rd"] },
                { "required": ["topoObjectType", "name"] }
            ],
            "properties": {
                "topoObjectType": {"type": "string", "enum": ["vpnId"]},
                "rd": {
                    "type": "string",
                    "pattern": "^([0-9]+L*|[0-9.]+):[0-9]+"
                },
                "name": {
                    "type": "string"
                }
            }
        },
        "ipv6Prefix" : {
            "type" : "object",
            "description": "IP Prefix",
            "required" : ["address"],
            "properties" : {
              "topoObjectType" : {"type" : "string","enum" : ["prefixIPv6"]},
              "address" : {"type" : "string","format":"ipv6"},
              "length"  : {"type" : "number","description":"prefix length"}
            }
        }
    }
}
