From 949f3be40345145e76c3cdab5f69c1ec6f8c9736 Mon Sep 17 00:00:00 2001 From: Kelly McDonald Date: Mon, 12 Apr 2021 12:23:33 -0400 Subject: [PATCH] give an endpoint to return all files associated with a study --- crc/api.yml | 6 ++++++ crc/api/file.py | 9 ++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/crc/api.yml b/crc/api.yml index 6dc1afa6..da466058 100644 --- a/crc/api.yml +++ b/crc/api.yml @@ -565,6 +565,12 @@ paths: description: The unique key of a workflow task form field. Make sure this matches a document in the irb_documents.xslx reference sheet. schema: type: string + - name: study_id + in: query + required: false + description: The study that the files are related to + schema: + type: integer get: operationId: crc.api.file.get_files summary: Provides a list of files that match the given parameters (such as a spec id) IMPORTANT, only includes metadata, not the file content. diff --git a/crc/api/file.py b/crc/api/file.py index 861f9f04..035b8086 100644 --- a/crc/api/file.py +++ b/crc/api/file.py @@ -17,13 +17,16 @@ def to_file_api(file_model): FileService.get_doc_dictionary()) -def get_files(workflow_spec_id=None, workflow_id=None, form_field_key=None): - if all(v is None for v in [workflow_spec_id, workflow_id, form_field_key]): +def get_files(workflow_spec_id=None, workflow_id=None, form_field_key=None,study_id=None): + if all(v is None for v in [workflow_spec_id, workflow_id, form_field_key,study_id]): raise ApiError('missing_parameter', 'Please specify either a workflow_spec_id or a ' 'workflow_id with an optional form_field_key') - file_models = FileService.get_files(workflow_spec_id=workflow_spec_id, + if study_id is not None: + file_models = FileService.get_files_for_study(study_id=study_id) + else: + file_models = FileService.get_files(workflow_spec_id=workflow_spec_id, workflow_id=workflow_id, irb_doc_code=form_field_key)