From 189e58d3126a3c6aefd0e76a9e2c97b71f08b8ca Mon Sep 17 00:00:00 2001 From: Justin Ehlert Date: Thu, 11 Jan 2018 08:18:34 -0600 Subject: [PATCH 01/21] Allow template parameters to be optional Parameters can now be optional or required, which allows for more advanced template usage. Updated existing templates to set the required flag. Added documentation for root level analyses apis via existing templates. --- swagger/index.yaml | 3 ++ swagger/paths/acquisitions.yaml | 2 ++ swagger/paths/analyses.yaml | 28 +++++++++++++++++++ swagger/paths/collections.yaml | 2 ++ swagger/paths/projects.yaml | 2 ++ swagger/paths/sessions.yaml | 2 ++ swagger/support/swagger-resolver.js | 2 +- swagger/templates/analyses-list.yaml | 3 ++ ...analysis-files-create-ticket-filename.yaml | 13 +++++++-- swagger/templates/analysis-files.yaml | 11 +++++++- swagger/templates/analysis-item.yaml | 24 ++++++++++++++-- swagger/templates/analysis-notes-item.yaml | 3 ++ swagger/templates/analysis-notes.yaml | 3 ++ swagger/templates/container-item.yaml | 5 ++++ swagger/templates/container.yaml | 4 +++ swagger/templates/file-item.yaml | 3 ++ swagger/templates/file-list-upload.yaml | 3 ++ swagger/templates/notes-note.yaml | 3 ++ swagger/templates/notes.yaml | 3 ++ swagger/templates/packfile-end.yaml | 3 ++ swagger/templates/packfile-start.yaml | 3 ++ swagger/templates/packfile.yaml | 3 ++ swagger/templates/permissions-user.yaml | 3 ++ swagger/templates/permissions.yaml | 3 ++ swagger/templates/tags-tag.yaml | 3 ++ swagger/templates/tags.yaml | 3 ++ 26 files changed, 133 insertions(+), 7 deletions(-) create mode 100644 swagger/paths/analyses.yaml diff --git a/swagger/index.yaml b/swagger/index.yaml index b9ed8a6e4..d47d08681 100644 --- a/swagger/index.yaml +++ b/swagger/index.yaml @@ -36,6 +36,8 @@ tags: description: Site-wide reports - name: batch description: Batch job operations + - name: analyses + description: Analysis operations paths: $include: @@ -60,6 +62,7 @@ paths: - paths/projects.yaml - paths/report.yaml - paths/batch.yaml + - paths/analyses.yaml securityDefinitions: diff --git a/swagger/paths/acquisitions.yaml b/swagger/paths/acquisitions.yaml index 81ee635f0..3f0834981 100644 --- a/swagger/paths/acquisitions.yaml +++ b/swagger/paths/acquisitions.yaml @@ -48,6 +48,8 @@ $template_arguments: $template: templates/analyses-list.yaml /acquisitions/{AcquisitionId}/analyses/{AnalysisId}: $template: templates/analysis-item.yaml + arguments: + supportsDelete: true /acquisitions/{AcquisitionId}/analyses/{AnalysisId}/inputs: $template: templates/analysis-files.yaml arguments: diff --git a/swagger/paths/analyses.yaml b/swagger/paths/analyses.yaml new file mode 100644 index 000000000..d6f1a281e --- /dev/null +++ b/swagger/paths/analyses.yaml @@ -0,0 +1,28 @@ +$template_arguments: + tag: 'analyses' + +/analyses/{AnalysisId}: + $template: templates/analysis-item.yaml + arguments: + supportsDelete: false + +/analyses/{AnalysisId}/inputs: + $template: templates/analysis-files.yaml + arguments: + filegroup: inputs + +/analyses/{AnalysisId}/inputs/{Filename}: + $template: templates/analysis-files-create-ticket-filename.yaml + arguments: + filegroup: inputs + +/analyses/{AnalysisId}/files: + $template: templates/analysis-files.yaml + arguments: + filegroup: outputs + +/analyses/{AnalysisId}/files/{Filename}: + $template: templates/analysis-files-create-ticket-filename.yaml + arguments: + filegroup: outputs + diff --git a/swagger/paths/collections.yaml b/swagger/paths/collections.yaml index e3ba2343b..a1b985254 100644 --- a/swagger/paths/collections.yaml +++ b/swagger/paths/collections.yaml @@ -173,6 +173,8 @@ $template_arguments: $template: templates/analyses-list.yaml /collections/{CollectionId}/analyses/{AnalysisId}: $template: templates/analysis-item.yaml + arguments: + supportsDelete: true /collections/{CollectionId}/analyses/{AnalysisId}/inputs: $template: templates/analysis-files.yaml arguments: diff --git a/swagger/paths/projects.yaml b/swagger/paths/projects.yaml index f5c63a463..de1b2eca9 100644 --- a/swagger/paths/projects.yaml +++ b/swagger/paths/projects.yaml @@ -226,6 +226,8 @@ $template_arguments: $template: templates/analyses-list.yaml /projects/{ProjectId}/analyses/{AnalysisId}: $template: templates/analysis-item.yaml + arguments: + supportsDelete: true /projects/{ProjectId}/analyses/{AnalysisId}/inputs: $template: templates/analysis-files.yaml arguments: diff --git a/swagger/paths/sessions.yaml b/swagger/paths/sessions.yaml index de7beef7c..822c0d968 100644 --- a/swagger/paths/sessions.yaml +++ b/swagger/paths/sessions.yaml @@ -110,6 +110,8 @@ $template_arguments: /sessions/{SessionId}/analyses/{AnalysisId}: $template: templates/analysis-item.yaml + arguments: + supportsDelete: true /sessions/{SessionId}/analyses/{AnalysisId}/inputs: $template: templates/analysis-files.yaml arguments: diff --git a/swagger/support/swagger-resolver.js b/swagger/support/swagger-resolver.js index ee2575df0..6b154dccf 100644 --- a/swagger/support/swagger-resolver.js +++ b/swagger/support/swagger-resolver.js @@ -34,7 +34,7 @@ function validateTemplateArgs(tmplpath, template, args) { if( !param.name ) { throw 'Template "' + tmplpath + '" parameter does not have a name!'; } - if( _.isNil(args[param.name]) ) { + if( param.required && _.isNil(args[param.name]) ) { throw 'Template "' + tmplpath + '" invocation is missing parameter: ' + param.name; } } diff --git a/swagger/templates/analyses-list.yaml b/swagger/templates/analyses-list.yaml index ad44c1a10..6d76dc2d1 100644 --- a/swagger/templates/analyses-list.yaml +++ b/swagger/templates/analyses-list.yaml @@ -1,10 +1,13 @@ parameters: - name: resource type: string + required: true - name: parameter type: string + required: true - name: tag type: string + required: true template: | parameters: - required: true diff --git a/swagger/templates/analysis-files-create-ticket-filename.yaml b/swagger/templates/analysis-files-create-ticket-filename.yaml index c448b4206..9e0c76812 100644 --- a/swagger/templates/analysis-files-create-ticket-filename.yaml +++ b/swagger/templates/analysis-files-create-ticket-filename.yaml @@ -5,14 +5,18 @@ parameters: type: string - name: tag type: string + required: true - name: filegroup type: string + required: true template: | parameters: + {{#parameter}} - required: true type: string in: path - name: '{{parameter}}' + name: '{{.}}' + {{/parameter}} - required: true type: string in: path @@ -31,7 +35,12 @@ template: | {{filegroup}} in the anlaysis. If no "ticket" query param is included, {{filegroup}} will be downloaded directly. - operationId: download_{{resource}}_analysis_{{filegroup}}_by_filename + {{#resource}} + operationId: download_{{.}}_analysis_{{filegroup}}_by_filename + {{/resource}} + {{^resource}} + operationId: download_analysis_{{filegroup}}_by_filename + {{/resource}} tags: - '{{tag}}' produces: diff --git a/swagger/templates/analysis-files.yaml b/swagger/templates/analysis-files.yaml index 6408c3024..459055473 100644 --- a/swagger/templates/analysis-files.yaml +++ b/swagger/templates/analysis-files.yaml @@ -5,14 +5,18 @@ parameters: type: string - name: tag type: string + required: true - name: filegroup type: string + required: true template: | parameters: + {{#parameter}} - required: true type: string in: path - name: '{{parameter}}' + name: '{{.}}' + {{/parameter}} - required: true type: string in: path @@ -26,7 +30,12 @@ template: | {{filegroup}} in the anlaysis If no "ticket" query param is included, server error 500 + {{#resource}} operationId: download_{{resource}}_analysis_{{filegroup}} + {{/resource}} + {{^resource}} + operationId: download_analysis_{{filegroup}} + {{/resource}} tags: - '{{tag}}' produces: diff --git a/swagger/templates/analysis-item.yaml b/swagger/templates/analysis-item.yaml index 0a46cde8b..3b2251535 100644 --- a/swagger/templates/analysis-item.yaml +++ b/swagger/templates/analysis-item.yaml @@ -5,19 +5,30 @@ parameters: type: string - name: tag type: string + required: true + - name: supportsDelete + type: boolean + required: true template: | parameters: + {{#parameter}} - required: true type: string in: path - name: '{{parameter}}' + name: '{{.}}' + {{/parameter}} - required: true type: string in: path name: AnalysisId get: summary: Get an analysis. - operationId: get_{{resource}}_analysis + {{#resource}} + operationId: get_{{.}}_analysis + {{/resource}} + {{^resource}} + operationId: get_analysis + {{/resource}} tags: - '{{tag}}' responses: @@ -28,11 +39,18 @@ template: | examples: response: $ref: examples/output/analysis.json + {{#supportsDelete}} delete: summary: Delete an anaylsis - operationId: delete_{{resource}}_analysis + {{#resource}} + operationId: delete_{{.}}_analysis + {{/resource}} + {{^resource}} + operationId: delete_analysis + {{/resource}} tags: - '{{tag}}' responses: '200': $ref: '#/responses/200:deleted-with-count' + {{/supportsDelete}} diff --git a/swagger/templates/analysis-notes-item.yaml b/swagger/templates/analysis-notes-item.yaml index f4a87a726..6ee57edb7 100644 --- a/swagger/templates/analysis-notes-item.yaml +++ b/swagger/templates/analysis-notes-item.yaml @@ -1,10 +1,13 @@ parameters: - name: resource type: string + required: true - name: parameter type: string + required: true - name: tag type: string + required: true template: | parameters: - required: true diff --git a/swagger/templates/analysis-notes.yaml b/swagger/templates/analysis-notes.yaml index 2627f2edd..12168f23c 100644 --- a/swagger/templates/analysis-notes.yaml +++ b/swagger/templates/analysis-notes.yaml @@ -1,10 +1,13 @@ parameters: - name: resource type: string + required: true - name: parameter type: string + required: true - name: tag type: string + required: true template: | parameters: - required: true diff --git a/swagger/templates/container-item.yaml b/swagger/templates/container-item.yaml index dd7853b45..c215179cd 100644 --- a/swagger/templates/container-item.yaml +++ b/swagger/templates/container-item.yaml @@ -1,14 +1,19 @@ parameters: - name: resource type: string + required: true - name: tag type: string + required: true - name: parameter type: string + required: true - name: update-input-schema type: string + required: true - name: get-output-schema type: string + required: true - name: delete-description type: string template: | diff --git a/swagger/templates/container.yaml b/swagger/templates/container.yaml index d867de6d3..c5efe50bc 100644 --- a/swagger/templates/container.yaml +++ b/swagger/templates/container.yaml @@ -1,12 +1,16 @@ parameters: - name: resource type: string + required: true - name: tag type: string + required: true - name: list-output-schema type: string + required: true - name: create-input-schema type: string + required: true template: | get: summary: Get a list of {{#pluralize}}{{resource}}{{/pluralize}} diff --git a/swagger/templates/file-item.yaml b/swagger/templates/file-item.yaml index 5cc66a2ae..a2dc47588 100644 --- a/swagger/templates/file-item.yaml +++ b/swagger/templates/file-item.yaml @@ -1,10 +1,13 @@ parameters: - name: resource type: string + required: true - name: parameter type: string + required: true - name: tag type: string + required: true template: | parameters: - required: true diff --git a/swagger/templates/file-list-upload.yaml b/swagger/templates/file-list-upload.yaml index e8985e014..3d28a3da9 100644 --- a/swagger/templates/file-list-upload.yaml +++ b/swagger/templates/file-list-upload.yaml @@ -1,10 +1,13 @@ parameters: - name: resource type: string + required: true - name: parameter type: string + required: true - name: tag type: string + required: true template: | parameters: - name: '{{parameter}}' diff --git a/swagger/templates/notes-note.yaml b/swagger/templates/notes-note.yaml index 899ad54a8..77636a02d 100644 --- a/swagger/templates/notes-note.yaml +++ b/swagger/templates/notes-note.yaml @@ -1,10 +1,13 @@ parameters: - name: resource type: string + required: true - name: parameter type: string + required: true - name: tag type: string + required: true template: | parameters: - required: true diff --git a/swagger/templates/notes.yaml b/swagger/templates/notes.yaml index 1c4936b09..60513ca89 100644 --- a/swagger/templates/notes.yaml +++ b/swagger/templates/notes.yaml @@ -1,10 +1,13 @@ parameters: - name: resource type: string + required: true - name: parameter type: string + required: true - name: tag type: string + required: true template: | parameters: - required: true diff --git a/swagger/templates/packfile-end.yaml b/swagger/templates/packfile-end.yaml index 0b662d20a..3af0ca3c4 100644 --- a/swagger/templates/packfile-end.yaml +++ b/swagger/templates/packfile-end.yaml @@ -1,10 +1,13 @@ parameters: - name: resource type: string + required: true - name: parameter type: string + required: true - name: tag type: string + required: true template: | parameters: - required: true diff --git a/swagger/templates/packfile-start.yaml b/swagger/templates/packfile-start.yaml index d8b5ebfc4..065d0ff7c 100644 --- a/swagger/templates/packfile-start.yaml +++ b/swagger/templates/packfile-start.yaml @@ -1,10 +1,13 @@ parameters: - name: resource type: string + required: true - name: parameter type: string + required: true - name: tag type: string + required: true template: | parameters: - required: true diff --git a/swagger/templates/packfile.yaml b/swagger/templates/packfile.yaml index d302d75c0..c2df8b52f 100644 --- a/swagger/templates/packfile.yaml +++ b/swagger/templates/packfile.yaml @@ -1,10 +1,13 @@ parameters: - name: resource type: string + required: true - name: parameter type: string + required: true - name: tag type: string + required: true template: | parameters: - required: true diff --git a/swagger/templates/permissions-user.yaml b/swagger/templates/permissions-user.yaml index f8ab38625..339aeb98c 100644 --- a/swagger/templates/permissions-user.yaml +++ b/swagger/templates/permissions-user.yaml @@ -1,10 +1,13 @@ parameters: - name: resource type: string + required: true - name: parameter type: string + required: true - name: tag type: string + required: true template: | parameters: - required: true diff --git a/swagger/templates/permissions.yaml b/swagger/templates/permissions.yaml index ff9ef38c2..9ca64e8b6 100644 --- a/swagger/templates/permissions.yaml +++ b/swagger/templates/permissions.yaml @@ -1,10 +1,13 @@ parameters: - name: resource type: string + required: true - name: parameter type: string + required: true - name: tag type: string + required: true template: | parameters: - required: true diff --git a/swagger/templates/tags-tag.yaml b/swagger/templates/tags-tag.yaml index d12ad63f5..cb9495968 100644 --- a/swagger/templates/tags-tag.yaml +++ b/swagger/templates/tags-tag.yaml @@ -1,10 +1,13 @@ parameters: - name: resource type: string + required: true - name: parameter type: string + required: true - name: tag type: string + required: true template: | parameters: - required: true diff --git a/swagger/templates/tags.yaml b/swagger/templates/tags.yaml index d396ec790..3c4ca6204 100644 --- a/swagger/templates/tags.yaml +++ b/swagger/templates/tags.yaml @@ -1,10 +1,13 @@ parameters: - name: resource type: string + required: true - name: parameter type: string + required: true - name: tag type: string + required: true template: | parameters: - required: true From 85657ffd5cffbe87237bee6fe8ad1a8fa0e9f2de Mon Sep 17 00:00:00 2001 From: Ryan Sanford Date: Fri, 12 Jan 2018 10:19:07 -0600 Subject: [PATCH 02/21] Initial addition of reaper upload API doc --- swagger/index.yaml | 1 + swagger/paths/upload-by-reaper.yaml | 37 +++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 swagger/paths/upload-by-reaper.yaml diff --git a/swagger/index.yaml b/swagger/index.yaml index d47d08681..11778c473 100644 --- a/swagger/index.yaml +++ b/swagger/index.yaml @@ -44,6 +44,7 @@ paths: - paths/login.yaml - paths/download.yaml - paths/upload-by-label.yaml + - paths/upload-by-reaper.yaml - paths/upload-by-uid.yaml - paths/upload-match-uid.yaml - paths/clean-packfiles.yaml diff --git a/swagger/paths/upload-by-reaper.yaml b/swagger/paths/upload-by-reaper.yaml new file mode 100644 index 000000000..ea28acc75 --- /dev/null +++ b/swagger/paths/upload-by-reaper.yaml @@ -0,0 +1,37 @@ +/upload/reaper: + post: + summary: Bottom-up UID matching of Multipart form upload with N file fields, each with their desired filename. + description: | + Upload data, allowing users to move sessions during scans without causing new data to be + created in referenced project/group. + + + ### Evaluation Order: + + * If a matching acquisition UID is found anywhere on the system, the related files will be placed under that acquisition. + * **OR** If a matching session UID is found, a new acquistion is created with the specified UID under that Session UID. + * **OR** If a matching group ID and project label are found, a new session and acquisition will be created within that project + * **OR** If a matching group ID is found, a new project and session and acquisition will be created within that group. + * **OR** A new session and acquisition will be created within a special "Unknown" group and project, which is only visible to system administrators. + + operationId: upload_by_reaper + tags: + - files + responses: + '200': + description: 'Files uploaded successfully' + schema: + $ref: schemas/output/file-list.json + examples: + application/json: + $ref: examples/file_info_list.json + '402': + description: Uploads must be from an authorized drone + consumes: + - multipart/form-data + parameters: + # TODO: Need to add ref to json input schema. Proper way not yet defined for Multipart form uploads. + # See api/schemas/input/uidupload.json for the format of this metadata. + - in: formData + name: formData + type: string \ No newline at end of file From ffa27ae6164bc798052cba33d32bec3c1a991cd3 Mon Sep 17 00:00:00 2001 From: David Farkas Date: Fri, 12 Jan 2018 17:33:07 +0100 Subject: [PATCH 03/21] Add jobs/logs, jobs/prepare-complete, jobs/accept-failed-output endpoints doc --- swagger/paths/jobs.yaml | 57 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/swagger/paths/jobs.yaml b/swagger/paths/jobs.yaml index 04c328ef3..9c91568f2 100644 --- a/swagger/paths/jobs.yaml +++ b/swagger/paths/jobs.yaml @@ -142,3 +142,60 @@ schema: example: $ref: examples/output/job-config.json +/jobs/{JobId}/logs: + parameters: + - required: true + type: string + in: path + name: JobId + post: + summary: Add logs to a job. + operationId: add_logs + tags: + - jobs + responses: + '200': + description: Logs were added. No value is returned. +/jobs/{JobId}/accept-failed-output: + parameters: + - required: true + type: string + in: path + name: JobId + post: + summary: Accept failed job output. + description: > + Remove the 'from_failed_job' flag from the files. + + Create any automatic jobs for the accepted files. + operationId: accept_failed_output + tags: + - jobs + responses: + '200': + description: Failed output is accepted and created any automatic jobs. + '400': + description: Can only accept failed output of a job that failed. +/jobs/{JobId}/prepare-complete: + parameters: + - required: true + type: string + in: path + name: JobId + post: + summary: Create a ticket with the job id and its status. + operationId: prepare_compete + tags: + - jobs + parameters: + - name: body + in: body + schema: + example: + success: True + responses: + '200': + description: 'Returns a ticket' + schema: + example: + ticket: 579e97738120be2ada087feb \ No newline at end of file From f07740e6a0231cf2ab97a0cf699c48bea9589bc6 Mon Sep 17 00:00:00 2001 From: Ambrus Simon Date: Fri, 12 Jan 2018 17:42:18 +0100 Subject: [PATCH 04/21] Document site rules --- swagger/examples/output/rule.json | 17 +++++++++ swagger/index.yaml | 1 + swagger/paths/projects.yaml | 53 ++++++++++++++++++-------- swagger/paths/site-rules.yaml | 62 +++++++++++++++++++++++++++++++ swagger/schemas/output/rule.json | 7 ++++ 5 files changed, 125 insertions(+), 15 deletions(-) create mode 100644 swagger/examples/output/rule.json create mode 100644 swagger/paths/site-rules.yaml create mode 100644 swagger/schemas/output/rule.json diff --git a/swagger/examples/output/rule.json b/swagger/examples/output/rule.json new file mode 100644 index 000000000..da502290d --- /dev/null +++ b/swagger/examples/output/rule.json @@ -0,0 +1,17 @@ +{ + "_id": "5a12f2923306be0016179f47", + "name": "dcm2niix", + "alg": "dcm2niix", + "any": [], + "all": [ + { + "regex": true, + "type": "file.measurements", + "value": "^(?!non-image).+$" + }, + { + "type": "file.type", + "value": "nifti" + } + ] +} diff --git a/swagger/index.yaml b/swagger/index.yaml index 11778c473..a55fe7c48 100644 --- a/swagger/index.yaml +++ b/swagger/index.yaml @@ -64,6 +64,7 @@ paths: - paths/report.yaml - paths/batch.yaml - paths/analyses.yaml + - paths/site-rules.yaml securityDefinitions: diff --git a/swagger/paths/projects.yaml b/swagger/paths/projects.yaml index de1b2eca9..fc359e47f 100644 --- a/swagger/paths/projects.yaml +++ b/swagger/paths/projects.yaml @@ -21,7 +21,7 @@ $template_arguments: summary: List all groups which have a project in them operationId: get_all_projects_groups tags: - - 'projects' + - projects responses: '200': description: '' @@ -38,7 +38,7 @@ $template_arguments: summary: List all sessions for the given project. operationId: get_project_sessions tags: - - 'projects' + - projects responses: '200': description: '' @@ -55,23 +55,25 @@ $template_arguments: summary: List all acquisitions for the given project. operationId: get_project_acquisitions tags: - - 'projects' + - projects responses: '200': description: '' schema: $ref: schemas/output/acquisition-list.json -'/projects/{ProjectId}/rules': +/projects/{ProjectId}/rules: parameters: - in: path type: string name: ProjectId required: true get: + summary: List all rules for a project. operationId: get_project_rules tags: - - 'projects' + - projects + - rules responses: '200': description: '' @@ -81,7 +83,8 @@ $template_arguments: summary: Create a new rule for a project. operationId: add_project_rule tags: - - 'projects' + - projects + - rules responses: default: description: '' @@ -91,7 +94,7 @@ $template_arguments: schema: $ref: schemas/input/rule-new.json -'/projects/{ProjectId}/rules/{RuleId}': +/projects/{ProjectId}/rules/{RuleId}: parameters: - in: path type: string @@ -101,11 +104,23 @@ $template_arguments: type: string name: RuleId required: true + get: + summary: Get a project rule. + operationId: get_project_rule + tags: + - projects + - rules + responses: + '200': + description: '' + schema: + $ref: schemas/output/rule.json put: summary: Update a rule on a project. operationId: modify_project_rule tags: - - 'projects' + - projects + - rules responses: default: description: '' @@ -113,10 +128,18 @@ $template_arguments: - in: body name: body schema: - $ref: schemas/input/rule-update.json - + $ref: schemas/input/rule-update.json + delete: + summary: Remove a project rule. + operationId: remove_project_rule + tags: + - projects + - rules + responses: + '200': + $ref: '#/responses/200:deleted-with-count' -'/projects/{ProjectId}/template': +/projects/{ProjectId}/template: parameters: - in: path type: string @@ -126,7 +149,7 @@ $template_arguments: summary: Set the session template for a project. operationId: set_project_template tags: - - 'projects' + - projects parameters: - in: body name: body @@ -141,7 +164,7 @@ $template_arguments: summary: Remove the session template for a project. operationId: remove_project_template tags: - - 'projects' + - projects responses: '200': $ref: '#/responses/200:deleted-with-count' @@ -159,7 +182,7 @@ $template_arguments: description: Returns list of modified session ids. operationId: recalc_project tags: - - 'projects' + - projects responses: '200': description: | @@ -179,7 +202,7 @@ $template_arguments: Returns list of modified session ids. operationId: recalc_all_projects tags: - - 'projects' + - projects responses: '200': description: | diff --git a/swagger/paths/site-rules.yaml b/swagger/paths/site-rules.yaml new file mode 100644 index 000000000..73b23e709 --- /dev/null +++ b/swagger/paths/site-rules.yaml @@ -0,0 +1,62 @@ +/site/rules: + get: + summary: List all site rules. + operationId: get_site_rules + tags: + - rules + responses: + '200': + description: '' + schema: + $ref: schemas/output/rule-list.json + post: + summary: Create a new site rule. + operationId: add_site_rule + tags: + - rules + responses: + default: + description: '' + parameters: + - in: body + name: body + schema: + $ref: schemas/input/rule-new.json + +/site/rules/{RuleId}: + parameters: + - name: RuleId + type: string + in: path + required: true + get: + summary: Get a site rule. + operationId: get_site_rule + tags: + - rules + responses: + '200': + description: '' + schema: + $ref: schemas/output/rule.json + put: + summary: Update a site rule. + operationId: modify_site_rule + tags: + - rules + responses: + default: + description: '' + parameters: + - in: body + name: body + schema: + $ref: schemas/input/rule-update.json + delete: + summary: Remove a site rule. + operationId: remove_site_rule + tags: + - rules + responses: + '200': + $ref: '#/responses/200:deleted-with-count' diff --git a/swagger/schemas/output/rule.json b/swagger/schemas/output/rule.json new file mode 100644 index 000000000..77ec4fc71 --- /dev/null +++ b/swagger/schemas/output/rule.json @@ -0,0 +1,7 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "Rule", + "type": "object", + "allOf": [{"$ref": "../definitions/rule.json#/definitions/rule-output"}], + "example": {"$ref": "../../examples/output/rule.json"} +} From 880106073e757a252ecaa40180d0bc4d9bccf7a5 Mon Sep 17 00:00:00 2001 From: Justin Ehlert Date: Tue, 30 Jan 2018 13:52:57 -0600 Subject: [PATCH 05/21] Add missing DELETE file --- swagger/templates/file-item.yaml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/swagger/templates/file-item.yaml b/swagger/templates/file-item.yaml index a2dc47588..512c38a04 100644 --- a/swagger/templates/file-item.yaml +++ b/swagger/templates/file-item.yaml @@ -87,3 +87,12 @@ template: | '200': $ref: '#/responses/200:deleted-with-count' + delete: + summary: Delete a file + operationId: delete_{{resource}}_file + tags: + - '{{tag}}' + responses: + '200': + $ref: '#/responses/200:modified-with-count' + From ce41a33bd412ffaca1ab3752c962a875368746f7 Mon Sep 17 00:00:00 2001 From: Justin Ehlert Date: Tue, 30 Jan 2018 13:58:21 -0600 Subject: [PATCH 06/21] Reorder tags --- swagger/index.yaml | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/swagger/index.yaml b/swagger/index.yaml index a55fe7c48..8015c5929 100644 --- a/swagger/index.yaml +++ b/swagger/index.yaml @@ -12,32 +12,35 @@ consumes: - 'application/json' tags: - - name: files - description: File upload/download operations - - name: devices - description: Device operations - name: users description: User operations - - name: gears - description: Gear operations - name: groups description: Group operations - - name: jobs - description: Job operations - - name: collections - description: Collection operations + - name: projects + description: Project operations - name: sessions description: Session operations - name: acquisitions description: Acquisition operations - - name: projects - description: Project operations + - name: analyses + description: Analysis operations + - name: collections + description: Collection operations + - name: files + description: File upload/download operations + - name: devices + description: Device operations + - name: gears + description: Gear operations + - name: rules + description: Gear rule configuration + - name: jobs + description: Job operations - name: reports description: Site-wide reports - name: batch description: Batch job operations - - name: analyses - description: Analysis operations + - name: default paths: $include: From 09aa71cf3b24547688899be23817601fb62f08fb Mon Sep 17 00:00:00 2001 From: Justin Ehlert Date: Tue, 30 Jan 2018 15:37:04 -0600 Subject: [PATCH 07/21] Add schemas for gear APIs. --- api/config.py | 1 + swagger/examples/gear_full.json | 37 ----- swagger/examples/gears_list_just_name.json | 11 -- swagger/examples/output/gear-list.json | 35 ++++ swagger/examples/output/gear.json | 35 ++++ swagger/paths/gears.yaml | 68 +++++--- swagger/schemas/definitions/gear.json | 182 +++++++++++++++++++++ swagger/schemas/input/gear.json | 38 +++++ swagger/schemas/output/gear-list.json | 7 + swagger/schemas/output/gear.json | 5 + 10 files changed, 344 insertions(+), 75 deletions(-) delete mode 100755 swagger/examples/gear_full.json delete mode 100755 swagger/examples/gears_list_just_name.json create mode 100644 swagger/examples/output/gear-list.json create mode 100644 swagger/examples/output/gear.json create mode 100644 swagger/schemas/definitions/gear.json create mode 100644 swagger/schemas/input/gear.json create mode 100644 swagger/schemas/output/gear-list.json create mode 100644 swagger/schemas/output/gear.json diff --git a/api/config.py b/api/config.py index 6c231dbff..75c6ed4ee 100644 --- a/api/config.py +++ b/api/config.py @@ -160,6 +160,7 @@ def apply_env_variables(config): 'file.json', 'file-list.json', 'file-update.json', + 'gear.json', 'group-new.json', 'group-update.json', 'info_update.json', diff --git a/swagger/examples/gear_full.json b/swagger/examples/gear_full.json deleted file mode 100755 index 908f0ad58..000000000 --- a/swagger/examples/gear_full.json +++ /dev/null @@ -1,37 +0,0 @@ -{ - "name": "test-case-gear", - "manifest": { - "name": "test-case-gear", - "label": "Test Case Gear", - "version": "0", - - "author": "Nathaniel Kofalt", - "description": "A gear built to drive test cases", - - "url": "http://none.example", - "source": "http://none.example", - "license": "MIT", - - "config": { - "two-digit multiple of ten": { - "exclusiveMaximum": true, - "type": "number", - "multipleOf": 10, - "maximum": 100 - } - }, - - "inputs": { - "any text file <= 100 KB": { - "base": "file", - "name": { - "pattern": "^.*.txt$" - }, - "size": { - "maximum": 100000 - } - } - } - }, - "input": {} -} diff --git a/swagger/examples/gears_list_just_name.json b/swagger/examples/gears_list_just_name.json deleted file mode 100755 index e56e4078e..000000000 --- a/swagger/examples/gears_list_just_name.json +++ /dev/null @@ -1,11 +0,0 @@ -[ - { - "name": "dicom_mr_classifier" - }, - { - "name": "dcm_convert" - }, - { - "name": "qa-report-fmri" - } -] \ No newline at end of file diff --git a/swagger/examples/output/gear-list.json b/swagger/examples/output/gear-list.json new file mode 100644 index 000000000..490934c94 --- /dev/null +++ b/swagger/examples/output/gear-list.json @@ -0,0 +1,35 @@ +[{ + "category": "converter", + "gear": { + "inputs": { + "audio": { + "base": "file", + "description": "Any audio file. Plain speech suggested!" + } + }, + "maintainer": "Nathaniel Kofalt", + "description": "Detects the speech content of an audio file, using the machine-learning DeepSpeech library by Mozilla.", + "license": "Other", + "author": "Nathaniel Kofalt", + "url": "", + "label": "Speech Recognition", + "source": "https://github.com/mozilla/DeepSpeech", + "version": "1", + "custom": { + "gear-builder": { + "image": "gear-builder-kdfqapbezk-20171219165918", + "container": "c15189b625a0ea450cafbb24ef0df03c26cc8cf151181976ec4289801e191032" + } + }, + "config": {}, + "name": "speech-recognition" + }, + "created": "2017-12-20T00:09:50.381000+00:00", + "exchange": { + "git-commit": "local", + "rootfs-hash": "sha384:e01d925f90b097b554be0f802ef6ebb9f07000d7a6a2a0c3a25dac26893d4ac2414381e2c8e60f4b58b27c7fe8e56099", + "rootfs-url": "/api/gears/temp/5a39aa4e07a393001b663910" + }, + "modified": "2017-12-20T00:09:50.381000+00:00", + "_id": "5a39aa4e07a393001b663910" +}] \ No newline at end of file diff --git a/swagger/examples/output/gear.json b/swagger/examples/output/gear.json new file mode 100644 index 000000000..841f2b536 --- /dev/null +++ b/swagger/examples/output/gear.json @@ -0,0 +1,35 @@ +{ + "category": "converter", + "gear": { + "inputs": { + "audio": { + "base": "file", + "description": "Any audio file. Plain speech suggested!" + } + }, + "maintainer": "Nathaniel Kofalt", + "description": "Detects the speech content of an audio file, using the machine-learning DeepSpeech library by Mozilla.", + "license": "Other", + "author": "Nathaniel Kofalt", + "url": "", + "label": "Speech Recognition", + "source": "https://github.com/mozilla/DeepSpeech", + "version": "1", + "custom": { + "gear-builder": { + "image": "gear-builder-kdfqapbezk-20171219165918", + "container": "c15189b625a0ea450cafbb24ef0df03c26cc8cf151181976ec4289801e191032" + } + }, + "config": {}, + "name": "speech-recognition" + }, + "created": "2017-12-20T00:09:50.381000+00:00", + "exchange": { + "git-commit": "local", + "rootfs-hash": "sha384:e01d925f90b097b554be0f802ef6ebb9f07000d7a6a2a0c3a25dac26893d4ac2414381e2c8e60f4b58b27c7fe8e56099", + "rootfs-url": "/api/gears/temp/5a39aa4e07a393001b663910" + }, + "modified": "2017-12-20T00:09:50.381000+00:00", + "_id": "5a39aa4e07a393001b663910" +} \ No newline at end of file diff --git a/swagger/paths/gears.yaml b/swagger/paths/gears.yaml index b34f53681..fd6191b64 100644 --- a/swagger/paths/gears.yaml +++ b/swagger/paths/gears.yaml @@ -5,12 +5,36 @@ tags: - gears responses: - default: - description: '' + '200': + description: 'Returns a list of gears installed on the system' + schema: + $ref: schemas/output/gear-list.json + examples: + response: + $ref: examples/output/gear-list.json # TODO: Can we make the parameter here consistent, or split # this into two separate APIs? /gears/{GearIdOrName}: + get: + summary: Retrieve details about a specific gear + operationId: get_gear + tags: + - gears + parameters: + - name: GearIdOrName + in: path + type: string + required: true + description: Id of the gear to interact with + responses: + '200': + description: 'Details about a single gear' + schema: + $ref: schemas/output/gear.json + examples: + response: + $ref: examples/output/gear.json post: summary: Create or update a gear. description: | @@ -18,44 +42,34 @@ Otherwise, the specified gear will be updated operationId: add_gear parameters: - - required: true - description: Name of the gear to interact with - type: string + - name: GearIdOrName in: path - name: GearIdOrName - tags: - - gears - responses: - default: - description: '' - get: - summary: Retrieve details about a specific gear - operationId: get_gear + type: string + required: true + description: Name of the gear to interact with + - name: body + in: body + required: true + schema: + $ref: schemas/input/gear.json tags: - gears - parameters: - - required: true - description: Id of the gear to interact with - type: string - in: path - name: GearIdOrName responses: '200': - description: '' + description: 'The gear was created or updated successfully' schema: - example: - $ref: examples/gear_full.json + $ref: schemas/output/collection-new.json delete: summary: Delete a gear (not recommended) operationId: delete_gear tags: - gears parameters: - - required: true - description: Id of the gear to interact with - type: string + - name: GearIdOrName in: path - name: GearIdOrName + type: string + required: true + description: Id of the gear to interact with responses: '200': description: Gear was deleted diff --git a/swagger/schemas/definitions/gear.json b/swagger/schemas/definitions/gear.json new file mode 100644 index 000000000..674ac4fb0 --- /dev/null +++ b/swagger/schemas/definitions/gear.json @@ -0,0 +1,182 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "$comment": "This is based on https://github.com/flywheel-io/gears/blob/master/spec/manifest.schema.json. It is NOT used for validation, just for doc/code gen.", + "definitions": { + "gear-directive": { + "type": "object", + "description": "A schema directive." + }, + "gear-author": { + "type": "string", + "description": "The author of this gear." + }, + "gear-maintainer": { + "type": "string", + "description": "(optional) The maintainer of this gear. Can be used to distinguish the algorithm author from the gear maintainer." + }, + "gear-cite": { + "type": "string", + "description": "(optional) Any citations relevant to the algorithm(s) or work present in the gear." + }, + "gear-config": { + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/gear-directive" + }, + "description": "Schema snippets describing the options this gear consumes. Not currently processed." + }, + "gear-custom": { + "type": "object", + "description": "A place for gear authors to put arbitrary information." + }, + "gear-description": { + "type": "string", + "description": "A brief description of the gear's purpose. Ideally 1-4 sentences." + }, + "gear-environment": { + "type": "object", + "additionalProperties": { "type": "string" }, + "description": "Environment variables that should be set for the gear." + }, + "gear-command": { + "type": "string", + "description": "If provided, the starting command for the gear, rather than /flywheel/v0/run. Will be templated according to the spec." + }, + "gear-label": { + "type": "string", + "description": "The human-friendly name of this gear." + }, + "gear-license": { + "type": "string", + "description": "Software license of the gear" + }, + "gear-name": { + "type": "string", + "pattern": "^[a-z0-9\\-]+$", + "description": "The identification of this gear." + }, + "gear-uri": { + "type": "string", + "description": "A valid URI, or empty string." + }, + "gear-input-item": { + "description": "Describes a gear input", + "properties": { + "base": { + "type": "string", + "enum": [ "file", "api-key" ], + "description": "The type of gear input." + }, + "description": { + "type": "string", + "description": "Hackaround for description not technically being a schema directive" + }, + "optional": { + "type": "boolean", + "description": "Allow the gear to mark an input file as optional." + } + }, + "required": [ "base" ], + "additionalProperties": { + "$ref": "#/definitions/gear-directive" + } + }, + "gear-inputs": { + "type": "object", + "additionalProperties": { + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/gear-input-item" + } + }, + "description": "Schema snippets describing the inputs this gear consumes." + }, + "gear-source": { + "$ref": "#/definitions/gear-uri", + "description": "The URL where the source code of this gear can be found. Leave blank if none." + }, + "gear-url": { + "$ref": "#/definitions/gear-uri", + "description": "The URL where more information about this gear can be found. Leave blank if none." + }, + "gear-version": { + "type": "string", + "description": "A human-friendly string explaining the release version of this gear. Example: 3.2.1" + }, + + "gear-exchange": { + "type": "object", + "description": "Metadata object that describes the origin of a gear version", + "properties": { + "git-commit": { + "type": "string", + "description": "The SHA-1 hash referring to the git commit" + }, + "rootfs-hash": { + "type": "string", + "description": "The cryptographic hash of the root filesystem in the form of \"algorithm:\"" + }, + "rootfs-url": { + "type": "string", + "description": "The absolute URL of the gear's root file system" + } + }, + "required": [ + "git-commit", + "rootfs-hash", + "rootfs-url" + ] + }, + "gear": { + "type": "object", + "description": "Gear manifest", + "properties": { + "author": { "$ref": "#/definitions/gear-author" }, + "maintainer": { "$ref": "#/definitions/gear-maintainer" }, + "cite": { "$ref": "#/definitions/gear-cite" }, + "config": { "$ref": "#/definitions/gear-config" }, + "custom": { "$ref": "#/definitions/gear-custom" }, + "description": { "$ref": "#/definitions/gear-description" }, + "environment": { "$ref": "#/definitions/gear-environment" }, + "command": { "$ref": "#/definitions/gear-command" }, + "inputs": { "$ref": "#/definitions/gear-inputs" }, + "label": { "$ref": "#/definitions/gear-label" }, + "license": { "$ref": "#/definitions/gear-license" }, + "name": { "$ref": "#/definitions/gear-name" }, + "source": { "$ref": "#/definitions/gear-source" }, + "url": { "$ref": "#/definitions/gear-url" }, + "version": { "$ref": "#/definitions/gear-version" } + }, + "required": [ + "author", + "config", + "description", + "inputs", + "label", + "license", + "name", + "source", + "url", + "version" + ], + "additionalProperties": false + }, + "gear-category": { + "type": "string", + "enum": [ "utility", "analysis", "converter", "qa" ], + "description": "The gear category" + }, + "gear-doc": { + "type": "object", + "properties": { + "_id": { "$ref": "common.json#/definitions/objectid" }, + "category": { "$ref": "#/definitions/gear-category" }, + "gear": { "$ref": "#/definitions/gear" }, + "exchange": { "$ref": "#/definitions/gear-exchange" }, + "created": { "$ref":"created-modified.json#/definitions/created"}, + "modified": { "$ref":"created-modified.json#/definitions/modified"} + }, + "description": "A full gear description, including manifest and exchange information" + } + } +} diff --git a/swagger/schemas/input/gear.json b/swagger/schemas/input/gear.json new file mode 100644 index 000000000..1f700aa54 --- /dev/null +++ b/swagger/schemas/input/gear.json @@ -0,0 +1,38 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "Analysis", + "type": "object", + "allOf":[{"$ref":"../definitions/gear.json#/definitions/gear-doc"}], + "example": { + "category": "converter", + "gear": { + "inputs": { + "audio": { + "base": "file", + "description": "Any audio file. Plain speech suggested!" + } + }, + "maintainer": "Nathaniel Kofalt", + "description": "Detects the speech content of an audio file, using the machine-learning DeepSpeech library by Mozilla.", + "license": "Other", + "author": "Nathaniel Kofalt", + "url": "", + "label": "Speech Recognition", + "source": "https://github.com/mozilla/DeepSpeech", + "version": "1", + "custom": { + "gear-builder": { + "image": "gear-builder-kdfqapbezk-20171219165918", + "container": "c15189b625a0ea450cafbb24ef0df03c26cc8cf151181976ec4289801e191032" + } + }, + "config": {}, + "name": "speech-recognition" + }, + "exchange": { + "git-commit": "local", + "rootfs-hash": "sha384:e01d925f90b097b554be0f802ef6ebb9f07000d7a6a2a0c3a25dac26893d4ac2414381e2c8e60f4b58b27c7fe8e56099", + "rootfs-url": "/api/gears/temp/5a39aa4e07a393001b663910" + } + } +} \ No newline at end of file diff --git a/swagger/schemas/output/gear-list.json b/swagger/schemas/output/gear-list.json new file mode 100644 index 000000000..e022766d0 --- /dev/null +++ b/swagger/schemas/output/gear-list.json @@ -0,0 +1,7 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "type":"array", + "items":{ + "allOf":[{"$ref":"../definitions/gear.json#/definitions/gear-doc"}] + } +} diff --git a/swagger/schemas/output/gear.json b/swagger/schemas/output/gear.json new file mode 100644 index 000000000..b64b79625 --- /dev/null +++ b/swagger/schemas/output/gear.json @@ -0,0 +1,5 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "type":"object", + "allOf":[{"$ref":"../definitions/gear.json#/definitions/gear-doc"}] +} From 1974715f9b3cade67ddfdafecb682d1e5b9b5c98 Mon Sep 17 00:00:00 2001 From: Justin Ehlert Date: Wed, 31 Jan 2018 13:50:32 -0600 Subject: [PATCH 08/21] Add schema and endpoint for jobs Added input schema for adding a job, and the endpoint for GET /job/{JobId}/logs. --- api/config.py | 1 + swagger/examples/input/job-new.json | 20 -------------------- swagger/paths/jobs.yaml | 14 ++++++++++++-- swagger/schemas/definitions/job.json | 20 ++++++++++++++++++++ swagger/schemas/input/job-new.json | 25 +++++++++++++++++++++++++ swagger/schemas/output/job-log.json | 11 +++++++++++ 6 files changed, 69 insertions(+), 22 deletions(-) delete mode 100755 swagger/examples/input/job-new.json create mode 100644 swagger/schemas/input/job-new.json create mode 100644 swagger/schemas/output/job-log.json diff --git a/api/config.py b/api/config.py index 75c6ed4ee..b7393ce9f 100644 --- a/api/config.py +++ b/api/config.py @@ -164,6 +164,7 @@ def apply_env_variables(config): 'group-new.json', 'group-update.json', 'info_update.json', + 'job-new.json', 'note.json', 'packfile.json', 'permission.json', diff --git a/swagger/examples/input/job-new.json b/swagger/examples/input/job-new.json deleted file mode 100755 index 934e2e763..000000000 --- a/swagger/examples/input/job-new.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "gear_id": "aex", - "inputs": { - "dicom": { - "type": "acquisition", - "id": "573c9e6a844eac7fc01747cd", - "name" : "1_1_dicom.zip" - } - }, - "config": { - "two-digit multiple of ten": 20 - }, - "destination": { - "type": "acquisition", - "id": "573c9e6a844eac7fc01747cd" - }, - "tags": [ - "ad-hoc" - ] -} diff --git a/swagger/paths/jobs.yaml b/swagger/paths/jobs.yaml index 9c91568f2..48daa3269 100644 --- a/swagger/paths/jobs.yaml +++ b/swagger/paths/jobs.yaml @@ -7,9 +7,9 @@ parameters: - name: body in: body + required: true schema: - example: - $ref: examples/input/job-new.json + $ref: schemas/input/job-new.json responses: '200': description: '' @@ -148,6 +148,16 @@ type: string in: path name: JobId + get: + summary: Get job logs + operationId: get_job_logs + tags: + - jobs + responses: + '200': + description: The current job log + schema: + $ref: schemas/output/job-log.json post: summary: Add logs to a job. operationId: add_logs diff --git a/swagger/schemas/definitions/job.json b/swagger/schemas/definitions/job.json index 5b06bd041..08724b41c 100644 --- a/swagger/schemas/definitions/job.json +++ b/swagger/schemas/definitions/job.json @@ -53,6 +53,26 @@ ], "additionalProperties":false }, + "job-log-statement": { + "type": "object", + "properties": { + "fd": { "type": "integer" }, + "msg": { "type": "string" } + }, + "required": ["fd", "msg"] + }, + "job-log": { + "type": "object", + "properties": { + "id": {"$ref":"common.json#/definitions/objectid"}, + "logs": { + "type": "array", + "items": { + "$ref": "#/definitions/job-log-statement" + } + } + } + }, "saved_files": { "type": "array", "items": {"$ref": "file.json#/definitions/name"} diff --git a/swagger/schemas/input/job-new.json b/swagger/schemas/input/job-new.json new file mode 100644 index 000000000..eed7eb7f7 --- /dev/null +++ b/swagger/schemas/input/job-new.json @@ -0,0 +1,25 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "type": "object", + "allOf": [{"$ref": "../definitions/job.json#/definitions/job-input"}], + "example": { + "gear_id": "aex", + "inputs": { + "dicom": { + "type": "acquisition", + "id": "573c9e6a844eac7fc01747cd", + "name" : "1_1_dicom.zip" + } + }, + "config": { + "two-digit multiple of ten": 20 + }, + "destination": { + "type": "acquisition", + "id": "573c9e6a844eac7fc01747cd" + }, + "tags": [ + "ad-hoc" + ] + } +} diff --git a/swagger/schemas/output/job-log.json b/swagger/schemas/output/job-log.json new file mode 100644 index 000000000..810151388 --- /dev/null +++ b/swagger/schemas/output/job-log.json @@ -0,0 +1,11 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "type": "object", + "allOf": [{"$ref": "../definitions/job.json#/definitions/job-log"}], + "example": { + "_id": "57ac7394c700190017123fb8", + "logs": [ + { "fd": 1, "msg": "Hello World!" } + ] + } +} From bcfacc2905f8129e0d0ec0efcc22a9d09fa84ffa Mon Sep 17 00:00:00 2001 From: Justin Ehlert Date: Tue, 6 Feb 2018 16:01:29 -0600 Subject: [PATCH 09/21] Add docs for modify info --- swagger/paths/acquisitions.yaml | 5 +++ swagger/paths/collections.yaml | 6 +++ swagger/paths/projects.yaml | 5 +++ swagger/paths/sessions.yaml | 5 +++ swagger/schemas/output/file-info.json | 21 ++++++++++ swagger/templates/container-item-info.yaml | 33 +++++++++++++++ swagger/templates/file-item-info.yaml | 47 ++++++++++++++++++++++ 7 files changed, 122 insertions(+) create mode 100644 swagger/schemas/output/file-info.json create mode 100644 swagger/templates/container-item-info.yaml create mode 100644 swagger/templates/file-item-info.yaml diff --git a/swagger/paths/acquisitions.yaml b/swagger/paths/acquisitions.yaml index 3f0834981..a2c77a454 100644 --- a/swagger/paths/acquisitions.yaml +++ b/swagger/paths/acquisitions.yaml @@ -17,6 +17,9 @@ $template_arguments: delete-description: Read-write project permissions are required to delete an acquisition.
Admin project permissions are required if the acquisition contains data uploaded by sources other than users and jobs. +/acquisitions/{AcquisitionId}/info: + $template: templates/container-item-info.yaml + # ===== Tags ===== /acquisitions/{AcquisitionId}/tags: $template: templates/tags.yaml @@ -36,6 +39,8 @@ $template_arguments: $template: templates/file-list-upload.yaml /acquisitions/{AcquisitionId}/files/{FileName}: $template: templates/file-item.yaml +/acquisitions/{AcquisitionId}/files/{FileName}/info: + $template: templates/file-item-info.yaml # ===== Notes ===== /acquisitions/{AcquisitionId}/notes: diff --git a/swagger/paths/collections.yaml b/swagger/paths/collections.yaml index a1b985254..1a8703ed0 100644 --- a/swagger/paths/collections.yaml +++ b/swagger/paths/collections.yaml @@ -53,6 +53,7 @@ $template_arguments: examples: response: $ref: examples/output/collection-curators-list.json + /collections/{CollectionId}: parameters: - required: true @@ -96,6 +97,9 @@ $template_arguments: '200': description: Collection was deleted +/collections/{CollectionId}/info: + $template: templates/container-item-info.yaml + /collections/{CollectionId}/sessions: parameters: - required: true @@ -161,6 +165,8 @@ $template_arguments: $template: templates/permissions.yaml /collections/{CollectionId}/permissions/{UserId}: $template: templates/permissions-user.yaml +/collections/{CollectionId}/files/{FileName}/info: + $template: templates/file-item-info.yaml # ===== Notes ===== /collections/{CollectionId}/notes: diff --git a/swagger/paths/projects.yaml b/swagger/paths/projects.yaml index fc359e47f..6c6a02bf7 100644 --- a/swagger/paths/projects.yaml +++ b/swagger/paths/projects.yaml @@ -16,6 +16,9 @@ $template_arguments: get-output-schema: schemas/output/project.json delete-description: Only site admins and users with "admin" project permissions may delete a project +/projects/{ProjectId}/info: + $template: templates/container-item-info.yaml + /projects/groups: get: summary: List all groups which have a project in them @@ -231,6 +234,8 @@ $template_arguments: $template: templates/file-list-upload.yaml /projects/{ProjectId}/files/{FileName}: $template: templates/file-item.yaml +/projects/{ProjectId}/files/{FileName}/info: + $template: templates/file-item-info.yaml # ===== Permissions ===== /projects/{ProjectId}/permissions: diff --git a/swagger/paths/sessions.yaml b/swagger/paths/sessions.yaml index 822c0d968..0ac7ec28d 100644 --- a/swagger/paths/sessions.yaml +++ b/swagger/paths/sessions.yaml @@ -16,6 +16,9 @@ $template_arguments: get-output-schema: schemas/output/session.json delete-description: Read-write project permissions are required to delete a session.
Admin project permissions are required if the session or it's acquisitions contain data uploaded by sources other than users and jobs. +/sessions/{SessionId}/info: + $template: templates/container-item-info.yaml + /sessions/{SessionId}/jobs: parameters: - in: path @@ -61,6 +64,8 @@ $template_arguments: $template: templates/file-list-upload.yaml /sessions/{SessionId}/files/{FileName}: $template: templates/file-item.yaml +/sessions/{SessionId}/files/{FileName}/info: + $template: templates/file-item-info.yaml # ===== Notes ===== /sessions/{SessionId}/notes: diff --git a/swagger/schemas/output/file-info.json b/swagger/schemas/output/file-info.json new file mode 100644 index 000000000..43f6fc036 --- /dev/null +++ b/swagger/schemas/output/file-info.json @@ -0,0 +1,21 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "type":"object", + "allOf":[{"$ref":"../definitions/file.json#/definitions/file-output"}], + "example": { + "origin": { + "type": "job", + "id": "58063f24e5dc5b001657a87f" + }, + "mimetype": "application/octet-stream", + "hash": "v0-sha384-12188e00a26650b2baa3f0195337dcf504f4362bb2136eef0cdbefb57159356b1355a0402fca0ab5ab081f21c305e5c2", + "name": "cortical_surface_right_hemisphere.obj", + "tags": [], + "measurements": [], + "modified": "2016-10-18T15:26:35.701000+00:00", + "modality": null, + "size": 21804112, + "type": "None", + "info": {} + } +} diff --git a/swagger/templates/container-item-info.yaml b/swagger/templates/container-item-info.yaml new file mode 100644 index 000000000..b30b37a25 --- /dev/null +++ b/swagger/templates/container-item-info.yaml @@ -0,0 +1,33 @@ +parameters: + - name: resource + type: string + required: true + - name: parameter + type: string + required: true + - name: tag + type: string + required: true +template: | + parameters: + - required: true + type: string + in: path + name: '{{parameter}}' + post: + summary: Update or replace info for a {{resource}}. + operationId: modify_{{resource}}_info + x-sdk-modify-info: true + tags: + - '{{tag}}' + parameters: + - name: body + in: body + required: true + schema: + $ref: schemas/input/info_update.json + responses: + '200': + description: 'The info was updated successfully' + + diff --git a/swagger/templates/file-item-info.yaml b/swagger/templates/file-item-info.yaml new file mode 100644 index 000000000..ef53a2f5b --- /dev/null +++ b/swagger/templates/file-item-info.yaml @@ -0,0 +1,47 @@ +parameters: + - name: resource + type: string + required: true + - name: parameter + type: string + required: true + - name: tag + type: string + required: true +template: | + parameters: + - required: true + type: string + in: path + name: '{{parameter}}' + - required: true + type: string + in: path + name: FileName + get: + summary: Get info for a particular file. + operationId: get_{{resource}}_file_info + tags: + - '{{tag}}' + responses: + '200': + description: 'The file object, including info' + schema: + $ref: schemas/output/file-info.json + post: + summary: Update info for a particular file. + operationId: modify_{{resource}}_file_info + x-sdk-modify-info: true + tags: + - '{{tag}}' + parameters: + - name: body + in: body + required: true + schema: + $ref: schemas/input/info_update.json + responses: + '200': + $ref: '#/responses/200:modified-with-count' + + From a6f546f6dce7eb176de9d456affa96f8c59dc307 Mon Sep 17 00:00:00 2001 From: Justin Ehlert Date: Wed, 7 Feb 2018 11:16:02 -0600 Subject: [PATCH 10/21] Add documentation for PUT on file endpoints --- swagger/responses/index.yaml | 16 ++++++++++++++++ swagger/templates/file-item.yaml | 15 +++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/swagger/responses/index.yaml b/swagger/responses/index.yaml index 03986aaa2..1b4e4c486 100644 --- a/swagger/responses/index.yaml +++ b/swagger/responses/index.yaml @@ -22,6 +22,22 @@ example: modified: 1 +'200:modified-with-count-and-jobs': + description: The number of records modified and number of jobs started. + schema: + type: object + properties: + modified: + type: integer + jobs_triggered: + type: integer + required: + - modified + - jobs_triggered + example: + modified: 1 + jobs_triggered: 0 + '400:invalid-body-json': description: | JSON did not validate against schema for this endpoint. diff --git a/swagger/templates/file-item.yaml b/swagger/templates/file-item.yaml index 512c38a04..b8a48d2a2 100644 --- a/swagger/templates/file-item.yaml +++ b/swagger/templates/file-item.yaml @@ -87,6 +87,21 @@ template: | '200': $ref: '#/responses/200:deleted-with-count' + put: + summary: Modify a file's attributes + operationId: modify_{{resource}}_file + tags: + - '{{tag}}' + parameters: + - name: body + in: body + required: true + schema: + $ref: schemas/input/file-update.json + responses: + '200': + $ref: '#/responses/200:modified-with-count-and-jobs' + delete: summary: Delete a file operationId: delete_{{resource}}_file From 080834e033cf1a41df4a06921afdc8dd5a7a7146 Mon Sep 17 00:00:00 2001 From: Justin Ehlert Date: Wed, 7 Feb 2018 15:23:23 -0600 Subject: [PATCH 11/21] Add missing parameter to collection/acquisitions Added "session" query parameter that limits the returned acquisitions. --- swagger/paths/collections.yaml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/swagger/paths/collections.yaml b/swagger/paths/collections.yaml index 1a8703ed0..d82af15d5 100644 --- a/swagger/paths/collections.yaml +++ b/swagger/paths/collections.yaml @@ -122,10 +122,14 @@ $template_arguments: /collections/{CollectionId}/acquisitions: parameters: - - required: true - type: string + - name: CollectionId in: path - name: CollectionId + type: string + required: true + - name: session + in: query + type: string + description: The id of a session, to which the acquisitions returned will be restricted get: summary: List acquisitions in a collection operationId: get_collection_acquisitions From 2282db3d7528b3e37cbb1a2a95f2aa733b4f76c1 Mon Sep 17 00:00:00 2001 From: Justin Ehlert Date: Wed, 7 Feb 2018 15:24:57 -0600 Subject: [PATCH 12/21] Add missing gear invocation endpoint This endpoint returns the JSON schema for gear configuration. --- swagger/paths/gears.yaml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/swagger/paths/gears.yaml b/swagger/paths/gears.yaml index fd6191b64..6f9ccac10 100644 --- a/swagger/paths/gears.yaml +++ b/swagger/paths/gears.yaml @@ -73,3 +73,23 @@ responses: '200': description: Gear was deleted + +/gears/{GearId}/invocation: + parameters: + - name: GearId + in: path + type: string + required: true + description: Id of the gear to interact with + get: + summary: Get a schema for invoking a gear. + operationId: get_gear_invocation + tags: + - gears + responses: + '200': + description: The gear invocation schema. + schema: + type: object + + From 7a2b794662643e8f5d0e6ec611c165d4deb09a3d Mon Sep 17 00:00:00 2001 From: Justin Ehlert Date: Fri, 9 Feb 2018 08:50:08 -0600 Subject: [PATCH 13/21] Rename update_job endpoint --- swagger/paths/jobs.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/swagger/paths/jobs.yaml b/swagger/paths/jobs.yaml index 48daa3269..c2199da76 100644 --- a/swagger/paths/jobs.yaml +++ b/swagger/paths/jobs.yaml @@ -89,7 +89,7 @@ 'running' state. Accepts the same body as /api/jobs/add , except all fields are optional. - operationId: update_job + operationId: modify_job tags: - jobs responses: @@ -98,6 +98,7 @@ parameters: - name: body in: body + required: true schema: example: $ref: examples/input/job-update.json From b1e661f19f5410e39cea2fb54fdcb74e585656bf Mon Sep 17 00:00:00 2001 From: Justin Ehlert Date: Fri, 9 Feb 2018 08:55:41 -0600 Subject: [PATCH 14/21] Add get_analyses endpoint documentation This documents the endpoints for ///analyses as well as ////analyses. --- swagger/paths/acquisitions.yaml | 2 + swagger/paths/analyses.yaml | 48 +++++++++++++++++++++++ swagger/paths/collections.yaml | 2 + swagger/paths/projects.yaml | 2 + swagger/paths/sessions.yaml | 23 ++--------- swagger/schemas/definitions/analysis.json | 33 +++++++++++++++- swagger/schemas/output/analyses-list.json | 5 +++ swagger/templates/analyses-list.yaml | 38 ++++++++++++++++-- swagger/templates/analysis-item.yaml | 5 +++ swagger/templates/analysis-notes.yaml | 1 + swagger/templates/file-item.yaml | 10 ----- 11 files changed, 134 insertions(+), 35 deletions(-) create mode 100644 swagger/schemas/output/analyses-list.json diff --git a/swagger/paths/acquisitions.yaml b/swagger/paths/acquisitions.yaml index a2c77a454..e205aff48 100644 --- a/swagger/paths/acquisitions.yaml +++ b/swagger/paths/acquisitions.yaml @@ -51,6 +51,8 @@ $template_arguments: # ===== Analyses ===== /acquisitions/{AcquisitionId}/analyses: $template: templates/analyses-list.yaml + arguments: + allowCreate: true /acquisitions/{AcquisitionId}/analyses/{AnalysisId}: $template: templates/analysis-item.yaml arguments: diff --git a/swagger/paths/analyses.yaml b/swagger/paths/analyses.yaml index d6f1a281e..6c3be8aee 100644 --- a/swagger/paths/analyses.yaml +++ b/swagger/paths/analyses.yaml @@ -26,3 +26,51 @@ $template_arguments: arguments: filegroup: outputs +/{ContainerName}/{ContainerId}/{SubcontainerName}/analyses: + parameters: + - name: ContainerName + in: path + type: string + required: true + enum: + - groups + - projects + - sessions + - acquisitions + - collections + description: The parent container type + - name: ContainerId + in: path + type: string + required: true + description: The parent container id + - name: SubcontainerName + in: path + type: string + required: true + enum: + - all + - projects + - sessions + - acquisitions + description: The sub container type + get: + summary: Get nested analyses for a container + description: > + Returns analyses that belong to containers of the specified type that belong + to ContainerId. + + For example: `projects/{ProjectId}/acquisitions/analyses` will return any analyses + that have an acquisition that is under that project as a parent. + + The `all` keyword is also supported, for example: projects/{ProjectId}/all/analyses + will return any analyses that have any session or acquisition or the project itself as a parent. + operationId: get_analyses + tags: + - analyses + responses: + '200': + description: The list of analyses + schema: + $ref: schemas/output/analyses-list.json + diff --git a/swagger/paths/collections.yaml b/swagger/paths/collections.yaml index d82af15d5..f4b884fca 100644 --- a/swagger/paths/collections.yaml +++ b/swagger/paths/collections.yaml @@ -181,6 +181,8 @@ $template_arguments: # ===== Analyses ===== /collections/{CollectionId}/analyses: $template: templates/analyses-list.yaml + arguments: + allowCreate: true /collections/{CollectionId}/analyses/{AnalysisId}: $template: templates/analysis-item.yaml arguments: diff --git a/swagger/paths/projects.yaml b/swagger/paths/projects.yaml index 6c6a02bf7..b5f78ef04 100644 --- a/swagger/paths/projects.yaml +++ b/swagger/paths/projects.yaml @@ -252,6 +252,8 @@ $template_arguments: # ===== Analyses ===== /projects/{ProjectId}/analyses: $template: templates/analyses-list.yaml + arguments: + allowCreate: true /projects/{ProjectId}/analyses/{AnalysisId}: $template: templates/analysis-item.yaml arguments: diff --git a/swagger/paths/sessions.yaml b/swagger/paths/sessions.yaml index 0ac7ec28d..64c9f908d 100644 --- a/swagger/paths/sessions.yaml +++ b/swagger/paths/sessions.yaml @@ -93,26 +93,9 @@ $template_arguments: # ===== Analyses ===== /sessions/{SessionId}/analyses: - parameters: - - in: path - type: string - required: true - name: SessionId - post: - summary: Create an analysis. - description: '' - operationId: add_session_analysis - tags: - - 'sessions' - parameters: - - in: body - name: body - schema: - $ref: schemas/input/analysis.json - responses: - '200': - description: '' - + $template: templates/analyses-list.yaml + arguments: + allowCreate: true /sessions/{SessionId}/analyses/{AnalysisId}: $template: templates/analysis-item.yaml arguments: diff --git a/swagger/schemas/definitions/analysis.json b/swagger/schemas/definitions/analysis.json index 3d0f37cb3..e828fd1ed 100644 --- a/swagger/schemas/definitions/analysis.json +++ b/swagger/schemas/definitions/analysis.json @@ -68,7 +68,7 @@ "job":{ "oneOf":[ {"$ref":"common.json#/definitions/objectid"}, - {"type":"object"} + {"$ref": "job.json#/definitions/job-output"} ] }, "notes": {"$ref":"note.json#/definitions/notes-list-output"}, @@ -79,6 +79,37 @@ }, "required":["_id", "files", "label", "created", "modified"] }, + "analysis-list-entry":{ + "type":"object", + "properties":{ + "_id":{"$ref":"common.json#/definitions/objectid"}, + "files":{ + "type":"array", + "items":{"$ref":"file.json#/definitions/file-entry"} + }, + "job": {"$ref":"common.json#/definitions/objectid"}, + "notes": {"$ref":"note.json#/definitions/notes-list-output"}, + "description": {"$ref":"common.json#/definitions/description"}, + "label": {"$ref":"common.json#/definitions/label"}, + "created": {"$ref":"created-modified.json#/definitions/created"}, + "modified": {"$ref":"created-modified.json#/definitions/modified"} + }, + "required":["_id", "files", "label", "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"}] + } + } + }, "analysis-files-create-ticket-output": { "type":"object", "properties":{ diff --git a/swagger/schemas/output/analyses-list.json b/swagger/schemas/output/analyses-list.json new file mode 100644 index 000000000..5a78c08a9 --- /dev/null +++ b/swagger/schemas/output/analyses-list.json @@ -0,0 +1,5 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "type": "array", + "items": {"$ref":"../definitions/analysis.json#/definitions/analysis-list-entry"} +} diff --git a/swagger/templates/analyses-list.yaml b/swagger/templates/analyses-list.yaml index 6d76dc2d1..22d5ef522 100644 --- a/swagger/templates/analyses-list.yaml +++ b/swagger/templates/analyses-list.yaml @@ -8,23 +8,53 @@ parameters: - name: tag type: string required: true + - name: allowCreate + type: boolean + required: false template: | parameters: - required: true type: string in: path name: '{{parameter}}' + get: + summary: Get analyses for {{resource}}. + description: Returns analyses that directly belong to this resource. + operationId: get_{{resource}}_analyses + tags: + - '{{tag}}' + responses: + '200': + description: The list of analyses + schema: + $ref: schemas/output/analyses-list.json + + {{#allowCreate}} 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_{{resource}}_analysis tags: - '{{tag}}' consumes: + - application/json - multipart/form-data parameters: - - in: formData - name: formData - type: string + - in: body + name: body + required: true + schema: + $ref: schemas/input/analysis.json + - name: job + in: query + type: boolean + description: Return job as an object instead of an id responses: '200': - description: '' + description: Returns the id of the analysis that was created. + schema: + $ref: schemas/output/container-new.json + {{/allowCreate}} diff --git a/swagger/templates/analysis-item.yaml b/swagger/templates/analysis-item.yaml index 3b2251535..958017691 100644 --- a/swagger/templates/analysis-item.yaml +++ b/swagger/templates/analysis-item.yaml @@ -31,6 +31,11 @@ template: | {{/resource}} tags: - '{{tag}}' + parameters: + - name: inflate_job + in: query + type: boolean + description: Return job as an object instead of an id responses: '200': description: '' diff --git a/swagger/templates/analysis-notes.yaml b/swagger/templates/analysis-notes.yaml index 12168f23c..58dc6b9ae 100644 --- a/swagger/templates/analysis-notes.yaml +++ b/swagger/templates/analysis-notes.yaml @@ -26,6 +26,7 @@ template: | parameters: - name: body in: body + required: true schema: $ref: schemas/input/note.json responses: diff --git a/swagger/templates/file-item.yaml b/swagger/templates/file-item.yaml index b8a48d2a2..3db7397ae 100644 --- a/swagger/templates/file-item.yaml +++ b/swagger/templates/file-item.yaml @@ -86,7 +86,6 @@ template: | responses: '200': $ref: '#/responses/200:deleted-with-count' - put: summary: Modify a file's attributes operationId: modify_{{resource}}_file @@ -102,12 +101,3 @@ template: | '200': $ref: '#/responses/200:modified-with-count-and-jobs' - delete: - summary: Delete a file - operationId: delete_{{resource}}_file - tags: - - '{{tag}}' - responses: - '200': - $ref: '#/responses/200:modified-with-count' - From 0eafd69aeea7924a4a593d3e1e74bb304896ff9b Mon Sep 17 00:00:00 2001 From: Justin Ehlert Date: Fri, 9 Feb 2018 09:21:43 -0600 Subject: [PATCH 15/21] Fix failing tests for analyses --- swagger/examples/output/analysis.json | 4 ++-- swagger/schemas/definitions/analysis.json | 2 +- swagger/schemas/output/analyses-list.json | 27 ++++++++++++++++++++++- 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/swagger/examples/output/analysis.json b/swagger/examples/output/analysis.json index 1531326a6..fe6a9a225 100644 --- a/swagger/examples/output/analysis.json +++ b/swagger/examples/output/analysis.json @@ -43,7 +43,6 @@ } }, "attempt": 1, - "name": "cortex-demo", "tags": ["ad-hoc", "cortex-demo", "analysis"], "destination": { "type": "analysis", @@ -81,7 +80,8 @@ "created": "2016-10-18T17:45:11.816000+00:00", "state": "complete", "config": {}, - "id": "58065fa7e5dc5b001457a882" + "id": "58065fa7e5dc5b001457a882", + "gear_id": "58065fa7e5dc5b001457a882" }, "_id": "58065fa7e5dc5b001457a881" } diff --git a/swagger/schemas/definitions/analysis.json b/swagger/schemas/definitions/analysis.json index e828fd1ed..1c963712e 100644 --- a/swagger/schemas/definitions/analysis.json +++ b/swagger/schemas/definitions/analysis.json @@ -85,7 +85,7 @@ "_id":{"$ref":"common.json#/definitions/objectid"}, "files":{ "type":"array", - "items":{"$ref":"file.json#/definitions/file-entry"} + "items":{"$ref":"file.json#/definitions/file"} }, "job": {"$ref":"common.json#/definitions/objectid"}, "notes": {"$ref":"note.json#/definitions/notes-list-output"}, diff --git a/swagger/schemas/output/analyses-list.json b/swagger/schemas/output/analyses-list.json index 5a78c08a9..988581c68 100644 --- a/swagger/schemas/output/analyses-list.json +++ b/swagger/schemas/output/analyses-list.json @@ -1,5 +1,30 @@ { "$schema": "http://json-schema.org/draft-04/schema#", "type": "array", - "items": {"$ref":"../definitions/analysis.json#/definitions/analysis-list-entry"} + "items": {"$ref":"../definitions/analysis.json#/definitions/analysis-list-entry"}, + "example": [{ + "files": [{ + "origin": { + "type": "job", + "id": "58063f24e5dc5b001657a87f" + }, + "mimetype": "application/octet-stream", + "hash": "v0-sha384-12188e00a26650b2baa3f0195337dcf504f4362bb2136eef0cdbefb57159356b1355a0402fca0ab5ab081f21c305e5c2", + "name": "cortical_surface_right_hemisphere.obj", + "tags": [], + "measurements": [], + "modified": "2016-10-18T15:26:35.701000+00:00", + "modality": null, + "input": true, + "size": 21804112, + "type": "None", + "info": {} + }], + "created": "2016-10-18T17:45:11.778000+00:00", + "modified": "2016-10-18T17:45:11.778000+00:00", + "label": "cortex-demo 10/18/2016 13:45:5", + "job": "58065fa7e5dc5b001457a882", + "user": "canakgun@flywheel.io", + "_id": "58065fa7e5dc5b001457a881" + }] } From 7fa4103fa408633b22fb1469456b33a1d860aac9 Mon Sep 17 00:00:00 2001 From: Justin Ehlert Date: Fri, 9 Feb 2018 11:28:46 -0600 Subject: [PATCH 16/21] Add schemas for batch job scheduling Also refactored a few schemas to better match the SDK. --- api/config.py | 1 + swagger/paths/batch.yaml | 49 ++++++------ swagger/schemas/definitions/acquisition.json | 2 +- swagger/schemas/definitions/batch.json | 81 ++++++++++++++++++++ swagger/schemas/definitions/collection.json | 2 +- swagger/schemas/definitions/container.json | 31 +++++++- swagger/schemas/definitions/file.json | 13 ++-- swagger/schemas/definitions/job.json | 15 +++- swagger/schemas/definitions/project.json | 2 +- swagger/schemas/definitions/session.json | 2 +- swagger/schemas/definitions/tag.json | 2 +- swagger/schemas/input/propose-batch.json | 14 ++++ swagger/schemas/output/batch-cancel.json | 8 ++ swagger/schemas/output/batch-list.json | 23 ++++++ swagger/schemas/output/batch-proposal.json | 18 +++++ swagger/schemas/output/batch.json | 23 ++++++ 16 files changed, 246 insertions(+), 40 deletions(-) create mode 100644 swagger/schemas/definitions/batch.json create mode 100644 swagger/schemas/input/propose-batch.json create mode 100644 swagger/schemas/output/batch-cancel.json create mode 100644 swagger/schemas/output/batch-list.json create mode 100644 swagger/schemas/output/batch-proposal.json create mode 100644 swagger/schemas/output/batch.json diff --git a/api/config.py b/api/config.py index b7393ce9f..9add77140 100644 --- a/api/config.py +++ b/api/config.py @@ -171,6 +171,7 @@ def apply_env_variables(config): 'project.json', 'project-template.json', 'project-update.json', + 'propose-batch.json', 'rule-new.json', 'rule-update.json', 'session.json', diff --git a/swagger/paths/batch.yaml b/swagger/paths/batch.yaml index b407f82c3..900d45550 100644 --- a/swagger/paths/batch.yaml +++ b/swagger/paths/batch.yaml @@ -2,34 +2,31 @@ get: summary: Get a list of batch jobs the user has created. description: Requires login. - operationId: get_all_batch_jobs + operationId: get_all_batches tags: - batch responses: '200': - description: '' - # Schema file does not exist - # schema: - # $ref: schemas/output/batch-list.json + description: 'Returns a list of all known batch jobs for the user' + schema: + $ref: schemas/output/batch-list.json post: summary: Create a batch job proposal and insert it as 'pending'. - operationId: create_batch_job + operationId: propose_batch tags: - batch parameters: - name: body in: body - description: '' + required: true + description: The batch proposal schema: - type: object - # Schema file does not exist - # $ref: schemas/input/batch-insert.json + $ref: schemas/input/propose-batch.json responses: '200': - description: '' - # Schema file does not exist - # schema: - # $ref: schemas/output/batch-insert.json + description: The batch proposal object that was created + schema: + $ref: schemas/output/batch-proposal.json /batch/{BatchId}: parameters: @@ -40,19 +37,18 @@ get: summary: Get batch job details. parameters: - - in: query + - name: jobs + in: query type: boolean - name: jobs description: If true, return job objects instead of job ids - operationId: get_batch_job + operationId: get_batch tags: - batch responses: '200': - description: '' - # Schema file does not exist - # schema: - # $ref: schemas/output/batch.json + description: 'The batch object' + schema: + $ref: schemas/output/batch.json '404': $ref: '#/responses/404:resource-not-found' @@ -67,7 +63,7 @@ description: | Creates jobs from proposed inputs, returns jobs enqueued. Moves 'pending' batch job to 'running'. - operationId: run_batch_job + operationId: start_batch tags: - batch responses: @@ -87,12 +83,11 @@ description: | Cancels jobs that are still pending, returns number of jobs cancelled. Moves a 'running' batch job to 'cancelled'. - operationId: cancel_batch_job + operationId: cancel_batch tags: - batch responses: '200': - description: '' - examples: - response: - canceled_jobs: 4 + description: 'The number of jobs canceled' + schema: + $ref: schemas/output/batch-cancel.json diff --git a/swagger/schemas/definitions/acquisition.json b/swagger/schemas/definitions/acquisition.json index 181bfb6da..4c646e5c1 100644 --- a/swagger/schemas/definitions/acquisition.json +++ b/swagger/schemas/definitions/acquisition.json @@ -61,7 +61,7 @@ "items":{"$ref":"permission.json#/definitions/permission-output-default-required"} }, "notes":{"allOf":[{"$ref":"note.json#/definitions/notes-list-output"}]}, - "tags":{"allOf":[{"$ref":"tag.json#/definitions/tag-output-list"}]}, + "tags":{"allOf":[{"$ref":"tag.json#/definitions/tag-list"}]}, "analyses":{ "type":"array", "items":{"$ref":"analysis.json#/definitions/analysis-output"} diff --git a/swagger/schemas/definitions/batch.json b/swagger/schemas/definitions/batch.json new file mode 100644 index 000000000..e3803402d --- /dev/null +++ b/swagger/schemas/definitions/batch.json @@ -0,0 +1,81 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "definitions": { + "matched-container-list": { + "type": "array", + "items": {"$ref":"container.json#/definitions/container-output-with-files"} + }, + "batch-proposal-detail": { + "type": "object", + "properties": { + "analysis": {"$ref": "analysis.json#/definitions/analysis-input"}, + "tags": {"$ref":"tag.json#/definitions/tag-list"} + }, + "additionalProperties": false + }, + "batch": { + "type": "object", + "properties": { + "_id": {"$ref":"common.json#/definitions/objectid"}, + "gear_id": {"$ref":"job.json#/definitions/gear_id"}, + "state": {"$ref":"job.json#/definitions/state"}, + "origin": {"$ref":"job.json#/definitions/job-origin"}, + "config": {"$ref":"job.json#/definitions/config"}, + "jobs": { + "type": "array", + "items": { "$ref": "common.json#/definitions/objectid" } + }, + "created":{"$ref":"created-modified.json#/definitions/created"}, + "modified":{"$ref":"created-modified.json#/definitions/modified"} + } + }, + "batch-proposal": { + "type": "object", + "properties": { + "_id": {"$ref":"common.json#/definitions/objectid"}, + "gear_id": {"$ref":"job.json#/definitions/gear_id"}, + "state": {"$ref":"job.json#/definitions/state"}, + "config": {"$ref":"job.json#/definitions/config"}, + "origin": {"$ref":"job.json#/definitions/job-origin"}, + + "proposal": { "$ref": "#/definitions/batch-proposal-detail" }, + + "ambiguous": { "$ref": "#/definitions/matched-container-list" }, + "matched": { "$ref": "#/definitions/matched-container-list" }, + "not_matched": { "$ref": "#/definitions/matched-container-list" }, + + "improper_permissions": { + "type": "array", + "items": {"$ref":"container.json#/definitions/_id"} + }, + + "created":{"$ref":"created-modified.json#/definitions/created"}, + "modified":{"$ref":"created-modified.json#/definitions/modified"} + }, + "additionalProperties": false + }, + "batch-proposal-input": { + "type": "object", + "properties": { + "gear_id": {"$ref":"job.json#/definitions/gear_id"}, + "config": {"$ref":"job.json#/definitions/config"}, + "tags": {"$ref":"tag.json#/definitions/tag-list"}, + "analysis": {"$ref": "analysis.json#/definitions/analysis-input"}, + "targets": { + "type": "array", + "items": {"$ref":"container.json#/definitions/container-reference"} + } + }, + "additionalProperties": false + }, + "batch-cancel-output": { + "type": "object", + "properties": { + "number_cancelled": {"type":"integer"} + }, + "additionalProperties": false, + "required": ["number_cancelled"], + "x-sdk-return": "number_cancelled" + } + } +} diff --git a/swagger/schemas/definitions/collection.json b/swagger/schemas/definitions/collection.json index 67caaed72..d391f3987 100644 --- a/swagger/schemas/definitions/collection.json +++ b/swagger/schemas/definitions/collection.json @@ -50,7 +50,7 @@ "items":{"$ref":"file.json#/definitions/file-output"} }, "notes": {"$ref":"note.json#/definitions/notes-list-output"}, - "tags": {"$ref":"tag.json#/definitions/tag-output-list"}, + "tags": {"$ref":"tag.json#/definitions/tag-list"}, "analyses":{ "type":"array", "items":{"$ref":"analysis.json#/definitions/analysis-output"} diff --git a/swagger/schemas/definitions/container.json b/swagger/schemas/definitions/container.json index ed3161013..caf1f1699 100644 --- a/swagger/schemas/definitions/container.json +++ b/swagger/schemas/definitions/container.json @@ -8,6 +8,11 @@ "uid": {"type": "string"}, "timestamp": {"type": ["string", "null"], "format": "date-time"}, "timezone": {"type": "string"}, + "container-type": { + "type": "string", + "enum": ["group", "project", "session", "acquisition", "collection", "analysis"], + "description": "The type of container (e.g. session)" + }, "container-new-output": { "type": "object", @@ -15,6 +20,30 @@ "_id": {"$ref":"#/definitions/_id"} }, "required": ["_id"] - } + }, + "container-reference": { + "type": "object", + "properties": { + "type": {"$ref":"#/definitions/container-type"}, + "id": {"$ref":"#/definitions/_id"} + }, + "required": [ "type", "id" ], + "additionalProperties":false, + "description": "A reference to an individual container, by type and id" + }, + "container-output-with-files": { + "type": "object", + "properties": { + "_id": {"$ref":"#/definitions/_id"}, + "label": {"$ref":"common.json#/definitions/label"}, + "files":{ + "type":"array", + "items":{"$ref":"file.json#/definitions/file-output"} + }, + "created": {"$ref":"created-modified.json#/definitions/created"}, + "modified": {"$ref":"created-modified.json#/definitions/modified"} + }, + "description": "Generic container output with files" + } } } diff --git a/swagger/schemas/definitions/file.json b/swagger/schemas/definitions/file.json index 24a243afb..26f7cbf73 100644 --- a/swagger/schemas/definitions/file.json +++ b/swagger/schemas/definitions/file.json @@ -95,12 +95,13 @@ "file-reference": { "type": "object", "properties": { - "type": {"type": "string"}, - "id": {"type": "string"}, - "name": {"type": "string"} + "type": {"$ref":"container.json#/definitions/container-type"}, + "id": {"$ref":"container.json#/definitions/_id"}, + "name": {"$ref":"#/definitions/name"} }, - "required": ["type", "id", "name"], - "additionalProperties": false - } + "required": [ "type", "id", "name" ], + "additionalProperties":false, + "description": "A reference to an individual file in a container, by type, id and name" + } } } diff --git a/swagger/schemas/definitions/job.json b/swagger/schemas/definitions/job.json index 08724b41c..aa3b51c4e 100644 --- a/swagger/schemas/definitions/job.json +++ b/swagger/schemas/definitions/job.json @@ -21,6 +21,18 @@ "[-_ a-zA-Z0-9]+": {"$ref":"file.json#/definitions/file-reference"} } }, + "inputs-array":{ + "type":"array", + "items":{ + "type":"object", + "properties":{ + "type": {"$ref":"container.json#/definitions/container-type"}, + "id": {"$ref":"container.json#/definitions/_id"}, + "name": {"$ref":"file.json#/definitions/name"}, + "input":{"type":"string"} + } + } + }, "destination": { "type": "object", "properties": { @@ -88,7 +100,8 @@ }, "state":{ - "type":"string" + "type":"string", + "enum": [ "pending", "running", "failed", "complete", "cancelled" ] }, "attempt":{ "type":"integer" diff --git a/swagger/schemas/definitions/project.json b/swagger/schemas/definitions/project.json index 6cb7dc156..366a7642c 100644 --- a/swagger/schemas/definitions/project.json +++ b/swagger/schemas/definitions/project.json @@ -46,7 +46,7 @@ } }, "notes": {"$ref":"note.json#/definitions/notes-list-output"}, - "tags": {"$ref":"tag.json#/definitions/tag-output-list"}, + "tags": {"$ref":"tag.json#/definitions/tag-list"}, "analyses":{ "type":"array", "items":{"$ref":"analysis.json#/definitions/analysis-output"} diff --git a/swagger/schemas/definitions/session.json b/swagger/schemas/definitions/session.json index 9c1c9775b..16702f47e 100644 --- a/swagger/schemas/definitions/session.json +++ b/swagger/schemas/definitions/session.json @@ -63,7 +63,7 @@ "items":{"$ref":"file.json#/definitions/file-output"} }, "notes": {"$ref":"note.json#/definitions/notes-list-output"}, - "tags": {"$ref":"tag.json#/definitions/tag-output-list"}, + "tags": {"$ref":"tag.json#/definitions/tag-list"}, "analyses":{ "type":"array", "items":{"$ref":"analysis.json#/definitions/analysis-output"} diff --git a/swagger/schemas/definitions/tag.json b/swagger/schemas/definitions/tag.json index e53e657c7..cf1e974cd 100644 --- a/swagger/schemas/definitions/tag.json +++ b/swagger/schemas/definitions/tag.json @@ -9,7 +9,7 @@ "additionalProperties": false, "required": ["value"] }, - "tag-output-list":{ + "tag-list":{ "type":"array", "items":{ "allOf":[{"$ref":"#/definitions/tag"}] diff --git a/swagger/schemas/input/propose-batch.json b/swagger/schemas/input/propose-batch.json new file mode 100644 index 000000000..0ec0934ce --- /dev/null +++ b/swagger/schemas/input/propose-batch.json @@ -0,0 +1,14 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "type": "object", + "allOf": [{"$ref":"../definitions/batch.json#/definitions/batch-proposal-input"}], + "example": { + "gear_id": "59b1b5b0e105c40019f50015", + "config": {}, + "tags": ["test-tag"], + "targets": [{ + "type": "session", + "id": "deb1b5b0e105c40019f500af" + }] + } +} diff --git a/swagger/schemas/output/batch-cancel.json b/swagger/schemas/output/batch-cancel.json new file mode 100644 index 000000000..8ca8186a0 --- /dev/null +++ b/swagger/schemas/output/batch-cancel.json @@ -0,0 +1,8 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "type": "object", + "allOf": [{"$ref": "../definitions/batch.json#/definitions/batch-cancel-output"}], + "example": { + "number_cancelled": 4 + } +} diff --git a/swagger/schemas/output/batch-list.json b/swagger/schemas/output/batch-list.json new file mode 100644 index 000000000..d120f9d03 --- /dev/null +++ b/swagger/schemas/output/batch-list.json @@ -0,0 +1,23 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "type": "array", + "items": {"$ref":"../definitions/batch.json#/definitions/batch"}, + "example": [{ + "origin": { + "type": "user", + "id": "justinehlert@flywheel.io" + }, + "jobs": [ + "5a33fa6652e95c001707489c", + "5a33fa6652e95c001707489d", + "5a33fa6652e95c001707489e", + "5a33fa6652e95c001707489f" + ], + "created": "2017-12-15T16:37:55.538000+00:00", + "modified": "2017-12-15T16:38:01.107000+00:00", + "state": "complete", + "gear_id": "59b1b5b0e105c40019f50015", + "_id": "5a33fa6352e95c001707489b", + "config": {} + }] +} diff --git a/swagger/schemas/output/batch-proposal.json b/swagger/schemas/output/batch-proposal.json new file mode 100644 index 000000000..c0c61ec2c --- /dev/null +++ b/swagger/schemas/output/batch-proposal.json @@ -0,0 +1,18 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "type": "object", + "allOf": [{"$ref":"../definitions/batch.json#/definitions/batch-proposal"}], + "example": { + "_id": "5a33fa6352e95c001707489b", + "gear_id": "59b1b5b0e105c40019f50015", + "config": {}, + "state": "pending", + "origin": { + "type": "user", + "id": "justinehlert@flywheel.io" + }, + "proposal": {}, + "created": "2017-12-15T16:37:55.538000+00:00", + "modified": "2017-12-15T16:38:01.107000+00:00" + } +} diff --git a/swagger/schemas/output/batch.json b/swagger/schemas/output/batch.json new file mode 100644 index 000000000..fa73bafff --- /dev/null +++ b/swagger/schemas/output/batch.json @@ -0,0 +1,23 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "type": "object", + "allOf": [{"$ref":"../definitions/batch.json#/definitions/batch"}], + "example": { + "origin": { + "type": "user", + "id": "justinehlert@flywheel.io" + }, + "jobs": [ + "5a33fa6652e95c001707489c", + "5a33fa6652e95c001707489d", + "5a33fa6652e95c001707489e", + "5a33fa6652e95c001707489f" + ], + "created": "2017-12-15T16:37:55.538000+00:00", + "modified": "2017-12-15T16:38:01.107000+00:00", + "state": "complete", + "gear_id": "59b1b5b0e105c40019f50015", + "_id": "5a33fa6352e95c001707489b", + "config": {} + } +} From 1f9ce5be59901bdf7a7fe5f8726294b648e07e91 Mon Sep 17 00:00:00 2001 From: Justin Ehlert Date: Fri, 9 Feb 2018 12:18:28 -0600 Subject: [PATCH 17/21] Add schema for adding job logs --- api/config.py | 1 + swagger/paths/jobs.yaml | 15 ++++++++++++++- swagger/schemas/input/job-logs.json | 8 ++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 swagger/schemas/input/job-logs.json diff --git a/api/config.py b/api/config.py index 9add77140..d806b376f 100644 --- a/api/config.py +++ b/api/config.py @@ -164,6 +164,7 @@ def apply_env_variables(config): 'group-new.json', 'group-update.json', 'info_update.json', + 'job-logs.json', 'job-new.json', 'note.json', 'packfile.json', diff --git a/swagger/paths/jobs.yaml b/swagger/paths/jobs.yaml index c2199da76..38e26dc69 100644 --- a/swagger/paths/jobs.yaml +++ b/swagger/paths/jobs.yaml @@ -25,6 +25,13 @@ operationId: get_next_job tags: - jobs + parameters: + - name: tags + in: query + type: array + items: + type: string + collectionFormat: multi responses: '200': description: '' @@ -161,9 +168,15 @@ $ref: schemas/output/job-log.json post: summary: Add logs to a job. - operationId: add_logs + operationId: add_job_logs tags: - jobs + parameters: + - name: body + in: body + required: true + schema: + $ref: schemas/input/job-logs.json responses: '200': description: Logs were added. No value is returned. diff --git a/swagger/schemas/input/job-logs.json b/swagger/schemas/input/job-logs.json new file mode 100644 index 000000000..43e5f9444 --- /dev/null +++ b/swagger/schemas/input/job-logs.json @@ -0,0 +1,8 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "type": "array", + "items": {"$ref": "../definitions/job.json#/definitions/job-log-statement"}, + "example": [ + { "fd": 1, "msg": "Hello World!" } + ] +} From 8dd3712f46d3e58e417a97ebe652408963c5f765 Mon Sep 17 00:00:00 2001 From: Justin Ehlert Date: Fri, 9 Feb 2018 15:38:50 -0600 Subject: [PATCH 18/21] Add API documentation for search endpoint --- api/config.py | 1 + swagger/index.yaml | 1 + swagger/paths/dataexplorer.yaml | 21 +++ swagger/schemas/definitions/search.json | 128 ++++++++++++++++++ swagger/schemas/input/search-query.json | 9 ++ .../schemas/output/search-response-list.json | 6 + 6 files changed, 166 insertions(+) create mode 100644 swagger/paths/dataexplorer.yaml create mode 100644 swagger/schemas/definitions/search.json create mode 100644 swagger/schemas/input/search-query.json create mode 100644 swagger/schemas/output/search-response-list.json diff --git a/api/config.py b/api/config.py index d806b376f..7a2b7d159 100644 --- a/api/config.py +++ b/api/config.py @@ -175,6 +175,7 @@ def apply_env_variables(config): 'propose-batch.json', 'rule-new.json', 'rule-update.json', + 'search-query.json', 'session.json', 'session-update.json', 'subject.json', diff --git a/swagger/index.yaml b/swagger/index.yaml index 8015c5929..e6372f23a 100644 --- a/swagger/index.yaml +++ b/swagger/index.yaml @@ -68,6 +68,7 @@ paths: - paths/batch.yaml - paths/analyses.yaml - paths/site-rules.yaml + - paths/dataexplorer.yaml securityDefinitions: diff --git a/swagger/paths/dataexplorer.yaml b/swagger/paths/dataexplorer.yaml new file mode 100644 index 000000000..b17c60e52 --- /dev/null +++ b/swagger/paths/dataexplorer.yaml @@ -0,0 +1,21 @@ +/dataexplorer/search: + post: + summary: Perform a search query + operationId: search + parameters: + - name: simple + in: query + type: boolean + - name: limit + in: query + type: integer + - name: body + in: body + required: true + schema: + $ref: schemas/input/search-query.json + responses: + '200': + description: A list of results of the search query + schema: + $ref: schemas/output/search-response-list.json diff --git a/swagger/schemas/definitions/search.json b/swagger/schemas/definitions/search.json new file mode 100644 index 000000000..218f47e72 --- /dev/null +++ b/swagger/schemas/definitions/search.json @@ -0,0 +1,128 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "definitions": { + "search-type": { + "type": "string", + "enum": ["file", "acquisition", "session", "analysis", "collection"], + "description": "Sets the type of search results to return" + }, + "search-query": { + "type": "object", + "properties": { + "return_type": {"$ref": "#/definitions/search-type"}, + "search_string": { + "type": "string", + "description": "Represents the plain text search query" + }, + "all_data": { + "type": "boolean", + "description": "When set will include all data that the user does not have access to read", + "default": false + }, + "filters": { + "type": "object", + "description": "See https://www.elastic.co/guide/en/elasticsearch/reference/current/term-level-queries.html" + } + }, + "required": ["return_type"] + }, + "search-project-response": { + "type": "object", + "properties": { + "_id": {"$ref":"container.json#/definitions/_id"}, + "label": {"$ref":"common.json#/definitions/label"} + }, + "description": "Fields for project search response" + }, + "search-group-response": { + "type": "object", + "properties": { + "_id": {"$ref":"container.json#/definitions/_id"}, + "label": {"$ref":"common.json#/definitions/label"} + }, + "description": "Fields for group search response" + }, + "search-session-response": { + "type": "object", + "properties": { + "_id": {"$ref":"container.json#/definitions/_id"}, + "label": {"$ref":"common.json#/definitions/label"}, + "timestamp": {"$ref":"common.json#/definitions/timestamp"}, + "created": {"$ref":"created-modified.json#/definitions/created"} + }, + "description": "Fields for session search response" + }, + "search-acquisition-response": { + "type": "object", + "properties": { + "_id": {"$ref":"container.json#/definitions/_id"}, + "label": {"$ref":"common.json#/definitions/label"}, + "timestamp": {"$ref":"common.json#/definitions/timestamp"}, + "created": {"$ref":"created-modified.json#/definitions/created"} + }, + "description": "Fields for acquisition search response" + }, + "search-subject-response": { + "type": "object", + "properties": { + "code": {"$ref":"subject.json#/definitions/code"} + }, + "description": "Fields for subject search response" + }, + "search-file-response": { + "type": "object", + "properties": { + "measurements": {"$ref":"file.json#/definitions/measurements"}, + "created": {"$ref":"created-modified.json#/definitions/created"}, + "type": {"$ref":"file.json#/definitions/file-type"}, + "name": {"$ref":"file.json#/definitions/name"}, + "size": {"$ref":"file.json#/definitions/size"} + }, + "description": "Fields for file search response" + }, + "search-analysis-response": { + "type": "object", + "properties": { + "_id": {"$ref":"container.json#/definitions/_id"}, + "label": {"$ref":"common.json#/definitions/label"}, + "user": {"$ref":"common.json#/definitions/user-id"}, + "created": {"$ref":"created-modified.json#/definitions/created"} + }, + "description": "Fields for acquisition search response" + }, + "search-parent-response": { + "type": "object", + "properties": { + "_id": {"$ref":"container.json#/definitions/_id"}, + "type": {"$ref":"container.json#/definitions/container-type"} + }, + "description": "Fields for parent search response" + }, + "search-collection-response": { + "type": "object", + "properties": { + "_id": {"$ref":"container.json#/definitions/_id"}, + "label": {"$ref":"common.json#/definitions/label"}, + "curator": {"$ref":"common.json#/definitions/user-id"}, + "created": {"$ref":"created-modified.json#/definitions/created"} + }, + "description": "Fields for collection search response" + }, + "search-response": { + "type": "object", + "properties": { + "project": {"$ref":"#/definitions/search-project-response"}, + "group": {"$ref":"#/definitions/search-group-response"}, + "session": {"$ref":"#/definitions/search-session-response"}, + "acquisition": {"$ref":"#/definitions/search-acquisition-response"}, + "subject": {"$ref":"#/definitions/search-subject-response"}, + "file": {"$ref":"#/definitions/search-file-response"}, + "collection": {"$ref":"#/definitions/search-collection-response"}, + "analysis": {"$ref":"#/definitions/search-analysis-response"}, + "parent": {"$ref":"#/definitions/search-parent-response"}, + "permissions": {"$ref":"permission.json#/definitions/permission-output-list"} + }, + "description": "Single search response entry" + } + } +} \ No newline at end of file diff --git a/swagger/schemas/input/search-query.json b/swagger/schemas/input/search-query.json new file mode 100644 index 000000000..5d76f2aee --- /dev/null +++ b/swagger/schemas/input/search-query.json @@ -0,0 +1,9 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "type": "object", + "allOf":[{"$ref":"../definitions/search.json#/definitions/search-query"}], + "example": { + "return_type": "session", + "search_string": "amyg" + } +} diff --git a/swagger/schemas/output/search-response-list.json b/swagger/schemas/output/search-response-list.json new file mode 100644 index 000000000..6368c2947 --- /dev/null +++ b/swagger/schemas/output/search-response-list.json @@ -0,0 +1,6 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "type": "array", + "items": {"$ref":"../definitions/search.json#/definitions/search-response"}, + "example": [] +} From e74183eab5c972d0906d6276186d322d0e7d53c3 Mon Sep 17 00:00:00 2001 From: Justin Ehlert Date: Tue, 13 Feb 2018 16:01:41 -0600 Subject: [PATCH 19/21] Cleanup packfile endpoints Removed packfile endpoints for sessions, collections, and acquisitions. Added missing parameters to packfile and packfile-end endpoints. --- swagger/paths/acquisitions.yaml | 8 -------- swagger/paths/collections.yaml | 8 -------- swagger/paths/sessions.yaml | 8 -------- swagger/templates/packfile-end.yaml | 12 +++++++++--- swagger/templates/packfile.yaml | 9 +++++++-- 5 files changed, 16 insertions(+), 29 deletions(-) diff --git a/swagger/paths/acquisitions.yaml b/swagger/paths/acquisitions.yaml index e205aff48..9367e31dc 100644 --- a/swagger/paths/acquisitions.yaml +++ b/swagger/paths/acquisitions.yaml @@ -26,14 +26,6 @@ $template_arguments: /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 diff --git a/swagger/paths/collections.yaml b/swagger/paths/collections.yaml index f4b884fca..35bd2980c 100644 --- a/swagger/paths/collections.yaml +++ b/swagger/paths/collections.yaml @@ -150,14 +150,6 @@ $template_arguments: /collections/{CollectionId}/tags/{TagValue}: $template: templates/tags-tag.yaml -# ===== Packfile ===== -/collections/{CollectionId}/packfile-start: - $template: templates/packfile-start.yaml -/collections/{CollectionId}/packfile: - $template: templates/packfile.yaml -/collections/{CollectionId}/packfile-end: - $template: templates/packfile-end.yaml - # ===== Files ===== /collections/{CollectionId}/files: $template: templates/file-list-upload.yaml diff --git a/swagger/paths/sessions.yaml b/swagger/paths/sessions.yaml index 64c9f908d..55ee24218 100644 --- a/swagger/paths/sessions.yaml +++ b/swagger/paths/sessions.yaml @@ -51,14 +51,6 @@ $template_arguments: /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 diff --git a/swagger/templates/packfile-end.yaml b/swagger/templates/packfile-end.yaml index 3af0ca3c4..02c000aa3 100644 --- a/swagger/templates/packfile-end.yaml +++ b/swagger/templates/packfile-end.yaml @@ -14,7 +14,7 @@ template: | type: string in: path name: '{{parameter}}' - post: + get: summary: End a packfile upload operationId: end_{{resource}}_packfile_upload tags: @@ -22,9 +22,15 @@ template: | produces: - text/event-stream parameters: - - in: formData - name: formData + - name: token + in: query type: string + required: true + - name: metadata + in: query + type: string + required: true + description: string-encoded metadata json object. responses: '200': description: '' diff --git a/swagger/templates/packfile.yaml b/swagger/templates/packfile.yaml index c2df8b52f..79e9edd0d 100644 --- a/swagger/templates/packfile.yaml +++ b/swagger/templates/packfile.yaml @@ -22,9 +22,14 @@ template: | consumes: - multipart/form-data parameters: - - in: formData - name: formData + - name: token + in: query type: string + required: true + - name: file + in: formData + type: file + required: true responses: '200': description: '' From b59a98c6726294b15dff9a007b7b0f58f7ac2aef Mon Sep 17 00:00:00 2001 From: Justin Ehlert Date: Fri, 2 Mar 2018 12:09:06 -0600 Subject: [PATCH 20/21] Add documentation for resolver endpoint Closes #1088 --- api/config.py | 1 + swagger/index.yaml | 1 + swagger/paths/resolver.yaml | 26 ++++++++ swagger/schemas/definitions/resolver.json | 75 +++++++++++++++++++++++ swagger/schemas/input/resolver.json | 8 +++ swagger/schemas/output/resolver.json | 75 +++++++++++++++++++++++ 6 files changed, 186 insertions(+) create mode 100644 swagger/paths/resolver.yaml create mode 100644 swagger/schemas/definitions/resolver.json create mode 100644 swagger/schemas/input/resolver.json create mode 100644 swagger/schemas/output/resolver.json diff --git a/api/config.py b/api/config.py index 7a2b7d159..135f28081 100644 --- a/api/config.py +++ b/api/config.py @@ -173,6 +173,7 @@ def apply_env_variables(config): 'project-template.json', 'project-update.json', 'propose-batch.json', + 'resolver.json', 'rule-new.json', 'rule-update.json', 'search-query.json', diff --git a/swagger/index.yaml b/swagger/index.yaml index e6372f23a..c0c2d0a1f 100644 --- a/swagger/index.yaml +++ b/swagger/index.yaml @@ -69,6 +69,7 @@ paths: - paths/analyses.yaml - paths/site-rules.yaml - paths/dataexplorer.yaml + - paths/resolver.yaml securityDefinitions: diff --git a/swagger/paths/resolver.yaml b/swagger/paths/resolver.yaml new file mode 100644 index 000000000..bced3ed73 --- /dev/null +++ b/swagger/paths/resolver.yaml @@ -0,0 +1,26 @@ +/resolve: + post: + summary: Perform path based lookup of nodes in the Flywheel hierarchy + description: | + This will perform a deep lookup of a node (i.e. group/project/session/acquisition) and its children, + including any files. The query path is an array of strings in the following order (by default): + + * group id + * project label + * session label + * acquisition label + + An ID can be used instead of a label by formatting the string as ``. The full path + to the node, and the node's children will be included in the response. + operationId: resolve_path + parameters: + - name: body + in: body + required: true + schema: + $ref: schemas/input/resolver.json + responses: + '200': + description: '' + schema: + $ref: schemas/output/resolver.json diff --git a/swagger/schemas/definitions/resolver.json b/swagger/schemas/definitions/resolver.json new file mode 100644 index 000000000..f32093f41 --- /dev/null +++ b/swagger/schemas/definitions/resolver.json @@ -0,0 +1,75 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "definitions": { + "resolver-input": { + "type": "object", + "properties": { + "path": { + "type": "array", + "minLength": 1, + "items": { + "type": "string" + } + } + }, + "required": ["path"] + }, + "resolver-output": { + "type": "object", + "properties": { + "path": { "$ref": "#/definitions/resolver-node-list" }, + "children": { "$ref": "#/definitions/resolver-node-list" } + }, + "required": ["path"] + }, + "resolver-node": { + "type": "object", + "properties": { + "node_type": { + "type": "string" + } + }, + "discriminator": "node_type", + "required": ["node_type"] + }, + "resolver-node-list": { + "type": "array", + "items": { "$ref": "#/definitions/resolver-node" } + }, + "group-node": { + "allOf": [ + {"$ref":"#/definitions/resolver-node"}, + {"$ref":"group.json#/definitions/group-output"} + ], + "x-discriminator-value": "group" + }, + "project-node": { + "allOf": [ + {"$ref":"#/definitions/resolver-node"}, + {"$ref":"project.json#/definitions/project-output"} + ], + "x-discriminator-value": "project" + }, + "session-node": { + "allOf": [ + {"$ref":"#/definitions/resolver-node"}, + {"$ref":"session.json#/definitions/session-output"} + ], + "x-discriminator-value": "session" + }, + "acquisition-node": { + "allOf": [ + {"$ref":"#/definitions/resolver-node"}, + {"$ref":"acquisition.json#/definitions/acquisition-output"} + ], + "x-discriminator-value": "acquisition" + }, + "file-node": { + "allOf": [ + {"$ref":"#/definitions/resolver-node"}, + {"$ref":"file.json#/definitions/file-output"} + ], + "x-discriminator-value": "file" + } + } +} \ No newline at end of file diff --git a/swagger/schemas/input/resolver.json b/swagger/schemas/input/resolver.json new file mode 100644 index 000000000..11acc2c06 --- /dev/null +++ b/swagger/schemas/input/resolver.json @@ -0,0 +1,8 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "type": "object", + "allOf": [{"$ref": "../definitions/resolver.json#/definitions/resolver-input"}], + "example": { + "path": ["scitran", "Neuroscience"] + } +} diff --git a/swagger/schemas/output/resolver.json b/swagger/schemas/output/resolver.json new file mode 100644 index 000000000..fd8979424 --- /dev/null +++ b/swagger/schemas/output/resolver.json @@ -0,0 +1,75 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "type":"object", + "allOf": [{ "$ref": "../definitions/resolver.json#/definitions/resolver-output" }], + "example": { + "path": [ + { + "node_type": "group", + "_id": "scitran", + "label": "Scitran", + "permissions": [ + { + "access": "admin", + "_id": "coltonlw@flywheel.io" + } + ], + "created": "2016-08-19T11:41:15.360000+00:00", + "modified": "2016-08-19T11:41:15.360000+00:00" + }, + { + "node_type": "project", + "_id": "57e452791cff88b85f9f9c97", + "label": "Neuroscience", + "group": "scitran", + "created": "2016-09-22T21:51:53.151000+00:00", + "modified": "2016-09-22T21:51:53.151000+00:00", + "public": false, + "permissions": [{ + "access": "admin", + "_id": "coltonlw@flywheel.io" + }] + } + ], + "children": [ + { + "node_type": "session", + "_id": "57e01cccb1dc04000fb83f03", + "label": "control_1", + "group": "scitran", + "created": "2016-09-19T17:13:48.164000+00:00", + "subject": { + "code": "ex4784", + "_id": "57e01cccb1dc04000fb83f02" + }, + "modified": "2016-09-19T17:13:48.164000+00:00", + "project": "57e01cccf6b5d5edbcb4e1cf", + "public": false, + "permissions": [{ + "access": "admin", + "_id": "coltonlw@flywheel.io" + }] + }, + { + "node_type": "file", + "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", + "modality": null, + "info": {}, + "type": "dicom", + "size": 989933 + } + ] + } +} From 38d9a38c30a50beb2f59a45784202a2d73d2e80f Mon Sep 17 00:00:00 2001 From: Justin Ehlert Date: Thu, 15 Mar 2018 13:57:42 -0500 Subject: [PATCH 21/21] Remove input property from analysis example --- swagger/schemas/output/analyses-list.json | 1 - 1 file changed, 1 deletion(-) diff --git a/swagger/schemas/output/analyses-list.json b/swagger/schemas/output/analyses-list.json index 988581c68..858056b0f 100644 --- a/swagger/schemas/output/analyses-list.json +++ b/swagger/schemas/output/analyses-list.json @@ -15,7 +15,6 @@ "measurements": [], "modified": "2016-10-18T15:26:35.701000+00:00", "modality": null, - "input": true, "size": 21804112, "type": "None", "info": {}