diff --git a/api/config.py b/api/config.py index 6c231dbff..135f28081 100644 --- a/api/config.py +++ b/api/config.py @@ -160,17 +160,23 @@ def apply_env_variables(config): 'file.json', 'file-list.json', 'file-update.json', + 'gear.json', 'group-new.json', 'group-update.json', 'info_update.json', + 'job-logs.json', + 'job-new.json', 'note.json', 'packfile.json', 'permission.json', 'project.json', 'project-template.json', 'project-update.json', + 'propose-batch.json', + 'resolver.json', 'rule-new.json', 'rule-update.json', + 'search-query.json', 'session.json', 'session-update.json', 'subject.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/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/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/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/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 b9ed8a6e4..c0c2d0a1f 100644 --- a/swagger/index.yaml +++ b/swagger/index.yaml @@ -12,36 +12,42 @@ 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: default paths: $include: - 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 @@ -60,6 +66,10 @@ paths: - paths/projects.yaml - paths/report.yaml - paths/batch.yaml + - paths/analyses.yaml + - paths/site-rules.yaml + - paths/dataexplorer.yaml + - paths/resolver.yaml securityDefinitions: diff --git a/swagger/paths/acquisitions.yaml b/swagger/paths/acquisitions.yaml index 81ee635f0..9367e31dc 100644 --- a/swagger/paths/acquisitions.yaml +++ b/swagger/paths/acquisitions.yaml @@ -17,25 +17,22 @@ $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 /acquisitions/{AcquisitionId}/tags/{TagValue}: $template: templates/tags-tag.yaml -# ===== Packfile ===== -/acquisitions/{AcquisitionId}/packfile-start: - $template: templates/packfile-start.yaml -/acquisitions/{AcquisitionId}/packfile: - $template: templates/packfile.yaml -/acquisitions/{AcquisitionId}/packfile-end: - $template: templates/packfile-end.yaml - # ===== Files ===== /acquisitions/{AcquisitionId}/files: $template: templates/file-list-upload.yaml /acquisitions/{AcquisitionId}/files/{FileName}: $template: templates/file-item.yaml +/acquisitions/{AcquisitionId}/files/{FileName}/info: + $template: templates/file-item-info.yaml # ===== Notes ===== /acquisitions/{AcquisitionId}/notes: @@ -46,8 +43,12 @@ $template_arguments: # ===== Analyses ===== /acquisitions/{AcquisitionId}/analyses: $template: templates/analyses-list.yaml + arguments: + allowCreate: true /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..6c3be8aee --- /dev/null +++ b/swagger/paths/analyses.yaml @@ -0,0 +1,76 @@ +$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 + +/{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/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/paths/collections.yaml b/swagger/paths/collections.yaml index e3ba2343b..35bd2980c 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 @@ -118,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 @@ -142,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 @@ -161,6 +161,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: @@ -171,8 +173,12 @@ $template_arguments: # ===== Analyses ===== /collections/{CollectionId}/analyses: $template: templates/analyses-list.yaml + arguments: + allowCreate: true /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/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/paths/gears.yaml b/swagger/paths/gears.yaml index b34f53681..6f9ccac10 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,54 @@ 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 + +/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 + + diff --git a/swagger/paths/jobs.yaml b/swagger/paths/jobs.yaml index 04c328ef3..38e26dc69 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: '' @@ -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: '' @@ -89,7 +96,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 +105,7 @@ parameters: - name: body in: body + required: true schema: example: $ref: examples/input/job-update.json @@ -142,3 +150,76 @@ schema: example: $ref: examples/output/job-config.json +/jobs/{JobId}/logs: + parameters: + - required: true + 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_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. +/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 diff --git a/swagger/paths/projects.yaml b/swagger/paths/projects.yaml index f5c63a463..b5f78ef04 100644 --- a/swagger/paths/projects.yaml +++ b/swagger/paths/projects.yaml @@ -16,12 +16,15 @@ $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 operationId: get_all_projects_groups tags: - - 'projects' + - projects responses: '200': description: '' @@ -38,7 +41,7 @@ $template_arguments: summary: List all sessions for the given project. operationId: get_project_sessions tags: - - 'projects' + - projects responses: '200': description: '' @@ -55,23 +58,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 +86,8 @@ $template_arguments: summary: Create a new rule for a project. operationId: add_project_rule tags: - - 'projects' + - projects + - rules responses: default: description: '' @@ -91,7 +97,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 +107,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 +131,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 +152,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 +167,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 +185,7 @@ $template_arguments: description: Returns list of modified session ids. operationId: recalc_project tags: - - 'projects' + - projects responses: '200': description: | @@ -179,7 +205,7 @@ $template_arguments: Returns list of modified session ids. operationId: recalc_all_projects tags: - - 'projects' + - projects responses: '200': description: | @@ -208,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: @@ -224,8 +252,12 @@ $template_arguments: # ===== Analyses ===== /projects/{ProjectId}/analyses: $template: templates/analyses-list.yaml + arguments: + allowCreate: true /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/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/paths/sessions.yaml b/swagger/paths/sessions.yaml index de7beef7c..55ee24218 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 @@ -48,19 +51,13 @@ $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 /sessions/{SessionId}/files/{FileName}: $template: templates/file-item.yaml +/sessions/{SessionId}/files/{FileName}/info: + $template: templates/file-item-info.yaml # ===== Notes ===== /sessions/{SessionId}/notes: @@ -88,28 +85,13 @@ $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: + supportsDelete: true /sessions/{SessionId}/analyses/{AnalysisId}/inputs: $template: templates/analysis-files.yaml arguments: 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/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 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/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/analysis.json b/swagger/schemas/definitions/analysis.json index 3d0f37cb3..1c963712e 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"} + }, + "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/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/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/definitions/job.json b/swagger/schemas/definitions/job.json index 5b06bd041..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": { @@ -53,6 +65,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"} @@ -68,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/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/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/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/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/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!" } + ] +} 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/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/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/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/analyses-list.json b/swagger/schemas/output/analyses-list.json new file mode 100644 index 000000000..858056b0f --- /dev/null +++ b/swagger/schemas/output/analyses-list.json @@ -0,0 +1,29 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "type": "array", + "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, + "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" + }] +} 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": {} + } +} 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/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"}] +} 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!" } + ] + } +} 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 + } + ] + } +} 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"} +} 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": [] +} 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..22d5ef522 100644 --- a/swagger/templates/analyses-list.yaml +++ b/swagger/templates/analyses-list.yaml @@ -1,27 +1,60 @@ parameters: - name: resource type: string + required: true - name: parameter type: string + required: true - 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-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..958017691 100644 --- a/swagger/templates/analysis-item.yaml +++ b/swagger/templates/analysis-item.yaml @@ -5,21 +5,37 @@ 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}}' + parameters: + - name: inflate_job + in: query + type: boolean + description: Return job as an object instead of an id responses: '200': description: '' @@ -28,11 +44,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..58dc6b9ae 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 @@ -23,6 +26,7 @@ template: | parameters: - name: body in: body + required: true schema: $ref: schemas/input/note.json responses: 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/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-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' + + diff --git a/swagger/templates/file-item.yaml b/swagger/templates/file-item.yaml index 5cc66a2ae..3db7397ae 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 @@ -83,4 +86,18 @@ template: | responses: '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' 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..02c000aa3 100644 --- a/swagger/templates/packfile-end.yaml +++ b/swagger/templates/packfile-end.yaml @@ -1,17 +1,20 @@ 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: + get: summary: End a packfile upload operationId: end_{{resource}}_packfile_upload tags: @@ -19,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-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..79e9edd0d 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 @@ -19,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: '' 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