Skip to content
Snippets Groups Projects
Commit 8fd1965d authored by Colton Leekley-Winslow's avatar Colton Leekley-Winslow
Browse files

Add RAML for ContainerHandler based routes

parent 600d5625
No related branches found
No related tags found
No related merge requests found
Showing
with 239 additions and 60 deletions
......@@ -8,3 +8,4 @@ bootstrap.json
.cache
/.coverage*
coverage.xml
node_modules/
......@@ -145,7 +145,7 @@ routes = [
webapp2.Route(_format(r'/api/<cont_name:{cont_name_re}>'), containerhandler.ContainerHandler, name='cont_list', handler_method='get_all', methods=['GET']),
webapp2.Route(_format(r'/api/<cont_name:{cont_name_re}>'), containerhandler.ContainerHandler, methods=['POST']),
webapp2.Route(_format(r'/api/<cont_name:{cont_name_re}>/<cid:{cid_re}>'), containerhandler.ContainerHandler, name='cont_details', methods=['GET','PUT','DELETE']),
webapp2.Route(_format(r'/api/<cont_name:{cont_name_re}>/<cid:{cid_re}>/jobs'), containerhandler.ContainerHandler, name='cont_jobs', handler_method='get_jobs', methods=['GET']),
webapp2.Route(_format(r'/api/sessions/<cid:{cid_re}>/jobs'), containerhandler.ContainerHandler, name='cont_jobs', handler_method='get_jobs', methods=['GET']),
webapp2.Route(_format(r'/api/<cont_name:groups>/<cid:{group_id_re}>/<list_name:roles>'), listhandler.ListHandler, name='group_roles_post', methods=['POST']),
webapp2.Route(_format(r'/api/<cont_name:groups>/<cid:{group_id_re}>/<list_name:roles>/<site:{site_id_re}>/<_id:{user_id_re}>'), listhandler.ListHandler, name='group_roles', methods=['GET', 'PUT', 'DELETE']),
......
......@@ -118,8 +118,11 @@ expected_mongo_schemas = set([
])
expected_input_schemas = set([
'acquisition.json',
'acquisition-update.json',
'analysis.json',
'avatars.json',
'collection.json',
'collection-update.json',
'container.json',
'file.json',
'group-new.json',
......@@ -129,11 +132,12 @@ expected_input_schemas = set([
'permission.json',
'project.json',
'project-template.json',
'project-update.json',
'session.json',
'session-update.json',
'subject.json',
'user-new.json',
'user-update.json',
'avatars.json',
'download.json',
'tag.json',
'enginemetadata.json',
......
......@@ -118,8 +118,15 @@ class CollectionsHandler(ContainerHandler):
return results
def curators(self):
curator_ids = list(set((c['curator'] for c in self.get_all('collections'))))
return list(config.db.users.find({'_id': {'$in': curator_ids}}, ['firstname', 'lastname']))
curator_ids = []
for collection in self.get_all():
if collection['curator'] not in curator_ids:
curator_ids.append(collection['curator'])
curators = config.db.users.find(
{'_id': {'$in': curator_ids}},
['firstname', 'lastname']
)
return list(curators)
def get_sessions(self, cid):
"""Return the list of sessions in a collection."""
......
......@@ -172,62 +172,10 @@ class ContainerHandler(base.RequestHandler):
if user_perm.get('access') != 'admin':
result['permissions'] = [user_perm] if user_perm else []
def get_jobs(self, cont_name, cid):
"""
.. http:get:: /api/(cont_name)/(cid)/jobs
Return any jobs that mention this container as an input.
:query states: filter results by job state
:type states: string
:query tags: filter results by job tags
:type cid: string
:statuscode 200: no error
**Example request**:
.. sourcecode:: http
GET /api/sessions/3/jobs?states=pending&states=failed&tags=a&tags=b HTTP/1.1
Host: demo.flywheel.io
Accept: */*
**Example response**:
.. sourcecode:: http
HTTP/1.1 200 OK
Vary: Accept-Encoding
Content-Type: application/json; charset=utf-8
[
{
"_id": "57336257ea360500272c2f11",
"algorithm_id": "dicom_mr_classifier",
"state": "pending",
"tags": [
"a"
]
//...
},
{
"_id": "57336257ea360500272c2f12",
"algorithm_id": "dcm_convert",
"state": "failed",
"tags": [
"b"
]
// ...
}
]
"""
self.config = self.container_handler_configurations[cont_name]
def get_jobs(self, cid):
# Only enabled for sessions container type per url rule in api.py
self.config = self.container_handler_configurations["sessions"]
self.storage = self.config['storage']
if cont_name != 'sessions':
self.abort(400, 'Can only request jobs at the session level.')
cont = self._get_container(cid, projection={'permissions': 0}, get_children=True)
permchecker = self._get_permchecker(cont)
......
......@@ -87,4 +87,4 @@ fi
# Install testing dependencies
echo "Installing testing dependencies"
pip install -r "test/integration_tests/requirements-integration-test.txt"
npm install -g test/integration_tests
npm install test/integration_tests
......@@ -11,6 +11,10 @@ traits:
description: |
JSON did not validate against schema for this endpoint
resourceTypes:
- container: !include resourceTypes/container.raml
- container-item: !include resourceTypes/container-item.raml
/download: !include resources/download.raml
/upload/label: !include resources/upload-by-label.raml
/upload/uid: !include resources/upload-by-uid.raml
......@@ -26,4 +30,7 @@ traits:
/gears: !include resources/gears.raml
/rules: !include resources/rules.raml
/groups: !include resources/groups.raml
/collections: !include resources/collections.raml
/sessions: !include resources/sessions.raml
/acquisitions: !include resources/acquisitions.raml
/projects: !include resources/projects.raml
{
"label": "example-acquisition-new-label"
}
{
"label": "example-acquisition",
"session": "57e45328466d8e000e33a85b",
"public": false
}
{
"contents": {
"operation": "add",
"nodes": [{
"level": "session",
"_id": "57dc50b0931cefd8ac2a371e"
}]
}
}
{"label":"control-group"}
{"label":"test2-project-new-label"}
{"group":"scitran","label":"test2"}
{
"subject": {
"code": "a subject"
},
"label": "a session",
"project": "57e29f8aa479a44d25f28c47",
"public": false
}
[
{
"files": [
{
"origin": {
"method": "importer",
"type": "device",
"id": "importer_Admin_Import",
"name": "Admin Import"
},
"mimetype": "application/zip",
"measurements": [],
"hash": "v0-sha384-dd3c97bfe0ad1fcba75ae6718c6e81038c59af4f447f5db194d52732efa4f955b28455db02eb64cad3e4e55f11e3679f",
"name": "4784_1_1_localizer_dicom.zip",
"tags": [],
"created": "2016-09-21T14:56:09.943000+00:00",
"modified": "2016-09-21T14:56:09.943000+00:00",
"instrument": null,
"metadata": {},
"type": "dicom",
"size": 989933
}
],
"created": "2016-09-21T14:56:10.026000+00:00",
"timestamp": "2016-09-21T19:24:45.539570+00:00",
"modified": "2016-09-21T14:56:10.026000+00:00",
"label": "4784_1_1_localizer",
"session": "57e29f8afab726000f7ec6b1",
"collections": [
"57e2a026675ca0000f0eeb0c"
],
"_id": "57e29f8afab726000f7ec6b2",
"public": false,
"permissions": [
{
"access": "admin",
"_id": "coltonlw@flywheel.io",
"site": "local"
}
]
},
{
"files": [
{
"origin": {
"method": "importer",
"type": "device",
"id": "importer_Admin_Import",
"name": "Admin Import"
},
"mimetype": "application/zip",
"measurements": [],
"hash": "v0-sha384-ca055fb36845db86e4278cf6e185f8674d11a96f4b29af27e401fc495cc82ef6b53a5729c3757713064649dc71c8c725",
"name": "4784_3_1_t1_dicom.zip",
"tags": [],
"created": "2016-09-21T14:56:11.224000+00:00",
"modified": "2016-09-21T14:56:11.224000+00:00",
"instrument": null,
"metadata": {},
"type": "dicom",
"size": 2921881
}
],
"created": "2016-09-21T14:56:11.452000+00:00",
"timestamp": "2016-09-21T19:24:45.539580+00:00",
"modified": "2016-09-21T14:56:11.452000+00:00",
"label": "4784_3_1_t1",
"session": "57e29f8afab726000f7ec6b1",
"collections": [
"57e2a026675ca0000f0eeb0c"
],
"_id": "57e29f8bfab726000e7ec6b0",
"public": false,
"permissions": [
{
"access": "admin",
"_id": "coltonlw@flywheel.io",
"site": "local"
}
]
},
{
"files": [
{
"origin": {
"method": "importer",
"type": "device",
"id": "importer_Admin_Import",
"name": "Admin Import"
},
"mimetype": "application/zip",
"measurements": [],
"hash": "v0-sha384-537e42b1dd8f1feef9844fbfb4f60461361e71cafa7055556097e9d0b9f7fac68c8f234ed126af9412bd43a548948847",
"name": "4784_5_1_fmri_dicom.zip",
"tags": [],
"created": "2016-09-21T14:56:13.580000+00:00",
"modified": "2016-09-21T14:56:13.580000+00:00",
"instrument": null,
"metadata": {},
"type": "dicom",
"size": 4525137
}
],
"created": "2016-09-21T14:56:13.886000+00:00",
"timestamp": "2016-09-21T19:24:45.539582+00:00",
"modified": "2016-09-21T14:56:13.886000+00:00",
"label": "4784_5_1_fmri",
"session": "57e29f8afab726000f7ec6b1",
"collections": [
"57e2a026675ca0000f0eeb0c"
],
"_id": "57e29f8dfab726000e7ec6b3",
"public": false,
"permissions": [
{
"access": "admin",
"_id": "coltonlw@flywheel.io",
"site": "local"
}
]
}
]
{
"files": [
{
"origin": {
"method": "importer",
"type": "device",
"id": "importer_Admin_Import",
"name": "Admin Import"
},
"mimetype": "application/zip",
"measurements": [],
"hash": "v0-sha384-dd3c97bfe0ad1fcba75ae6718c6e81038c59af4f447f5db194d52732efa4f955b28455db02eb64cad3e4e55f11e3679f",
"name": "4784_1_1_localizer_dicom.zip",
"tags": [],
"created": "2016-09-21T14:56:09.943000+00:00",
"modified": "2016-09-21T14:56:09.943000+00:00",
"instrument": null,
"metadata": {},
"type": "dicom",
"size": 989933
}
],
"created": "2016-09-21T14:56:10.026000+00:00",
"timestamp": "2016-09-21T19:24:45.539570+00:00",
"modified": "2016-09-21T14:56:10.026000+00:00",
"label": "4784_1_1_localizer",
"session": "57e29f8afab726000f7ec6b1",
"collections": [
"57e2a026675ca0000f0eeb0c"
],
"_id": "57e29f8afab726000f7ec6b2",
"public": false,
"permissions": [
{
"access": "admin",
"_id": "coltonlw@flywheel.io",
"site": "local"
}
]
}
[
{
"lastname": "LW",
"_id": "coltonlw@flywheel.io",
"firstname": "Colton"
}
]
{
"_id":"57bb486a9e512c41c8b7fdd5"
}
{
"created": "2016-08-30T17:22:05.299000+00:00",
"curator": "user@test.com",
"label": "test",
"modified": "2016-08-30T17:22:05.299000+00:00",
"_id": "57c5c0bd9e512c606dd3df09",
"permissions": [{
"access": "admin",
"_id": "user@test.com",
"site": "local"
}]
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment