{
    "id" : "lsp-containers.json",
    "title" : "TE++ LSP Containers Schema",
    "$schema": "http://json-schema.org/draft-04/schema#",
    "$ref" : "#/definitions/containerList",
    "links" : [
	{
	    "title" : "get all containers",
	    "href" : "/",
	    "method" : "GET",
	    "rel" : "instances",
	    "schema" : {"$ref" : "#/definitions/containerList"}
	},
	{
	    "title" : "get an container",
	    "href" : "/{containerIndex}",
	    "method" : "GET",
	    "rel" : "self",
	    "schema" : {"$ref" : "#/definitions/container"}
	},
        {"title" : "get SSE notification stream", "href" : "/stream","method" : "GET"},
	{
	    "title" : "create a new Container",
	    "description" : "Create a new LSP schema on request is #/definitions/createLsp",
	    "href" : "/",
	    "method" : "POST",
	    "rel" : "create",
	    "schema" : {"$ref" : "#/definitions/createContainer"},
	    "targetSchema" : {
		"$ref" : "#/definitions/container"
	    }
	},
	{
	    "title" : "update a container",
	    "href" : "/{containerIndex}",
	    "description" : "Update an existing te-lsp, schema on request is #/definitions/updateLsp",
	    "method" : "PUT",
	    "rel" : "self",
	    "schema" : {"$ref" : "#/definitions/updateContainer"},
	    "targetSchema" : {"$ref" : "#/definitions/container"}
	},
        {
	    "title" : "PATCH a a container",
	    "href" : "/{containerIndex}",
	    "description" : "Update an existing te-lsp, accepting a RFC6902 document producing a  #/definitions/updateLsp ",
	    "method" : "PATCH",
	    "rel" : "self",
            "schema" : {"$ref" : "json-patch.json"},
	    "targetSchema" : {"$ref" : "#/definitions/container"}
	},
	{
	    "title" : "delete a container",
	    "href" : "/{containerIndex}",
	    "method" : "DELETE"
	},
	{
	    "title" : "Create a set of  new container",
	    "description" : "Create a set of new LSP, return code only indicate the acceptance of the request, response contains a list of lsp indexes",
	    "href" : "/bulk/",
	    "method" : "POST",
	    "rel" : "create",
            "schema" : {"$ref" : "#/definitions/containerCreateList"},
            "targetSchema" : {"$ref" : "#/definitions/containerList"}
	},
	{
	    "title" : "update a set of container",
	    "description" : "update a set of LSP, return code only indicate the acceptance of the request",
	    "href" : "/bulk",
	    "method" : "PUT",
            "schema" : {"$ref" : "#/definitions/containerUpdateList"},
            "targetSchema" : {"$ref" : "#/definitions/containerList"}
	},
        {
	    "title" : "Patch  a set of container",
	    "description" : "update a set of LSP, return code only indicate the acceptance of the request",
	    "href" : "/bulk",
	    "method" : "PATCH",
            "schema" : {"$ref" : "#/definitions/containerListPatch"},
            "targetSchema" : {"$ref" : "#/definitions/containerList"}

	},        
	{
	    "title" : "delete a set of containers",
	    "description" : "delete a set of LSPs, return code only indicate the acceptance of the request",
	    "href" : "/bulk",
	    "method" : "DELETE",
            "schema" : {"$ref" : "#/definitions/containerListDelete"},
            "targetSchema" : {"$ref" : "#/definitions/containerList"}
	}
    ],
    "definitions" : {
        "containerListPatch" : {
            "type" : "array",
            "minItems" : 1,
            "maxItems" : 10000,
	    "items" :{
                "type" : "object",
                "required" : ["containerIndex","patch"],
                "properties" : {
                    "containerIndex": {
                        "description": "Program ID for container",
                        "$ref" : "common.json#/definitions/index"
                    },
                    "patch" : {"$ref" : "json-patch.json"}
                }
            }
        },
        "containerList" : {
            "type" : "array",
            "items" :{"$ref" : "#/definitions/container"}
        },
        "containerListDelete" : {
            "description" : "schema for bulk container delete, the number of entries that can be modified at a time is limited",
	    "type" : "array",
            "minItems" : 1,
            "maxItems" : 10000,
	    "items" : {
                "description" : "Information required to delete a container.",
                "type" :"object",
	        "additionalProperties" : true,
	        "required" : ["containerIndex"],
                "properties" : {
		    "containerIndex": {
                        "description": "Program ID for Container",
                        "$ref" : "common.json#/definitions/index"
                    }
                }
            }
        },
        "containerUpdateList" : {
            "description" : "schema for bulk Container update, the number of entries that can be modified at a time is limited",
            "type" : "array",
            "minItems" : 1,
            "maxItems" : 10000,
	    "items" :{"$ref" : "#/definitions/updateContainer"}

        },
        "containerCreateList" : {
            "description" : "schema for bulk Container creation, the number of entries that can be modified at a time is limited",
            "type" : "array",
            "minItems" : 1,
            "maxItems" : 10000,
	    "items" :{"$ref" : "#/definitions/createContainer"}
        },
        "container" : {
            "description" : "define a TE++ container",
            "type" :"object",
	    "additionalProperties" : false,
	    "required" : ["containerIndex","name","from","to","minimumLSPCount","maximumLSPCount","mergingBandwidth","splittingBandwidth"],
            "properties" : {
		"containerIndex": {
                    "description": " Program ID for lsp",
                    "$ref" : "common.json#/definitions/index"
                },		
                "name": {
                    "description": "Container name, unique per from node, fixed once created",
                    "$ref" : "common.json#/definitions/name64"},
                "from": {
                    "description": "tunnel source address, should reference an interface or a node, same for all TE-LSP of a tunnel, fixed once created",
                    "oneOf" : [
			{"$ref" : "link.json#/definitions/ipv4Reference"}
                    ]
                },
                "to": {
                    "description": "tunnel destination, should reference an interface or a node, same for all TE-LSP of a tunnel, fixed once created",
                    "oneOf" : [
			{"$ref" : "link.json#/definitions/ipv4Reference"}
                    ]
                },
                "provisioningType" : {"description" : "Indicate the type of TE Path" , "type" : "string","enum":["RSVP","SR"],"default":"RSVP"},
                "creationConfigurationMethod" : {"description" : "This is the SouthBound protocol/interface used by NorthStar to create the LSP." , "type" : "string","enum":["PCEP"],"default":"PCEP"},
                "minimumLSPCount" : {
                    "description" : "The minimum number of sub-LSP in the container.",
                    "type": "integer",
                    "minimum": 1,
                    "default" : 1
                },
                "maximumLSPCount" : {
                    "description" : "The maximum number of sub-LSP in the container.",
                    "type": "integer",
                    "minimum": 0,
                    "default" : 64
                },
                "splittingBandwidth" : {
                    "description": "If the per-sub lsp bandwith (aggregated bandwidth/number of sub-LSPs) is greater than splittingBandwidth, new members will be created. The number of sub-LSPs created will be computed to be greater that (aggregatedBw/splittingBandwidth), but maximumLSPCount will take precedence. In addition  splittingBandwidth must be greater or equal to mergingBandwidth",
                    "$ref": "common.json#/definitions/Bandwidth"
                },
                "mergingBandwidth" : {
                    "description": "If the per-sub lsp bandwith (aggregated bandwidth/number of sub-LSPs) is lower than mergingBandwidth, LSPs will be deleted. Similarly with splittingBandwidth, the number of sub-lsps are computed to be less or equal to aggregatedBw/mergingBandwidth.",
                    "$ref": "common.json#/definitions/Bandwidth"
                },
                "minimumLSPBandwidth" : {
                    "description": "Minimum Member LSP bandwidth.",
                    "$ref": "common.json#/definitions/Bandwidth"
                },
                "maximumLSPBandwidth" : {
                    "description": "Maximum Member LSP bandwidth.",
                    "$ref": "common.json#/definitions/Bandwidth"
                },
		"subLSPProperties":{
		    "description" : "LSP planned properties, used to create the sub-lsps",
		    "additionalProperties" : false,
		    "$ref" : "#/definitions/subLspPlannedPathProperties"
		},
                "subLSPs" : {
                    "description" : "list of sub-lsps index and link",
                    "type" :"array",
                    "items" : {
                        "anyOf" : [
                            {"$ref" : "lsp.json#/definitions/lspReferenceIndex"},
                            {"$ref" : "common.json#/definitions/APILink"}
                        ]
                    }
                }
            }
        },        
        "createContainer" : {
            "description" : "Properties allowed on container creation",
            "type" :"object",
	    "additionalProperties" : false,
	    "required" : ["name","from","to","minimumLSPCount","maximumLSPCount","mergingBandwidth","splittingBandwidth"],
            "properties" : {			
                "name": {
                    "description": "Container name, unique per from node, fixed once created",
                    "$ref" : "common.json#/definitions/name64"},
                "from": {
                    "description": "tunnel source address, should reference an interface or a node, same for all TE-LSP of a tunnel, fixed once created",
                    "oneOf" : [
			{"$ref" : "link.json#/definitions/ipv4Reference"}
                    ]
                },
                "to": {
                    "description": "tunnel destination, should reference an interface or a node, same for all TE-LSP of a tunnel, fixed once created",
                    "oneOf" : [
			{"$ref" : "link.json#/definitions/ipv4Reference"}
                    ]
                },
                "provisioningType" : {"description" : "Indicate the type of TE Path" , "type" : "string","enum":["RSVP","SR"],"default":"RSVP"},
                "creationConfigurationMethod" : {"description" : "This is the SouthBound protocol/interface used by NorthStar to create the LSP." , "type" : "string","enum":["PCEP"],"default":"PCEP"},
                "minimumLSPCount" : {
                    "description" : "the minimum number of sub-LSP in the container",
                    "type": "integer",
                    "minimum": 1,
                    "default" : 1
                },
                "maximumLSPCount" : {
                    "description" : "the minimum number of sub-LSP in the container",
                    "type": "integer",
                    "minimum": 0,
                    "default" : 64
                },
                "splittingBandwidth" : {
                    "description": "If the per-sub lsp bandwith (aggregated bandwidth/number of sub-LSPs) is greater than splittingBandwidth, new members will be created splittingBandwidth>=mergingBandwidth",
                    "$ref": "common.json#/definitions/Bandwidth"
                },
                "mergingBandwidth" : {
                    "description": "If the per-sub lsp bandwith (aggregated bandwidth/number of sub-LSPs) is lower than mergingBandwidth, LSPs will be deleted",
                    "$ref": "common.json#/definitions/Bandwidth"
                },
                "minimumLSPBandwidth" : {
                    "description": "Minimum Member LSP bandwidth.",
                    "$ref": "common.json#/definitions/Bandwidth"
                },
                "maximumLSPBandwidth" : {
                    "description": "Maximum Member LSP bandwidth.",
                    "$ref": "common.json#/definitions/Bandwidth"
                },
		"subLSPProperties":{
		    "description" : "LSP planned properties, used to create the sub-lsps",
		    "additionalProperties" : false,
		    "$ref" : "#/definitions/subLspPlannedPathProperties"
		}
            }

        },
        "updateContainer" : {
            "description" : "Properties on modify",
            "type" :"object",
	    "additionalProperties" : false,
	    "required" : ["containerIndex","name","from","to","minimumLSPCount","maximumLSPCount","mergingBandwidth","splittingBandwidth"],
            "properties" : {
		"containerIndex": {
                    "description": " Program ID for lsp",
                    "$ref" : "common.json#/definitions/index"
                },		
                "name": {
                    "description": "Container name, unique per from node, fixed once created",
                    "$ref" : "common.json#/definitions/name64"},
                "from": {
                    "description": "tunnel source address, should reference an interface or a node, same for all TE-LSP of a tunnel, fixed once created",
                    "oneOf" : [
			{"$ref" : "link.json#/definitions/ipv4Reference"}
                    ]
                },
                "to": {
                    "description": "tunnel destination, should reference an interface or a node, same for all TE-LSP of a tunnel, fixed once created",
                    "oneOf" : [
			{"$ref" : "link.json#/definitions/ipv4Reference"}
                    ]
                },
                "provisioningType" : {"description" : "Indicate the type of TE Path" , "type" : "string","enum":["RSVP","SR"],"default":"RSVP"},
                "creationConfigurationMethod" : {"description" : "This is the SouthBound protocol/interface used by NorthStar to create the LSP." , "type" : "string","enum":["PCEP"],"default":"PCEP"},
                "minimumLSPCount" : {
                    "description" : "the minimum number of sub-LSP in the container",
                    "type": "integer",
                    "minimum": 1,
                    "default" : 1
                },
                "maximumLSPCount" : {
                    "description" : "the minimum number of sub-LSP in the container",
                    "type": "integer",
                    "minimum": 0,
                    "default" : 64
                },
                "splittingBandwidth" : {
                    "description": "If the per-sub lsp bandwith (aggregated bandwidth/number of sub-LSPs) is greater than splittingBandwidth, new members will be created splittingBandwidth>=mergingBandwidth",
                    "$ref": "common.json#/definitions/Bandwidth"
                },
                "mergingBandwidth" : {
                    "description": "If the per-sub lsp bandwith (aggregated bandwidth/number of sub-LSPs) is lower than mergingBandwidth, LSPs will be deleted",
                    "$ref": "common.json#/definitions/Bandwidth"
                },
                "minimumLSPBandwidth" : {
                    "description": "Minimum Member LSP bandwidth.",
                    "$ref": "common.json#/definitions/Bandwidth"
                },
                "maximumLSPBandwidth" : {
                    "description": "Maximum Member LSP bandwidth.",
                    "$ref": "common.json#/definitions/Bandwidth"
                },
		"subLSPProperties":{
		    "description" : "LSP planned properties, used to create the sub-lsps",
		    "additionalProperties" : false,
		    "$ref" : "#/definitions/subLspPlannedPathProperties"
		},
                "subLSPs" : {
                    "description" : "list of sub-lsps index and link. Ignored but allowed in the schema to ease modification.",
                    "type" :"array",
                    "items" : {
                        "anyOf" : [
                            {"$ref" : "lsp.json#/definitions/lspReferenceIndex"},
                            {"$ref" : "common.json#/definitions/APILink"}
                        ]
                    }
                }
            }
        },        
        "subLspPlannedPathProperties" : {
            "description" : "PLanned properties that can be inherited on on sub-lsps, this is a subset of the LSP plannedProperties lsp.json#/definitions/lspPlannedPathProperties",
            "type" :"object",
	    "additionalProperties" : false,
            "properties" : {
                "comment"           : {"description" : "Comment" , "type" : "string"},
		"setupPriority"     : {"description" : "Setup priority" , "type" : "integer", "minimum" : 0, "maximum" : 7},
                "holdingPriority"   : {"description" : "Holding priority" , "type" : "integer", "minimum" : 0, "maximum" : 7},
		"adminStatus"       : {"$ref" : "common.json#/definitions/adminStatus"},
		"metric"            : {"type" : "integer","description": "resulting IGP metric of the tunnel"},
                "design"            : {"$ref" : "lsp.json#/definitions/designParameters"},
                "policy"            : {"$ref" : "lsp.json#/definitions/plannedPolicies"},
		"ero": {
                    "type":"array",
		    "description" : "required explicit path",
                    "minItems" : 1,
                    "maxItems" : 255,
                    "items" : {"$ref" :"lsp.json#/definitions/EROHop"}
                },
		"preferredEro" : {
		    "description" : "desired explicit path--if not feasible NorthStar will calculate another path",
                    "type":"array",
                    "minItems" : 0,
                    "maxItems" : 255,
                    "items" : {"$ref" :"lsp.json#/definitions/EROHop"}
                },
                "xro": {
                    "type":"array",
		    "description" : "Exclusions as ERO HOP list. The loose flag not considered.",
                    "minItems" : 0,
                    "maxItems" : 255,
                    "items" : {"$ref" :"lsp.json#/definitions/EROHop"}
                },
		"preferredXro" : {
		    "description" : "Desired exclusions path, as ERO HOP list. The loose flag not considered. --if not feasible NorthStar will calculate another path",
                    "type":"array",
                    "minItems" : 0,
                    "maxItems" : 255,
                    "items" : {"$ref" :"lsp.json#/definitions/EROHop"}
                },	
                "userProperties" : {"$ref" : "userProperties.json#/definitions/lspUserProperties"},
		"bindingSID"       : {"description": "Binding SID assigned to the LSP",  "$ref" : "common.json#/definitions/SID"},
                "color": {"$ref": "common.json#/definitions/lspColor"}
            }
        },
        "containerReferenceIndex" : {
            "description" : "Object containing the minimum required information to reference a container.",
            "type" :"object",
	    "additionalProperties" : true,
	    "required" : ["containerIndex"],
            "properties" : {
		"containerIndex": {
                    "description": "Program ID for TE-Container",
                    "$ref" : "common.json#/definitions/index"
                }
            }
        }
    }
}
