From 31af36c52e690e827f97f32a878643396b0b966f Mon Sep 17 00:00:00 2001 From: Gareth Sylvester-Bradley Date: Tue, 16 May 2023 17:21:44 +0100 Subject: [PATCH 1/3] Add and use constraint_set.json and dependencies from BCP-004-01 v1.0 and resource_core.json from IS-04 v1.3.2 --- APIs/schemas/constraint_set.json | 30 ++++++++++++++ APIs/schemas/constraints_active.json | 2 +- APIs/schemas/empty_constraints_active.json | 2 +- APIs/schemas/input.json | 2 +- APIs/schemas/output.json | 2 +- APIs/schemas/param_constraint.json | 13 ++++++ APIs/schemas/param_constraint_boolean.json | 15 +++++++ APIs/schemas/param_constraint_integer.json | 21 ++++++++++ APIs/schemas/param_constraint_number.json | 21 ++++++++++ APIs/schemas/param_constraint_rational.json | 39 ++++++++++++++++++ APIs/schemas/param_constraint_string.json | 15 +++++++ APIs/schemas/resource_core.json | 45 +++++++++++++++++++++ 12 files changed, 203 insertions(+), 4 deletions(-) create mode 100644 APIs/schemas/constraint_set.json create mode 100644 APIs/schemas/param_constraint.json create mode 100644 APIs/schemas/param_constraint_boolean.json create mode 100644 APIs/schemas/param_constraint_integer.json create mode 100644 APIs/schemas/param_constraint_number.json create mode 100644 APIs/schemas/param_constraint_rational.json create mode 100644 APIs/schemas/param_constraint_string.json create mode 100644 APIs/schemas/resource_core.json diff --git a/APIs/schemas/constraint_set.json b/APIs/schemas/constraint_set.json new file mode 100644 index 0000000..ab439d3 --- /dev/null +++ b/APIs/schemas/constraint_set.json @@ -0,0 +1,30 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "description": "Describes a Constraint Set", + "title": "Constraint Set", + "type": "object", + "minProperties": 1, + "properties": { + "urn:x-nmos:cap:meta:label": { + "description": "Freeform string label for the Constraint Set", + "type": "string" + }, + "urn:x-nmos:cap:meta:preference": { + "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.", + "type": "integer", + "default": 0, + "maximum": 100, + "minimum": -100 + }, + "urn:x-nmos:cap:meta:enabled": { + "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", + "default": true + } + }, + "patternProperties": { + "^urn:x-nmos:cap:(?!meta:)": { + "$ref": "param_constraint.json" + } + } +} diff --git a/APIs/schemas/constraints_active.json b/APIs/schemas/constraints_active.json index b9a9253..539dbec 100644 --- a/APIs/schemas/constraints_active.json +++ b/APIs/schemas/constraints_active.json @@ -10,7 +10,7 @@ "constraint_sets": { "type": "array", "items": { - "$ref": "https://github.com/AMWA-TV/bcp-004-01/raw/v1.0.x/APIs/schemas/constraint_set.json" + "$ref": "constraint_set.json" } } } diff --git a/APIs/schemas/empty_constraints_active.json b/APIs/schemas/empty_constraints_active.json index 6a9627b..a75a5e2 100644 --- a/APIs/schemas/empty_constraints_active.json +++ b/APIs/schemas/empty_constraints_active.json @@ -9,7 +9,7 @@ "constraint_sets": { "type": "array", "items": { - "$ref": "https://raw.githubusercontent.com/AMWA-TV/nmos-receiver-capabilities/v1.0.0/APIs/schemas/constraint_set.json" + "$ref": "constraint_set.json" }, "minItems": 0, "maxItems": 0 diff --git a/APIs/schemas/input.json b/APIs/schemas/input.json index 4effb85..c99a7a3 100644 --- a/APIs/schemas/input.json +++ b/APIs/schemas/input.json @@ -4,7 +4,7 @@ "description": "Describes an Input", "title": "Input resource", "allOf": [ - { "$ref": "https://raw.githubusercontent.com/AMWA-TV/nmos-discovery-registration/v1.3.1/APIs/schemas/resource_core.json" }, + { "$ref": "resource_core.json" }, { "type": "object", "required": [ diff --git a/APIs/schemas/output.json b/APIs/schemas/output.json index c0b479c..d2b7e51 100644 --- a/APIs/schemas/output.json +++ b/APIs/schemas/output.json @@ -4,7 +4,7 @@ "description": "Describes an Output", "title": "Output resource", "allOf": [ - { "$ref": "https://raw.githubusercontent.com/AMWA-TV/nmos-discovery-registration/v1.3.1/APIs/schemas/resource_core.json" }, + { "$ref": "resource_core.json" }, { "type": "object", "required": [ diff --git a/APIs/schemas/param_constraint.json b/APIs/schemas/param_constraint.json new file mode 100644 index 0000000..0537109 --- /dev/null +++ b/APIs/schemas/param_constraint.json @@ -0,0 +1,13 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "description": "Describes a Parameter Constraint", + "title": "Parameter Constraint", + "type": "object", + "anyOf": [ + { "$ref": "param_constraint_string.json" }, + { "$ref": "param_constraint_integer.json" }, + { "$ref": "param_constraint_number.json" }, + { "$ref": "param_constraint_boolean.json" }, + { "$ref": "param_constraint_rational.json" } + ] +} diff --git a/APIs/schemas/param_constraint_boolean.json b/APIs/schemas/param_constraint_boolean.json new file mode 100644 index 0000000..fac6b99 --- /dev/null +++ b/APIs/schemas/param_constraint_boolean.json @@ -0,0 +1,15 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "description": "Describes a Boolean Parameter Constraint", + "title": "Boolean Parameter Constraint", + "type": "object", + "properties": { + "enum": { + "type": "array", + "minItems": 1, + "items": { + "type": "boolean" + } + } + } +} diff --git a/APIs/schemas/param_constraint_integer.json b/APIs/schemas/param_constraint_integer.json new file mode 100644 index 0000000..35c5aec --- /dev/null +++ b/APIs/schemas/param_constraint_integer.json @@ -0,0 +1,21 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "description": "Describes an Integer Parameter Constraint", + "title": "Integer Parameter Constraint", + "type": "object", + "properties": { + "enum": { + "type": "array", + "minItems": 1, + "items": { + "type": "integer" + } + }, + "minimum": { + "type": "integer" + }, + "maximum": { + "type": "integer" + } + } +} diff --git a/APIs/schemas/param_constraint_number.json b/APIs/schemas/param_constraint_number.json new file mode 100644 index 0000000..24a93c1 --- /dev/null +++ b/APIs/schemas/param_constraint_number.json @@ -0,0 +1,21 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "description": "Describes a Number Parameter Constraint", + "title": "Number Parameter Constraint", + "type": "object", + "properties": { + "enum": { + "type": "array", + "minItems": 1, + "items": { + "type": "number" + } + }, + "minimum": { + "type": "number" + }, + "maximum": { + "type": "number" + } + } +} diff --git a/APIs/schemas/param_constraint_rational.json b/APIs/schemas/param_constraint_rational.json new file mode 100644 index 0000000..31a8db6 --- /dev/null +++ b/APIs/schemas/param_constraint_rational.json @@ -0,0 +1,39 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "description": "Describes a Rational Parameter Constraint", + "title": "Rational Parameter Constraint", + "type": "object", + "properties": { + "enum": { + "type": "array", + "minItems": 1, + "items": { + "$ref": "#/definitions/rational" + } + }, + "minimum": { + "$ref": "#/definitions/rational" + }, + "maximum": { + "$ref": "#/definitions/rational" + } + }, + "definitions": { + "rational": { + "type": "object", + "required": [ + "numerator" + ], + "properties": { + "numerator": { + "type": "integer" + }, + "denominator": { + "type": "integer", + "default": 1 + } + }, + "additionalProperties": false + } + } +} diff --git a/APIs/schemas/param_constraint_string.json b/APIs/schemas/param_constraint_string.json new file mode 100644 index 0000000..a866008 --- /dev/null +++ b/APIs/schemas/param_constraint_string.json @@ -0,0 +1,15 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "description": "Describes a String Parameter Constraint", + "title": "String Parameter Constraint", + "type": "object", + "properties": { + "enum": { + "type": "array", + "minItems": 1, + "items": { + "type": "string" + } + } + } +} diff --git a/APIs/schemas/resource_core.json b/APIs/schemas/resource_core.json new file mode 100644 index 0000000..4bb69f8 --- /dev/null +++ b/APIs/schemas/resource_core.json @@ -0,0 +1,45 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "type": "object", + "description": "Describes the foundations of all NMOS resources", + "title": "Base resource", + "required": [ + "id", + "version", + "label", + "description", + "tags" + ], + "properties": { + "id": { + "description": "Globally unique identifier for the resource", + "type": "string", + "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$" + }, + "version": { + "description": "String formatted TAI timestamp (:) indicating precisely when an attribute of the resource last changed", + "type": "string", + "pattern": "^[0-9]+:[0-9]+$" + }, + "label": { + "description": "Freeform string label for the resource", + "type": "string" + }, + "description": { + "description": "Detailed description of the resource", + "type": "string" + }, + "tags": { + "description": "Key value set of freeform string tags to aid in filtering resources. Values should be represented as an array of strings. Can be empty.", + "type": "object", + "patternProperties": { + "": { + "type": "array", + "items": { + "type": "string" + } + } + } + } + } +} From d5147a774050b8dad8e10061e2f07b759f1bd683 Mon Sep 17 00:00:00 2001 From: N-Nagorny Date: Sat, 1 Jul 2023 01:23:49 +0400 Subject: [PATCH 2/3] Add APIs/schemas/README.md --- APIs/schemas/README.md | 16 ++++++++++++++++ APIs/schemas/resource_core.json | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 APIs/schemas/README.md diff --git a/APIs/schemas/README.md b/APIs/schemas/README.md new file mode 100644 index 0000000..3e2433f --- /dev/null +++ b/APIs/schemas/README.md @@ -0,0 +1,16 @@ +This directory is for JSON Schemas used in documentation. Some of them were copied from other AMWA NMOS specifications. + +[IS-04 v1.3.2]: +- [resource_core.json](https://github.com/AMWA-TV/is-04/raw/v1.3.2/APIs/schemas/resource_core.json) + +[BCP-004-01 v1.0.0]: +- [constraint_set.json](https://github.com/AMWA-TV/bcp-004-01/raw/v1.0.0/APIs/schemas/constraint_set.json) +- [param_constraint.json](https://github.com/AMWA-TV/bcp-004-01/raw/v1.0.0/APIs/schemas/param_constraint.json) +- [param_constraint_boolean.json](https://github.com/AMWA-TV/bcp-004-01/raw/v1.0.0/APIs/schemas/param_constraint_boolean.json) +- [param_constraint_integer.json](https://github.com/AMWA-TV/bcp-004-01/raw/v1.0.0/APIs/schemas/param_constraint_integer.json) +- [param_constraint_number.json](https://github.com/AMWA-TV/bcp-004-01/raw/v1.0.0/APIs/schemas/param_constraint_number.json) +- [param_constraint_rational.json](https://github.com/AMWA-TV/bcp-004-01/raw/v1.0.0/APIs/schemas/param_constraint_rational.json) +- [param_constraint_string.json](https://github.com/AMWA-TV/bcp-004-01/raw/v1.0.0/APIs/schemas/param_constraint_string.json) + +[IS-04 v1.3.2]: https://specs.amwa.tv/is-04/releases/v1.3.2/ +[BCP-004-01 v1.0.0]: https://specs.amwa.tv/bcp-004-01/releases/v1.0.0/ diff --git a/APIs/schemas/resource_core.json b/APIs/schemas/resource_core.json index 4bb69f8..4eb583a 100644 --- a/APIs/schemas/resource_core.json +++ b/APIs/schemas/resource_core.json @@ -42,4 +42,4 @@ } } } -} +} \ No newline at end of file From c442a945a13fcb2dc14bd15f1c5f051fcf83798e Mon Sep 17 00:00:00 2001 From: N-Nagorny Date: Sat, 1 Jul 2023 01:25:54 +0400 Subject: [PATCH 3/3] Add trailing []s --- APIs/schemas/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/APIs/schemas/README.md b/APIs/schemas/README.md index 3e2433f..e984750 100644 --- a/APIs/schemas/README.md +++ b/APIs/schemas/README.md @@ -1,9 +1,9 @@ This directory is for JSON Schemas used in documentation. Some of them were copied from other AMWA NMOS specifications. -[IS-04 v1.3.2]: +[IS-04 v1.3.2][]: - [resource_core.json](https://github.com/AMWA-TV/is-04/raw/v1.3.2/APIs/schemas/resource_core.json) -[BCP-004-01 v1.0.0]: +[BCP-004-01 v1.0.0][]: - [constraint_set.json](https://github.com/AMWA-TV/bcp-004-01/raw/v1.0.0/APIs/schemas/constraint_set.json) - [param_constraint.json](https://github.com/AMWA-TV/bcp-004-01/raw/v1.0.0/APIs/schemas/param_constraint.json) - [param_constraint_boolean.json](https://github.com/AMWA-TV/bcp-004-01/raw/v1.0.0/APIs/schemas/param_constraint_boolean.json)