{
    "id": "p2mp.json",
    "title": "P2MP Tree API",
    "$schema": "http://json-schema.org/draft-04/schema#",
    "$ref": "#/definitions/p2mpList",
    "links": [
        {
            "title": "get all P2MP groups",
            "href": "/",
            "method": "GET",
            "rel": "instances",
            "schema": {
                "$ref": "#/definitions/p2mpList"
            }
        },
        {
            "title": "get a specific P2MP group",
            "href": "/{p2mpGroupIndex}",
            "method": "GET",
            "rel": "self",
            "schema": {
                "$ref": "#/definitions/p2mpGroup"
            }
        },
        {
            "title": "get SSE notification stream",
            "href": "/stream",
            "method": "GET"
        },
        {
            "title": "Modify a specific P2MP group, if the LSPS are not specified, all leaves will be deleted. If the LSPs are specified, the set of LSPs will be modified. I.e LSP not in the new list will be remove, the other will be added/updated",

            "href": "/{p2mpGroupIndex}",
            "method": "PUT",
            "rel": "self",
            "schema": {
                "$ref": "#/definitions/updateP2mpGroup"
            }
        },
        {
            "title": "PATCH  a p2mpGroup,if the LSPS are not specified, thecommon properties are changed, not the LSPs. If the LSPs are specified, the set of LSPs will be modified. I.e LSP not in the new list will be remove, the other will be added/updated",

            "href": "/{p2mpGroupIndex}",
            "description": "patch a maintance using an RFC6906 patch",
            "method": "PATCH",
            "rel": "self",
            "schema": {
                "$ref": "json-patch.json"
            }
        },
        {
            "title": "get a specific P2MP branch ",
            "href": "/{p2mpGroupIndex}/{lspIndex}",
            "method": "GET",
            "rel": "instance",
            "schema": {
                "$ref": "lsp.json#/definitions/lsp"
            }
        },
        {
            "title": "create a new P2MP group",
            "description": " Schema for input is createP2mpGroup",
            "href": "/",
            "method": "POST",
            "rel": "create",
            "schema": {
                "$ref": "#/definitions/createP2mpGroup"
            }
        },
        {
            "title": "Add new LSPS to the group",
            "description": " Schema for input is createP2mpLeavesList",
            "href": "/{p2mpGroupIndex}",
            "method": "POST",
            "rel": "create",
            "schema": {
                "$ref": "#/definitions/createP2mpLeavesList"
            }
        },
        {
            "title": "Remove an LSP from a group",
            "href": "/{p2mpGroupIndex}/{lspIndex}",
            "method": "DELETE"
        },
        {
            "title": "Remove an list of leaf LSP from a group",
            "href": "/{p2mpGroupIndex}/bulk",
            "method": "DELETE",
            "schema": {
                "$ref": "lsp.json#/definitions/lspListDelete"
            }
        },
        {
            "title": "delete a group",
            "href": "/{p2mpGroupIndex}",
            "method": "DELETE"
        },
        {
            "title": "Bulk group deletion",
            "href": "/bulk",
            "method": "DELETE",
            "schema": {
                "$ref": "lsp.json#/definitions/bulkDelete"
            }
        }
    ],
    "definitions": {
        "bulkDelete": {
            "description": "schema for bulk P2MP group delete, the number of entries that can be modified at a time is limited",

            "type": "array",
            "minItems": 1,
            "maxItems": 300,
            "items": {
                "description": "Minimum required ids.",
                "type": "object",
                "additionalProperties": true,
                "required": ["p2mpGroupIndex"],
                "properties": {
                    "p2mpGroupIndex": {
                        "description": " Program ID for P2MP group",
                        "$ref": "common.json#/definitions/index"
                    }
                }
            }
        },
        "p2mpList": {
            "type": "array",
            "items": {
                "$ref": "#/definitions/p2mpGroupSummary"
            }
        },
        "p2mpGroupReference": {
            "type": "object",
            "description": "Ids describing a P2MP group",
            "properties": {
                "topoObjectType": {
                    "type": "string",
                    "enum": ["p2mpGroup"]
                },
                "p2mpGroupIndex": {
                    "description": " Program ID for P2MP group",
                    "$ref": "common.json#/definitions/index"
                },
                "name": {
                    "type": "string",
                    "description": "P2MP group name"
                },
                "from": {
                    "description": "source address of the node where the P2MP tree is originating",
                    "oneOf": [
                        {
                            "$ref": "link.json#/definitions/ipv4Reference"
                        }
                    ]
                }
            },
            "not": {
                "type": "object",
                "required": ["lsps"],
                "properties": {
                    "lsps": {
                        "type": "array"
                    }
                }
            }
        },
        "p2mpGroupSummary": {
            "type": "object",
            "description": "P2MP group without the LSPs beeing expanded for performance reasons",
            "properties": {
                "topoObjectType": {
                    "type": "string",
                    "enum": ["p2mpGroup"]
                },
                "p2mpGroupIndex": {
                    "description": " Program ID for lsp",
                    "$ref": "common.json#/definitions/index"
                },
                "name": {
                    "type": "string",
                    "description": "P2MP group name"
                },
                "p2mpIndex": {
                    "description": "signaling protocol p2mp id, may be empty, same for all TE-LSP of a tunnel",
                    "type": "integer"
                },
                "from": {
                    "description": "source address of the node where the P2MP tree is originating",
                    "oneOf": [
                        {
                            "$ref": "link.json#/definitions/ipv4Reference"
                        }
                    ]
                },
                "creationConfigurationMethod": {
                    "description": "This is the SouthBound protocol/interface used by NorthStar to create the LSP.",
                    "type": "string",
                    "enum": ["PCEP", "NETCONF"],
                    "default": "NETCONF"
                },
                "links": {
                    "$ref": "common.json#/definitions/APILinkList",
                    "description": "Link to the p2mp group definition. The Links will contain the self relation"
                }
            }
        },
        "updateP2mpGroup": {           
            "type": "object",
            "properties": {
                "topoObjectType": {
                    "type": "string",
                    "enum": ["p2mpGroup"]
                },
                "p2mpGroupIndex": {
                    "description": " Program ID for lsp",
                    "$ref": "common.json#/definitions/index"
                },
                "name": {
                    "type": "string",
                    "description": "P2MP group name"
                },
                "p2mpIndex": {
                    "description": "signaling protocol p2mp id, may be empty, same for all TE-LSP of a tunnel",
                    "type": "integer"
                },
                "from": {
                    "description": "source address of the node where the P2MP tree is originating",
                    "oneOf": [
                        {
                            "$ref": "link.json#/definitions/ipv4Reference"
                        }
                    ]
                },
                "plannedProperties": {
                    "$ref": "lsp.json#/definitions/p2mpGroupCommonPlannedProperties"
                },
                "lsps": {
                    "$ref": "#/definitions/createP2mpLeafList"
                }
            }
        }, 
        "p2mpGroup": {
            "type": "object",
            "properties": {
                "topoObjectType": {
                    "type": "string",
                    "enum": ["p2mpGroup"]
                },
                "p2mpGroupIndex": {
                    "description": " Program ID for lsp",
                    "$ref": "common.json#/definitions/index"
                },
                "name": {
                    "type": "string",
                    "description": "P2MP group name"
                },
                "p2mpIndex": {
                    "description": "signaling protocol p2mp id, may be empty, same for all TE-LSP of a tunnel",
                    "type": "integer"
                },
                "from": {
                    "description": "source address of the node where the P2MP tree is originating",
                    "oneOf": [
                        {
                            "$ref": "link.json#/definitions/ipv4Reference"
                        }
                    ]
                },
                "creationConfigurationMethod": {
                    "description": "This is the SouthBound protocol/interface used by NorthStar to create the LSP.",
                    "type": "string",
                    "enum": ["PCEP", "NETCONF"],
                    "default": "NETCONF"
                },
                "plannedProperties": {
                    "$ref": "lsp.json#/definitions/p2mpGroupCommonPlannedProperties"
                },
                "lsps": {
                    "$ref": "lsp.json#/definitions/lspList"
                },
                "links": {
                    "$ref": "common.json#/definitions/APILinkList",
                    "description": "Link to the p2mp group definition. The Links will contain the self relation"
                }
            }
        },
        "createP2MPGroup": {
            "type": "object",
            "required": ["from", "lsps"],
            "properties": {
                "topoObjectType": {
                    "type": "string",
                    "enum": ["p2mpGroup"]
                },
                "name": {
                    "type": "string",
                    "description": "P2MP group name"
                },
                "from": {
                    "description": "source address of the node where the P2MP tree is originating",
                    "oneOf": [
                        {
                            "$ref": "link.json#/definitions/ipv4Reference"
                        }
                    ]
                },
                "plannedProperties": {
                    "$ref": "lsp.json#/definitions/p2mpGroupCommonPlannedProperties"
                },
                "lsps": {
                    "type": "array",
                    "minItems": 1,
                    "maxItems": 10000,
                    "items": {
                        "$ref": "lsp.json#/definitions/createP2MPMember"
                    }
                },
                "creationConfigurationMethod": {
                    "description": "This is the SouthBound protocol/interface used by NorthStar to create an LSP",
                    "type": "string",
                    "enum": ["PCEP", "NETCONF"]
                }
            }
        },
        "createP2mpGroup": {
            "anyOf": [
                {
                    "$ref": "#/definitions/createP2mpGroupPCEP"
                },
                {
                    "$ref": "#/definitions/createP2mpGroupNETCONF"
                }
            ]
        },
        "createP2mpGroupNETCONF": {
            "type": "object",
            "required": ["name", "from", "lsps"],
            "properties": {
                "topoObjectType": {
                    "type": "string",
                    "enum": ["p2mpGroup"]
                },
                "name": {
                    "type": "string",
                    "description": "P2MP group name"
                },
                "from": {
                    "description": "source address of the node where the P2MP tree is originating",
                    "oneOf": [
                        {
                            "$ref": "link.json#/definitions/ipv4Reference"
                        }
                    ]
                },
                "plannedProperties": {
                    "$ref": "lsp.json#/definitions/p2mpGroupCommonPlannedPropertiesNETCONF"
                },
                "lsps": {
                    "type": "array",
                    "minItems": 1,
                    "maxItems": 10000,
                    "items": {
                        "$ref": "lsp.json#/definitions/createP2MPMemberNETCONF"
                    }
                },
                "creationConfigurationMethod": {
                    "description": "This is the SouthBound protocol/interface used by NorthStar to create the LSP.l",
                    "type": "string",
                    "enum": ["NETCONF"],
                    "default": "NETCONF"
                }
            }
        },
        "createP2mpGroupPCEP": {
            "type": "object",
            "required": ["name", "from", "lsps", "creationConfigurationMethod"],
            "properties": {
                "topoObjectType": {
                    "type": "string",
                    "enum": ["p2mpGroup"]
                },
                "name": {
                    "type": "string",
                    "description": "P2MP group name"
                },
                "from": {
                    "description": "source address of the node where the P2MP tree is originating",
                    "oneOf": [
                        {
                            "$ref": "link.json#/definitions/ipv4Reference"
                        }
                    ]
                },
                "plannedProperties": {
                    "$ref": "lsp.json#/definitions/p2mpGroupCommonPlannedPropertiesPCEP"
                },
                "lsps": {
                    "type": "array",
                    "minItems": 1,
                    "maxItems": 10000,
                    "items": {
                        "$ref": "lsp.json#/definitions/createP2MPMemberPCEP"
                    }
                },
                "creationConfigurationMethod": {
                    "description": "This is the SouthBound protocol/interface used by NorthStar to create the LSP.l",
                    "type": "string",
                    "enum": ["PCEP"]
                }
            }
        },
        "createP2mpLeafList": {
            "description": "Depending on the group provisioning method, one schema or the other will be used. For PCEP the name is not allowed and generated by NorthStar.",
            "type": "array",
            "minItems": 1,
            "maxItems": 10000,
            "items": {
                "$ref": "lsp.json#/definitions/createP2MPMember"
            }
        },
        "createP2mpLeavesList": {
            "description": "Schema used to add leaves to P2MP Groups",
            "oneOf": [
                {"$ref": "#/definitions/createP2mpLeavesListPCEP"},
                {"$ref": "#/definitions/createP2mpLeavesListNETCONF"}
            ]

        },
        "createP2mpLeavesListPCEP": {
            "type": "array",
            "minItems": 1,
            "maxItems": 10000,
            "items": {
                "$ref": "lsp.json#/definitions/createP2MPMemberPCEP"
            }
        },
        "createP2mpLeavesListNETCONF": {
            "type": "array",
            "minItems": 1,
            "maxItems": 10000,
            "items": {
                "$ref": "lsp.json#/definitions/createP2MPMemberNETCONF"
            }
        }
    }
}
