diff --git a/api/config.py b/api/config.py index 186ed608ae7c2181ccf619807dfaaaa92e798a6a..8bc5375bc230a1112b911c3f0091d79aa07b978c 100644 --- a/api/config.py +++ b/api/config.py @@ -171,7 +171,7 @@ expected_input_schemas = set([ 'project.json', 'project-template.json', 'project-update.json', - 'rule-add.json', + 'rule-new.json', 'rule-update.json', 'session.json', 'session-update.json', diff --git a/api/jobs/handlers.py b/api/jobs/handlers.py index 52d797f09d75b1bf5897f8dc0cf31e490e8b8554..478599dbbf9ab2c3570e99ba81ca24156a1455d7 100644 --- a/api/jobs/handlers.py +++ b/api/jobs/handlers.py @@ -175,7 +175,7 @@ class RulesHandler(base.RequestHandler): doc = self.request.json - validate_data(doc, 'rule-add.json', 'input', 'POST', optional=True) + validate_data(doc, 'rule-new.json', 'input', 'POST', optional=True) try: get_gear_by_name(doc['alg']) except APINotFoundException: diff --git a/raml/schemas/definitions/rule.json b/raml/schemas/definitions/rule.json index 64f8553f1db87b5d912b131206db6873fdf05184..f6904596e7674f1946d4ac43bb97540600351e4d 100644 --- a/raml/schemas/definitions/rule.json +++ b/raml/schemas/definitions/rule.json @@ -1,22 +1,50 @@ { "$schema": "http://json-schema.org/draft-04/schema#", - "type": "object", - "properties": { - "alg": { - "type": "string" - }, - "all":{ - "type":"array", - "items":{ - "type":"array", - "items":{ - "type":"string" - } + "definitions": { + "rule-items": { + "type": "array", + "items": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": [ + "file.type", + "file.name", + "file.measurements", + "container.has-type", + "container.has-measurement" + ] + }, + "value": { "type": "string" } + }, + "required": [ "type", "value" ], + "additionalProperties": false + } + }, + + "rule-input": { + "type": "object", + "properties": { + "_id": { "type": "string" }, + "project_id": { "type": "string" }, + "alg": { "type": "string" }, + "name": { "type": "string" }, + "any": { "$ref": "#/definitions/rule-items" }, + "all": { "$ref": "#/definitions/rule-items" } + }, + "additionalProperties": false + }, + + "rule-output": { + "type": "object", + "properties": { + "_id": { "type": "string" }, + "alg": { "type": "string" }, + "name": { "type": "string" }, + "any": { "$ref": "#/definitions/rule-items" }, + "all": { "$ref": "#/definitions/rule-items" } + } } - } - }, - "required": [ - "alg", - "all" - ] + } } diff --git a/raml/schemas/input/rule-add.json b/raml/schemas/input/rule-add.json deleted file mode 100644 index bf41dde0b862c13dad873c79eed9ad69ba1d0715..0000000000000000000000000000000000000000 --- a/raml/schemas/input/rule-add.json +++ /dev/null @@ -1,62 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-04/schema#", - "title": "rule", - "type": "object", - "properties": { - "alg": { - "type": "string" - }, - "name": { - "type": "string" - }, - "any": { - "type": "array", - "items": { - "type": "object", - "properties": { - "type": { - "type": "string", - "enum": [ - "file.type", - "file.name", - "file.measurements", - "container.has-type", - "container.has-measurement" - ] - }, - "value": { - "type": "string" - } - } - } - }, - "all": { - "type": "array", - "items": { - "type": "object", - "properties": { - "type": { - "type": "string", - "enum": [ - "file.type", - "file.name", - "file.measurements", - "container.has-type", - "container.has-measurement" - ] - }, - "value": { - "type": "string" - } - } - } - } - }, - "required": [ - "alg", - "all", - "any", - "name" - ], - "additionalProperties": false -} diff --git a/raml/schemas/input/rule-new.json b/raml/schemas/input/rule-new.json new file mode 100644 index 0000000000000000000000000000000000000000..c456eaec4c2662f9ad060cc397b46b682f63c64c --- /dev/null +++ b/raml/schemas/input/rule-new.json @@ -0,0 +1,7 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "Rule", + "type": "object", + "allOf": [{"$ref": "../definitions/rule.json#/definitions/rule-input"}], + "required": ["alg", "name", "any", "all"] +} diff --git a/raml/schemas/input/rule-update.json b/raml/schemas/input/rule-update.json index 2db5a226703f5b91169c3d274ef60529fbb6c755..31ffc6d6023a7d57fc4c77f5a31bc98628a8241c 100644 --- a/raml/schemas/input/rule-update.json +++ b/raml/schemas/input/rule-update.json @@ -1,62 +1,6 @@ { "$schema": "http://json-schema.org/draft-04/schema#", - "title": "rule", + "title": "Rule", "type": "object", - "properties": { - "_id": { - "type": "string" - }, - "project_id": { - "type": "string" - }, - "alg": { - "type": "string" - }, - "name": { - "type": "string" - }, - "any": { - "type": "array", - "items": { - "type": "object", - "properties": { - "type": { - "type": "string", - "enum": [ - "file.type", - "file.name", - "file.measurements", - "container.has-type", - "container.has-measurement" - ] - }, - "value": { - "type": "string" - } - } - } - }, - "all": { - "type": "array", - "items": { - "type": "object", - "properties": { - "type": { - "type": "string", - "enum": [ - "file.type", - "file.name", - "file.measurements", - "container.has-type", - "container.has-measurement" - ] - }, - "value": { - "type": "string" - } - } - } - } - }, - "additionalProperties": false + "allOf": [{"$ref": "../definitions/rule.json#/definitions/rule-input"}] } diff --git a/raml/schemas/output/rule-list.json b/raml/schemas/output/rule-list.json new file mode 100644 index 0000000000000000000000000000000000000000..fffc98fe82dd5e0c5e78f4b26643c2169555cc4d --- /dev/null +++ b/raml/schemas/output/rule-list.json @@ -0,0 +1,5 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "type": "array", + "items": { "$ref": "../definitions/rule.json#/definitions/rule-output" } +} diff --git a/raml/schemas/output/rules-list.json b/raml/schemas/output/rules-list.json deleted file mode 100644 index 22c31bcbf81f61a8469309c85c56a088e79cf464..0000000000000000000000000000000000000000 --- a/raml/schemas/output/rules-list.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-04/schema#", - "type": "array", - "items": { - "$ref":"../definitions/rule.json#" - } -}