diff --git a/TESTING.md b/TESTING.md index a6c1681716af0d211ad9f0fa8c24aba1433a1950..af53c2100fcd697ab3aaef8b4937fbdbb6282e22 100644 --- a/TESTING.md +++ b/TESTING.md @@ -13,7 +13,6 @@ All tests are executed by default. Subsets can be run using the filtering option * To run linting, use `--lint` (`-l`) * To run unit tests, use `--unit` (`-u`) * To run integration tests, use `--integ` (`-i`) -* To run abao tests, use `--abao` (`-a`) * To pass any arguments to `py.test`, use `-- PYTEST_ARGS` See [py.test usage](https://docs.pytest.org/en/latest/usage.html) for more. @@ -34,11 +33,3 @@ Without rebuilding the image, run only integration tests matching `foo`, use the ``` **NOTE:** The mongodb version is pinned via the `MONGO_VERSION` variable in `tests/bin/run-tests-docker.sh`. - -### Tools -- [abao](https://github.com/cybertk/abao/) - -### Testing API against RAML with Abao -Abao is one of the testing tools run during our TravisCI build. It tests the API implementation against what鈥檚 defined in the RAML spec. Adding a new resource / url to the RAML spec will cause Abao to verify that resource during integration tests. Sometimes abao cannot properly test a resource (file field uploads) or a test may require chaining variable. Abao has before and after hooks for tests, written in javascript. These can be used to skip a test, inject variables into the request, or make extra assertions about the response. See tests/integration/abao in the repo for the hooks file. See [abao github readme](https://github.com/cybertk/abao/blob/master/README.md) for more information on how to use hooks. - -Abao tests can depend on specific resources (eg. group, project, session, etc.) pre-existing in the DB. That resource loading should be maintained within `tests/integration_tests/abao/load_fixture.py` and is executed automatically via the integration test scripts at `test/bin`. diff --git a/api/config.py b/api/config.py index 74657503d1b0904aa8660ff2c5cc8e094ec385b6..58b9eaba1c74a0ad74c9b41b5b87489da3c79f6e 100644 --- a/api/config.py +++ b/api/config.py @@ -157,7 +157,6 @@ expected_input_schemas = set([ 'avatars.json', 'collection.json', 'collection-update.json', - 'container.json', 'device.json', 'file.json', 'file-update.json', @@ -182,8 +181,7 @@ expected_input_schemas = set([ 'enginemetadata.json', 'labelupload.json', 'uidupload.json', - 'uidmatchupload.json', - 'search.json' + 'uidmatchupload.json' ]) mongo_schemas = set() input_schemas = set() diff --git a/raml/examples/input/acquisition-update.json b/raml/examples/input/acquisition-update.json deleted file mode 100644 index bb0a63619ff34985c1316fc391622fb92c40cc64..0000000000000000000000000000000000000000 --- a/raml/examples/input/acquisition-update.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "label": "example-acquisition-new-label" -} diff --git a/raml/examples/input/acquisition.json b/raml/examples/input/acquisition.json deleted file mode 100644 index 09d29718cefc38319f845f2d047e60945944cebc..0000000000000000000000000000000000000000 --- a/raml/examples/input/acquisition.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "label": "example-acquisition", - "session": "57e45328466d8e000e33a85b", - "public": false -} diff --git a/raml/examples/input/analysis-job.json b/raml/examples/input/analysis-job.json deleted file mode 100644 index dcc0e303d77d95e2dbe75e1d0c413a3a5db17d26..0000000000000000000000000000000000000000 --- a/raml/examples/input/analysis-job.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "analysis": { - "label": "Test Analysis 1" - }, - "job" : { - "gear": "dcm_convert", - "inputs": { - "dicom": { - "type": "acquisition", - "id": "57081d06b386a6dc79ca386b", - "name" : "test_acquisition_dicom.zip" - } - }, - "tags": ["example"] - } -} diff --git a/raml/examples/input/analysis.json b/raml/examples/input/analysis.json index df5172f7f6dda6d1a27fe2e11bb8194cf2d33789..57a68f4fe6262f7acd3a9a1571f9f96cf4b4c2ac 100644 --- a/raml/examples/input/analysis.json +++ b/raml/examples/input/analysis.json @@ -43,5 +43,5 @@ "description": "This is an analysis description", "job": "54759eb3c090d83494e2d804", "label": "Analysis label", - "user": "user_1" -} \ No newline at end of file + "user": "canakgun@flywheel.io" +} diff --git a/raml/examples/input/collection-update.json b/raml/examples/input/collection-update.json deleted file mode 100644 index a5ba22e911c70a8648347309faec92282bb63b06..0000000000000000000000000000000000000000 --- a/raml/examples/input/collection-update.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "contents": { - "operation": "add", - "nodes": [{ - "level": "session", - "_id": "57dc50b0931cefd8ac2a371e" - }] - } -} diff --git a/raml/examples/input/collection.json b/raml/examples/input/collection.json deleted file mode 100644 index 3a3b621a34d20352d30ddd7ffbc8ce39c0b1d699..0000000000000000000000000000000000000000 --- a/raml/examples/input/collection.json +++ /dev/null @@ -1 +0,0 @@ -{"label":"control-group","description":"Control group collection"} diff --git a/raml/examples/input/device.json b/raml/examples/input/device.json deleted file mode 100644 index a3c4f9c39a9b357aea7cc9b07519a94275cd4540..0000000000000000000000000000000000000000 --- a/raml/examples/input/device.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "info": { - "basic": "info" - }, - "errors": [ - "An Error" - ], - "interval": 400 -} diff --git a/raml/examples/input/group-new.json b/raml/examples/input/group-new.json deleted file mode 100644 index 855d960bbb64d905f30f98bae0e9e66a55d6734a..0000000000000000000000000000000000000000 --- a/raml/examples/input/group-new.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "label": "Example Group", - "_id": "example_group" -} diff --git a/raml/examples/input/group-update.json b/raml/examples/input/group-update.json deleted file mode 100644 index ab1189cddb41b6dd83c1d11f3a109c4fc06095e0..0000000000000000000000000000000000000000 --- a/raml/examples/input/group-update.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "label":"New group label" -} diff --git a/raml/examples/input/note.json b/raml/examples/input/note.json deleted file mode 100644 index a7083fe751b759d69868fd6d72f52953652354bd..0000000000000000000000000000000000000000 --- a/raml/examples/input/note.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "text":"Scitran core!" -} diff --git a/raml/examples/input/permission.json b/raml/examples/input/permission.json deleted file mode 100644 index 7a6ecbf7a9fbb976cae976b172c74a1f82d5aae6..0000000000000000000000000000000000000000 --- a/raml/examples/input/permission.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "_id":"coltonlw@flywheel.io", - "access":"admin" -} diff --git a/raml/examples/input/tag.json b/raml/examples/input/tag.json deleted file mode 100644 index 64af535353a0a19503ee1be11adbcb4f58fb172a..0000000000000000000000000000000000000000 --- a/raml/examples/input/tag.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "value":"example-tag" -} diff --git a/raml/examples/input/user-new.json b/raml/examples/input/user-new.json deleted file mode 100755 index c02daedf24d31afb0445c81b90405a068f76e47e..0000000000000000000000000000000000000000 --- a/raml/examples/input/user-new.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "_id": "jane.doe@gmail.com", - "firstname": "Jane", - "lastname": "Doe", - "email": "jane.doe@gmail.com", - "root": false -} diff --git a/raml/examples/input/user-update.json b/raml/examples/input/user-update.json deleted file mode 100644 index 7b9da1c4eece71fa086e20513dd871c229b90f46..0000000000000000000000000000000000000000 --- a/raml/examples/input/user-update.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "firstname": "Jane", - "lastname": "Smith", - "email": "jane.smith@gmail.com" -} diff --git a/raml/examples/output/job-list.json b/raml/examples/output/job-list.json index 5103e17118d9997d6427bd042b97371a977c6cf2..653ffd4d7e0739e62544824897ff39f9887a2311 100755 --- a/raml/examples/output/job-list.json +++ b/raml/examples/output/job-list.json @@ -1,13 +1,12 @@ [ { - "inputs": [ - { - "input": "dicom", - "type": "acquisition", - "id": "57d75ec38e4eb9699b3c245e", - "name": "1_1_dicom.zip" - } - ], + "inputs": { + "dicom": { + "type": "acquisition", + "id": "57d75ec38e4eb9699b3c245e", + "name": "1_1_dicom.zip" + } + }, "attempt": 1, "gear_id": "dcm-convert", "tags": [ @@ -20,20 +19,19 @@ "modified": "2016-08-11T12:46:12.593000+00:00", "created": "2016-08-11T12:46:12.593000+00:00", "state": "pending", - "_id": "57ac7394c700190017123fb8", + "id": "57ac7394c700190017123fb8", "config":{ "speed":3 } }, { - "inputs": [ - { - "input":"dicom", + "inputs": { + "dicom": { "type": "acquisition", "id": "57ac7394c700190017123fb7", "name": "8403_4_1_t1_dicom.zip" } - ], + }, "attempt": 1, "gear_id": "dcm_convert", "tags": [ @@ -47,7 +45,7 @@ "modified": "2016-08-11T13:02:09.055000+00:00", "created": "2016-08-11T13:02:09.055000+00:00", "state": "pending", - "_id": "57ac77515e325c0018cd17cf", + "id": "57ac77515e325c0018cd17cf", "config":{ "speed":3 } diff --git a/raml/examples/output/job-next.json b/raml/examples/output/job-next.json deleted file mode 100755 index 42137ba411bf06119de50842697bdede15d3d274..0000000000000000000000000000000000000000 --- a/raml/examples/output/job-next.json +++ /dev/null @@ -1,44 +0,0 @@ -{ - "inputs": [{ - "input": "dicom", - "type": "acquisition", - "id": "57e45279a74e91000ed6898f", - "name": "4784_1_1_localizer_dicom.zip" - }], - "attempt": 1, - "gear_id": "dicom-mr-classifier", - "tags": ["dicom-mr-classifier"], - "destination": { - "type": "acquisition", - "id": "57e45279a74e91000ed6898f" - }, - "request": { - "inputs": [{ - "vu": "vu0:sha384:tXvdI2pspng-YH6lwa2UcLsww0yR6LfEKbLm89eIqEGicLRHW9d1V8bs7gXHTlZ3", - "type": "http", - "location": "/", - "uri": "https://storage.googleapis.com/flywheel/gears/v1/scitran/dicom-mr-classifier/dicom-mr-classifier_latest_20160803T220847.856417Z.tar.gz" - }, { - "type": "scitran", - "uri": "/acquisitions/57e45279a74e91000ed6898f/files/4784_1_1_localizer_dicom.zip", - "location": "/flywheel/v0/input/dicom" - }], - "target": { - "command": ["bash", "-c", "rm -rf output; mkdir -p output; ./run; echo \"Exit was $?\""], - "env": { - "PATH": "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" - }, - "dir": "/flywheel/v0" - }, - "outputs": [{ - "type": "scitran", - "uri": "/engine?level=acquisition&id=57e45279a74e91000ed6898f&job=57e45279a74e91000ed68991", - "location": "/flywheel/v0/output" - }] - }, - "modified": "2016-09-28T16:11:36.260000+00:00", - "created": "2016-09-22T21:51:53.174000+00:00", - "state": "running", - "_id": "57e45279a74e91000ed68991", - "config": null -} diff --git a/raml/schemas/definitions/acquisition.json b/raml/schemas/definitions/acquisition.json index ec7a8e5750d30615f8f6a6a8d2f249d0d10f8247..181bfb6da1d0244689a44c8eb836cb456aa979a5 100644 --- a/raml/schemas/definitions/acquisition.json +++ b/raml/schemas/definitions/acquisition.json @@ -2,11 +2,10 @@ "$schema": "http://json-schema.org/draft-04/schema#", "definitions":{ "acquisition-input":{ - "x-gen-name": "acquisition", "type": "object", "properties": { "public": {"$ref":"container.json#/definitions/public"}, - "label": {"$ref":"container.json#/definitions/label"}, + "label": {"$ref":"common.json#/definitions/label"}, "info": {"$ref":"container.json#/definitions/info"}, "session": {"$ref":"common.json#/definitions/objectid"}, "uid": {"$ref":"container.json#/definitions/uid"}, @@ -15,13 +14,32 @@ }, "additionalProperties":false }, + "acquisition-metadata-input": { + "type": "object", + "x-note": "Are all of these fields still used/valid? Can this be reconciled with enginemetadata.json#/definitions/uid-upload-input?", + "properties": { + "public": {"type": ["boolean", "null"]}, + "label": {"type": ["string", "null"]}, + "info": {"type": ["object", "null"]}, + "metadata": {"type": ["object", "null"]}, + "measurement": {"type": ["string", "null"]}, + "instrument": {"type": ["string", "null"]}, + "uid": {"type": ["string", "null"]}, + "timestamp": {"$ref":"container.json#/definitions/timestamp"}, + "timezone": {"type": ["string", "null"]}, + "files": { + "type": ["array", "null"], + "items": {"$ref": "file.json#/definitions/file-input"} + } + }, + "additionalProperties": false + }, "acquisition-output":{ - "x-gen-name": "acquisition", "type":"object", "properties": { "_id": {"$ref":"common.json#/definitions/objectid"}, "public": {"$ref":"container.json#/definitions/public"}, - "label": {"$ref":"container.json#/definitions/label"}, + "label": {"$ref":"common.json#/definitions/label"}, "info": {"$ref":"container.json#/definitions/info"}, "session": {"$ref":"common.json#/definitions/objectid"}, "uid": {"$ref":"container.json#/definitions/uid"}, diff --git a/raml/schemas/definitions/analysis.json b/raml/schemas/definitions/analysis.json index 271104f37a65b9be1131c07f2c9803aaf7f33a00..ea48fb875103e40a1e13b21ada614d6d3ad6e680 100644 --- a/raml/schemas/definitions/analysis.json +++ b/raml/schemas/definitions/analysis.json @@ -9,17 +9,16 @@ "type": ["array", "null"], "items": {"$ref":"file.json#/definitions/file"} }, - "user": {"type": "string"}, "analysis-input":{ "type":"object", "properties":{ "inputs": {"$ref":"#/definitions/inputs"}, "outputs": {"$ref":"#/definitions/outputs"}, "notes": {"$ref":"note.json#/definitions/notes-list-output"}, - "description": {"type":"string"}, + "description": {"$ref":"common.json#/definitions/description"}, "job": {"$ref":"common.json#/definitions/objectid"}, "label": {"$ref":"common.json#/definitions/label"}, - "user": {"$ref":"#/definitions/user"} + "user": {"$ref":"common.json#/definitions/user-id"} }, "additionalProperties": false }, @@ -45,13 +44,27 @@ ] }, "notes": {"$ref":"note.json#/definitions/notes-list-output"}, - "description": {"type":"string"}, + "description": {"$ref":"common.json#/definitions/description"}, "label": {"$ref":"common.json#/definitions/label"}, "user": {"$ref":"common.json#/definitions/user-id"}, "created": {"$ref":"created-modified.json#/definitions/created"}, "modified": {"$ref":"created-modified.json#/definitions/modified"} }, "required":["_id", "files", "label", "user", "created", "modified"] + }, + "analysis-job": { + "type": "object", + "properties":{ + "analysis":{ + "type":"object", + "allOf":[{"$ref":"#/definitions/analysis-input"}], + "required":["label"] + } + }, + "job":{ + "type":"object", + "allOf":[{"$ref":"job.json#/definitions/job-input"}] + } } } } diff --git a/raml/schemas/definitions/collection.json b/raml/schemas/definitions/collection.json index 2ab513a5bff871af2b97ae2b92c591a0baaefea4..bf3542b76662a789180c3a3f0ca2d528495ff948 100644 --- a/raml/schemas/definitions/collection.json +++ b/raml/schemas/definitions/collection.json @@ -1,59 +1,52 @@ { "$schema": "http://json-schema.org/draft-04/schema#", "definitions":{ - "curator":{"$ref":"../definitions/user.json#/definitions/_id"}, - "description": {"type": "string"}, "collection-input":{ "type": "object", "properties": { - "public": {"$ref": "../definitions/container.json#/definitions/public"}, - "label": {"$ref": "../definitions/container.json#/definitions/label"}, - "info": {"$ref": "../definitions/container.json#/definitions/info"}, - "description": {"$ref": "../definitions/project.json#/definitions/description"} + "public": {"$ref": "container.json#/definitions/public"}, + "label": {"$ref": "common.json#/definitions/label"}, + "info": {"$ref": "container.json#/definitions/info"}, + "description": {"$ref": "common.json#/definitions/description"} }, "additionalProperties": false }, "collection-input-with-contents":{ "type": "object", "properties": { - "public": {"$ref": "../definitions/container.json#/definitions/public"}, - "label": {"$ref": "../definitions/container.json#/definitions/label"}, - "info": {"$ref": "../definitions/container.json#/definitions/info"}, - "description": {"$ref": "../definitions/project.json#/definitions/description"}, - "contents": { "type": "object" } + "public": {"$ref": "container.json#/definitions/public"}, + "label": {"$ref": "common.json#/definitions/label"}, + "info": {"$ref": "container.json#/definitions/info"}, + "description": {"$ref": "common.json#/definitions/description"}, + "contents": { "type": "object" } }, "additionalProperties": false }, "collection-output":{ "type": "object", "properties": { - "_id":{"$ref":"../definitions/objectid.json#"}, - "public": {"$ref": "../definitions/container.json#/definitions/public"}, - "label": {"$ref": "../definitions/container.json#/definitions/label"}, - "description": {"$ref": "../definitions/collection.json#/definitions/description"}, - "info": {"$ref": "../definitions/container.json#/definitions/info"}, - "info_exists": {"$ref": "../definitions/container.json#/definitions/info_exists"}, - "curator": {"$ref":"#/definitions/curator"}, - "created":{"$ref":"../definitions/created-modified.json#/definitions/created"}, - "modified":{"$ref":"../definitions/created-modified.json#/definitions/modified"}, + "_id": {"$ref":"common.json#/definitions/objectid"}, + "public": {"$ref": "container.json#/definitions/public"}, + "label": {"$ref": "common.json#/definitions/label"}, + "description": {"$ref": "common.json#/definitions/description"}, + "info": {"$ref": "container.json#/definitions/info"}, + "info_exists": {"$ref": "container.json#/definitions/info_exists"}, + "curator": {"$ref": "common.json#/definitions/user-id"}, + "created": {"$ref": "created-modified.json#/definitions/created"}, + "modified": {"$ref": "created-modified.json#/definitions/modified"}, "permissions":{ "type":"array", - "items":{"$ref":"../definitions/permission.json#/definitions/permission-output-default-required"} + "items":{"$ref":"permission.json#/definitions/permission-output-default-required"} }, "files":{ "type":"array", - "items":{ - "allOf":[{"$ref":"../definitions/file.json#/definitions/file-output"}] - } + "items":{"$ref":"file.json#/definitions/file-output"} }, - "notes":{"allOf":[{"$ref":"../definitions/note.json#/definitions/notes-list-output"}]}, - "tags":{"allOf":[{"$ref":"../definitions/tag.json#/definitions/tag-output-list"}]}, + "notes": {"$ref":"note.json#/definitions/notes-list-output"}, + "tags": {"$ref":"tag.json#/definitions/tag-output-list"}, "analyses":{ "type":"array", - "items":{ - "type":"object", - "allOf":[{"$ref":"../definitions/analysis.json#/definitions/analysis-output"}] - } + "items":{"$ref":"analysis.json#/definitions/analysis-output"} } }, "additionalProperties":false diff --git a/raml/schemas/definitions/common.json b/raml/schemas/definitions/common.json index 01db699dcaae9515cc4e872edf550ee03571118e..129a6bbe0d1c7baebf0b4f9e43ceede1c2f22749 100644 --- a/raml/schemas/definitions/common.json +++ b/raml/schemas/definitions/common.json @@ -6,6 +6,9 @@ "minLength": 1, "maxLength": 256 }, + "description": { + "type": "string" + }, "objectid": { "type": "string", "pattern": "^[a-fA-F0-9]{24}$" @@ -19,6 +22,34 @@ "user-id": { "type": "string", "format": "email" - } + }, + "timestamp": { + "type": ["string", "null"], + "format": "date-time" + }, + "deleted-count": { + "type":"object", + "properties": { + "deleted": { + "type": "integer" + } + } + }, + "modified-count": { + "type": "object", + "properties": { + "modified": { + "type": "integer" + } + } + }, + "object-created": { + "type": "object", + "properties": { + "_id": { + "type": "string" + } + } + } } } \ No newline at end of file diff --git a/raml/schemas/definitions/device.json b/raml/schemas/definitions/device.json index 5f4608c2bb93a7065ea4f840b553040c5400bef4..7753d2e7a13bc8f9f16f14be80ed71b9beec471a 100644 --- a/raml/schemas/definitions/device.json +++ b/raml/schemas/definitions/device.json @@ -8,11 +8,24 @@ "type": "string" } }, - "name": {"type": "string"}, "interval": {"type": "integer"}, - "id": {"type": "string"}, - "method": {"type": "string"}, - "last_seen": {"type": ["string", "null"], "format": "date-time"}, + "status-value": { + "type": "string", + "enum": ["ok", "missing", "error", "unknown"] + }, + "device": { + "type": "object", + "properties": { + "_id": {"type":"string"}, + "method": {"type":"string"}, + "name": {"type":"string"}, + "errors": {"$ref":"#/definitions/errors"}, + "info": {"$ref":"#/definitions/info"}, + "interval": {"$ref":"#/definitions/interval"}, + "last_seen": {"$ref":"common.json#/definitions/timestamp"} + }, + "additionalProperties": false + }, "device-input":{ "type": "object", "properties": { @@ -21,6 +34,25 @@ "info": {"$ref":"#/definitions/info"} }, "additionalProperties": false + }, + "device-output": { + "type": "object", + "allOf": [{"$ref":"#/definitions/device"}], + "required": ["_id", "name", "method", "last_seen"] + }, + "device-status": { + "type":"object", + "patternProperties": { + "^[0-9a-z.@_-]*$":{ + "properties":{ + "errors": {"$ref":"#/definitions/errors"}, + "last_seen": {"$ref":"common.json#/definitions/timestamp"}, + "status": {"$ref":"#/definitions/status-value"} + }, + "additionalProperties":false, + "required": ["last_seen", "status"] + } + } } } } diff --git a/raml/schemas/definitions/download.json b/raml/schemas/definitions/download.json new file mode 100644 index 0000000000000000000000000000000000000000..6fa32a24ddebc335f4d2baac6cf741ed683df56c --- /dev/null +++ b/raml/schemas/definitions/download.json @@ -0,0 +1,70 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "definitions": { + "filter-definition": { + "type": "object", + "properties": { + "+": {"$ref": "#/definitions/filter-items"}, + "plus": {"$ref": "#definitions/filterItems"}, + "-": {"$ref": "#/definitions/filter-items"}, + "minus": {"$ref": "#definitions/filterItems"} + }, + "additionalProperties": false + }, + "filter-items": { "type": "array", + "minItems": 1, + "items": { + "type": "string" + } + }, + "download-node": { + "type": "object", + "properties": { + "level": { + "type": "string", + "enum": ["project", "session", "acquisition", "analysis"] + }, + "_id": { + "type": "string", + "pattern": "^[0-9a-f]{24}$" + } + }, + "required": ["level", "_id"], + "additionalProperties": false + }, + "download-filter": { + "type": "object", + "properties": { + "tags": {"$ref": "#/definitions/filter-definition"}, + "types": {"$ref": "#/definitions/filter-definition"} + } + }, + "download-input": { + "title": "Download", + "type": "object", + "properties": { + "optional": { "type": "boolean" }, + "nodes": { + "type": "array", + "minItems": 1, + "items": {"$ref": "#/definitions/download-node"} + }, + "filters": { + "type": "array", + "minItems": 1, + "items": {"$ref": "#/definitions/download-filter"} + } + }, + "required": ["optional", "nodes"], + "additionalProperties": false + }, + "download-ticket": { + "type":"object", + "properties":{ + "ticket":{"type":"string"} + }, + "additionalProperties":false, + "required":["ticket"] + } + } +} diff --git a/raml/schemas/definitions/enginemetadata.json b/raml/schemas/definitions/enginemetadata.json new file mode 100644 index 0000000000000000000000000000000000000000..be2c0036cd53bc7348fca11ce35cd5f526362c57 --- /dev/null +++ b/raml/schemas/definitions/enginemetadata.json @@ -0,0 +1,103 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "definitions": { + "upload-acquisition-metadata-input": { + "type": "object", + "properties": { + "public": {"type": ["boolean", "null"]}, + "label": {"type": ["string", "null"]}, + "info": {"type": ["object", "null"]}, + "uid": {"type": ["string", "null"]}, + "timestamp": {"$ref":"container.json#/definitions/timestamp"}, + "timezone": {"type": ["string", "null"]}, + "files": { + "type": ["array", "null"], + "items": {"$ref": "file.json#/definitions/file-input"} + } + }, + "additionalProperties": false + }, + + "engine-upload-input": { + "type": "object", + "properties": { + "project": {"$ref": "project.json#/definitions/project-metadata-input"}, + "session": {"$ref": "session.json#/definitions/session-metadata-input"}, + "acquisition": {"$ref": "acquisition.json#/definitions/acquisition-metadata-input"} + }, + "additionalProperties": false + }, + "label-upload-input": { + "type": "object", + "properties": { + "group": { + "type": "object", + "allOf": [{"$ref":"group.json#/definitions/group-metadata-input"}], + "required": ["_id"] + }, + "project": { + "type": "object", + "allOf": [{"$ref":"project.json#/definitions/project-metadata-input"}], + "required": ["label"] + }, + "session": { + "type": "object", + "allOf": [{"$ref":"session.json#/definitions/session-metadata-input"}], + "required": ["label"] + }, + "acquisition": { + "type": "object", + "allOf": [{"$ref":"#/definitions/upload-acquisition-metadata-input"}], + "required": ["label"] + } + }, + "required": ["group", "project"], + "additionalProperties": false + }, + "uid-upload-input": { + "type": "object", + "properties": { + "group": { + "type": "object", + "allOf": [{"$ref":"group.json#/definitions/group-metadata-input"}], + "required": ["_id"] + }, + "project": { + "type": "object", + "allOf": [{"$ref":"project.json#/definitions/project-metadata-input"}], + "required": ["label"] + }, + "session": { + "type": "object", + "allOf": [{"$ref":"session.json#/definitions/session-metadata-input"}], + "required": ["uid"] + }, + "acquisition": { + "type": "object", + "allOf": [{"$ref":"#/definitions/upload-acquisition-metadata-input"}], + "required": ["uid"] + } + }, + "required": ["acquisition", "group", "project", "session"], + "additionalProperties": false + }, + "uid-match-upload-input": { + "type": "object", + "properties": { + "project": {"$ref": "project.json#/definitions/project-metadata-input"}, + "session": { + "type": "object", + "allOf": [{"$ref":"session.json#/definitions/session-metadata-input"}], + "required": ["uid"] + }, + "acquisition": { + "type": "object", + "allOf": [{"$ref":"#/definitions/upload-acquisition-metadata-input"}], + "required": ["uid"] + } + }, + "required": ["acquisition", "session"], + "additionalProperties": false + } + } +} \ No newline at end of file diff --git a/raml/schemas/definitions/file.json b/raml/schemas/definitions/file.json index 9e3578b132d48b78db71dc2835181d3dc0c83032..a3be0aa7673a3abc562b51464f5efbd2fd9bc88a 100644 --- a/raml/schemas/definitions/file.json +++ b/raml/schemas/definitions/file.json @@ -52,16 +52,16 @@ ] }, "measurements": {"$ref":"#/definitions/measurements"}, - "tags": {"$ref":"#/definitions/tags"}, - "info": {"$ref":"#/definitions/info"}, - "origin":{"$ref":"#/definitions/origin"}, - "hash":{"$ref":"#/definitions/hash"}, - "created":{"$ref":"../definitions/created-modified.json#/definitions/created"}, - "modified":{"$ref":"../definitions/created-modified.json#/definitions/modified"}, - "size":{"$ref":"#/definitions/size"}, + "tags": {"$ref":"#/definitions/tags"}, + "info": {"$ref":"#/definitions/info"}, + "origin": {"$ref":"#/definitions/origin"}, + "hash": {"$ref":"#/definitions/hash"}, + "created": {"$ref":"created-modified.json#/definitions/created"}, + "modified": {"$ref":"created-modified.json#/definitions/modified"}, + "size": {"$ref":"#/definitions/size"}, "info_exists": {"type": "boolean"}, - "input": {"type":"boolean"}, - "output": {"type":"boolean"} + "input": {"type":"boolean"}, + "output": {"type":"boolean"} }, "additionalProperties": false }, @@ -73,8 +73,8 @@ "mimetype": {"$ref":"#/definitions/mimetype"}, "modality": {"$ref":"#/definitions/modality"}, "measurements": {"$ref":"#/definitions/measurements"}, - "tags": {"$ref":"#/definitions/tags"}, - "info": {"$ref":"#/definitions/info"} + "tags": {"$ref":"#/definitions/tags"}, + "info": {"$ref":"#/definitions/info"} }, "additionalProperties": false }, diff --git a/raml/schemas/definitions/group.json b/raml/schemas/definitions/group.json index a3d75631804a5364da821c15b666483cbc6b1ff9..e03a5e73c1dc7dfc982d18e50542168eb60a3796 100644 --- a/raml/schemas/definitions/group.json +++ b/raml/schemas/definitions/group.json @@ -1,7 +1,6 @@ { "$schema": "http://json-schema.org/draft-04/schema#", "definitions":{ - "_id":{"$ref":"../definitions/string-id.json#"}, "label": { "maxLength": 64, "minLength": 1, @@ -9,57 +8,50 @@ "title": "label", "type": "string" }, + "group": { + "type": "object", + "properties": { + "_id":{"$ref":"common.json#/definitions/string-id"}, + "label": {"$ref": "#/definitions/label"}, + "permissions": {"$ref": "permission.json#/definitions/permission-output-list"}, + "created": {"$ref":"created-modified.json#/definitions/created"}, + "modified": {"$ref":"created-modified.json#/definitions/modified"} + }, + "additionalProperties":false + }, "group-input":{ "type": "object", "properties": { - "_id":{"$ref":"#/definitions/_id"}, - "label": {"$ref": "../definitions/container.json#/definitions/label"} + "_id":{"$ref":"common.json#/definitions/string-id"}, + "label": {"$ref": "#/definitions/label"} }, "additionalProperties": false }, - "group-output":{ + "group-metadata-input": { "type": "object", "properties": { - "_id":{"$ref":"#/definitions/_id"}, - "label": {"$ref": "../definitions/container.json#/definitions/label"}, - "permissions": { - "type": "array", - "items": {"$ref": "../definitions/permission.json#/definitions/permission-output-default-required"}, - "uniqueItems": true - }, - "created": {"$ref":"../definitions/created-modified.json#/definitions/created"}, - "modified": {"$ref":"../definitions/created-modified.json#/definitions/modified"} + "_id":{"type":"string"} }, - "additionalProperties":false, + "additionalProperties": false + }, + "group-output":{ + "type": "object", + "allOf": [{"$ref":"#/definitions/group"}], "required": ["permissions", "created","modified","_id"] }, "group-output-list":{ "type":"array", - "items":{ - "allOf":[{"$ref":"#/definitions/group-output"}] - } + "items":{"$ref":"#/definitions/group-output"} }, "project-group-output":{ "type": "object", - "properties": { - "_id":{"$ref":"#/definitions/_id"}, - "label": {"$ref": "../definitions/container.json#/definitions/label"}, - "permissions": { - "type": "array", - "items": {"$ref": "../definitions/permission.json#/definitions/permission-output-default-required"}, - "uniqueItems": true - }, - "created": {"$ref":"../definitions/created-modified.json#/definitions/created"}, - "modified": {"$ref":"../definitions/created-modified.json#/definitions/modified"} - }, - "additionalProperties":false, + "allOf": [{"$ref":"#/definitions/group"}], "required": ["_id"] }, "project-group-output-list":{ "type":"array", - "items":{ - "allOf":[{"$ref":"#/definitions/project-group-output"}] - } + "items":{"$ref":"#/definitions/project-group-output"} } } } + diff --git a/raml/schemas/definitions/info.json b/raml/schemas/definitions/info.json new file mode 100644 index 0000000000000000000000000000000000000000..fc4d65558c4296fd7d685731fadb73f509e209d7 --- /dev/null +++ b/raml/schemas/definitions/info.json @@ -0,0 +1,33 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "definitions": { + "info-add-remove": { + "properties": { + "set": {"type": "object", "minProperties": 1}, + "delete": { + "type": "array", + "uniqueItems": true, + "minItems": 1, + "items": { + "type": "string" + } + } + }, + "additionalProperties": false + }, + "info-replace": { + "properties": { + "replace": {"type": "object"} + }, + "additionalProperties": false + }, + "info-update-input": { + "description": "Helper endpoint for editing an object's info key", + "type": "object", + "oneOf": [ + {"$ref":"#/definitions/info-add-remove"}, + {"$ref":"#/definitions/info-replace"} + ] + } + } +} diff --git a/raml/schemas/definitions/job.json b/raml/schemas/definitions/job.json index bd4742d01534e4feabc50915cecc1231dca58e59..e2a3acfce477c972a56da5d772a81f53c1d222b6 100644 --- a/raml/schemas/definitions/job.json +++ b/raml/schemas/definitions/job.json @@ -1,15 +1,17 @@ { "$schema": "http://json-schema.org/draft-04/schema#", "definitions": { - "_id": {"$ref":"../definitions/objectid.json#"}, + "gear_id": {"type":"string"}, "previous_job_id": {"type":"string"}, + "inputs-property-type":{"type":"string"}, "inputs-property-id":{"type":"string"}, "inputs-property-name":{"type":"string"}, + "inputs-object": { "type": "object", - "additionalProperties": { + "properties": { "type": "object", "properties": { "type": {"$ref":"#/definitions/inputs-property-type"}, @@ -117,6 +119,47 @@ "target":{"type":"object"}, "outputs":{"type":"array"} } + }, + "job": { + "type":"object", + "properties":{ + "id":{"$ref":"common.json#/definitions/objectid"}, + "origin":{"$ref":"#/definitions/origin"}, + "gear_id":{"$ref":"#/definitions/gear_id"}, + "previous_job_id":{"type":"string"}, + "inputs":{"$ref":"#/definitions/inputs-object"}, + "destination":{"$ref":"#/definitions/destination"}, + "tags":{"$ref":"#/definitions/tags"}, + "state":{"$ref":"#/definitions/state"}, + "attempt":{"$ref":"#/definitions/attempt"}, + "created":{"$ref":"created-modified.json#/definitions/created"}, + "modified":{"$ref":"created-modified.json#/definitions/modified"}, + "config":{"$ref":"#/definitions/config"}, + "request":{"$ref":"#/definitions/request"}, + "saved_files":{"$ref":"#/definitions/saved_files"}, + "produced_metadata":{"$ref":"#/definitions/produced_metadata"} + }, + "additionalProperties":false + }, + "job-input": { + "type":"object", + "properties": { + "gear_id":{"$ref":"#/definitions/gear_id"}, + "inputs":{"$ref":"#/definitions/inputs-object"}, + "destination":{"$ref":"#/definitions/destination"}, + "tags":{"$ref":"#/definitions/tags"}, + "config":{"$ref":"#/definitions/config"} + }, + "required": ["gear_id"], + "additionalProperties":false + }, + "job-output": { + "type": "object", + "allOf": [{"$ref":"#/definitions/job"}], + "required": [ + "id", "gear_id", "inputs", "config", + "destination", "tags", "state", "attempt" + ] } } } diff --git a/raml/schemas/definitions/note.json b/raml/schemas/definitions/note.json index 2e033431678f98e225d9220738c41bdd3a4376ff..58298f1a373a93d4b07057d669a0476584dde544 100644 --- a/raml/schemas/definitions/note.json +++ b/raml/schemas/definitions/note.json @@ -16,11 +16,11 @@ "note-output":{ "type":"object", "properties":{ - "_id":{"$ref":"../definitions/objectid.json"}, + "_id":{"$ref":"common.json#/definitions/objectid"}, "text":{"$ref":"#/definitions/text"}, - "created":{"$ref":"../definitions/created-modified.json#/definitions/created"}, - "modified":{"$ref":"../definitions/created-modified.json#/definitions/modified"}, - "user":{"$ref":"../definitions/user.json#/definitions/_id"} + "created":{"$ref":"created-modified.json#/definitions/created"}, + "modified":{"$ref":"created-modified.json#/definitions/modified"}, + "user":{"$ref":"common.json#/definitions/user-id"} }, "additionalProperties": false, "required":["_id", "text", "created", "modified", "user"] diff --git a/raml/schemas/definitions/packfile.json b/raml/schemas/definitions/packfile.json new file mode 100644 index 0000000000000000000000000000000000000000..d40dcffd21742962cec0a838de584827db4d821d --- /dev/null +++ b/raml/schemas/definitions/packfile.json @@ -0,0 +1,59 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "definitions": { + "packfile-project-input": { + "type": "object", + "properties": { + "_id": {"type": "string"} + }, + "additionalProperties": false, + "required": ["_id"] + }, + "packfile-session-input": { + "type": "object", + "properties": { + "label": {"type": "string"}, + "subject": {"$ref": "subject.json#/definitions/subject-input"} + }, + "additionalProperties": false, + "required": ["label"] + }, + "packfile-acquisition-input": { + "type": "object", + "properties": { + "label": {"type": "string"}, + "timestamp": {"type": ["string", "null"], "format": "date-time"}, + "timezone": {"type": "string"} + }, + "additionalProperties": false, + "required": ["label"] + }, + "packfile-packfile-input": { + "type": "object", + "properties": { + "type": {"type": "string"} + }, + "additionalProperties": false, + "required": ["type"] + }, + + "packfile-input": { + "title": "Packfile", + "type": "object", + "properties": { + "project": {"$ref":"#/definitions/packfile-project-input"}, + "session": {"$ref":"#/definitions/packfile-session-input"}, + "acquisition": {"$ref":"#/definitions/packfile-acquisition-input"}, + "packfile": {"$ref":"#/definitions/packfile-packfile-input"} + }, + "required": ["project", "session", "acquisition", "packfile"], + "additionalProperties": false + }, + "packfile-start": { + "type":"object", + "properties":{ + "token":{"$ref":"common.json#/definitions/objectid"} + } + } + } +} diff --git a/raml/schemas/definitions/permission.json b/raml/schemas/definitions/permission.json index bd4e63db4787387abed78bcb816f69d69de59966..03a48fd55d930e2413008dcdcf9320c79f3cfc44 100644 --- a/raml/schemas/definitions/permission.json +++ b/raml/schemas/definitions/permission.json @@ -1,12 +1,11 @@ { "$schema": "http://json-schema.org/draft-04/schema#", "definitions": { - "_id": { "type": "string" }, "access": { "enum": ["ro", "rw", "admin"] }, "permission":{ "type":"object", "properties":{ - "_id":{"$ref":"#/definitions/_id"}, + "_id":{"$ref":"common.json#/definitions/user-id"}, "access":{"$ref":"#/definitions/access"} }, "additionalProperties": false @@ -14,6 +13,11 @@ "permission-output-default-required":{ "allOf":[{"$ref":"#/definitions/permission"}], "required":["_id", "access"] + }, + "permission-output-list": { + "type": "array", + "items": {"$ref": "#/definitions/permission-output-default-required"}, + "uniqueItems": true } } } diff --git a/raml/schemas/definitions/project.json b/raml/schemas/definitions/project.json index ee77eab1818c976dbda75b1a33dbe610d3d0e9c4..6cb7dc156b1481fe769d92fee2b66a42cbf8eccc 100644 --- a/raml/schemas/definitions/project.json +++ b/raml/schemas/definitions/project.json @@ -1,49 +1,55 @@ { "$schema": "http://json-schema.org/draft-04/schema#", "definitions":{ - "description": {"type": "string"}, "project-input":{ "type": "object", "properties": { - "public": {"$ref": "../definitions/container.json#/definitions/public"}, - "label": {"$ref": "../definitions/container.json#/definitions/label"}, - "info": {"$ref": "../definitions/container.json#/definitions/info"}, - "description": {"$ref": "../definitions/project.json#/definitions/description"}, - "group":{"$ref":"../definitions/group.json#/definitions/_id"} + "public": {"$ref":"container.json#/definitions/public"}, + "label": {"$ref":"common.json#/definitions/label"}, + "info": {"$ref":"container.json#/definitions/info"}, + "description": {"$ref":"common.json#/definitions/description"}, + "group": {"$ref":"common.json#/definitions/string-id"} + }, + "additionalProperties": false + }, + "project-metadata-input": { + "type": "object", + "properties": { + "public": {"type": ["boolean", "null"]}, + "label": {"type": ["string", "null"]}, + "info": {"type": ["object", "null"]}, + "files": { + "type": ["array", "null"], + "items": {"$ref": "file.json#/definitions/file-input"} + } }, "additionalProperties": false }, "project-output":{ "type": "object", "properties": { - "_id": {"$ref":"../definitions/objectid.json#"}, - "public": {"$ref": "../definitions/container.json#/definitions/public"}, - "label": {"$ref": "../definitions/container.json#/definitions/label"}, - "info": {"$ref": "../definitions/container.json#/definitions/info"}, - "info_exists": {"$ref": "../definitions/container.json#/definitions/info_exists"}, - "description": {"$ref": "../definitions/project.json#/definitions/description"}, - "group":{"$ref":"../definitions/group.json#/definitions/_id"}, - "created":{"$ref":"../definitions/created-modified.json#/definitions/created"}, - "modified":{"$ref":"../definitions/created-modified.json#/definitions/modified"}, - "template":{"type":"object"}, - "permissions":{ - "type":"array", - "items":{"$ref":"../definitions/permission.json#/definitions/permission-output-default-required"} - }, + "_id": {"$ref":"common.json#/definitions/objectid"}, + "public": {"$ref":"container.json#/definitions/public"}, + "label": {"$ref":"common.json#/definitions/label"}, + "info": {"$ref":"container.json#/definitions/info"}, + "info_exists": {"$ref":"container.json#/definitions/info_exists"}, + "description": {"$ref":"common.json#/definitions/description"}, + "group": {"$ref":"common.json#/definitions/string-id"}, + "created": {"$ref":"created-modified.json#/definitions/created"}, + "modified": {"$ref":"created-modified.json#/definitions/modified"}, + "template": {"type":"object"}, + "permissions": {"$ref":"permission.json#/definitions/permission-output-list"}, "files":{ "type":"array", "items":{ - "allOf":[{"$ref":"../definitions/file.json#/definitions/file-output"}] + "allOf":[{"$ref":"file.json#/definitions/file-output"}] } }, - "notes":{"allOf":[{"$ref":"../definitions/note.json#/definitions/notes-list-output"}]}, - "tags":{"allOf":[{"$ref":"../definitions/tag.json#/definitions/tag-output-list"}]}, + "notes": {"$ref":"note.json#/definitions/notes-list-output"}, + "tags": {"$ref":"tag.json#/definitions/tag-output-list"}, "analyses":{ "type":"array", - "items":{ - "type":"object", - "allOf":[{"$ref":"../definitions/analysis.json#/definitions/analysis-output"}] - } + "items":{"$ref":"analysis.json#/definitions/analysis-output"} } }, "additionalProperties": false diff --git a/raml/schemas/definitions/report.json b/raml/schemas/definitions/report.json new file mode 100644 index 0000000000000000000000000000000000000000..ca8af0d424afd3e183c6ce87fd7befe58ceff2a8 --- /dev/null +++ b/raml/schemas/definitions/report.json @@ -0,0 +1,113 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "type":"object", + "definitions":{ + "gender_count":{ + "type":"object", + "properties":{ + "Male": {"type":"integer"}, + "Unknown or Not Reported":{"type":"integer"}, + "Female":{"type":"integer"} + }, + "additionalProperties":false, + "required":["Male", "Female", "Unknown or Not Reported"] + }, + "ethnicity_grid":{ + "type":"object", + "properties":{ + "Not Hispanic or Latino":{ + "allOf":[{"$ref":"#/definitions/gender_count"}] + }, + "Hispanic or Latino":{ + "allOf":[{"$ref":"#/definitions/gender_count"}] + }, + "Unknown or Not Reported":{ + "allOf":[{"$ref":"#/definitions/gender_count"}] + }, + "Total":{"type":"integer"} + } + }, + "demographics_grid": { + "type":"object", + "properties":{ + "Black or African American":{ + "allOf":[{"$ref":"#/definitions/ethnicity_grid"}] + }, + "Unknown or Not Reported":{ + "allOf":[{"$ref":"#/definitions/ethnicity_grid"}] + }, + "American Indian or Alaska Native":{ + "allOf":[{"$ref":"#/definitions/ethnicity_grid"}] + }, + "Asian":{ + "allOf":[{"$ref":"#/definitions/ethnicity_grid"}] + }, + "White":{ + "allOf":[{"$ref":"#/definitions/ethnicity_grid"}] + }, + "Total":{ + "allOf":[{"$ref":"#/definitions/ethnicity_grid"}] + }, + "Native Hawaiian or Other Pacific Islander":{ + "allOf":[{"$ref":"#/definitions/ethnicity_grid"}] + }, + "More Than One Race":{ + "allOf":[{"$ref":"#/definitions/ethnicity_grid"}] + }, + "male_count": {"type":"integer"}, + "group_label": {"$ref":"common.json#/definitions/label"}, + "over_18_count": {"type":"integer"}, + "under_18_count": {"type":"integer"}, + "female_count": {"type":"integer"}, + "subjects_count": {"type":"integer"}, + "other_count": {"type":"integer"}, + "name": {"$ref":"common.json#/definitions/label"}, + "session_count": {"type":"integer"}, + "admins": { + "type":"array", + "items":{ + "type":"string" + } + }, + "demographics_total": {"type":"integer"} + } + }, + "group-report": { + "type":"object", + "properties":{ + "project_count":{"type":"integer"}, + "label":{ + "oneOf":[ + {"$ref":"group.json#/definitions/label"}, + {"type":"null"} + ] + }, + "session_count":{"type":"integer"} + }, + "additionalProperties":false, + "required":["project_count", "label", "session_count"] + }, + + "report-project": { + "type":"object", + "properties":{ + "projects":{ + "type":"array", + "items":{"$ref":"#/definitions/demographics_grid"} + } + } + }, + "report-site": { + "type":"object", + "properties":{ + "group_count":{"type":"integer"}, + "groups":{ + "type":"array", + "items":{"$ref":"#/definitions/group-report"} + } + }, + "additionalProperties":false, + "required":["group_count", "groups"] + } + } +} diff --git a/raml/schemas/definitions/session.json b/raml/schemas/definitions/session.json index 920b7f07479126cfcb70a699db78b610520c8734..9c1c9775b2dd385282df95b6341973d605926f09 100644 --- a/raml/schemas/definitions/session.json +++ b/raml/schemas/definitions/session.json @@ -8,63 +8,98 @@ "session-input":{ "type": "object", "properties": { - "operator": {"$ref": "#/definitions/operator"}, - "public": {"$ref": "../definitions/container.json#/definitions/public"}, - "label": {"$ref": "../definitions/container.json#/definitions/label"}, - "info": {"$ref": "../definitions/container.json#/definitions/info"}, + "operator": {"$ref":"#/definitions/operator"}, + "public": {"$ref":"container.json#/definitions/public"}, + "label": {"$ref":"common.json#/definitions/label"}, + "info": {"$ref":"container.json#/definitions/info"}, "project": {"$ref":"#/definitions/project"}, - "uid": {"$ref":"../definitions/container.json#/definitions/uid"}, - "timestamp": {"$ref":"../definitions/container.json#/definitions/timestamp"}, - "timezone": {"$ref":"../definitions/container.json#/definitions/timezone"}, - "subject": { - "allOf":[{"$ref": "../definitions/subject.json#/definitions/subject-input"}] - } + "uid": {"$ref":"container.json#/definitions/uid"}, + "timestamp": {"$ref":"container.json#/definitions/timestamp"}, + "timezone": {"$ref":"container.json#/definitions/timezone"}, + "subject": {"$ref": "subject.json#/definitions/subject-input"} }, "additionalProperties": false }, + "session-metadata-input": { + "type": "object", + "properties": { + "public": {"type": ["boolean", "null"]}, + "label": {"type": ["string", "null"]}, + "info": {"type": ["object", "null"]}, + "operator": {"type": ["string", "null"]}, + "uid": {"type": ["string", "null"]}, + "timestamp": {"type": ["string", "null"], "format": "date-time"}, + "timezone": {"type": ["string", "null"]}, + "subject": {"$ref": "subject.json#/definitions/subject-input"}, + "files": { + "type": ["array", "null"], + "items": {"$ref": "file.json#/definitions/file-input"} + } + }, + "additionalProperties": false + }, "session-output":{ "type": "object", "properties": { - "_id": {"$ref":"../definitions/objectid.json#"}, - "public": {"$ref": "../definitions/container.json#/definitions/public"}, - "label": {"$ref": "../definitions/container.json#/definitions/label"}, - "info": {"$ref": "../definitions/container.json#/definitions/info"}, - "info_exists": {"$ref": "../definitions/container.json#/definitions/info_exists"}, - "operator": {"$ref": "#/definitions/operator"}, + "_id": {"$ref":"common.json#/definitions/objectid"}, + "public": {"$ref":"container.json#/definitions/public"}, + "label": {"$ref":"common.json#/definitions/label"}, + "info": {"$ref":"container.json#/definitions/info"}, + "info_exists": {"$ref":"container.json#/definitions/info_exists"}, + "operator": {"$ref":"#/definitions/operator"}, "project": {"$ref":"#/definitions/project"}, - "uid": {"$ref":"../definitions/container.json#/definitions/uid"}, - "timestamp": {"$ref":"../definitions/container.json#/definitions/timestamp"}, - "timezone": {"$ref":"../definitions/container.json#/definitions/timezone"}, - "subject": { - "type":"object", - "allOf":[{"$ref": "../definitions/subject.json#/definitions/subject-output-default-required"}] - }, - "created":{"$ref":"../definitions/created-modified.json#/definitions/created"}, - "modified":{"$ref":"../definitions/created-modified.json#/definitions/modified"}, - "permissions":{ - "type":"array", - "items":{"$ref":"../definitions/permission.json#/definitions/permission-output-default-required"} - }, - "group":{"$ref":"../definitions/group.json#/definitions/_id"}, - "project_has_template":{"$ref":"#/definitions/project_has_template"}, - "satisfies_template":{"$ref":"#/definitions/satisfies_template"}, + "uid": {"$ref":"container.json#/definitions/uid"}, + "timestamp": {"$ref":"container.json#/definitions/timestamp"}, + "timezone": {"$ref":"container.json#/definitions/timezone"}, + "subject": {"$ref":"subject.json#/definitions/subject-output-default-required"}, + "created": {"$ref":"created-modified.json#/definitions/created"}, + "modified": {"$ref":"created-modified.json#/definitions/modified"}, + "permissions": {"$ref":"permission.json#/definitions/permission-output-list"}, + "group": {"$ref":"common.json#/definitions/string-id"}, + "project_has_template": {"$ref":"#/definitions/project_has_template"}, + "satisfies_template": {"$ref":"#/definitions/satisfies_template"}, "files":{ "type":"array", - "items":{ - "allOf":[{"$ref":"../definitions/file.json#/definitions/file-output"}] - } + "items":{"$ref":"file.json#/definitions/file-output"} }, - "notes":{"allOf":[{"$ref":"../definitions/note.json#/definitions/notes-list-output"}]}, - "tags":{"allOf":[{"$ref":"../definitions/tag.json#/definitions/tag-output-list"}]}, + "notes": {"$ref":"note.json#/definitions/notes-list-output"}, + "tags": {"$ref":"tag.json#/definitions/tag-output-list"}, "analyses":{ + "type":"array", + "items":{"$ref":"analysis.json#/definitions/analysis-output"} + } + }, + "additionalProperties": false + }, + "session-jobs-output": { + "type": "object", + "properties":{ + "jobs":{ + "type":"array", + "items":{"$ref": "job.json#/definitions/job-output"} + }, + "containers":{ + "patternProperties": { + "^[a-fA-F0-9]{24}$":{ + "type": "object" + } + } + } + }, + "additionalProperties":false + }, + "session-template-recalc-output": { + "type": "object", + "properties":{ + "sessions_changed":{ "type":"array", "items":{ - "type":"object", - "allOf":[{"$ref":"../definitions/analysis.json#/definitions/analysis-output"}] + "allOf":[{"$ref":"common.json#/definitions/objectid"}] } } }, - "additionalProperties": false + "additionalProperties":false, + "required":["sessions_changed"] } } } diff --git a/raml/schemas/definitions/subject.json b/raml/schemas/definitions/subject.json index 4b0a0aa3b50fc3b14748520e804b12f8f4490a65..1e5e00c58156fb8f1255356cc87e17c154b12520 100644 --- a/raml/schemas/definitions/subject.json +++ b/raml/schemas/definitions/subject.json @@ -1,7 +1,7 @@ { "$schema": "http://json-schema.org/draft-04/schema#", "definitions":{ - "_id": {"$ref":"../definitions/objectid.json#"}, + "_id": {"$ref":"common.json#/definitions/objectid"}, "firstname": { "type": "string", "maxLength": 64 }, "lastname": { "type": "string", "maxLength": 64 }, "age": { "type": ["integer", "null"] }, @@ -29,9 +29,7 @@ "info": {"$ref":"#/definitions/info"}, "files":{ "type":"array", - "items":{ - "allOf":[{"$ref":"../definitions/file.json#/definitions/file-input"}] - } + "items":{"$ref":"file.json#/definitions/file-input"} } }, "additionalProperties": false @@ -54,9 +52,7 @@ "info_exists": {"$ref": "../definitions/container.json#/definitions/info_exists"}, "files":{ "type":"array", - "items":{ - "allOf":[{"$ref":"../definitions/file.json#/definitions/file-output"}] - } + "items":{"$ref":"file.json#/definitions/file-output"} } }, "additionalProperties": false diff --git a/raml/schemas/definitions/user.json b/raml/schemas/definitions/user.json index 4478bad02680ea97f3669885193b8ab911988a88..71a68f5f11ed78faccf7d76e92ed0aeea93d20fd 100644 --- a/raml/schemas/definitions/user.json +++ b/raml/schemas/definitions/user.json @@ -1,11 +1,6 @@ { "$schema": "http://json-schema.org/draft-04/schema#", "definitions": { - "_id": { - "format": "email", - "title": "ID", - "type": "string" - }, "firstname": { "maxLength": 64, "minLength": 1, @@ -42,7 +37,7 @@ "type":"object", "properties":{ "key": {"type": "string"}, - "created": {"$ref":"../definitions/created-modified.json#/definitions/created"}, + "created": {"$ref":"created-modified.json#/definitions/created"}, "last_used": {} }, "additionalProperties":false @@ -50,7 +45,7 @@ "user-input":{ "type":"object", "properties":{ - "_id":{"$ref":"#/definitions/_id"}, + "_id":{"$ref":"common.json#/definitions/user-id"}, "firstname":{"$ref":"#/definitions/firstname"}, "lastname":{"$ref":"#/definitions/lastname"}, "email":{"$ref":"#/definitions/email"}, @@ -68,7 +63,7 @@ "user-output":{ "type":"object", "properties":{ - "_id":{"$ref":"#/definitions/_id"}, + "_id":{"$ref":"common.json#/definitions/user-id"}, "firstname":{"$ref":"#/definitions/firstname"}, "lastname":{"$ref":"#/definitions/lastname"}, "email":{"$ref":"#/definitions/email"}, @@ -80,10 +75,35 @@ "wechat":{"$ref":"#/definitions/wechat"}, "firstlogin":{"$ref":"#/definitions/firstlogin"}, "lastlogin":{"$ref":"#/definitions/lastlogin"}, - "created":{"$ref":"../definitions/created-modified.json#/definitions/created"}, - "modified":{"$ref":"../definitions/created-modified.json#/definitions/modified"} + "created":{"$ref":"created-modified.json#/definitions/created"}, + "modified":{"$ref":"created-modified.json#/definitions/modified"} }, "additionalProperties":false + }, + "user-output-api-key": { + "type":"object", + "properties":{ + "_id":{"$ref":"common.json#/definitions/user-id"}, + "api_key":{"$ref":"#/definitions/api_key"}, + "firstname":{"$ref":"#/definitions/firstname"}, + "lastname":{"$ref":"#/definitions/lastname"}, + "email":{"$ref":"#/definitions/email"}, + "avatar":{"$ref":"#/definitions/avatar"}, + "avatars":{"$ref":"#/definitions/avatars"}, + "root":{"$ref":"#/definitions/root"}, + "disabled":{"$ref":"#/definitions/disabled"}, + "preferences":{"$ref":"#/definitions/preferences"}, + "wechat":{"$ref":"#/definitions/wechat"}, + "firstlogin":{"$ref":"#/definitions/firstlogin"}, + "lastlogin":{"$ref":"#/definitions/lastlogin"}, + "created":{"$ref":"created-modified.json#/definitions/created"}, + "modified":{"$ref":"created-modified.json#/definitions/modified"} + }, + "additionalProperties":false, + "required":[ + "_id", "firstname", "lastname", + "root", "email", "created", "modified" + ] } } } diff --git a/raml/schemas/definitions/version.json b/raml/schemas/definitions/version.json new file mode 100644 index 0000000000000000000000000000000000000000..b819ec7ed466fab5fbe079a98e7827d1fcb09b4a --- /dev/null +++ b/raml/schemas/definitions/version.json @@ -0,0 +1,20 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "definitions": { + "version-output": { + "type": "object", + "properties": { + "_id": { + "type": "string" + }, + "database": { + "type": "integer" + } + }, + "required": [ + "_id", + "database" + ] + } + } +} diff --git a/raml/schemas/input/acquisition-update.json b/raml/schemas/input/acquisition-update.json index 0475b21448bb18fb5f20b90fc15c718d468ce3dc..df6a087fdeec84ebed16982dcbe77552b8e044c1 100644 --- a/raml/schemas/input/acquisition-update.json +++ b/raml/schemas/input/acquisition-update.json @@ -2,5 +2,8 @@ "$schema": "http://json-schema.org/draft-04/schema#", "title": "Acquisition", "type": "object", - "allOf": [{"$ref": "../definitions/acquisition.json#/definitions/acquisition-input"}] + "allOf": [{"$ref": "../definitions/acquisition.json#/definitions/acquisition-input"}], + "example": { + "label": "example-acquisition-new-label" + } } diff --git a/raml/schemas/input/acquisition.json b/raml/schemas/input/acquisition.json index 572c9606373c744be6d3628a0e3ee498397690db..eeb6f83acca045313156792d4834cc8a4395134a 100644 --- a/raml/schemas/input/acquisition.json +++ b/raml/schemas/input/acquisition.json @@ -3,5 +3,10 @@ "title": "Acquisition", "type": "object", "allOf": [{"$ref": "../definitions/acquisition.json#/definitions/acquisition-input"}], - "required": ["label", "session"] + "required": ["label", "session"], + "example": { + "label": "example-acquisition", + "session": "57e45328466d8e000e33a85b", + "public": false + } } diff --git a/raml/schemas/input/analysis-job.json b/raml/schemas/input/analysis-job.json index 8de987c371c824da5da976cabcee8c7f3a80599f..ff780505924e50d0eb6165f0f14a16868ecd41a8 100644 --- a/raml/schemas/input/analysis-job.json +++ b/raml/schemas/input/analysis-job.json @@ -1,14 +1,21 @@ { "$schema": "http://json-schema.org/draft-04/schema#", "type": "object", - "properties":{ - "analysis":{ - "type":"object", - "allOf":[{"$ref":"../definitions/analysis.json#/definitions/analysis-input"}], - "required":["label"] + "allOf": [{"$ref":"../definitions/analysis.json#/definitions/analysis-job"}], + "example": { + "analysis": { + "label": "Test Analysis 1" }, - "job":{ - "type":"object" + "job" : { + "gear_id": "dcm_convert", + "inputs": { + "dicom": { + "type": "acquisition", + "id": "57081d06b386a6dc79ca386b", + "name" : "test_acquisition_dicom.zip" + } + }, + "tags": ["example"] } } } diff --git a/raml/schemas/input/collection-update.json b/raml/schemas/input/collection-update.json index 0548ea23a41968440cef93e352ee50657346397d..8f295d9b10b54e98b2ff6986a4d1fcddd4de7728 100644 --- a/raml/schemas/input/collection-update.json +++ b/raml/schemas/input/collection-update.json @@ -4,6 +4,12 @@ "type": "object", "allOf": [{"$ref": "../definitions/collection.json#/definitions/collection-input-with-contents"}], "example": { - "$ref": "../../examples/input/collection-update.json" - } + "contents": { + "operation": "add", + "nodes": [{ + "level": "session", + "_id": "57dc50b0931cefd8ac2a371e" + }] + } + } } diff --git a/raml/schemas/input/collection.json b/raml/schemas/input/collection.json index bd52b275a9a5657840f13ae6204b73f54537f1c8..05a952ab5ce0b99a3417ea945ffd60600b7338c7 100644 --- a/raml/schemas/input/collection.json +++ b/raml/schemas/input/collection.json @@ -5,6 +5,7 @@ "allOf": [{"$ref": "../definitions/collection.json#/definitions/collection-input"}], "required": ["label"], "example": { - "$ref": "../../examples/input/collection.json" + "label":"control-group", + "description":"Control group collection" } } diff --git a/raml/schemas/input/device.json b/raml/schemas/input/device.json index ea54fede5bc43678d2e1d7c8dc30c72aeb39db13..2e9a433c5ee2bfb1527a0ea443e5800b29f8844e 100644 --- a/raml/schemas/input/device.json +++ b/raml/schemas/input/device.json @@ -2,6 +2,12 @@ "$schema": "http://json-schema.org/draft-04/schema#", "allOf":[{"$ref":"../definitions/device.json#/definitions/device-input"}], "example": { - "$ref": "../../examples/input/device.json" - } + "info": { + "basic": "info" + }, + "errors": [ + "An Error" + ], + "interval": 400 + } } diff --git a/raml/schemas/input/download.json b/raml/schemas/input/download.json index fc5141878216d414d87c1998cd59b916479cfd69..ce1541d04c1a0019c644334b7bf95bbafb346c87 100644 --- a/raml/schemas/input/download.json +++ b/raml/schemas/input/download.json @@ -1,64 +1,8 @@ { "$schema": "http://json-schema.org/draft-04/schema#", - "definitions": { - "filterDefinition": { - "type": "object", - "properties": { - "+": {"$ref": "#/definitions/filterItems"}, - "plus": {"$ref": "#definitions/filterItems"}, - "-": {"$ref": "#/definitions/filterItems"}, - "minus": {"$ref": "#definitions/filterItems"} - }, - "additionalProperties": false - }, - "filterItems": { - "type": "array", - "minItems": 1, - "items": { - "type": "string" - } - } - }, - "title": "Download", - "type": "object", + "$ref": "../definitions/download.json#/definitions/download-input", + "example": { "$ref": "../../examples/create_download_incomplete_and_dicom.json" - }, - "properties": { - "optional": { - "type": "boolean" - }, - "nodes": { - "type": "array", - "minItems": 1, - "items": { - "type": "object", - "properties": { - "level": { - "type": "string", - "enum": ["project", "session", "acquisition", "analysis"] - }, - "_id": { - "type": "string", - "pattern": "^[0-9a-f]{24}$" - } - }, - "required": ["level", "_id"], - "additionalProperties": false - } - }, - "filters": { - "type": "array", - "minItems": 1, - "items": { - "type": "object", - "properties": { - "tags": {"$ref": "#/definitions/filterDefinition"}, - "types": {"$ref": "#/definitions/filterDefinition"} - } - } - } - }, - "required": ["optional", "nodes"], - "additionalProperties": false + } } diff --git a/raml/schemas/input/enginemetadata.json b/raml/schemas/input/enginemetadata.json index 7a50879d393281acd926f8b0228b5202e57c19d2..928435559e0ff3613597411fa255f9f491d8dc66 100644 --- a/raml/schemas/input/enginemetadata.json +++ b/raml/schemas/input/enginemetadata.json @@ -1,58 +1,4 @@ { "$schema": "http://json-schema.org/draft-04/schema#", - "title": "EngineMetadata", - "type": "object", - "properties": { - "project": { - "type": "object", - "properties": { - "public": {"type": ["boolean", "null"]}, - "label": {"type": ["string", "null"]}, - "info": {"type": ["object", "null"]}, - "files": { - "type": ["array", "null"], - "items": {"$ref": "file.json"} - } - }, - "additionalProperties": false - }, - "session": { - "type": "object", - "properties": { - "public": {"type": ["boolean", "null"]}, - "label": {"type": ["string", "null"]}, - "info": {"type": ["object", "null"]}, - "operator": {"type": ["string", "null"]}, - "uid": {"type": ["string", "null"]}, - "timestamp": {"type": ["string", "null"], "format": "date-time"}, - "timezone": {"type": ["string", "null"]}, - "subject": {"$ref": "subject.json"}, - "files": { - "type": ["array", "null"], - "items": {"$ref": "file.json"} - } - }, - "additionalProperties": false - }, - "acquisition": { - "type": "object", - "properties": { - "public": {"type": ["boolean", "null"]}, - "label": {"type": ["string", "null"]}, - "info": {"type": ["object", "null"]}, - "metadata": {"type": ["object", "null"]}, - "measurement": {"type": ["string", "null"]}, - "instrument": {"type": ["string", "null"]}, - "uid": {"type": ["string", "null"]}, - "timestamp": {"type": ["string", "null"], "format": "date-time"}, - "timezone": {"type": ["string", "null"]}, - "files": { - "type": ["array", "null"], - "items": {"$ref": "file.json"} - } - }, - "additionalProperties": false - } - }, - "additionalProperties": false + "$ref": "../definitions/enginemetadata.json#/definitions/engine-upload-input" } diff --git a/raml/schemas/input/group-new.json b/raml/schemas/input/group-new.json index a91eeab7b0c1993a37370397e76cb476e1e162d8..09a7e2be6abed5193e5cd2019b7a522c15e65793 100644 --- a/raml/schemas/input/group-new.json +++ b/raml/schemas/input/group-new.json @@ -5,6 +5,7 @@ ], "required": ["_id"], "example": { - "$ref": "../../examples/input/group-new.json" - } + "label": "Example Group", + "_id": "example_group" + } } diff --git a/raml/schemas/input/group-update.json b/raml/schemas/input/group-update.json index ca78a1358dc28f14e2b28ae2766faaf73e1503e4..7a1ee81e54d37fe8a096c9d8925f7150a2c058b0 100644 --- a/raml/schemas/input/group-update.json +++ b/raml/schemas/input/group-update.json @@ -2,6 +2,6 @@ "$schema": "http://json-schema.org/draft-04/schema#", "allOf":[{"$ref":"../definitions/group.json#/definitions/group-input"}], "example": { - "$ref": "../../examples/input/group-update.json" - } + "label":"New group label" + } } diff --git a/raml/schemas/input/info_update.json b/raml/schemas/input/info_update.json index 353780b0d9bc20c45245163c8ed2031038eed05b..d483672a2654e1df3d717236da7726d2e3f92b1c 100644 --- a/raml/schemas/input/info_update.json +++ b/raml/schemas/input/info_update.json @@ -1,25 +1,4 @@ { "$schema": "http://json-schema.org/draft-04/schema#", - "description": "Helper endpoint for editing an object's info key", - "type": "object", - "oneOf": [ - { - "properties": { - "set": {"type": "object", "minProperties": 1}, - "delete": { - "type": "array", - "uniqueItems": true, - "minItems": 1, - "items": { - "type": "string" - } - } - }, "additionalProperties": false - }, - { - "properties": { - "replace": {"type": "object"} - }, "additionalProperties": false - } - ] + "$ref": "../definitions/info.json#/definitions/info-update-input" } diff --git a/raml/schemas/input/labelupload.json b/raml/schemas/input/labelupload.json index da6bde93d5fedf337a26e8fc8b780e1bf977cd47..a981784ef25a863e87ea176f19e5cc8d3e7d5850 100644 --- a/raml/schemas/input/labelupload.json +++ b/raml/schemas/input/labelupload.json @@ -1,67 +1,4 @@ { "$schema": "http://json-schema.org/draft-04/schema#", - "title": "EngineMetadata", - "type": "object", - "properties": { - "group": { - "type": "object", - "properties": { - "_id": {"type": "string"} - }, - "additionalProperties": false, - "required": ["_id"] - }, - "project": { - "type": "object", - "properties": { - "public": {"type": ["boolean", "null"]}, - "label": {"type": "string"}, - "info": {"type": ["object", "null"]}, - "files": { - "type": ["array", "null"], - "items": {"$ref": "file.json"} - } - }, - "additionalProperties": false, - "required": ["label"] - }, - "session": { - "type": "object", - "properties": { - "public": {"type": ["boolean", "null"]}, - "label": {"type": "string"}, - "info": {"type": ["object", "null"]}, - "operator": {"type": ["string", "null"]}, - "uid": {"type": ["string", "null"]}, - "timestamp": {"type": ["string", "null"], "format": "date-time"}, - "timezone": {"type": ["string", "null"]}, - "subject": {"$ref": "subject.json"}, - "files": { - "type": ["array", "null"], - "items": {"$ref": "file.json"} - } - }, - "additionalProperties": false, - "required": ["label"] - }, - "acquisition": { - "type": "object", - "properties": { - "public": {"type": ["boolean", "null"]}, - "label": {"type": "string"}, - "info": {"type": ["object", "null"]}, - "uid": {"type": ["string", "null"]}, - "timestamp": {"type": ["string", "null"], "format": "date-time"}, - "timezone": {"type": ["string", "null"]}, - "files": { - "type": ["array", "null"], - "items": {"$ref": "file.json"} - } - }, - "additionalProperties": false, - "required": ["label"] - } - }, - "required": ["group", "project"], - "additionalProperties": false + "$ref": "../definitions/enginemetadata.json#/definitions/label-upload-input" } diff --git a/raml/schemas/input/note.json b/raml/schemas/input/note.json index abca18417c4c481368b6f5c07c9fc2a8cedfe7b1..372193eedc09367a5d8efbbecd4cde1187351c12 100644 --- a/raml/schemas/input/note.json +++ b/raml/schemas/input/note.json @@ -4,6 +4,6 @@ "allOf":[{"$ref":"../definitions/note.json#/definitions/note-input"}], "required": ["text"], "example": { - "$ref": "../../examples/input/note.json" - } + "text":"Scitran core!" + } } diff --git a/raml/schemas/input/packfile.json b/raml/schemas/input/packfile.json index c82d2999d2f9905fa97399bbabc3c7797e20fd22..7bc27ec0ad4ade00315e282882da9dae203a9b98 100644 --- a/raml/schemas/input/packfile.json +++ b/raml/schemas/input/packfile.json @@ -1,44 +1,4 @@ { "$schema": "http://json-schema.org/draft-04/schema#", - "title": "Packfile", - "type": "object", - "properties": { - "project": { - "type": "object", - "properties": { - "_id": {"type": "string"} - }, - "additionalProperties": false, - "required": ["_id"] - }, - "session": { - "type": "object", - "properties": { - "label": {"type": "string"}, - "subject": {"$ref": "subject.json"} - }, - "additionalProperties": false, - "required": ["label"] - }, - "acquisition": { - "type": "object", - "properties": { - "label": {"type": "string"}, - "timestamp": {"type": ["string", "null"], "format": "date-time"}, - "timezone": {"type": "string"} - }, - "additionalProperties": false, - "required": ["label"] - }, - "packfile": { - "type": "object", - "properties": { - "type": {"type": "string"} - }, - "additionalProperties": false, - "required": ["type"] - } - }, - "required": ["project", "session", "acquisition", "packfile"], - "additionalProperties": false + "$ref": "../definitions/packfile.json#/definitions/packfile-input" } diff --git a/raml/schemas/input/permission.json b/raml/schemas/input/permission.json index 0a609c4498d68ac149c7e7393884b40c87b3df30..b773ec8176832941cf3ba40e0cebf03bf5eb770b 100644 --- a/raml/schemas/input/permission.json +++ b/raml/schemas/input/permission.json @@ -5,6 +5,7 @@ "key_fields": ["_id"], "required": ["_id", "access"], "example": { - "$ref": "../../examples/input/permission.json" - } + "_id":"coltonlw@flywheel.io", + "access":"admin" + } } diff --git a/raml/schemas/input/search.json b/raml/schemas/input/search.json deleted file mode 100644 index 9cb5be0dcd90830f9fb72c6839d4266404d0f845..0000000000000000000000000000000000000000 --- a/raml/schemas/input/search.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-04/schema#", - "type": "object", - "properties": { - "node_type": { - "type": "string", - "enum": ["project", "session", "acquisition", "file", "note"] - }, - "rel_type": { - "type": "string", - "enum": ["target", "parent", "child"] - }, - "query": {"type": "object"}, - "relations": { - "type": "array", - "items": {"$ref": "#"} - } - }, - "additionalProperties": false, - "required": ["node_type", "rel_type", "query", "relations"] -} diff --git a/raml/schemas/input/tag.json b/raml/schemas/input/tag.json index b540ddbc0ef934632bcacb8a1cee8c790171b2f1..d47d9bab7ecd4f7037585d2221a57baafaa43143 100644 --- a/raml/schemas/input/tag.json +++ b/raml/schemas/input/tag.json @@ -2,6 +2,6 @@ "$schema": "http://json-schema.org/draft-04/schema#", "allOf":[{"$ref":"../definitions/tag.json#/definitions/tag"}], "example": { - "$ref": "../../examples/input/tag.json" - } + "value":"example-tag" + } } diff --git a/raml/schemas/input/uidmatchupload.json b/raml/schemas/input/uidmatchupload.json index ee4fe89f429eef554d4c5868a8d49d239ba71029..bfbe7b5640fdec422d821fa53bbbc9354441c617 100644 --- a/raml/schemas/input/uidmatchupload.json +++ b/raml/schemas/input/uidmatchupload.json @@ -1,58 +1,4 @@ { "$schema": "http://json-schema.org/draft-04/schema#", - "title": "EngineMetadata", - "type": "object", - "properties": { - "project": { - "type": "object", - "properties": { - "public": {"type": ["boolean", "null"]}, - "label": {"type": "string"}, - "info": {"type": ["object", "null"]}, - "files": { - "type": ["array", "null"], - "items": {"$ref": "file.json"} - } - }, - "additionalProperties": false - }, - "session": { - "type": "object", - "properties": { - "public": {"type": ["boolean", "null"]}, - "label": {"type": ["string", "null"]}, - "info": {"type": ["object", "null"]}, - "operator": {"type": ["string", "null"]}, - "uid": {"type": "string"}, - "timestamp": {"type": ["string", "null"], "format": "date-time"}, - "timezone": {"type": ["string", "null"]}, - "subject": {"$ref": "subject.json"}, - "files": { - "type": ["array", "null"], - "items": {"$ref": "file.json"} - } - }, - "additionalProperties": false, - "required": ["uid"] - }, - "acquisition": { - "type": "object", - "properties": { - "public": {"type": ["boolean", "null"]}, - "label": {"type": ["string", "null"]}, - "info": {"type": ["object", "null"]}, - "uid": {"type": "string"}, - "timestamp": {"type": ["string", "null"], "format": "date-time"}, - "timezone": {"type": ["string", "null"]}, - "files": { - "type": ["array", "null"], - "items": {"$ref": "file.json"} - } - }, - "additionalProperties": false, - "required": ["uid"] - } - }, - "required": ["acquisition", "session"], - "additionalProperties": false + "$ref": "../definitions/enginemetadata.json#/definitions/uid-match-upload-input" } diff --git a/raml/schemas/input/uidupload.json b/raml/schemas/input/uidupload.json index deb84256fdd9a8af64dd4b5ac51e4134ecb6d383..319cbddf40939c3f8e82acaed711333a7bb4eacd 100644 --- a/raml/schemas/input/uidupload.json +++ b/raml/schemas/input/uidupload.json @@ -1,67 +1,4 @@ { "$schema": "http://json-schema.org/draft-04/schema#", - "title": "EngineMetadata", - "type": "object", - "properties": { - "group": { - "type": "object", - "properties": { - "_id": {"type": "string"} - }, - "additionalProperties": false, - "required": ["_id"] - }, - "project": { - "type": "object", - "properties": { - "public": {"type": ["boolean", "null"]}, - "label": {"type": "string"}, - "info": {"type": ["object", "null"]}, - "files": { - "type": ["array", "null"], - "items": {"$ref": "file.json"} - } - }, - "additionalProperties": false, - "required": ["label"] - }, - "session": { - "type": "object", - "properties": { - "public": {"type": ["boolean", "null"]}, - "label": {"type": ["string", "null"]}, - "info": {"type": ["object", "null"]}, - "operator": {"type": ["string", "null"]}, - "uid": {"type": "string"}, - "timestamp": {"type": ["string", "null"], "format": "date-time"}, - "timezone": {"type": ["string", "null"]}, - "subject": {"$ref": "subject.json"}, - "files": { - "type": ["array", "null"], - "items": {"$ref": "file.json"} - } - }, - "additionalProperties": false, - "required": ["uid"] - }, - "acquisition": { - "type": "object", - "properties": { - "public": {"type": ["boolean", "null"]}, - "label": {"type": ["string", "null"]}, - "info": {"type": ["object", "null"]}, - "uid": {"type": "string"}, - "timestamp": {"type": ["string", "null"], "format": "date-time"}, - "timezone": {"type": ["string", "null"]}, - "files": { - "type": ["array", "null"], - "items": {"$ref": "file.json"} - } - }, - "additionalProperties": false, - "required": ["uid"] - } - }, - "required": ["acquisition", "group", "project", "session"], - "additionalProperties": false + "$ref": "../definitions/enginemetadata.json#/definitions/uid-upload-input" } diff --git a/raml/schemas/input/user-new.json b/raml/schemas/input/user-new.json index 7e8d50cf76ba9cb62548fb066b9f7b3a714ae306..0043b064ab8c528bc2e9b703911d293dbd37ba20 100644 --- a/raml/schemas/input/user-new.json +++ b/raml/schemas/input/user-new.json @@ -4,6 +4,10 @@ "allOf":[{"$ref":"../definitions/user.json#/definitions/user-input"}], "required":["_id", "firstname", "lastname"], "example": { - "$ref": "../../examples/input/user-new.json" - } + "_id": "jane.doe@gmail.com", + "firstname": "Jane", + "lastname": "Doe", + "email": "jane.doe@gmail.com", + "root": false + } } diff --git a/raml/schemas/input/user-update.json b/raml/schemas/input/user-update.json index 1a9ca4a648024848af80eae499a51fa9eba2d1b8..2f401f23e3c3a9909aab5c9b730175c1e0857d6a 100644 --- a/raml/schemas/input/user-update.json +++ b/raml/schemas/input/user-update.json @@ -6,6 +6,8 @@ {"$ref":"../definitions/user.json#/definitions/user-input"} ], "example": { - "$ref": "../../examples/input/user-update.json" - } + "firstname": "Jane", + "lastname": "Smith", + "email": "jane.smith@gmail.com" + } } diff --git a/raml/schemas/output/collection-curators-list.json b/raml/schemas/output/collection-curators-list.json index 0775505e85cde5e5aea77a2d352e26397ebe6ce5..302206059378ba8014afe877512773c2aa6ea1b4 100644 --- a/raml/schemas/output/collection-curators-list.json +++ b/raml/schemas/output/collection-curators-list.json @@ -5,7 +5,7 @@ "properties":{ "firstname":{"$ref":"../definitions/user.json#/definitions/firstname"}, "lastname":{"$ref":"../definitions/user.json#/definitions/lastname"}, - "_id":{"$ref":"../definitions/user.json#/definitions/_id"} + "_id":{"$ref":"../definitions/common.json#/definitions/user-id"} } } } diff --git a/raml/schemas/output/device-list.json b/raml/schemas/output/device-list.json index c65170b95356b528e9fc654f5de0496b110f237e..d137fddad79ab51c2a232b83f135c955b70e5004 100644 --- a/raml/schemas/output/device-list.json +++ b/raml/schemas/output/device-list.json @@ -1,20 +1,5 @@ { "$schema": "http://json-schema.org/draft-04/schema#", "type": "array", - "items": { - "type":"object", - "properties":{ - "_id":{"$ref":"../definitions/device.json#/definitions/id"}, - "method":{"$ref":"../definitions/device.json#/definitions/method"}, - "name":{"$ref":"../definitions/device.json#/definitions/name"}, - "errors":{"$ref":"../definitions/device.json#/definitions/errors"}, - "info":{"$ref":"../definitions/device.json#/definitions/info"}, - "interval":{"$ref":"../definitions/device.json#/definitions/interval"}, - "last_seen":{"$ref":"../definitions/device.json#/definitions/last_seen"} - }, - "additionalProperties":false, - "required":[ - "_id", "name", "method", "last_seen" - ] - } + "items": { "$ref":"../definitions/device.json#/definitions/device-output" } } diff --git a/raml/schemas/output/device-status.json b/raml/schemas/output/device-status.json index 6b1999ca6759cbe0eb5cbe316c90d36ec32d25ee..d4c85724b389d0b667b9127ed753576e05c63a23 100644 --- a/raml/schemas/output/device-status.json +++ b/raml/schemas/output/device-status.json @@ -1,17 +1,4 @@ { "$schema": "http://json-schema.org/draft-04/schema#", - "type":"object", - "patternProperties": { - "^[0-9a-z.@_-]*$":{ - "properties":{ - "errors":{"$ref":"../definitions/device.json#/definitions/errors"}, - "last_seen":{"$ref":"../definitions/device.json#/definitions/last_seen"}, - "status": { "enum": ["ok", "missing", "error", "unknown"] } - }, - "additionalProperties":false, - "required":[ - "last_seen", "status" - ] - } - } + "allOf": [{"$ref":"../definitions/device.json#/definitions/device-status"}] } diff --git a/raml/schemas/output/device.json b/raml/schemas/output/device.json index 8f270db7b70fb8eb8e7d9a9983969be662567aa0..cb79c43788aea1e60fe84d4bdae59777355bdc96 100644 --- a/raml/schemas/output/device.json +++ b/raml/schemas/output/device.json @@ -1,17 +1,4 @@ { "$schema": "http://json-schema.org/draft-04/schema#", - "type":"object", - "properties":{ - "_id":{"$ref":"../definitions/device.json#/definitions/id"}, - "method":{"$ref":"../definitions/device.json#/definitions/method"}, - "name":{"$ref":"../definitions/device.json#/definitions/name"}, - "errors":{"$ref":"../definitions/device.json#/definitions/errors"}, - "info":{"$ref":"../definitions/device.json#/definitions/info"}, - "interval":{"$ref":"../definitions/device.json#/definitions/interval"}, - "last_seen":{"$ref":"../definitions/device.json#/definitions/last_seen"} - }, - "additionalProperties":false, - "required":[ - "_id", "name", "method", "last_seen" - ] + "allOf":[{"$ref":"../definitions/device.json#/definitions/device-output"}] } diff --git a/raml/schemas/output/file-download.json b/raml/schemas/output/file-download.json index 3c7592e29aa1be072cf0232f6c10eea9837360f2..8cd7a7f05ead309888996a2473cfe17cd257ea0d 100644 --- a/raml/schemas/output/file-download.json +++ b/raml/schemas/output/file-download.json @@ -1,9 +1,4 @@ { "$schema": "http://json-schema.org/draft-04/schema#", - "type":"object", - "properties":{ - "ticket":{"type":"string"} - }, - "additionalProperties":false, - "required":["ticket"] + "$ref": "../definitions/download.json#/definitions/download-ticket" } diff --git a/raml/schemas/output/gears-list.json b/raml/schemas/output/gears-list.json deleted file mode 100644 index e10eaf826b3f7020b1e9cd051e70c2ae8b67f635..0000000000000000000000000000000000000000 --- a/raml/schemas/output/gears-list.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-04/schema#", - "type": "array", - "items": { - "type": "object", - "properties": { - "name": { - "type": "string" - } - }, - "required": [ - "name" - ] - } -} diff --git a/raml/schemas/output/group-delete.json b/raml/schemas/output/group-delete.json index 300c991e4f1547ed8e41856281ae7cb85a9349c5..12e4a66089b694f7d02d9caa54cc14a5d2af1f55 100644 --- a/raml/schemas/output/group-delete.json +++ b/raml/schemas/output/group-delete.json @@ -1,9 +1,4 @@ { "$schema": "http://json-schema.org/draft-04/schema#", - "type":"object", - "properties":{ - "deleted":{ - "type":"number" - } - } + "$ref": "../definitions/common.json#/definitions/deleted-count" } diff --git a/raml/schemas/output/job-list.json b/raml/schemas/output/job-list.json index 7dcaf6d09153ea4ed47cd03cd36c7fba9149bc36..a7d1ac7b68d0ec31469ff0b2abbacfe1ee0b1715 100644 --- a/raml/schemas/output/job-list.json +++ b/raml/schemas/output/job-list.json @@ -1,29 +1,5 @@ { "$schema": "http://json-schema.org/draft-04/schema#", "type": "array", - "items": { - "type":"object", - "properties":{ - "_id":{"$ref":"../definitions/job.json#/definitions/_id"}, - "origin":{"$ref":"../definitions/job.json#/definitions/origin"}, - "gear_id":{"$ref":"../definitions/job.json#/definitions/gear_id"}, - "previous_job_id":{"$ref":"../definitions/job.json#/definitions/previous_job_id"}, - "inputs":{"$ref":"../definitions/job.json#/definitions/inputs-array"}, - "destination":{"$ref":"../definitions/job.json#/definitions/destination"}, - "tags":{"$ref":"../definitions/job.json#/definitions/tags"}, - "state":{"$ref":"../definitions/job.json#/definitions/state"}, - "attempt":{"$ref":"../definitions/job.json#/definitions/attempt"}, - "created":{"$ref":"../definitions/created-modified.json#/definitions/created"}, - "modified":{"$ref":"../definitions/created-modified.json#/definitions/modified"}, - "config":{"$ref":"../definitions/job.json#/definitions/config"}, - "request":{"$ref":"../definitions/job.json#/definitions/request"}, - "saved_files":{"$ref":"../definitions/job.json#/definitions/saved_files"}, - "produced_metadata":{"$ref":"../definitions/job.json#/definitions/produced_metadata"} - }, - "additionalProperties":false, - "required":[ - "_id", "gear_id", "inputs", - "destination", "tags", "state", "attempt" - ] - } + "items": {"$ref": "../definitions/job.json#/definitions/job-output"} } diff --git a/raml/schemas/output/job-new.json b/raml/schemas/output/job-new.json index f4cb59603fb44101bb4397b9c7e7489b9218b9ac..f153b501ed410139871f63d07f51f6c5c3fd4ee6 100644 --- a/raml/schemas/output/job-new.json +++ b/raml/schemas/output/job-new.json @@ -1,12 +1,4 @@ { "$schema": "http://json-schema.org/draft-04/schema#", - "type": "object", - "properties": { - "_id": { - "type": "string" - } - }, - "required": [ - "_id" - ] + "$ref": "../definitions/common.json#/definitions/object-created" } diff --git a/raml/schemas/output/job-next.json b/raml/schemas/output/job-next.json deleted file mode 100644 index 98cc5684e051efd997bf7b9cb7f0e67a234d8116..0000000000000000000000000000000000000000 --- a/raml/schemas/output/job-next.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-04/schema#", - "type":"object", - "properties":{ - "_id":{"$ref":"../definitions/job.json#/definitions/_id"}, - "origin":{"$ref":"../definitions/job.json#/definitions/origin"}, - "gear_id":{"$ref":"../definitions/job.json#/definitions/gear_id"}, - "previous_job_id":{"$ref":"../definitions/job.json#/definitions/previous_job_id"}, - "inputs":{"$ref":"../definitions/job.json#/definitions/inputs-array"}, - "destination":{"$ref":"../definitions/job.json#/definitions/destination"}, - "tags":{"$ref":"../definitions/job.json#/definitions/tags"}, - "state":{"$ref":"../definitions/job.json#/definitions/state"}, - "attempt":{"$ref":"../definitions/job.json#/definitions/attempt"}, - "created":{"$ref":"../definitions/created-modified.json#/definitions/created"}, - "modified":{"$ref":"../definitions/created-modified.json#/definitions/modified"}, - "config":{"$ref":"../definitions/job.json#/definitions/config"}, - "request":{"$ref":"../definitions/job.json#/definitions/request"}, - "saved_files":{"$ref":"../definitions/job.json#/definitions/saved_files"}, - "produced_metadata":{"$ref":"../definitions/job.json#/definitions/produced_metadata"} - }, - "additionalProperties":false, - "required":[ - "_id", "gear_id", "inputs", "config", - "destination", "tags", "state", "attempt" - ] -} diff --git a/raml/schemas/output/job.json b/raml/schemas/output/job.json index 46b3ca9fe999c2a5a6768a4a2fc05806e7ae4c9c..1b3149f4ee5896a40bbb61102666c830fd08ae3c 100644 --- a/raml/schemas/output/job.json +++ b/raml/schemas/output/job.json @@ -1,26 +1,5 @@ { "$schema": "http://json-schema.org/draft-04/schema#", "type":"object", - "properties":{ - "id":{"$ref":"../definitions/job.json#/definitions/_id"}, - "origin":{"$ref":"../definitions/job.json#/definitions/origin"}, - "gear_id":{"$ref":"../definitions/job.json#/definitions/gear_id"}, - "previous_job_id":{"$ref":"../definitions/job.json#/definitions/previous_job_id"}, - "inputs":{"$ref":"../definitions/job.json#/definitions/inputs-object"}, - "destination":{"$ref":"../definitions/job.json#/definitions/destination"}, - "tags":{"$ref":"../definitions/job.json#/definitions/tags"}, - "state":{"$ref":"../definitions/job.json#/definitions/state"}, - "attempt":{"$ref":"../definitions/job.json#/definitions/attempt"}, - "created":{"$ref":"../definitions/created-modified.json#/definitions/created"}, - "modified":{"$ref":"../definitions/created-modified.json#/definitions/modified"}, - "config":{"$ref":"../definitions/job.json#/definitions/config"}, - "request":{"$ref":"../definitions/job.json#/definitions/request"}, - "saved_files":{"$ref":"../definitions/job.json#/definitions/saved_files"}, - "produced_metadata":{"$ref":"../definitions/job.json#/definitions/produced_metadata"} - }, - "additionalProperties":false, - "required":[ - "id", "gear_id", "inputs", "config", - "destination", "tags", "state", "attempt" - ] + "allOf":[{"$ref":"../definitions/job.json#/definitions/job-output"}] } diff --git a/raml/schemas/output/packfile-start.json b/raml/schemas/output/packfile-start.json index 41133098cae62c55ff710cf172709cc1d870b268..addf037e72f8b2e18dc129fa142134c892b52753 100644 --- a/raml/schemas/output/packfile-start.json +++ b/raml/schemas/output/packfile-start.json @@ -1,7 +1,4 @@ { "$schema": "http://json-schema.org/draft-04/schema#", - "type":"object", - "properties":{ - "token":{"$ref":"../definitions/objectid.json#"} - } + "$ref": "../definitions/packfile.json#/definitions/packfile-start" } diff --git a/raml/schemas/output/report-project.json b/raml/schemas/output/report-project.json index 96e493cdfd7a7e6270c41e978ed47057cd3536a2..9ead3363d7140f10c94325aa8e8065b3dab250d1 100644 --- a/raml/schemas/output/report-project.json +++ b/raml/schemas/output/report-project.json @@ -1,86 +1,4 @@ { "$schema": "http://json-schema.org/draft-04/schema#", - "type":"object", - "definitions":{ - "gender_count":{ - "type":"object", - "properties":{ - "Male": {"type":"integer"}, - "Unknown or Not Reported":{"type":"integer"}, - "Female":{"type":"integer"} - }, - "additionalProperties":false, - "required":["Male", "Female", "Unknown or Not Reported"] - }, - "ethnicity_grid":{ - "type":"object", - "properties":{ - "Not Hispanic or Latino":{ - "allOf":[{"$ref":"#/definitions/gender_count"}] - }, - "Hispanic or Latino":{ - "allOf":[{"$ref":"#/definitions/gender_count"}] - }, - "Unknown or Not Reported":{ - "allOf":[{"$ref":"#/definitions/gender_count"}] - }, - "Total":{"type":"integer"} - } - } - }, - "properties":{ - "projects":{ - "type":"array", - "items":{ - "type":"object", - "properties":{ - "demographics_grid":{ - "type":"object", - "properties":{ - "Black or African American":{ - "allOf":[{"$ref":"#/definitions/ethnicity_grid"}] - }, - "Unknown or Not Reported":{ - "allOf":[{"$ref":"#/definitions/ethnicity_grid"}] - }, - "American Indian or Alaska Native":{ - "allOf":[{"$ref":"#/definitions/ethnicity_grid"}] - }, - "Asian":{ - "allOf":[{"$ref":"#/definitions/ethnicity_grid"}] - }, - "White":{ - "allOf":[{"$ref":"#/definitions/ethnicity_grid"}] - }, - "Total":{ - "allOf":[{"$ref":"#/definitions/ethnicity_grid"}] - }, - "Native Hawaiian or Other Pacific Islander":{ - "allOf":[{"$ref":"#/definitions/ethnicity_grid"}] - }, - "More Than One Race":{ - "allOf":[{"$ref":"#/definitions/ethnicity_grid"}] - }, - "male_count": {"type":"integer"}, - "group_label": {"$ref":"../definitions/container.json#/definitions/label"}, - "over_18_count": {"type":"integer"}, - "under_18_count": {"type":"integer"}, - "female_count": {"type":"integer"}, - "subjects_count": {"type":"integer"}, - "other_count": {"type":"integer"}, - "name": {"$ref":"../definitions/container.json#/definitions/label"}, - "session_count": {"type":"integer"}, - "admins": { - "type":"array", - "items":{ - "type":"string" - } - }, - "demographics_total": {"type":"integer"} - } - } - } - } - } - } + "$ref": "../definitions/report.json#/definitions/report-project" } diff --git a/raml/schemas/output/report-site.json b/raml/schemas/output/report-site.json index a764b8e2c092d1f9ddde907cae886e390fd08aa1..da9f8518a668a73ae85177d172a1b085997ca433 100644 --- a/raml/schemas/output/report-site.json +++ b/raml/schemas/output/report-site.json @@ -1,27 +1,4 @@ { "$schema": "http://json-schema.org/draft-04/schema#", - "type":"object", - "properties":{ - "group_count":{"type":"integer"}, - "groups":{ - "type":"array", - "items":{ - "type":"object", - "properties":{ - "project_count":{"type":"integer"}, - "label":{ - "oneOf":[ - {"$ref":"../definitions/group.json#/definitions/label"}, - {"type":"null"} - ] - }, - "session_count":{"type":"integer"} - }, - "additionalProperties":false, - "required":["project_count", "label", "session_count"] - } - } - }, - "additionalProperties":false, - "required":["group_count", "groups"] + "$ref": "../definitions/report.json#/definitions/report-site" } diff --git a/raml/schemas/output/session-jobs.json b/raml/schemas/output/session-jobs.json index e0a35caa3155f78603d4f03fc4f52951fdeab530..2de34142b3cd2a9fb2f2399031deab2558465c66 100644 --- a/raml/schemas/output/session-jobs.json +++ b/raml/schemas/output/session-jobs.json @@ -1,41 +1,4 @@ { "$schema": "http://json-schema.org/draft-04/schema#", - "type": "object", - "properties":{ - "jobs":{ - "type":"array", - "items":{ - "type":"object", - "properties":{ - "id":{"$ref":"../definitions/job.json#/definitions/_id"}, - "origin":{"$ref":"../definitions/job.json#/definitions/origin"}, - "gear_id":{"$ref":"../definitions/job.json#/definitions/gear_id"}, - "inputs":{"$ref":"../definitions/job.json#/definitions/inputs-object"}, - "destination":{"$ref":"../definitions/job.json#/definitions/destination"}, - "tags":{"$ref":"../definitions/job.json#/definitions/tags"}, - "state":{"$ref":"../definitions/job.json#/definitions/state"}, - "attempt":{"$ref":"../definitions/job.json#/definitions/attempt"}, - "created":{"$ref":"../definitions/created-modified.json#/definitions/created"}, - "modified":{"$ref":"../definitions/created-modified.json#/definitions/modified"}, - "config":{"$ref":"../definitions/job.json#/definitions/config"}, - "request":{"$ref":"../definitions/job.json#/definitions/request"}, - "saved_files":{"$ref":"../definitions/job.json#/definitions/saved_files"}, - "produced_metadata":{"$ref":"../definitions/job.json#/definitions/produced_metadata"} - }, - "additionalProperties":false, - "required":[ - "id", "gear_id", "inputs", "config", - "destination", "tags", "state", "attempt" - ] - } - }, - "containers":{ - "patternProperties": { - "^[a-fA-F0-9]{24}$":{ - "type": "object" - } - } - } - }, - "additionalProperties":false + "$ref": "../definitions/session.json#/definitions/session-jobs-output" } diff --git a/raml/schemas/output/session-template-recalc.json b/raml/schemas/output/session-template-recalc.json index b490c631fe33e6d5d8fa024401d3f09cbe9912a9..874ef13fc38b7ff5e38fd0f95a46a2c73d0cace7 100644 --- a/raml/schemas/output/session-template-recalc.json +++ b/raml/schemas/output/session-template-recalc.json @@ -1,14 +1,4 @@ { "$schema": "http://json-schema.org/draft-04/schema#", - "type": "object", - "properties":{ - "sessions_changed":{ - "type":"array", - "items":{ - "allOf":[{"$ref":"../definitions/objectid.json#"}] - } - } - }, - "additionalProperties":false, - "required":["sessions_changed"] + "$ref": "../definitions/session.json#/definitions/session-template-recalc-output" } diff --git a/raml/schemas/output/sites-list.json b/raml/schemas/output/sites-list.json deleted file mode 100644 index 7e7504b016b3f5db359b9d4bb944accdffe849d9..0000000000000000000000000000000000000000 --- a/raml/schemas/output/sites-list.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-04/schema#", - "type": "array", - "items": { - "type": "object", - "properties": { - "_id": { - "type": "string" - }, - "onload": { - "type": "boolean" - }, - "name": { - "type": "string" - } - }, - "required": [ - "_id", - "onload", - "name" - ] - } -} diff --git a/raml/schemas/output/user-delete.json b/raml/schemas/output/user-delete.json index d9877921d031657143bee32804764331f93cf82a..12e4a66089b694f7d02d9caa54cc14a5d2af1f55 100644 --- a/raml/schemas/output/user-delete.json +++ b/raml/schemas/output/user-delete.json @@ -1,12 +1,4 @@ { "$schema": "http://json-schema.org/draft-04/schema#", - "type": "object", - "properties": { - "deleted": { - "type": "integer" - } - }, - "required": [ - "deleted" - ] + "$ref": "../definitions/common.json#/definitions/deleted-count" } diff --git a/raml/schemas/output/user-new.json b/raml/schemas/output/user-new.json index 3279fda1c83df826d108138395338bfbf5433aba..e1551ebcd6fdfb01ed035b08a515c437cd78937c 100644 --- a/raml/schemas/output/user-new.json +++ b/raml/schemas/output/user-new.json @@ -1,14 +1,6 @@ { "$schema": "http://json-schema.org/draft-04/schema#", - "type": "object", - "properties": { - "_id": { - "type": "string" - } - }, - "required": [ - "_id" - ], + "$ref": "../definitions/common.json#/definitions/object-created", "example": { "$ref": "../../examples/output/user-new.json" } diff --git a/raml/schemas/output/user-self.json b/raml/schemas/output/user-self.json index be5a072af1504eba2f5e2fc7c0975f3dfe7a1794..687a7b62f314db1779f5d0361cfcbf336536116c 100644 --- a/raml/schemas/output/user-self.json +++ b/raml/schemas/output/user-self.json @@ -1,26 +1,5 @@ { "$schema": "http://json-schema.org/draft-04/schema#", "type":"object", - "properties":{ - "_id":{"$ref":"../definitions/user.json#/definitions/_id"}, - "firstname":{"$ref":"../definitions/user.json#/definitions/firstname"}, - "lastname":{"$ref":"../definitions/user.json#/definitions/lastname"}, - "email":{"$ref":"../definitions/user.json#/definitions/email"}, - "avatar":{"$ref":"../definitions/user.json#/definitions/avatar"}, - "avatars":{"$ref":"../definitions/user.json#/definitions/avatars"}, - "root":{"$ref":"../definitions/user.json#/definitions/root"}, - "disabled":{"$ref":"../definitions/user.json#/definitions/disabled"}, - "preferences":{"$ref":"../definitions/user.json#/definitions/preferences"}, - "created":{"$ref":"../definitions/created-modified.json#/definitions/created"}, - "modified":{"$ref":"../definitions/created-modified.json#/definitions/modified"}, - "api_key":{"$ref":"../definitions/user.json#/definitions/api_key"}, - "wechat":{"$ref":"../definitions/user.json#/definitions/wechat"}, - "firstlogin":{"$ref":"../definitions/user.json#/definitions/firstlogin"}, - "lastlogin":{"$ref":"../definitions/user.json#/definitions/lastlogin"} - }, - "additionalProperties":false, - "required":[ - "_id", "firstname", "lastname", - "root", "email", "created", "modified" - ] + "allOf": [{"$ref":"../definitions/user.json#/definitions/user-output-api-key"}] } diff --git a/raml/schemas/output/user-update.json b/raml/schemas/output/user-update.json index 1634f722b1d9b354844375491d4e1b440f1e6c8f..5f028c946741ca44c054e0cdd62fa0e5bdf3a915 100644 --- a/raml/schemas/output/user-update.json +++ b/raml/schemas/output/user-update.json @@ -1,12 +1,4 @@ { "$schema": "http://json-schema.org/draft-04/schema#", - "type": "object", - "properties": { - "modified": { - "type": "integer" - } - }, - "required": [ - "modified" - ] + "$ref": "../definitions/common.json#/definitions/modified-count" } diff --git a/raml/schemas/output/version.json b/raml/schemas/output/version.json index c01eea8b23d5ade193245c0cbbc4945c9f056ef4..52791553945abd0de204f9f1c8bdd53b1a26d341 100644 --- a/raml/schemas/output/version.json +++ b/raml/schemas/output/version.json @@ -1,16 +1,4 @@ { "$schema": "http://json-schema.org/draft-04/schema#", - "type": "object", - "properties": { - "_id": { - "type": "string" - }, - "database": { - "type": "integer" - } - }, - "required": [ - "_id", - "database" - ] + "$ref": "../definitions/version.json#/definitions/version-output" } diff --git a/swagger/index.yaml b/swagger/index.yaml index 221973900acf90ced910c883b4d185ebd06ea281..34626b765d01b8af61eedfda203b1628a3d1a586 100644 --- a/swagger/index.yaml +++ b/swagger/index.yaml @@ -26,6 +26,16 @@ tags: description: Job operations - name: collections description: Collection operations + - name: sessions + description: Session operations + - name: acquisitions + description: Acquisition operations + - name: projects + description: Project operations + - name: reports + description: Site-wide reports + - name: batch + description: Batch job operations paths: $include: @@ -45,6 +55,12 @@ paths: - paths/devices.yaml - paths/groups.yaml - paths/collections.yaml + - paths/sessions.yaml + - paths/acquisitions.yaml + - paths/projects.yaml + - paths/report.yaml + - paths/batch.yaml + securityDefinitions: ApiKey: diff --git a/swagger/package-lock.json b/swagger/package-lock.json index d5ed24392e0c091c806085a1cefeda6cd230fac9..6add6536d94a5523d1a92a7da6fae16102c69a9b 100644 --- a/swagger/package-lock.json +++ b/swagger/package-lock.json @@ -1250,6 +1250,12 @@ "find-up": "1.1.2" } }, + "pluralize": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/pluralize/-/pluralize-7.0.0.tgz", + "integrity": "sha512-ARhBOdzS3e41FbkW/XWrTEtukqqLoK5+Z/4UeDaLuSW+39JPeFgs4gCGqsrJHVZX0fUrx//4OF0K1CUGwlIFow==", + "dev": true + }, "portscanner": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/portscanner/-/portscanner-1.2.0.tgz", diff --git a/swagger/package.json b/swagger/package.json index 2f57b4a9d27cb8d609802b9e1ba8e3c70d165945..2eb3771879be6ddc0c542f99024076fba4281625 100644 --- a/swagger/package.json +++ b/swagger/package.json @@ -20,6 +20,7 @@ "load-grunt-tasks": "^3.5.2", "lodash": "^4.17.4", "mustache": "^2.3.0", + "pluralize": "^7.0.0", "swagger-ui-dist": "^3.6.0" } } diff --git a/swagger/paths/acquisitions.yaml b/swagger/paths/acquisitions.yaml new file mode 100644 index 0000000000000000000000000000000000000000..325ad7499da4051d90a4a6474b9d121d2f934f7e --- /dev/null +++ b/swagger/paths/acquisitions.yaml @@ -0,0 +1,56 @@ +$template_arguments: + resource: acquisition + tag: acquisitions + parameter: AcquisitionId + +/acquisitions: + $template: templates/container.yaml + arguments: + list-output-schema: schemas/output/acquisition-list.json + create-input-schema: schemas/input/acquisition.json + +/acquisitions/{AcquisitionId}: + $template: templates/container-item.yaml + arguments: + update-input-schema: schemas/input/acquisition-update.json + get-output-schema: schemas/output/acquisition.json + +# ===== Tags ===== +/acquisitions/{AcquisitionId}/tags: + $template: templates/tags.yaml +/acquisitions/{AcquisitionId}/tags/{TagValue}: + $template: templates/tags-tag.yaml + +# ===== Packfile ===== +/acquisitions/{AcquisitionId}/packfile-start: + $template: templates/packfile-start.yaml +/acquisitions/{AcquisitionId}/packfile: + $template: templates/packfile.yaml +/acquisitions/{AcquisitionId}/packfile-end: + $template: templates/packfile-end.yaml + +# ===== Files ===== +/acquisitions/{AcquisitionId}/files: + $template: templates/file-list-upload.yaml +/acquisitions/{AcquisitionId}/files/{FileName}: + $template: templates/file-item.yaml + +# ===== Notes ===== +/acquisitions/{AcquisitionId}/notes: + $template: templates/notes.yaml +/acquisitions/{AcquisitionId}/notes/{NoteId}: + $template: templates/notes-note.yaml + +# ===== Analyses ===== +/acquisitions/{AcquisitionId}/analyses: + $template: templates/analyses-list.yaml +/acquisitions/{AcquisitionId}/analyses/{AnalysisId}: + $template: templates/analysis-item.yaml +/acquisitions/{AcquisitionId}/analyses/{AnalysisId}/files: + $template: templates/analysis-files.yaml +/acquisitions/{AcquisitionId}/analyses/{AnalysisId}/files/{Filename}: + $template: templates/analysis-files-create-ticket-filename.yaml +/acquisitions/{AcquisitionId}/analyses/{AnalysisId}/notes: + $template: templates/analysis-notes.yaml +/acquisitions/{AcquisitionId}/analyses/{AnalysisId}/notes/{NoteId}: + $template: templates/analysis-notes-item.yaml diff --git a/swagger/paths/batch.yaml b/swagger/paths/batch.yaml new file mode 100644 index 0000000000000000000000000000000000000000..564bcd75927babe2f8b45c6e806e8d46f82056e9 --- /dev/null +++ b/swagger/paths/batch.yaml @@ -0,0 +1,87 @@ +/batch: + get: + summary: Get a list of batch jobs the user has created. + description: Requires login. + operationId: get_all_batch_jobs + tags: + - batch + responses: + '200': + schema: + $ref: schemas/output/batch-list.json + post: + summary: Create a batch job proposal and insert it as 'pending'. + operationId: create_batch_job + tags: + - batch + parameters: + - name: body + in: body + schema: + $ref: schemas/input/batch-insert.json + responses: + '200': + schema: + $ref: schemas/output/batch-insert.json + +/batch/{BatchId}: + parameters: + - in: path + type: string + name: BatchId + required: true + get: + summary: Get batch job details. + parameters: + - in: query + type: boolean + name: jobs + description: If true, return job objects instead of job ids + operationId: get_batch_job + tags: + - batch + responses: + '200': + schema: + $ref: schemas/output/batch.json + '404': + $ref: '#/responses/404:resource-not-found' + +/batch/{BatchId}/run: + parameters: + - in: path + type: string + name: BatchId + required: true + post: + summary: Launch a job. + description: | + Creates jobs from proposed inputs, returns jobs enqueued. + Moves 'pending' batch job to 'running'. + operationId: run_batch_job + tags: + - batch + responses: + '200': + schema: + $ref: schemas/output/job-list.json + +/batch/{BatchId}/cancel: + parameters: + - in: path + type: string + name: BatchId + required: true + post: + summary: Cancel a Job + description: | + Cancels jobs that are still pending, returns number of jobs cancelled. + Moves a 'running' batch job to 'cancelled'. + operationId: cancel_batch_job + tags: + - batch + responses: + '200': + schema: + example: + canceled_jobs: 4 diff --git a/swagger/paths/config-js.yaml b/swagger/paths/config-js.yaml index 09ffa6a754ccf10ff83ac5349f9f98ca5f953021..c26b420e2effe42ea8742fa9b38038a39f7cd637 100644 --- a/swagger/paths/config-js.yaml +++ b/swagger/paths/config-js.yaml @@ -7,8 +7,8 @@ responses: '200': description: '' - schema: - example: | + examples: + 'application/javascript': | config = { "auth": { "auth_endpoint": "https://accounts.google.com/o/oauth2/auth", diff --git a/swagger/paths/jobs.yaml b/swagger/paths/jobs.yaml index b65e2e513286cb476485fd9f2372a0cf5ab02beb..04c328ef3560987d2d6690330c3dff0aad9224d5 100644 --- a/swagger/paths/jobs.yaml +++ b/swagger/paths/jobs.yaml @@ -26,8 +26,13 @@ tags: - jobs responses: - default: + '200': description: '' + schema: + $ref: schemas/output/job.json + examples: + response: + $ref: examples/output/job.json /jobs/stats: get: summary: Get stats about all current jobs diff --git a/swagger/paths/projects.yaml b/swagger/paths/projects.yaml new file mode 100644 index 0000000000000000000000000000000000000000..d499e8af6dd633981395dc25676c287564457adb --- /dev/null +++ b/swagger/paths/projects.yaml @@ -0,0 +1,227 @@ +$template_arguments: + resource: project + tag: projects + parameter: ProjectId + +/projects: + $template: templates/container.yaml + arguments: + list-output-schema: schemas/output/project-list.json + create-input-schema: schemas/input/project.json + +/projects/{ProjectId}: + $template: templates/container-item.yaml + arguments: + update-input-schema: schemas/input/project-update.json + get-output-schema: schemas/output/project.json + +/projects/groups: + get: + summary: List all groups which have a project in them + operationId: get_all_projects_groups + tags: + - 'projects' + responses: + '200': + description: '' + schema: + $ref: schemas/output/groups-list.json + +'/projects/{ProjectId}/sessions': + parameters: + - in: path + type: string + name: ProjectId + required: true + get: + summary: List all sessions for the given project. + operationId: get_project_sessions + tags: + - 'projects' + responses: + '200': + schema: + $ref: schemas/output/session-list.json + +'/projects/{ProjectId}/acquisitions': + get: + summary: List all acquisitions for the given project. + operationId: get_project_acquisitions + tags: + - 'projects' + responses: + '200': + schema: + $ref: schemas/output/acquisition-list.json + +'/projects/{ProjectId}/rules': + parameters: + - in: path + type: string + name: ProjectId + required: true + get: + operationId: get_project_rules + tags: + - 'projects' + responses: + '200': + schema: + $ref: schemas/output/rule-list.json + post: + summary: Create a new rule for a project. + operationId: add_project_rule + tags: + - 'projects' + responses: + default: + description: '' + parameters: + - in: body + name: body + schema: + $ref: schemas/input/rule-new.json + +'/projects/{ProjectId}/rules/{RuleId}': + parameters: + - in: path + type: string + name: ProjectId + required: true + - in: path + type: string + name: RuleId + required: true + put: + summary: Update a rule on a project. + operationId: modify_project_rule + tags: + - 'projects' + responses: + default: + description: '' + parameters: + - in: body + name: body + schema: + $ref: schemas/input/rule-update.json + + +'/projects/{ProjectId}/template': + parameters: + - in: path + type: string + name: ProjectId + required: true + post: + summary: Set the session template for a project. + operationId: set_project_template + tags: + - 'projects' + parameters: + - in: body + name: body + schema: + $ref: schemas/input/project-template.json + responses: + '200': + $ref: '#/responses/200:modified-with-count' + '404': + $ref: '#/responses/404:resource-not-found' + delete: + summary: Remove the session template for a project. + operationId: remove_project_template + tags: + - 'projects' + responses: + '200': + $ref: '#/responses/200:deleted-with-count' + '404': + $ref: '#/responses/404:resource-not-found' + +'/projects/{ProjectId}/recalc': + parameters: + - in: path + type: string + name: ProjectId + required: true + post: + summary: Recalculate if sessions in the project satisfy the template. + description: Returns list of modified session ids. + operationId: recalc_project + tags: + - 'projects' + responses: + '200': + description: | + Project's sessions' compliance was recalculated. + Returns list of session that were modified. + schema: + $ref: schemas/output/session-template-recalc.json + '404': + $ref: '#/responses/404:resource-not-found' + +/projects/recalc: + post: + summary: Recalculate all sessions against their project templates. + description: | + Iterates all projects that have a session template. + Recalculate if projects' sessions satisfy the template. + Returns list of modified session ids. + operationId: recalc_all_projects + tags: + - 'projects' + responses: + '200': + description: | + Projects' sessions' compliance was recalculated. + Returns list of session that were modified. + schema: + $ref: schemas/output/session-template-recalc.json + + +# ===== Tags ===== +/projects/{ProjectId}/tags: + $template: templates/tags.yaml +/projects/{ProjectId}/tags/{TagValue}: + $template: templates/tags-tag.yaml + +# ===== Packfile ===== +/projects/{ProjectId}/packfile-start: + $template: templates/packfile-start.yaml +/projects/{ProjectId}/packfile: + $template: templates/packfile.yaml +/projects/{ProjectId}/packfile-end: + $template: templates/packfile-end.yaml + +# ===== Files ===== +/projects/{ProjectId}/files: + $template: templates/file-list-upload.yaml +/projects/{ProjectId}/files/{FileName}: + $template: templates/file-item.yaml + +# ===== Permissions ===== +/projects/{ProjectId}/permissions: + $template: templates/permissions.yaml +/projects/{ProjectId}/permissions/{UserId}: + $template: templates/permissions-user.yaml + +# ===== Notes ===== +/projects/{ProjectId}/notes: + $template: templates/notes.yaml +/projects/{ProjectId}/notes/{NoteId}: + $template: templates/notes-note.yaml + +# ===== Analyses ===== +/projects/{ProjectId}/analyses: + $template: templates/analyses-list.yaml +/projects/{ProjectId}/analyses/{AnalysisId}: + $template: templates/analysis-item.yaml +/projects/{ProjectId}/analyses/{AnalysisId}/files: + $template: templates/analysis-files.yaml +/projects/{ProjectId}/analyses/{AnalysisId}/files/{Filename}: + $template: templates/analysis-files-create-ticket-filename.yaml +/projects/{ProjectId}/analyses/{AnalysisId}/notes: + $template: templates/analysis-notes.yaml +/projects/{ProjectId}/analyses/{AnalysisId}/notes/{NoteId}: + $template: templates/analysis-notes-item.yaml diff --git a/swagger/paths/report.yaml b/swagger/paths/report.yaml new file mode 100644 index 0000000000000000000000000000000000000000..000a9ec1f184cd00ade166c89df098420f770091 --- /dev/null +++ b/swagger/paths/report.yaml @@ -0,0 +1,34 @@ +/report/site: + get: + operationId: get_site_report + tags: + - 'reports' + responses: + '200': + description: '' + schema: + $ref: schemas/output/report-site.json + +/report/project: + get: + operationId: get_project_report + tags: + - 'reports' + parameters: + - in: query + type: string + name: projects + description: Specify multiple times to include projects in the report + - in: query + type: string + name: start_date + description: Report start date + - in: query + type: string + name: end_date + description: Report end date + responses: + '200': + description: '' + schema: + $ref: schemas/output/report-project.json diff --git a/swagger/paths/sessions.yaml b/swagger/paths/sessions.yaml new file mode 100644 index 0000000000000000000000000000000000000000..d78452b3c560194cc8e437ef4743ae89f0dd0a03 --- /dev/null +++ b/swagger/paths/sessions.yaml @@ -0,0 +1,126 @@ +$template_arguments: + resource: session + tag: sessions + parameter: SessionId + +/sessions: + $template: templates/container.yaml + arguments: + list-output-schema: schemas/output/session-list.json + create-input-schema: schemas/input/session.json + +/sessions/{SessionId}: + $template: templates/container-item.yaml + arguments: + update-input-schema: schemas/input/session.json + get-output-schema: schemas/output/session.json + +'/sessions/{SessionId}/jobs': + parameters: + - in: path + type: string + name: SessionId + required: true + get: + summary: Return any jobs that use inputs from this session + operationId: get_session_jobs + tags: + - 'sessions' + parameters: + - in: query + type: string + name: states + description: filter results by job state + - in: query + type: string + name: tags + description: filter results by job tags + responses: + '200': + schema: + $ref: schemas/output/session-jobs.json + +# ===== Tags ===== +/sessions/{SessionId}/tags: + $template: templates/tags.yaml +/sessions/{SessionId}/tags/{TagValue}: + $template: templates/tags-tag.yaml + +# ===== Packfile ===== +/sessions/{SessionId}/packfile-start: + $template: templates/packfile-start.yaml +/sessions/{SessionId}/packfile: + $template: templates/packfile.yaml +/sessions/{SessionId}/packfile-end: + $template: templates/packfile-end.yaml + +# ===== Files ===== +/sessions/{SessionId}/files: + $template: templates/file-list-upload.yaml +/sessions/{SessionId}/files/{FileName}: + $template: templates/file-item.yaml + +# ===== Notes ===== +/sessions/{SessionId}/notes: + $template: templates/notes.yaml +/sessions/{SessionId}/notes/{NoteId}: + $template: templates/notes-note.yaml + +'/sessions/{SessionId}/acquisitions': + parameters: + - in: path + type: string + name: SessionId + required: true + get: + summary: List acquisitions in a session + operationId: get_session_acquisitions + tags: + - 'sessions' + responses: + '200': + description: '' + schema: + $ref: schemas/output/acquisition-list.json + +# ===== Analyses ===== +/sessions/{SessionId}/analyses: + parameters: + - required: true + type: string + in: path + name: 'SessionId' + post: + summary: Create an analysis and upload files. + description: | + When query param "job" is "true", send JSON to create + an analysis and job. Otherwise, multipart/form-data + to upload files and create an analysis. + operationId: add_session_analysis + tags: + - 'sessions' + parameters: + - in: body + name: body + schema: + $ref: schemas/input/analysis-job.json + - in: query + type: boolean + name: job + responses: + '200': + description: '' + + + +/sessions/{SessionId}/analyses/{AnalysisId}: + $template: templates/analysis-item.yaml +/sessions/{SessionId}/analyses/{AnalysisId}/files: + $template: templates/analysis-files.yaml +/sessions/{SessionId}/analyses/{AnalysisId}/files/{Filename}: + $template: templates/analysis-files-create-ticket-filename.yaml +/sessions/{SessionId}/analyses/{AnalysisId}/notes: + $template: templates/analysis-notes.yaml +/sessions/{SessionId}/analyses/{AnalysisId}/notes/{NoteId}: + $template: templates/analysis-notes-item.yaml + diff --git a/swagger/paths/users.yaml b/swagger/paths/users.yaml index dcccc30a454f265ab61f5ffad0d751bea6b7621d..f2af9b8fadea368a0d42844861396b1f18ec9d16 100644 --- a/swagger/paths/users.yaml +++ b/swagger/paths/users.yaml @@ -53,10 +53,10 @@ Redirects to the image file of the current user's avatar /users/{UserId}: parameters: - - required: true + - in: path type: string - in: path name: UserId + required: true get: summary: Get information about the specified user operationId: get_user diff --git a/swagger/responses/index.yaml b/swagger/responses/index.yaml index bd2d076f3585d8fa91f2b34dbff82bc4cd02f6ec..03986aaa24bbe3161ddf006b40892decca28bdc9 100644 --- a/swagger/responses/index.yaml +++ b/swagger/responses/index.yaml @@ -24,4 +24,8 @@ '400:invalid-body-json': description: | - JSON did not validate against schema for this endpoint + JSON did not validate against schema for this endpoint. + +'404:resource-not-found': + description: | + The specified resource could not be found. \ No newline at end of file diff --git a/swagger/support/swagger-resolver.js b/swagger/support/swagger-resolver.js index d40b27276d97083f5568b1e4a6d1852a984697a9..ee2575df0ebc65b58b23793d6e2039275aa380f8 100644 --- a/swagger/support/swagger-resolver.js +++ b/swagger/support/swagger-resolver.js @@ -5,10 +5,24 @@ var path = require('path'); var fs = require('fs'); var process = require('process'); var yaml = require('js-yaml'); +var pluralize = require('pluralize'); var Mustache = require('mustache'); var walk = require('./walk'); +var TEMPLATE_FUNCS = { + 'pluralize': function() { + return function(text, render) { + return pluralize.plural(render(text)); + }; + }, + 'singularize': function() { + return function(text, render) { + return pluralize.singular(render(text)); + }; + } +}; + // Throws if args are missing function validateTemplateArgs(tmplpath, template, args) { var i, param; @@ -73,18 +87,20 @@ SwaggerResolver.prototype.loadFile = function(relpath) { }; SwaggerResolver.prototype.visit = function(obj) { + if( !obj ) { + return obj; + } + // obj will have $template or $include, not both if( obj.hasOwnProperty('$include') ) { obj = this.resolveIncludes(obj); - - // Recursively resolve content - obj = this.resolveObject(obj); } else if( obj.hasOwnProperty('$template') ) { obj = this.resolveTemplate(obj); // Recursively resolve content obj = this.resolveObject(obj); } else if( obj.hasOwnProperty('$template_arguments') ) { + // Save off template arguments for later this.templateArguments = obj['$template_arguments']; delete obj['$template_arguments']; } @@ -102,8 +118,10 @@ SwaggerResolver.prototype.resolveIncludes = function(obj) { delete obj['$include']; for( i = 0; i < includes.length; i++ ) { - // Load the include file + // Load and resolve the include file inc = this.loadFile(includes[i]); + inc = this.resolveObject(inc); + // And merge its contents into obj _.extend(obj, inc); } @@ -124,7 +142,7 @@ SwaggerResolver.prototype.resolveTemplate = function(obj) { } // Validate arguments? - args = obj['arguments']||this.templateArguments||{}; + args = _.extend({}, TEMPLATE_FUNCS, this.templateArguments, obj['arguments']); validateTemplateArgs(tmplpath, tmpl, args); // Render the template, and parse diff --git a/swagger/support/tasks/schemas-to-defs.js b/swagger/support/tasks/schemas-to-defs.js index a81d1243d5f4d5f6e7ba314b51550f7d7f925106..efcaa87a1239f3acc96eb42735bfaa5c39e4d3aa 100644 --- a/swagger/support/tasks/schemas-to-defs.js +++ b/swagger/support/tasks/schemas-to-defs.js @@ -59,7 +59,7 @@ module.exports = function(grunt) { if( !root.definitions ) { root.definitions = {}; } - _.extend(root.definitions, schemas.getComplexDefinitions()); + // _.extend(root.definitions, schemas.getComplexDefinitions()); // Write destination file var data = JSON.stringify(root, null, 2); diff --git a/swagger/templates/container-item.yaml b/swagger/templates/container-item.yaml new file mode 100644 index 0000000000000000000000000000000000000000..c7a864df8b4c7037a4042c53e73fa9276033ce49 --- /dev/null +++ b/swagger/templates/container-item.yaml @@ -0,0 +1,49 @@ +parameters: + - name: resource + type: string + - name: tag + type: string + - name: parameter + type: string + - name: update-input-schema + type: string + - name: get-output-schema + type: string +template: | + parameters: + - in: path + type: string + name: '{{parameter}}' + required: true + get: + summary: Get a single {{resource}} + operationId: get_{{resource}} + tags: + - '{{tag}}' + responses: + '200': + schema: + $ref: {{{get-output-schema}}} + put: + summary: Update a {{resource}} + operationId: modify_{{resource}} + tags: + - '{{tag}}' + parameters: + - in: body + name: body + schema: + $ref: {{{update-input-schema}}} + responses: + '200': + $ref: '#/responses/200:modified-with-count' + '400': + $ref: '#/responses/400:invalid-body-json' + delete: + summary: Delete a {{resource}} + operationId: delete_{{resource}} + tags: + - '{{tag}}' + responses: + '200': + $ref: '#/responses/200:deleted-with-count' diff --git a/swagger/templates/container.yaml b/swagger/templates/container.yaml new file mode 100644 index 0000000000000000000000000000000000000000..72d87c9ea0f3ddf7109e90a247788a18cb9872c0 --- /dev/null +++ b/swagger/templates/container.yaml @@ -0,0 +1,35 @@ +parameters: + - name: resource + type: string + - name: tag + type: string + - name: list-output-schema + type: string + - name: create-input-schema + type: string +template: | + get: + summary: Get a list of {{#pluralize}}{{resource}}{{/pluralize}} + operationId: get_all_{{#pluralize}}{{resource}}{{/pluralize}} + tags: + - '{{tag}}' + responses: + '200': + schema: + $ref: {{{list-output-schema}}} + post: + summary: Create a new {{resource}} + operationId: create_{{resource}} + tags: + - '{{tag}}' + parameters: + - in: body + name: body + schema: + $ref: {{{create-input-schema}}} + responses: + '200': + schema: + $ref: schemas/output/container-new.json + '400': + $ref: '#/responses/400:invalid-body-json' diff --git a/tests/bin/run-tests-ubuntu.sh b/tests/bin/run-tests-ubuntu.sh index 8c7d94fa559a903b6091b5b606f26acecdb28386..688119f08352527a9eee89b748f57957c17214a6 100755 --- a/tests/bin/run-tests-ubuntu.sh +++ b/tests/bin/run-tests-ubuntu.sh @@ -19,7 +19,6 @@ Options: -l, --lint Run linting -u, --unit Run unit tests -i, --integ Run integration tests - -a, --abao Run abao tests -h, --help Print this help and exit -- PYTEST_ARGS Arguments passed to py.test @@ -40,7 +39,6 @@ function main() { local RUN_LINT=false local RUN_UNIT=false local RUN_INTEG=false - local RUN_ABAO=false local PYTEST_ARGS= while [[ "$#" > 0 ]]; do @@ -48,7 +46,6 @@ function main() { -l|--lint) RUN_ALL=false; RUN_LINT=true ;; -u|--unit) RUN_ALL=false; RUN_UNIT=true ;; -i|--integ) RUN_ALL=false; RUN_INTEG=true ;; - -a|--abao) RUN_ALL=false; RUN_ABAO=true ;; -h|--help) usage; exit 0 ;; --) PYTEST_ARGS="${@:2}"; break ;; *) echo "Invalid argument: $1" >&2; usage; exit 1 ;; @@ -61,8 +58,7 @@ function main() { RUN_LINT=true RUN_UNIT=true RUN_INTEG=true - RUN_ABAO=true - elif ${RUN_LINT} && ${RUN_UNIT} && ${RUN_INTEG} && ${RUN_ABAO}; then + elif ${RUN_LINT} && ${RUN_UNIT} && ${RUN_INTEG}; then # All filtering options were used, the same as none RUN_ALL=true fi @@ -100,7 +96,7 @@ function main() { py.test --cov=api --cov-report= tests/unit_tests/python $PYTEST_ARGS fi - if ${RUN_INTEG} || ${RUN_ABAO}; then + if ${RUN_INTEG}; then echo "Spinning up dependencies ..." uwsgi --http "localhost:8081" --master --http-keepalive \ --so-keepalive --add-header "Connection: Keep-Alive" \ @@ -123,38 +119,10 @@ function main() { printf '.' sleep 1 done - fi - if ${RUN_INTEG}; then echo "Running integration tests ..." py.test tests/integration_tests/python $PYTEST_ARGS fi - - if ${RUN_ABAO}; then - echo "Running abao tests ..." - # Create resources that Abao relies on - python tests/integration_tests/abao/load_fixture.py - - # If no VIRTUAL_ENV, make sure /usr/local/bin is in the path - if [[ -z "${VIRTUAL_ENV:-}" ]]; then - PATH="/usr/local/bin:$PATH" - npm install tests/integration_tests - else - npm install --global tests/integration_tests - fi - - PATH="$(npm bin):$PATH" - - # Allow us to require modules from package.json, - # since abao_test_hooks.js is not being called from the package directory - integration_test_node_modules="$(pwd)/node_modules/scitran-core-integration-tests/node_modules" - - # Have to change into definitions directory to resolve - # relative $ref's in the jsonschema's - pushd raml/schemas/definitions - NODE_PATH="$integration_test_node_modules" abao ../../api.raml "--server=$SCITRAN_SITE_API_URL" "--hookfiles=../../../tests/integration_tests/abao/abao_test_hooks.js" - popd - fi } diff --git a/tests/bin/setup-integration-tests-ubuntu.sh b/tests/bin/setup-integration-tests-ubuntu.sh index 9a700f37d2c01d5d9ca6a8d9d47a805cbe349b5c..7719063ccf9a6ea145f8f888894ec13e66994a34 100755 --- a/tests/bin/setup-integration-tests-ubuntu.sh +++ b/tests/bin/setup-integration-tests-ubuntu.sh @@ -5,10 +5,3 @@ cd "$( dirname "${BASH_SOURCE[0]}" )/../.." sudo pip install -U -r "tests/integration_tests/requirements-integration-test.txt" -NODE_URL="https://nodejs.org/dist/v6.4.0/node-v6.4.0-linux-x64.tar.gz" - -if [[ -z "${VIRTUAL_ENV:-}" ]]; then - curl $NODE_URL | sudo tar xz -C /usr/local --strip-components 1 -else - curl $NODE_URL | tar xz -C $VIRTUAL_ENV --strip-components 1 -fi diff --git a/tests/integration_tests/abao/abao_test_hooks.js b/tests/integration_tests/abao/abao_test_hooks.js deleted file mode 100644 index 270c43aae48f9001f1b0db69ca091a30da8a16f3..0000000000000000000000000000000000000000 --- a/tests/integration_tests/abao/abao_test_hooks.js +++ /dev/null @@ -1,1463 +0,0 @@ -var hooks = require('hooks'); -var chai = require('chai'); -var assert = chai.assert; - -// Variables for passing results as input to subsequent tests -var gear_name = 'test-case-gear'; -var group_id = 'test-group'; -var delete_group_id = 'example_group'; -var test_group_tag = 'test-group-tag'; -var collection_id = 'test-collection-1'; -var delete_collection_id = ''; -var test_collection_1 = null; -var test_collection_tag = 'test-collection-tag'; -var test_session_1 = null; -var test_session_2_id = null; -var test_session_tag = 'test-session-tag'; -var test_session_1_analysis_2_id = null; -var test_acquisition_1 = null; -var test_acquisition_tag = 'test-acq-tag'; -var example_acquisition_id = ''; -var test_project_1 = null; -var test_project_tag = 'test-project-tag'; -var delete_project_id = ''; -var device_id = 'bootstrapper_Bootstrapper' -var injected_api_key = 'XZpXI40Uk85eozjQkU1zHJ6yZHpix+j0mo1TMeGZ4dPzIqVPVGPmyfeK' - -// Tests we're skipping, fix these - -// Fails only in travis -hooks.skip("GET /version -> 200"); - -// Should 400 to say invalid json -hooks.skip("GET /download -> 400"); - -// Should 422 for missing metadata field -hooks.skip("POST /upload/label -> 402"); -hooks.skip("POST /upload/uid -> 402"); -hooks.skip("POST /upload/uid-match -> 402"); - -// Should 404 -hooks.skip("GET /jobs/{JobId} -> 404"); - -// Can only retry a failed job -hooks.skip("POST /jobs/{JobId}/retry -> 200"); - -// Cannot get JobId without GET /jobs endpoint -hooks.skip("GET /jobs/{JobId} -> 200"); -hooks.skip("GET /jobs/{JobId}/config.json -> 200"); -hooks.skip("POST /jobs/{JobId}/retry -> 200"); -hooks.skip("GET /jobs/{JobId} -> 404"); - -// https://github.com/cybertk/abao/issues/160 -hooks.skip("GET /users/self/avatar -> 307"); -hooks.skip("GET /users/{UserId}/avatar -> 307"); - -// drones currently use shared secret, allow when using API keys -hooks.skip("POST /devices -> 200") -hooks.skip("GET /devices/self -> 200") - -// Tests that are skipped because we do them in python - -// Skipping because abao doesn't support file fields -hooks.skip("POST /download -> 200"); -hooks.skip("GET /download -> 200"); -hooks.skip("POST /upload/label -> 200"); -hooks.skip("POST /upload/uid -> 200"); -hooks.skip("POST /upload/uid-match -> 200"); -hooks.skip("POST /upload/uid-match -> 404"); -hooks.skip("POST /engine -> 200"); -hooks.skip("POST /collections/{CollectionId}/packfile-start -> 200"); -hooks.skip("POST /collections/{CollectionId}/packfile -> 200"); -hooks.skip("GET /collections/{CollectionId}/packfile-end -> 200"); -hooks.skip("POST /sessions/{SessionId}/packfile-start -> 200"); -hooks.skip("POST /sessions/{SessionId}/packfile -> 200"); -hooks.skip("GET /sessions/{SessionId}/packfile-end -> 200"); -hooks.skip("POST /acquisitions/{AcquisitionId}/packfile-start -> 200"); -hooks.skip("POST /acquisitions/{AcquisitionId}/packfile -> 200"); -hooks.skip("GET /acquisitions/{AcquisitionId}/packfile-end -> 200"); -hooks.skip("POST /projects/{ProjectId}/packfile-start -> 200"); -hooks.skip("POST /projects/{ProjectId}/packfile -> 200"); -hooks.skip("GET /projects/{ProjectId}/packfile-end -> 200"); - - -// Skipping until merge with rest of project raml (So we have a ProjectId) -hooks.skip("POST /projects/{ProjectId}/template -> 200") -hooks.skip("DELETE /projects/{ProjectId}/template -> 200") -hooks.skip("POST /projects/{ProjectId}/recalc -> 200") -hooks.skip("GET /projects/{ProjectId}/rules -> 200") - -// Porting to python as per #600 -hooks.skip("POST /jobs/add -> 200") -hooks.skip("PUT /jobs/{JobId} -> 200") -hooks.skip("GET /gears/{GearId} -> 200") -hooks.skip("GET /sessions/{SessionId}/jobs -> 200") - -// Cannot be ran due to gear IDs being used as per # -hooks.skip("POST /sessions/{SessionId}/analyses -> 200") -hooks.skip("GET /sessions/{SessionId}/analyses/{AnalysisId} -> 200") -hooks.skip("DELETE /sessions/{SessionId}/analyses/{AnalysisId} -> 200") -// Related, ref #696 -hooks.skip("DELETE /gears/{GearId} -> 200") - - -hooks.before("POST /login -> 200", function(test, done) { - test.request.body = { - 'code': injected_api_key, - 'auth_type': 'api-key' - }; - done(); -}); - -hooks.beforeEach(function (test, done) { - test.request.query.root = "true" - test.request.headers.Authorization = "scitran-user XZpXI40Uk85eozjQkU1zHJ6yZHpix+j0mo1TMeGZ4dPzIqVPVGPmyfeK"; - done(); -}); - -hooks.before("GET /download -> 404", function(test, done) { - test.request.query = { - ticket: '1234' - }; - done(); -}); - -hooks.before("POST /users -> 400", function(test, done) { - test.request.body = {api_key:{key:"test"}}; - done(); -}); - -hooks.before("GET /users/{UserId} -> 200", function(test, done) { - test.request.params = { - UserId: "jane.doe@gmail.com" - }; - done(); -}); - -hooks.before("PUT /users/{UserId} -> 200", function(test, done) { - test.request.params = { - UserId: "jane.doe@gmail.com" - }; - done(); -}); - -hooks.before("PUT /users/{UserId} -> 400", function(test, done) { - test.request.params = { - UserId: "jane.doe@gmail.com" - }; - test.request.body = {"not_a_valid_property":"foo"}; - done(); -}); - -hooks.before("DELETE /users/{UserId} -> 200", function(test, done) { - test.request.params = { - UserId: "jane.doe@gmail.com" - }; - done(); -}); - -hooks.before("GET /users/{UserId}/acquisitions -> 200", function(test, done) { - test.request.params = { - UserId: "admin@user.com" - }; - done(); -}); - -hooks.before("GET /users/{UserId}/collections -> 200", function(test, done) { - test.request.params = { - UserId: "admin@user.com" - }; - done(); -}); - -hooks.before("GET /users/{UserId}/projects -> 200", function(test, done) { - test.request.params = { - UserId: "admin@user.com" - }; - done(); -}); - -hooks.before("GET /users/{UserId}/sessions -> 200", function(test, done) { - test.request.params = { - UserId: "admin@user.com" - }; - done(); -}); - -hooks.before("PUT /groups/{GroupId} -> 400", function(test, done) { - test.request.params = { - GroupId: group_id - }; - test.request.body = {"not_a_real_property":"foo"}; - done(); -}); - -hooks.before("POST /groups -> 400", function(test, done) { - test.request.body = {"not_a_real_property":"foo"}; - done(); -}); - - -hooks.before("GET /groups/{GroupId} -> 200", function(test, done) { - test.request.params = { - GroupId: group_id - }; - done(); -}); - -hooks.before("DELETE /groups/{GroupId} -> 200", function(test, done) { - test.request.params = { - GroupId: delete_group_id - }; - done(); -}); - -hooks.before("POST /groups/{GroupId}/permissions -> 200", function(test, done) { - test.request.params = { - GroupId: group_id - }; - test.request.body = { - _id: "test@user.com", - access: "ro" - } - done(); -}); - -hooks.before("POST /groups/{GroupId}/permissions -> 400", function(test, done) { - test.request.params = { - GroupId: group_id - }; - test.request.body.foo = "bar"; - done(); -}); - -hooks.before("GET /groups/{GroupId}/permissions/{UserId} -> 200", function(test, done) { - test.request.params = { - GroupId: group_id, - UserId: "test@user.com" - }; - done(); -}); - -hooks.before("PUT /groups/{GroupId}/permissions/{UserId} -> 200", function(test, done) { - test.request.params = { - GroupId: group_id, - UserId: "test@user.com" - }; - test.request.body = { - _id: "test@user.com", - access: "admin" - }; - done(); -}); - -hooks.before("PUT /groups/{GroupId}/permissions/{UserId} -> 400", function(test, done) { - test.request.params = { - GroupId: group_id, - UserId:"test@user.com" - }; - test.request.body = { - _id: "test@user.com", - access: "rw", - not_a_real_property: "foo" - }; - done(); -}); - -hooks.before("DELETE /groups/{GroupId}/permissions/{UserId} -> 200", function(test, done) { - test.request.params = { - GroupId: group_id, - UserId: "test@user.com" - }; - done(); -}); - -hooks.before("POST /groups/{GroupId}/tags -> 200", function(test, done) { - test.request.params = { - GroupId: group_id - }; - test.request.body = { - "value":test_group_tag - }; - done(); -}); - -hooks.before("POST /groups/{GroupId}/tags -> 400", function(test, done) { - test.request.params = { - GroupId: group_id - }; - test.request.body = { - "value":test_group_tag, - "bad property": "foo" - }; - done(); -}); - -hooks.before("GET /groups/{GroupId}/tags/{TagValue} -> 200", function(test, done) { - test.request.params = { - GroupId: group_id, - TagValue: test_group_tag - }; - done(); -}); - -hooks.before("PUT /groups/{GroupId}/tags/{TagValue} -> 200", function(test, done) { - test.request.params = { - GroupId: group_id, - TagValue: test_group_tag - }; - test_group_tag = "a-new-tag"; - test.request.body = { - "value":test_group_tag - }; - done(); -}); - -hooks.before("PUT /groups/{GroupId}/tags/{TagValue} -> 400", function(test, done) { - test.request.params = { - GroupId: group_id, - TagValue: test_group_tag - }; - test.request.body = { - "value":test_group_tag, - "bad proeprty":"blah" - }; - done(); -}); - -hooks.before("DELETE /groups/{GroupId}/tags/{TagValue} -> 200", function(test, done) { - test.request.params = { - GroupId: group_id, - TagValue: test_group_tag - }; - done(); -}); - -hooks.before("GET /groups/{GroupId}/projects -> 200", function(test, done) { - test.request.params = { - GroupId: group_id - }; - done(); -}); - - -// set initial test_collection_1 -hooks.after("GET /collections -> 200", function(test, done) { - test_collection_1 = test.response.body[0]; - collection_id = test.response.body[0]._id; - delete_collection_id = test.response.body[1]._id; - done(); -}); - -hooks.before("GET /collections/{CollectionId} -> 200", function(test, done) { - test.request.params.CollectionId = collection_id; - done(); -}); - -// set detailed test_collection_1 (including analyses, that are omitted during listing) -hooks.after("GET /collections/{CollectionId} -> 200", function(test, done) { - test_collection_1 = test.response.body; - done(); -}); - -hooks.before("GET /collections/{CollectionId}/sessions -> 200", function(test, done) { - test.request.params.CollectionId = collection_id; - done(); -}); - -hooks.before("GET /collections/{CollectionId}/acquisitions -> 200", function(test, done) { - test.request.params.CollectionId = collection_id; - done(); -}); - -hooks.before("POST /collections -> 400", function(test, done) { - test.request.params.CollectionId = collection_id; - test.request.body.foo = "not an allowed property"; - done(); -}); - -hooks.before("PUT /collections/{CollectionId} -> 400", function(test, done) { - test.request.params.CollectionId = collection_id; - test.request.body.foo = "not an allowed property"; - done(); -}); - -hooks.before("DELETE /collections/{CollectionId} -> 200", function(test, done) { - test.request.params.CollectionId = delete_collection_id; - done(); -}); - -hooks.before("POST /collections/{CollectionId}/tags -> 200", function(test, done) { - test.request.params.CollectionId = collection_id; - test.request.body = { - "value":test_collection_tag - }; - done(); -}); - -hooks.before("POST /collections/{CollectionId}/tags -> 400", function(test, done) { - test.request.params.CollectionId = collection_id; - test.request.body = { - "value":"" - }; - done(); -}); - -hooks.before("GET /collections/{CollectionId}/tags/{TagValue} -> 200", function(test, done) { - test.request.params = { - CollectionId : collection_id, - TagValue : test_collection_tag - }; - done(); -}); - -hooks.before("PUT /collections/{CollectionId}/tags/{TagValue} -> 200", function(test, done) { - test.request.params = { - CollectionId : collection_id, - TagValue : test_collection_tag - }; - test_collection_tag = "new-tag-value"; - test.request.body = { - "value":test_collection_tag - }; - done(); -}); - -hooks.before("PUT /collections/{CollectionId}/tags/{TagValue} -> 400", function(test, done) { - test.request.params = { - CollectionId : collection_id, - TagValue : test_collection_tag - }; - test.request.body = { - "value":"" - }; - done(); -}); - -hooks.before("DELETE /collections/{CollectionId}/tags/{TagValue} -> 200", function(test, done) { - test.request.params = { - CollectionId : collection_id, - TagValue : test_collection_tag - }; - done(); -}); - -hooks.before("GET /collections/{CollectionId}/files/{FileName} -> 200", function(test, done) { - test.request.params = { - CollectionId : collection_id, - FileName : "notes.txt" - }; - test.request.query = { - "ticket":"" - }; - done(); -}); - -hooks.before("POST /collections/{CollectionId}/permissions -> 200", function(test, done) { - test.request.params = { - CollectionId : collection_id - }; - test.request.body = { - "_id":"test@user.com", - "access":"ro" - }; - done(); -}); - -hooks.before("POST /collections/{CollectionId}/permissions -> 400", function(test, done) { - test.request.params = { - CollectionId : collection_id - }; - test.request.body = { - "not a valid":"permissions entry" - }; - done(); -}); - -hooks.before("GET /collections/{CollectionId}/permissions/{UserId} -> 200", function(test, done) { - test.request.params = { - CollectionId : collection_id, - UserId: "test@user.com" - }; - done(); -}); - -hooks.before("PUT /collections/{CollectionId}/permissions/{UserId} -> 200", function(test, done) { - test.request.params = { - CollectionId : collection_id, - UserId: "test@user.com" - }; - test.request.body = { - "access":"rw", - "_id":"test@user.com" - }; - done(); -}); - -hooks.before("PUT /collections/{CollectionId}/permissions/{UserId} -> 400", function(test, done) { - test.request.params = { - CollectionId : collection_id, - UserId: "test@user.com" - }; - test.request.body = { - "not a valid":"permissions entry" - }; - done(); -}); - -hooks.before("DELETE /collections/{CollectionId}/permissions/{UserId} -> 200", function(test, done) { - test.request.params = { - CollectionId : collection_id, - UserId: "test@user.com" - }; - done(); -}); - -hooks.before("POST /collections/{CollectionId}/notes -> 200", function(test, done) { - test.request.params = { - CollectionId : collection_id - }; - done(); -}); - -hooks.before("POST /collections/{CollectionId}/notes -> 400", function(test, done) { - test.request.params = { - CollectionId : collection_id - }; - test.request.body = { - "not real":"property" - }; - done(); -}); - -hooks.before("GET /collections/{CollectionId}/notes/{NoteId} -> 200", function(test, done) { - test.request.params = { - CollectionId : collection_id, - NoteId: test_collection_1.notes[0]._id - }; - done(); -}); - -hooks.before("PUT /collections/{CollectionId}/notes/{NoteId} -> 200", function(test, done) { - test.request.params = { - CollectionId : collection_id, - NoteId: test_collection_1.notes[0]._id - }; - test.request.body = { - "text":"new note" - }; - done(); -}); - -hooks.before("PUT /collections/{CollectionId}/notes/{NoteId} -> 400", function(test, done) { - test.request.params = { - CollectionId : collection_id, - NoteId: test_collection_1.notes[0]._id - }; - test.request.body = { - "note a":"real property" - }; - done(); -}); - -hooks.before("DELETE /collections/{CollectionId}/notes/{NoteId} -> 200", function(test, done) { - test.request.params = { - CollectionId : collection_id, - NoteId: test_collection_1.notes[0]._id - }; - done(); -}); - -hooks.before("GET /collections/{CollectionId}/analyses/{AnalysisId} -> 200", function(test, done) { - test.request.params = { - CollectionId : collection_id, - AnalysisId: test_collection_1.analyses[0]._id - }; - done(); -}); - -hooks.before("DELETE /collections/{CollectionId}/analyses/{AnalysisId} -> 200", function(test, done) { - test.request.params = { - CollectionId : collection_id, - AnalysisId: test_collection_1.analyses[1]._id - }; - done(); -}); - -hooks.before("GET /collections/{CollectionId}/analyses/{AnalysisId}/files -> 200", function(test, done) { - test.request.params = { - CollectionId : collection_id, - AnalysisId: test_collection_1.analyses[0]._id - }; - test.request.query.ticket = ""; - done(); -}); - -hooks.before("GET /collections/{CollectionId}/analyses/{AnalysisId}/files/{Filename} -> 200", function(test, done) { - test.request.params = { - CollectionId : collection_id, - AnalysisId: test_collection_1.analyses[0]._id, - Filename: "test-1.dcm" - }; - test.request.query.ticket = ""; - done(); -}); - -hooks.before("POST /collections/{CollectionId}/analyses/{AnalysisId}/notes -> 200", function(test, done) { - test.request.params = { - CollectionId : collection_id, - AnalysisId: test_collection_1.analyses[0]._id - }; - done(); -}); - -hooks.before("POST /collections/{CollectionId}/analyses/{AnalysisId}/notes -> 400", function(test, done) { - test.request.params = { - CollectionId : collection_id, - AnalysisId: test_collection_1.analyses[0]._id - }; - test.request.body = { - "not a":"real property" - }; - done(); -}); - -hooks.before("DELETE /collections/{CollectionId}/analyses/{AnalysisId}/notes/{NoteId} -> 200", function(test, done) { - test.request.params = { - CollectionId : collection_id, - AnalysisId: test_collection_1.analyses[0]._id, - NoteId: test_collection_1.analyses[0].notes[0]._id - }; - done(); -}); - - -// set initial test_session_1 -hooks.after("GET /sessions -> 200", function(test, done) { - test_session_1 = test.response.body[0]; - assert.equal(test_session_1.label, "test-session-1"); - done(); -}); - -hooks.before("GET /sessions/{SessionId} -> 200", function(test, done) { - test.request.params.SessionId = test_session_1._id; - done(); -}); - -// set detailed test_session_1 (including analyses, that are omitted during listing) -hooks.after("GET /sessions/{SessionId} -> 200", function(test, done) { - test_session_1 = test.response.body; - done(); -}); - -hooks.after("GET /sessions/{SessionId} -> 200", function(test, done) { - test_session_1 = test.response.body; - assert.equal(test_session_1.label, "test-session-1"); - done(); -}); - -hooks.before("POST /sessions -> 200", function(test, done) { - test.request.body.project = test_session_1.project; - done(); -}); - -hooks.after("POST /sessions -> 200", function(test, done) { - test_session_2_id = test.response.body._id - done(); -}); - -hooks.before("POST /sessions -> 400", function(test, done) { - test.request.body.foo = "not an allowed property"; - test.request.body.project = test_session_1.project; - done(); -}); - -hooks.before("PUT /sessions/{SessionId} -> 200", function(test, done) { - test.request.params.SessionId = test_session_1._id; - test.request.body = { - project: test_session_1.project, - label: "new-label-test-session-1" - }; - done(); -}); - -hooks.before("PUT /sessions/{SessionId} -> 400", function(test, done) { - test.request.params.SessionId = test_session_1._id; - test.request.body = { - project: test_session_1.project, - "not_a_real_property": "new-label-test-session-1" - }; - done(); -}); - -hooks.before("DELETE /sessions/{SessionId} -> 200", function(test, done) { - test.request.params.SessionId = test_session_2_id; - done(); -}); - - -hooks.before("GET /sessions/{SessionId}/jobs -> 200", function(test, done) { - test.request.params.SessionId = test_session_1._id; - done(); -}); - -hooks.before("POST /sessions/{SessionId}/tags -> 200", function(test, done) { - test.request.params.SessionId = test_session_1._id; - test.request.body = { - value: test_session_tag - }; - done(); -}); - -hooks.before("POST /sessions/{SessionId}/tags -> 400", function(test, done) { - test.request.params.SessionId = test_session_1._id; - test.request.body = { - value: "" - }; - done(); -}); - -hooks.before("GET /sessions/{SessionId}/tags/{TagValue} -> 200", function(test, done) { - test.request.params = { - SessionId : test_session_1._id, - TagValue: test_session_tag - }; - done(); -}); - -hooks.before("PUT /sessions/{SessionId}/tags/{TagValue} -> 200", function(test, done) { - test.request.params = { - SessionId : test_session_1._id, - TagValue: test_session_tag - }; - test_session_tag = 'new-tag-value'; - test.request.body = { - value: test_session_tag - }; - done(); -}); - -hooks.before("PUT /sessions/{SessionId}/tags/{TagValue} -> 400", function(test, done) { - test.request.params = { - SessionId : test_session_1._id, - TagValue: test_session_tag - }; - test.request.body = { - value: "" - }; - done(); -}); - -hooks.before("DELETE /sessions/{SessionId}/tags/{TagValue} -> 200", function(test, done) { - test.request.params = { - SessionId : test_session_1._id, - TagValue: test_session_tag - }; - done(); -}); - -hooks.before("GET /sessions/{SessionId}/files/{FileName} -> 200", function(test, done) { - test.request.params = { - SessionId : test_session_1._id, - FileName : "notes.txt" - }; - test.request.query = { - "ticket":"" - }; - done(); -}); - -hooks.before("POST /sessions/{SessionId}/notes -> 200", function(test, done) { - test.request.params = { - SessionId : test_session_1._id - }; - test.request.body = { - "text":"test note" - }; - done(); -}); - -hooks.before("POST /sessions/{SessionId}/notes -> 400", function(test, done) { - test.request.params = { - SessionId : test_session_1._id - }; - test.request.body = { - "note a real":"property" - }; - done(); -}); - -hooks.before("GET /sessions/{SessionId}/notes/{NoteId} -> 200", function(test, done) { - test.request.params = { - SessionId : test_session_1._id, - NoteId: test_session_1.notes[0]._id - }; - done(); -}); - -hooks.before("PUT /sessions/{SessionId}/notes/{NoteId} -> 200", function(test, done) { - test.request.params = { - SessionId : test_session_1._id, - NoteId: test_session_1.notes[0]._id - }; - test.request.body = { - "text":"new note" - }; - done(); -}); - -hooks.before("PUT /sessions/{SessionId}/notes/{NoteId} -> 400", function(test, done) { - test.request.params = { - SessionId : test_session_1._id, - NoteId: test_session_1.notes[0]._id - }; - test.request.body = { - "not a real":"property" - }; - done(); -}); - -hooks.before("DELETE /sessions/{SessionId}/notes/{NoteId} -> 200", function(test, done) { - test.request.params = { - SessionId : test_session_1._id, - NoteId: test_session_1.notes[0]._id - }; - done(); -}); - -hooks.before("GET /sessions/{SessionId}/acquisitions -> 200", function(test, done) { - test.request.params.SessionId = test_session_1._id; - done(); -}); - -hooks.before("POST /sessions/{SessionId}/analyses -> 200", function(test, done) { - test.request.params.SessionId = test_session_1._id; - test.request.query = {"job":"true"}; - test.request.body = { - "analysis": { - "label": "Test Analysis 1" - }, - "job" : { - "gear": "test-case-gear", - "inputs": {}, - "tags": ["example"] - } - } - done(); -}); - -hooks.after("POST /sessions/{SessionId}/analyses -> 200", function(test, done) { - test_session_1_analysis_2_id = test.response.body._id; - done(); -}); - -hooks.before("GET /sessions/{SessionId}/analyses/{AnalysisId} -> 200", function(test, done) { - test.request.params.SessionId = test_session_1._id; - test.request.params.AnalysisId = test_session_1_analysis_2_id; - done(); -}); - -hooks.before("DELETE /sessions/{SessionId}/analyses/{AnalysisId} -> 200", function(test, done) { - test.request.params.SessionId = test_session_1._id; - test.request.params.AnalysisId = test_session_1_analysis_2_id; - done(); -}); - -hooks.before("GET /sessions/{SessionId}/analyses/{AnalysisId}/files -> 200", function(test, done) { - test.request.params.SessionId = test_session_1._id; - test.request.params.AnalysisId = test_session_1.analyses[0]._id; - test.request.query.ticket = ""; - done(); -}); - -hooks.before("GET /sessions/{SessionId}/analyses/{AnalysisId}/files/{Filename} -> 200", function(test, done) { - test.request.params.SessionId = test_session_1._id; - test.request.params.AnalysisId = test_session_1.analyses[0]._id; - test.request.params.Filename = "test-1.dcm"; - test.request.query.ticket = ""; - done(); -}); - -hooks.before("POST /sessions/{SessionId}/analyses/{AnalysisId}/notes -> 200", function(test, done) { - test.request.params.SessionId = test_session_1._id; - test.request.params.AnalysisId = test_session_1.analyses[0]._id; - done(); -}); - -hooks.before("POST /sessions/{SessionId}/analyses/{AnalysisId}/notes -> 400", function(test, done) { - test.request.params.SessionId = test_session_1._id; - test.request.params.AnalysisId = test_session_1.analyses[0]._id; - test.request.body = { - "not a":"real property" - }; - done(); -}); - -hooks.before("DELETE /sessions/{SessionId}/analyses/{AnalysisId}/notes/{NoteId} -> 200", function(test, done) { - test.request.params.SessionId = test_session_1._id; - test.request.params.AnalysisId = test_session_1.analyses[0]._id; - test.request.params.NoteId = test_session_1.analyses[0].notes[0]._id; - done(); -}); - - - -// set initial test_acquisition_1 -hooks.after("GET /acquisitions -> 200", function(test, done) { - test_acquisition_1 = test.response.body[0]; - assert.equal(test_acquisition_1.label, "test-acquisition-1"); - done(); -}); - -hooks.before("GET /acquisitions/{AcquisitionId} -> 200", function(test, done) { - test.request.params.AcquisitionId = test_acquisition_1._id; - done(); -}); - -// set detailed test_acquisition_1 (including analyses, that are omitted during listing) -hooks.after("GET /acquisitions/{AcquisitionId} -> 200", function(test, done) { - test_acquisition_1 = test.response.body; - done(); -}); - -hooks.before("POST /acquisitions -> 200", function(test, done) { - test.request.body.session = test_session_1._id; - done(); -}); - -hooks.after("POST /acquisitions -> 200", function(test, done) { - example_acquisition_id = test.response.body._id; - done(); -}); - -hooks.before("POST /acquisitions -> 400", function(test, done) { - test.request.body.session = test_session_1._id; - test.request.body.foo = "bar"; - done(); -}); - -hooks.before("PUT /acquisitions/{AcquisitionId} -> 200", function(test, done) { - test.request.params.AcquisitionId = test_acquisition_1._id; - test.request.body = {"label":"test-acquisition-1-new-label"}; - done(); -}); - - -hooks.before("PUT /acquisitions/{AcquisitionId} -> 400", function(test, done) { - test.request.params.AcquisitionId = test_acquisition_1._id; - test.request.body = {"not-real":"an invalid property"}; - done(); -}); - -hooks.before("DELETE /acquisitions/{AcquisitionId} -> 200", function(test, done) { - test.request.params.AcquisitionId = example_acquisition_id; - done(); -}); - -hooks.before("POST /acquisitions/{AcquisitionId}/tags -> 200", function(test, done) { - test.request.params.AcquisitionId = test_acquisition_1._id; - test.request.body = { - "value": test_acquisition_tag - }; - done(); -}); - -hooks.before("POST /acquisitions/{AcquisitionId}/tags -> 400", function(test, done) { - test.request.params.AcquisitionId = test_acquisition_1._id; - test.request.body = { - "value": test_acquisition_tag, - "bad property": "not a real property" - }; - done(); -}); - -hooks.before("GET /acquisitions/{AcquisitionId}/tags/{TagValue} -> 200", function(test, done) { - test.request.params = { - AcquisitionId : test_acquisition_1._id, - TagValue : test_acquisition_tag - }; - done(); -}); - -hooks.before("PUT /acquisitions/{AcquisitionId}/tags/{TagValue} -> 200", function(test, done) { - test.request.params = { - AcquisitionId : test_acquisition_1._id, - TagValue : test_acquisition_tag - }; - test_acquisition_tag = "new-tag-value"; - test.request.body = { - "value": test_acquisition_tag - }; - done(); -}); - -hooks.before("PUT /acquisitions/{AcquisitionId}/tags/{TagValue} -> 400", function(test, done) { - test.request.params = { - AcquisitionId : test_acquisition_1._id, - TagValue : test_acquisition_tag - }; - test.request.body = { - "value": test_acquisition_tag, - "bad property": "not a real property" - }; - done(); -}); - -hooks.before("DELETE /acquisitions/{AcquisitionId}/tags/{TagValue} -> 200", function(test, done) { - test.request.params = { - AcquisitionId : test_acquisition_1._id, - TagValue : test_acquisition_tag - }; - done(); -}); - -hooks.before("GET /acquisitions/{AcquisitionId}/files/{FileName} -> 200", function(test, done) { - test.request.params = { - AcquisitionId : test_acquisition_1._id, - FileName : "test-1.dcm" - }; - test.request.query = { - "ticket":"" - }; - done(); -}); - -hooks.before("POST /acquisitions/{AcquisitionId}/notes -> 200", function(test, done) { - test.request.params = { - AcquisitionId : test_acquisition_1._id - }; - done(); -}); - -hooks.before("POST /acquisitions/{AcquisitionId}/notes -> 400", function(test, done) { - test.request.params = { - AcquisitionId : test_acquisition_1._id - }; - test.request.body.not_real = "invalid property"; - done(); -}); - -hooks.before("GET /acquisitions/{AcquisitionId}/notes/{NoteId} -> 200", function(test, done) { - test.request.params = { - AcquisitionId : test_acquisition_1._id, - NoteId: test_acquisition_1.notes[0]._id - }; - done(); -}); - -hooks.before("PUT /acquisitions/{AcquisitionId}/notes/{NoteId} -> 200", function(test, done) { - test.request.params = { - AcquisitionId : test_acquisition_1._id, - NoteId: test_acquisition_1.notes[0]._id - }; - test.request.body = { - "text":"updated note text" - }; - done(); -}); - -hooks.before("PUT /acquisitions/{AcquisitionId}/notes/{NoteId} -> 400", function(test, done) { - test.request.params = { - AcquisitionId : test_acquisition_1._id, - NoteId: test_acquisition_1.notes[0]._id - }; - test.request.body = { - "invalid property":"specified" - }; - done(); -}); - -hooks.before("DELETE /acquisitions/{AcquisitionId}/notes/{NoteId} -> 200", function(test, done) { - test.request.params = { - AcquisitionId : test_acquisition_1._id, - NoteId: test_acquisition_1.notes[0]._id - }; - done(); -}); - -hooks.before("GET /acquisitions/{AcquisitionId}/analyses/{AnalysisId} -> 200", function(test, done) { - test.request.params = { - AcquisitionId : test_acquisition_1._id, - AnalysisId: test_acquisition_1.analyses[0]._id - }; - done(); -}); - -hooks.before("DELETE /acquisitions/{AcquisitionId}/analyses/{AnalysisId} -> 200", function(test, done) { - test.request.params = { - AcquisitionId : test_acquisition_1._id, - AnalysisId: test_acquisition_1.analyses[1]._id - }; - done(); -}); - -hooks.before("GET /acquisitions/{AcquisitionId}/analyses/{AnalysisId}/files -> 200", function(test, done) { - test.request.params = { - AcquisitionId : test_acquisition_1._id, - AnalysisId: test_acquisition_1.analyses[0]._id - }; - test.request.query.ticket = ""; - done(); -}); - -hooks.before("GET /acquisitions/{AcquisitionId}/analyses/{AnalysisId}/files/{Filename} -> 200", function(test, done) { - test.request.params = { - AcquisitionId : test_acquisition_1._id, - AnalysisId: test_acquisition_1.analyses[0]._id, - Filename: "test-1.dcm" - }; - test.request.query.ticket = ""; - done(); -}); - -hooks.before("POST /acquisitions/{AcquisitionId}/analyses/{AnalysisId}/notes -> 200", function(test, done) { - test.request.params = { - AcquisitionId : test_acquisition_1._id, - AnalysisId: test_acquisition_1.analyses[0]._id - }; - done(); -}); - -hooks.before("POST /acquisitions/{AcquisitionId}/analyses/{AnalysisId}/notes -> 400", function(test, done) { - test.request.params = { - AcquisitionId : test_acquisition_1._id, - AnalysisId: test_acquisition_1.analyses[0]._id - }; - test.request.body = { - "not a":"real property" - }; - done(); -}); - -hooks.before("GET /acquisitions/{AcquisitionId}/analyses/{AnalysisId}/notes/{NoteId} -> 200", function(test, done) { - test.request.params = { - AcquisitionId : test_acquisition_1._id, - AnalysisId: test_acquisition_1.analyses[0]._id, - NoteId: test_acquisition_1.analyses[0].notes[0]._id - }; - done(); -}); - -hooks.before("DELETE /acquisitions/{AcquisitionId}/analyses/{AnalysisId}/notes/{NoteId} -> 200", function(test, done) { - test.request.params = { - AcquisitionId : test_acquisition_1._id, - AnalysisId: test_acquisition_1.analyses[0]._id, - NoteId: test_acquisition_1.analyses[0].notes[0]._id - }; - done(); -}); - - -// set initial test_project_1 -hooks.after("GET /projects -> 200", function(test, done) { - test_project_1 = test.response.body[0]; - assert.equal(test_project_1.label, "test-project-1"); - done(); -}); - -hooks.after("POST /projects -> 200", function(test, done) { - delete_project_id = test.response.body._id; - done(); -}); - -hooks.before("POST /projects -> 400", function(test, done) { - test.request.body.not_real = "an invalid property"; - done(); -}); - -hooks.before("GET /projects/{ProjectId} -> 200", function(test, done) { - test.request.params.ProjectId = test_project_1._id; - done(); -}); - -// set detailed test_project_1 (including analyses, that are omitted during listing) -hooks.after("GET /projects/{ProjectId} -> 200", function(test, done) { - test_project_1 = test.response.body; - done(); -}); - -hooks.before("PUT /projects/{ProjectId} -> 400", function(test, done) { - test.request.params.ProjectId = test_project_1._id; - test.request.body = {"not_real":"fake property"}; - done(); -}); - -hooks.before("DELETE /projects/{ProjectId} -> 200", function(test, done) { - test.request.params.ProjectId = delete_project_id; - done(); -}); - -hooks.before("POST /projects/{ProjectId}/tags -> 200", function(test, done) { - test.request.params.ProjectId = test_project_1._id; - test.request.body = { - "value":test_project_tag - }; - done(); -}); - -hooks.before("POST /projects/{ProjectId}/tags -> 400", function(test, done) { - test.request.params.ProjectId = test_project_1._id; - test.request.body = { - "value":"" - }; - done(); -}); - -hooks.before("GET /projects/{ProjectId}/tags/{TagValue} -> 200", function(test, done) { - test.request.params = { - ProjectId : test_project_1._id, - TagValue : test_project_tag - }; - done(); -}); - -hooks.before("PUT /projects/{ProjectId}/tags/{TagValue} -> 200", function(test, done) { - test.request.params = { - ProjectId : test_project_1._id, - TagValue : test_project_tag - }; - test_project_tag = "new-tag-value"; - test.request.body = { - "value":test_project_tag - }; - done(); -}); - -hooks.before("PUT /projects/{ProjectId}/tags/{TagValue} -> 400", function(test, done) { - test.request.params = { - ProjectId : test_project_1._id, - TagValue : test_project_tag - }; - test.request.body = { - "value":"" - }; - done(); -}); - -hooks.before("DELETE /projects/{ProjectId}/tags/{TagValue} -> 200", function(test, done) { - test.request.params = { - ProjectId : test_project_1._id, - TagValue : test_project_tag - }; - done(); -}); - -hooks.before("GET /projects/{ProjectId}/files/{FileName} -> 200", function(test, done) { - test.request.params = { - ProjectId : test_project_1._id, - FileName : "notes.txt" - }; - test.request.query = { - "ticket":"" - }; - done(); -}); - -hooks.before("POST /projects/{ProjectId}/permissions -> 200", function(test, done) { - test.request.params = { - ProjectId : test_project_1._id - }; - test.request.body = { - "_id":"test@user.com", - "access":"ro" - }; - done(); -}); - -hooks.before("POST /projects/{ProjectId}/permissions -> 400", function(test, done) { - test.request.params = { - ProjectId : test_project_1._id - }; - test.request.body = { - "not a valid":"permissions entry" - }; - done(); -}); - -hooks.before("GET /projects/{ProjectId}/permissions/{UserId} -> 200", function(test, done) { - test.request.params = { - ProjectId : test_project_1._id, - UserId: "test@user.com" - }; - done(); -}); - -hooks.before("PUT /projects/{ProjectId}/permissions/{UserId} -> 200", function(test, done) { - test.request.params = { - ProjectId : test_project_1._id, - UserId: "test@user.com" - }; - test.request.body = { - "access":"rw", - "_id":"test@user.com" - }; - done(); -}); - -hooks.before("PUT /projects/{ProjectId}/permissions/{UserId} -> 400", function(test, done) { - test.request.params = { - ProjectId : test_project_1._id, - UserId: "test@user.com" - }; - test.request.body = { - "not a valid":"permissions entry" - }; - done(); -}); - -hooks.before("DELETE /projects/{ProjectId}/permissions/{UserId} -> 200", function(test, done) { - test.request.params = { - ProjectId : test_project_1._id, - UserId: "test@user.com" - }; - done(); -}); - -hooks.before("POST /projects/{ProjectId}/notes -> 200", function(test, done) { - test.request.params = { - ProjectId : test_project_1._id - }; - test.request.body = { - "text":"test note" - }; - done(); -}); - -hooks.before("POST /projects/{ProjectId}/notes -> 400", function(test, done) { - test.request.params = { - ProjectId : test_project_1._id - }; - test.request.body = { - "not a real":"property" - }; - done(); -}); - -hooks.before("GET /projects/{ProjectId}/notes/{NoteId} -> 200", function(test, done) { - test.request.params = { - ProjectId : test_project_1._id, - NoteId: test_project_1.notes[0]._id - }; - done(); -}); - -hooks.before("PUT /projects/{ProjectId}/notes/{NoteId} -> 200", function(test, done) { - test.request.params = { - ProjectId : test_project_1._id, - NoteId: test_project_1.notes[0]._id - }; - test.request.body = { - "text":"updated note" - }; - done(); -}); - -hooks.before("PUT /projects/{ProjectId}/notes/{NoteId} -> 400", function(test, done) { - test.request.params = { - ProjectId : test_project_1._id, - NoteId: test_project_1.notes[0]._id - }; - test.request.body = { - "not a real":"property" - }; - done(); -}); - -hooks.before("DELETE /projects/{ProjectId}/notes/{NoteId} -> 200", function(test, done) { - test.request.params = { - ProjectId : test_project_1._id, - NoteId: test_project_1.notes[0]._id - }; - done(); -}); - -hooks.before("GET /projects/{ProjectId}/sessions -> 200", function(test, done) { - test.request.params.ProjectId = test_project_1._id; - done(); -}); - -hooks.before("GET /projects/{ProjectId}/acquisitions -> 200", function(test, done) { - test.request.params.ProjectId = test_project_1._id; - done(); -}); - -hooks.before("GET /report/project -> 200", function(test, done) { - test.request.query = { - "projects":test_project_1._id - }; - done(); -}); - -hooks.before("GET /projects/{ProjectId}/analyses/{AnalysisId} -> 200", function(test, done) { - test.request.params = { - ProjectId: test_project_1._id, - AnalysisId: test_project_1.analyses[0]._id - }; - done(); -}); - -hooks.before("DELETE /projects/{ProjectId}/analyses/{AnalysisId} -> 200", function(test, done) { - test.request.params = { - ProjectId: test_project_1._id, - AnalysisId: test_project_1.analyses[1]._id - }; - done(); -}); - -hooks.before("GET /projects/{ProjectId}/analyses/{AnalysisId}/files -> 200", function(test, done) { - test.request.params = { - ProjectId: test_project_1._id, - AnalysisId: test_project_1.analyses[0]._id - }; - test.request.query.ticket = ""; - done(); -}); - -hooks.before("GET /projects/{ProjectId}/analyses/{AnalysisId}/files/{Filename} -> 200", function(test, done) { - test.request.params = { - ProjectId: test_project_1._id, - AnalysisId: test_project_1.analyses[0]._id, - Filename: "test-1.dcm" - }; - test.request.query.ticket = ""; - done(); -}); - -hooks.before("POST /projects/{ProjectId}/analyses/{AnalysisId}/notes -> 200", function(test, done) { - test.request.params = { - ProjectId: test_project_1._id, - AnalysisId: test_project_1.analyses[0]._id - }; - done(); -}); - - -hooks.before("POST /projects/{ProjectId}/analyses/{AnalysisId}/notes -> 400", function(test, done) { - test.request.params = { - ProjectId: test_project_1._id, - AnalysisId: test_project_1.analyses[0]._id - }; - test.request.body = { - "not a":"real property" - } - done(); -}); - -hooks.before("DELETE /projects/{ProjectId}/analyses/{AnalysisId}/notes/{NoteId} -> 200", function(test, done) { - test.request.params = { - ProjectId: test_project_1._id, - AnalysisId: test_project_1.analyses[0]._id, - NoteId: test_project_1.analyses[0].notes[0]._id - }; - done(); -}); - -hooks.before("GET /devices/{DeviceId} -> 200", function(test, done) { - test.request.params.DeviceId = device_id; - done(); -}); - -hooks.before("GET /devices/{DeviceId} -> 404", function(test, done) { - test.request.params.DeviceId = 'bad_device_id'; - done(); -}); diff --git a/tests/integration_tests/abao/load_fixture.py b/tests/integration_tests/abao/load_fixture.py deleted file mode 100644 index 32c036bdc8cc9ffb735a7658657ef358c5338786..0000000000000000000000000000000000000000 --- a/tests/integration_tests/abao/load_fixture.py +++ /dev/null @@ -1,433 +0,0 @@ -import datetime -import json -import os - -import pymongo -import requests - - -# load required envvars w/ the same name -SCITRAN_CORE_DRONE_SECRET = os.environ['SCITRAN_CORE_DRONE_SECRET'] -SCITRAN_PERSISTENT_DB_URI = os.environ['SCITRAN_PERSISTENT_DB_URI'] -SCITRAN_SITE_API_URL = os.environ['SCITRAN_SITE_API_URL'] - - -class BaseUrlSession(requests.Session): - """Requests session subclass using core api's base url""" - def request(self, method, url, **kwargs): - return super(BaseUrlSession, self).request(method, SCITRAN_SITE_API_URL + url, **kwargs) - - -def main(): - abao_user = 'abao@user.com' - abao_api_key = 'XZpXI40Uk85eozjQkU1zHJ6yZHpix+j0mo1TMeGZ4dPzIqVPVGPmyfeK' - - as_drone = BaseUrlSession() - as_drone.headers.update({ - 'X-SciTran-Method': 'bootstrapper', - 'X-SciTran-Name': 'Bootstrapper', - 'X-SciTran-Auth': SCITRAN_CORE_DRONE_SECRET, - }) - - as_drone.post('/users', json={ - '_id': abao_user, - 'firstname': 'Abao', - 'lastname': 'User', - 'root': True, - }) - api_db = pymongo.MongoClient(SCITRAN_PERSISTENT_DB_URI).get_default_database() - api_db.apikeys.insert_one({ - '_id': abao_api_key, - 'created': datetime.datetime.utcnow(), - 'last_seen': None, - 'type': 'user', - 'uid': abao_user - }) - - as_root = BaseUrlSession() - as_root.headers.update({'Authorization': 'scitran-user {}'.format(abao_api_key)}) - as_root.params.update({'root': 'true'}) - - # create scitran group - r = as_root.post('/groups', json={'_id': 'scitran'}) - assert r.ok - - # create test-group - r = as_root.post('/groups', json={'_id': 'test-group'}) - assert r.ok - - # upload file to test-project-1/test-session-1/test-acquisition-1 - # depends on 'create test-group' - r = as_root.post('/upload/label', files={ - 'file': ('test-1.dcm', open('tests/integration_tests/abao/test_files/test-1.dcm', 'rb')), - 'metadata': ('', json.dumps({ - 'group': { '_id': 'test-group' }, - 'project': { - 'label': 'test-project-1' - }, - 'session': { - 'label': 'test-session-1', - 'subject': { - 'age': 25, - 'sex': 'male', - 'firstname': 'xyz' - } - }, - 'acquisition': { - 'label': 'test-acquisition-1', - 'files': [{ 'name': 'test-1.dcm' }] - } - })) - }) - assert r.ok - - # list projects - # depends on 'upload file to test-project-1/test-session-1/test-acquisition-1' - r = as_root.get('/projects') - assert r.ok - assert r.json()[0]['label'] == 'test-project-1' - test_project = r.json()[0] - - # list sessions - # depends on 'upload file to test-project-1/test-session-1/test-acquisition-1' - r = as_root.get('/sessions') - assert r.ok - assert r.json()[0]['label'] == 'test-session-1' - test_session = r.json()[0] - - # list acquisitions for test-session-1 - # depends on 'upload file to test-project-1/test-session-1/test-acquisition-1' - r = as_root.get('/sessions/' + test_session['_id'] + '/acquisitions') - assert r.ok - assert r.json()[0]['label'] == 'test-acquisition-1' - test_acquisition = r.json()[0] - - # add test-case-gear - r = as_root.post('/gears/test-case-gear', json={ - 'category': 'converter', - 'gear': { - 'inputs': { - 'dicom': { - 'base': 'file', - 'type': { 'enum': [ 'wat' ] } - } - }, - 'maintainer': 'Example', - 'description': 'Example', - 'license': 'BSD-2-Clause', - 'author': 'Example', - 'url': 'https://example.example', - 'label': 'wat', - 'flywheel': '0', - 'source': 'https://example.example', - 'version': '0.0.1', - 'config': {}, - 'name': 'test-case-gear' - }, - 'exchange': { - 'git-commit': 'aex', - 'rootfs-hash': 'sha384:oy', - 'rootfs-url': 'https://example.example' - } - }) - assert r.ok - test_gear = r.json() - - # create test-collection-1 - r = as_root.post('/collections', json={ - 'label': 'test-collection-1' - }) - assert r.ok - test_collection = r.json() - - # add test-session-1 to test-collection-1 - # depends on 'upload file to test-project-1/test-session-1/test-acquisition-1' - # depends on 'create test-collection-1' - r = as_root.put('/collections/' + test_collection['_id'], json={ - 'contents':{ - 'operation': 'add', - 'nodes': [{ - 'level': 'session', - '_id': test_session['_id'] - }] - } - }) - assert r.ok - - # upload file to test-collection-1 - # depends on 'create test-collection-1' - r = as_root.post('/collections/' + test_collection['_id'] + '/files', files={ - 'file': ('notes.txt', open('tests/integration_tests/abao/test_files/notes.txt', 'rb')) - }) - assert r.ok - - # create test-collection-2 - r = as_root.post('/collections', json={ - 'label': 'test-collection-2' - }) - assert r.ok - - # upload file to test-project-1 - # depends on 'upload file to test-project-1/test-session-1/test-acquisition-1' - r = as_root.post('/projects/' + test_project['_id'] + '/files', files={ - 'file': ('notes.txt', open('tests/integration_tests/abao/test_files/notes.txt', 'rb')) - }) - assert r.ok - - # upload file to test-session-1 - # depends on 'upload file to test-project-1/test-session-1/test-acquisition-1' - r = as_root.post('/sessions/' + test_session['_id'] + '/files', files={ - 'file': ('notes.txt', open('tests/integration_tests/abao/test_files/notes.txt', 'rb')) - }) - assert r.ok - - # add a note to test-project-1 - # depends on 'upload file to test-project-1/test-session-1/test-acquisition-1' - r = as_root.post('/projects/' + test_project['_id'] + '/notes', json={ - 'text': 'test note' - }) - assert r.ok - - # add a note to test-session-1 - # depends on 'upload file to test-project-1/test-session-1/test-acquisition-1' - r = as_root.post('/sessions/' + test_session['_id'] + '/notes', json={ - 'text': 'test note' - }) - assert r.ok - - # add a note to test-acquisition-1 - # depends on 'upload file to test-project-1/test-session-1/test-acquisition-1' - r = as_root.post('/acquisitions/' + test_acquisition['_id'] + '/notes', json={ - 'text': 'test note' - }) - assert r.ok - - # add a note to test-collection-1 - # depends on 'create test-collection-1' - r = as_root.post('/collections/' + test_collection['_id'] + '/notes', json={ - 'text': 'test note' - }) - assert r.ok - - # create session 1 test-analysis-1 (job) - # depends on 'upload file to test-project-1/test-session-1/test-acquisition-1' - # depends on 'add test-case-gear' - r = as_root.post('/sessions/' + test_session['_id'] + '/analyses?job=true', json={ - 'analysis': { 'label': 'Test Analysis 1' }, - 'job': { - 'gear_id': test_gear['_id'], - 'inputs': { - 'dicom': { - 'type': 'acquisition', - 'id': test_acquisition['_id'], - 'name': 'test-1.dcm' - } - }, - 'tags': ['example'] - } - }) - assert r.ok - test_session_analysis = r.json() - - # create session 1 test-analysis (file upload) - # depends on 'upload file to test-project-1/test-session-1/test-acquisition-1' - r = as_root.post('/sessions/' + test_session['_id'] + '/analyses', files={ - 'file': ('test-1.dcm', open('tests/integration_tests/abao/test_files/test-1.dcm', 'rb')), - 'metadata': ('', json.dumps({ - 'label': 'test analysis', - 'inputs': [ { 'name': 'test-1.dcm' } ] - })) - }) - assert r.ok - test_session_analysis_upload = r.json() - - # delete session 1 test analysis (file upload) - # depends on 'create session 1 test-analysis (file upload)' - r = as_root.delete('/sessions/' + test_session['_id'] + '/analyses/' + test_session_analysis_upload['_id']) - assert r.ok - - # create acquisition 1 test-analysis (file upload) - # depends on 'upload file to test-project-1/test-session-1/test-acquisition-1' - r = as_root.post('/acquisitions/' + test_acquisition['_id'] + '/analyses', files={ - 'file': ('test-1.dcm', open('tests/integration_tests/abao/test_files/test-1.dcm', 'rb')), - 'metadata': ('', json.dumps({ - 'label': 'test analysis', - 'inputs': [ { 'name': 'test-1.dcm' } ] - })) - }) - assert r.ok - test_acquisition_analysis_upload = r.json() - - # create acquisition 1 test-analysis 2 (file upload) - # depends on 'upload file to test-project-1/test-session-1/test-acquisition-1' - r = as_root.post('/acquisitions/' + test_acquisition['_id'] + '/analyses', files={ - 'file': ('test-1.dcm', open('tests/integration_tests/abao/test_files/test-1.dcm', 'rb')), - 'metadata': ('', json.dumps({ - 'label': 'test analysis', - 'inputs': [ { 'name': 'test-1.dcm' } ] - })) - }) - assert r.ok - - # create collection 1 test-analysis (file upload) - # depends on 'create test-collection-1' - r = as_root.post('/collections/' + test_collection['_id'] + '/analyses', files={ - 'file': ('test-1.dcm', open('tests/integration_tests/abao/test_files/test-1.dcm', 'rb')), - 'metadata': ('', json.dumps({ - 'label': 'test analysis', - 'inputs': [ { 'name': 'test-1.dcm' } ] - })) - }) - assert r.ok - test_collection_analysis_upload = r.json() - - # create collection 1 test-analysis 2 (file upload) - # depends on 'create test-collection-1' - r = as_root.post('/collections/' + test_collection['_id'] + '/analyses', files={ - 'file': ('test-1.dcm', open('tests/integration_tests/abao/test_files/test-1.dcm', 'rb')), - 'metadata': ('', json.dumps({ - 'label': 'test analysis 2', - 'inputs': [ { 'name': 'test-1.dcm' } ] - })) - }) - assert r.ok - - # create project 1 test-analysis (file upload) - # depends on 'upload file to test-project-1/test-session-1/test-acquisition-1' - r = as_root.post('/projects/' + test_project['_id'] + '/analyses', files={ - 'file': ('test-1.dcm', open('tests/integration_tests/abao/test_files/test-1.dcm', 'rb')), - 'metadata': ('', json.dumps({ - 'label': 'test analysis', - 'inputs': [ { 'name': 'test-1.dcm' } ] - })) - }) - assert r.ok - test_project_analysis_upload = r.json() - - # create project 1 test-analysis 2 (file upload) - # depends on 'upload file to test-project-1/test-session-1/test-acquisition-1' - r = as_root.post('/projects/' + test_project['_id'] + '/analyses', files={ - 'file': ('test-1.dcm', open('tests/integration_tests/abao/test_files/test-1.dcm', 'rb')), - 'metadata': ('', json.dumps({ - 'label': 'test analysis', - 'inputs': [ { 'name': 'test-1.dcm' } ] - })) - }) - assert r.ok - - # add a note to test-acquisition-1 test-analysis-1 - # depends on 'create acquisition 1 test-analysis (file upload)' - r = as_root.post('/acquisitions/' + test_acquisition['_id'] + '/analyses/' + test_acquisition_analysis_upload['_id'] + '/notes', json={ - 'text': 'test note' - }) - assert r.ok - - # add a note to test-collection-1 test-analysis-1 - # depends on 'create test-collection-1' - r = as_root.post('/collections/' + test_collection['_id'] + '/analyses/' + test_collection_analysis_upload['_id'] + '/notes', json={ - 'text': 'test note' - }) - assert r.ok - - # add a note to test-session-1 test-analysis-1 - # depends on 'create session 1 test-analysis (file upload)' - r = as_root.post('/sessions/' + test_session['_id'] + '/analyses/' + test_session_analysis['_id'] + '/notes', json={ - 'text': 'test note' - }) - assert r.ok - - # add a note to test-project-1 test-analysis-1 - # depends on 'create project 1 test-analysis (file upload)' - r = as_root.post('/projects/' + test_project['_id'] + '/analyses/' + test_project_analysis_upload['_id'] + '/notes', json={ - 'text': 'test note' - }) - assert r.ok - - # create project - r = as_root.post('/projects', json={ - 'group': 'test-group', - 'label': 'Project with template', - 'public': False - }) - assert r.ok - st_project = r.json() - - # create compliant session - # depends on 'create project' - r = as_root.post('/sessions', json={ - 'subject': { 'code': 'ex8945' }, - 'label': 'Compliant Session', - 'project': st_project['_id'], - 'public': False - }) - assert r.ok - st_compliant_session = r.json() - - # create non-compliant session - # depends on 'create project' - r = as_root.post('/sessions', json={ - 'subject': { 'code': 'ex9849' }, - 'label': 'Non-compliant Session', - 'project': st_project['_id'], - 'public': False - }) - assert r.ok - st_noncompliant_session = r.json() - - # create acquisition-1 for compliant session - # depends on 'create compliant session' - r = as_root.post('/acquisitions', json={ - 'label': 'c-acquisition-1-t1', - 'session': st_compliant_session['_id'], - 'public': False - }) - assert r.ok - - # create acquisition-2 for compliant session - # depends on 'create compliant session' - r = as_root.post('/acquisitions', json={ - 'label': 'c-acquisition-2-t1', - 'session': st_compliant_session['_id'], - 'public': False - }) - assert r.ok - - # create acquisition-1 for noncompliant session - # depends on 'create non-compliant session' - r = as_root.post('/acquisitions', json={ - 'label': 'nc-acquisition-1-t1', - 'session': st_noncompliant_session['_id'], - 'public': False - }) - assert r.ok - - # add project template - r = as_root.post('/projects/' + st_project['_id'] + '/template', json={ - 'session': { 'subject': { 'code' : '^ex' } }, - 'acquisitions': [{ - 'label': 't1', - 'minimum': 2 - }] - }) - assert r.ok - assert r.json()['modified'] == 1 - - # create acquisition-2 for noncompliant session - # depends on 'create non-compliant session' - r = as_root.post('/acquisitions', json={ - 'label': 'nc-acquisition-2-t1', - 'session': st_noncompliant_session['_id'], - 'public': False - }) - assert r.ok - - # update session 2 to be non-compliant - # depends on 'create non-compliant session' - r = as_root.put('/sessions/' + st_noncompliant_session['_id'], json={ - 'subject': { 'code': 'bad-subject-code' } - }) - assert r.ok - - -if __name__ == '__main__': - main() diff --git a/tests/integration_tests/abao/test_files/engine-analyses-1.txt b/tests/integration_tests/abao/test_files/engine-analyses-1.txt deleted file mode 100644 index 6686dd9ae599f5946313397b37162b2053445cc8..0000000000000000000000000000000000000000 --- a/tests/integration_tests/abao/test_files/engine-analyses-1.txt +++ /dev/null @@ -1 +0,0 @@ -Replace this with something more realistic diff --git a/tests/integration_tests/abao/test_files/notes.txt b/tests/integration_tests/abao/test_files/notes.txt deleted file mode 100644 index 907b308167f0880fb2a5c0e1614bb0c7620f9dc3..0000000000000000000000000000000000000000 --- a/tests/integration_tests/abao/test_files/notes.txt +++ /dev/null @@ -1 +0,0 @@ -blah diff --git a/tests/integration_tests/abao/test_files/test-1.dcm b/tests/integration_tests/abao/test_files/test-1.dcm deleted file mode 100644 index f088aa8f90a25afd9b2b19c1cc9ceaa325d26915..0000000000000000000000000000000000000000 Binary files a/tests/integration_tests/abao/test_files/test-1.dcm and /dev/null differ diff --git a/tests/integration_tests/python/test_handlers.py b/tests/integration_tests/python/test_handlers.py index 65b5133cd9682cf23043a086f5a1e14a6e8d4638..668b867ef1bed289f63ed31ab4d28c37501bf665 100644 --- a/tests/integration_tests/python/test_handlers.py +++ b/tests/integration_tests/python/test_handlers.py @@ -14,7 +14,7 @@ def test_schemahandler(as_public): r = as_public.get('/schemas/definitions/user.json') assert r.ok schema = r.json() - assert all(attr in schema['definitions'] for attr in ('_id', 'firstname', 'lastname')) + assert all(attr in schema['definitions'] for attr in ('email', 'firstname', 'lastname')) def test_devicehandler(as_user, as_root, as_drone, api_db): diff --git a/tests/unit_tests/python/test_validators.py b/tests/unit_tests/python/test_validators.py index 8e14c1db16e7af86a4fc1d16f6d330fffcea0340..0dcfb157e7f8f2163423a4525132f189a950ee58 100644 --- a/tests/unit_tests/python/test_validators.py +++ b/tests/unit_tests/python/test_validators.py @@ -121,13 +121,30 @@ def pytest_generate_tests(metafunc): # Helper to load the example data from a file def load_example_data(schema_type, schema_name): + example_path = None example_data = None - relpath = os.path.join(schema_type, '{0}.json'.format(schema_name)) - - if relpath in EXAMPLES_MAP: - example_path = os.path.join(EXAMPLES_PATH, EXAMPLES_MAP[relpath]) - else: - example_path = os.path.join(EXAMPLES_PATH, relpath) + # First check if there is example data in the schema file + relpath = os.path.join(SCHEMAS_PATH, schema_type, '{0}.json'.format(schema_name)) + if os.path.exists(relpath): + with open(relpath) as f: + schema_data = json.load(f) + if schema_data and 'example' in schema_data: + example_data = schema_data['example'] + if '$ref' in example_data: + # Resolve ref + example_path = os.path.join(relpath, example_data['$ref']) + example_data = None + else: + return schema_data['example'] + + # Then check in the examples folder + if example_path is None or not os.path.exists(example_path): + relpath = os.path.join(schema_type, '{0}.json'.format(schema_name)) + + if relpath in EXAMPLES_MAP: + example_path = os.path.join(EXAMPLES_PATH, EXAMPLES_MAP[relpath]) + else: + example_path = os.path.join(EXAMPLES_PATH, relpath) if os.path.exists(example_path): with open(example_path) as f: