{
    "$schema": "http://json-schema.org/draft-04/schema",
    "description": "Describes Constraints",
    "properties": {
        "constraint_sets": {
            "items": {
                "$schema": "http://json-schema.org/draft-04/schema#",
                "description": "Describes a Constraint Set",
                "minProperties": 1,
                "patternProperties": {
                    "^urn:(?!x-nmos)[a-z0-9][a-z0-9-]+:cap:meta:": {
                        "oneOf": [
                            {
                                "type": [
                                    "boolean",
                                    "integer",
                                    "number",
                                    "string",
                                    "null"
                                ]
                            },
                            {
                                "items": {
                                    "type": [
                                        "boolean",
                                        "integer",
                                        "number",
                                        "string"
                                    ]
                                },
                                "type": "array"
                            }
                        ]
                    },
                    "^urn:[a-z0-9][a-z0-9-]+:cap:(?!meta:)": {
                        "$schema": "http://json-schema.org/draft-04/schema#",
                        "anyOf": [
                            {
                                "$schema": "http://json-schema.org/draft-04/schema#",
                                "description": "Describes a String Parameter Constraint",
                                "properties": {
                                    "enum": {
                                        "items": {
                                            "type": "string"
                                        },
                                        "minItems": 1,
                                        "type": "array"
                                    }
                                },
                                "title": "String Parameter Constraint",
                                "type": "object"
                            },
                            {
                                "$schema": "http://json-schema.org/draft-04/schema#",
                                "description": "Describes an Integer Parameter Constraint",
                                "properties": {
                                    "enum": {
                                        "items": {
                                            "type": "integer"
                                        },
                                        "minItems": 1,
                                        "type": "array"
                                    },
                                    "maximum": {
                                        "type": "integer"
                                    },
                                    "minimum": {
                                        "type": "integer"
                                    }
                                },
                                "title": "Integer Parameter Constraint",
                                "type": "object"
                            },
                            {
                                "$schema": "http://json-schema.org/draft-04/schema#",
                                "description": "Describes a Number Parameter Constraint",
                                "properties": {
                                    "enum": {
                                        "items": {
                                            "type": "number"
                                        },
                                        "minItems": 1,
                                        "type": "array"
                                    },
                                    "maximum": {
                                        "type": "number"
                                    },
                                    "minimum": {
                                        "type": "number"
                                    }
                                },
                                "title": "Number Parameter Constraint",
                                "type": "object"
                            },
                            {
                                "$schema": "http://json-schema.org/draft-04/schema#",
                                "description": "Describes a Boolean Parameter Constraint",
                                "properties": {
                                    "enum": {
                                        "items": {
                                            "type": "boolean"
                                        },
                                        "minItems": 1,
                                        "type": "array"
                                    }
                                },
                                "title": "Boolean Parameter Constraint",
                                "type": "object"
                            },
                            {
                                "$schema": "http://json-schema.org/draft-04/schema#",
                                "definitions": {
                                    "rational": {
                                        "additionalProperties": false,
                                        "properties": {
                                            "denominator": {
                                                "default": 1,
                                                "type": "integer"
                                            },
                                            "numerator": {
                                                "type": "integer"
                                            }
                                        },
                                        "required": [
                                            "numerator"
                                        ],
                                        "type": "object"
                                    }
                                },
                                "description": "Describes a Rational Parameter Constraint",
                                "properties": {
                                    "enum": {
                                        "items": {
                                            "additionalProperties": false,
                                            "properties": {
                                                "denominator": {
                                                    "default": 1,
                                                    "type": "integer"
                                                },
                                                "numerator": {
                                                    "type": "integer"
                                                }
                                            },
                                            "required": [
                                                "numerator"
                                            ],
                                            "type": "object"
                                        },
                                        "minItems": 1,
                                        "type": "array"
                                    },
                                    "maximum": {
                                        "additionalProperties": false,
                                        "properties": {
                                            "denominator": {
                                                "default": 1,
                                                "type": "integer"
                                            },
                                            "numerator": {
                                                "type": "integer"
                                            }
                                        },
                                        "required": [
                                            "numerator"
                                        ],
                                        "type": "object"
                                    },
                                    "minimum": {
                                        "additionalProperties": false,
                                        "properties": {
                                            "denominator": {
                                                "default": 1,
                                                "type": "integer"
                                            },
                                            "numerator": {
                                                "type": "integer"
                                            }
                                        },
                                        "required": [
                                            "numerator"
                                        ],
                                        "type": "object"
                                    }
                                },
                                "title": "Rational Parameter Constraint",
                                "type": "object"
                            }
                        ],
                        "description": "Describes a Parameter Constraint",
                        "title": "Parameter Constraint",
                        "type": "object"
                    }
                },
                "properties": {
                    "urn:x-nmos:cap:meta:enabled": {
                        "default": true,
                        "description": "This value indicates whether a Constraint Set is available to use immediately (true) or whether this is an offline capability which can be activated via some unspecified configuration mechanism (false). When the attribute is omitted its value is assumed to be true.",
                        "type": "boolean"
                    },
                    "urn:x-nmos:cap:meta:label": {
                        "description": "Freeform string label for the Constraint Set",
                        "type": "string"
                    },
                    "urn:x-nmos:cap:meta:preference": {
                        "default": 0,
                        "description": "This value expresses the relative 'weight' that the Receiver assigns to its preference for the streams satisfied by the associated Constraint Set. The weight is an integer in the range -100 through 100, where -100 is least preferred and 100 is most preferred. When the attribute is omitted, the effective value for the associated Constraint Set is 0.",
                        "maximum": 100,
                        "minimum": -100,
                        "type": "integer"
                    }
                },
                "title": "Constraint Set",
                "type": "object"
            },
            "type": "array"
        }
    },
    "required": [
        "constraint_sets"
    ],
    "title": "Constraints",
    "type": "object"
}
