{       
    "id" : "facilities.json",
    "title" : "API to access the nodes",
    "$schema": "http://json-schema.org/draft-04/schema#",
    "$ref" : "#/definitions/facilityList",
    "links" : [
	{
	    "title" : "get all Facilities",
	    "href" : "/",
	    "method" : "GET",
	    "rel" : "instances",
	    "schema" : {"$ref" : "#/definitions/facilityList"}
	},
	{
	    "title" : "get a given facility",
	    "href" : "/{facilityIndex}",
	    "method" : "GET",
	    "rel" : "self",
	    "schema" : {"$ref" : "#/definitions/facility"}
	},
        {"title" : "get SSE notification stream", "href" : "/stream","method" : "GET"},
	{
	    "title" : "create a new facility",
	    "description" : "Create a new facility, schema on request is #/definitions/createFacility",
	    "href" : "/",
	    "method" : "POST",
	    "rel" : "create",
	    "schema" : {"$ref" : "#/definitions/createFacility"},
            "targetSchema" : {"$ref" : "#/definitions/facility"}

	},
	{
	    "title" : "update a facility",
	    "href" : "/{facilityIndex}",
	    "description" : "Update an existing facility, schema on request is #/definitions/updateFacility",
	    "method" : "PUT",
	    "rel" : "self",	    
	    "schema" : {"$ref" : "#/definitions/updateFacility"},
            "targetSchema" : {"$ref" : "#/definitions/facility"}
	},
	{
	    "title" : "delete a facility",
	    "href" : "/{facilityIndex}",	    
	    "method" : "DELETE"
	}
    ],
    "definitions" : {
	"updateFacility" : {
            "$ref" : "#/definitions/facility"
	},
	"createFacility" : {
            "description" : "Schema for creating a facility",
	    "name" : "facility",
            "type" : "object",
	    "required" : ["topologyIndex","topoObjectType","name"],
            "properties": {
		"topoObjectType" : {"type" : "string","enum" : ["facility"]},
		"topologyIndex" : { "$ref" : "topology.json#/definitions/topologyIndex"},
                "name": {
                    "description": "Name of the facility. This parameter can be modified",
                    "$ref" : "common.json#/definitions/name",
                    "maxLength" : 255,
                    "minLength" : 1
                },
                "source": {
                    "description": "Identify who created the facility",
                    "type" :"string"
                },
                "comment": {
                    "description": "commnent",
                    "type" :"string"
                },
		"elements" : {
		    "description" : "List of elements part of this facility",
		    "type":"array",
		    "items" : {"$ref" : "#/definitions/facilityElement"}		    
		}
            }
	    
	},
        "facility" : {
            "description" : "Represent a single facility",
	    "name" : "facility",
            "type" : "object",
	    "required" : ["topologyIndex","topoObjectType","facilityIndex"],
            "properties": {
		"topoObjectType" : {"type" : "string","enum" : ["facility"]},
		"topologyIndex" : { "$ref" : "topology.json#/definitions/topologyIndex"},
                "facilityIndex": {
                    "description": "Program ID for facility",
                    "$ref" : "common.json#/definitions/index"                    
                },
                "id": {
                    "description": "Identifier of the facility. This parameter is fixed on creation and cannot be updated or chenged. Default for a facility created from BGP-LS is the SRLG, and for user-created nodes is the name",
                    "$ref" : "common.json#/definitions/name",
                    "maxLength" : 255,
                    "minLength" : 1
                },
                "name": {
                    "description": "Facility name (can be modified)",
                    "$ref" : "common.json#/definitions/name",
                    "maxLength" : 255,
                    "minLength" : 1
                },
                "source": {
                    "description": "Identify who created the facility",
                    "type" :"string"
                },
                "comment": {
                    "description": "commnent",
                    "type" :"string"
                },
		"elements" : {
		    "description" : "List of elements part of this facility",
		    "type":"array",
		    "items" : {"$ref" : "#/definitions/facilityElement"}		    
		}
            }
        },
	"facilityElement" : {
	    "type" : "object",
	    "required" : ["id","topoObjectType"],
	    "properties": {
		"id" : {"type":"string","description":"The id of the link, node or interface, depending on the type", "minLength" : 1},
		"topoObjectType" : {"type" : "string", "enum":["node","link","interface"]}
	    }
	},
	"facilityList" : {
	    "type" : "array",
	    "items" : {"$ref" : "#/definitions/facility"}	    
	},
        "facilityReference" : {
            "description" : "Reference to a facility",
            "type" : "object",
	    "required" : ["facilityIndex", "topoObjectType"],
            "properties": {
                "topoObjectType" : {"type" : "string","enum" : ["facility"]},
                "facilityIndex": {
                    "description": "Program ID for facility",
                    "$ref" : "common.json#/definitions/index"                    
                }
            }
        }        
    }  
}
