New method for file datastore api endpoint

This commit is contained in:
mike cullerton 2021-06-01 13:50:04 -04:00
parent e9fe555e05
commit 1ed144536f
1 changed files with 11 additions and 1 deletions

View File

@ -5,7 +5,7 @@ from crc import session
from crc.api.common import ApiError
from crc.models.data_store import DataStoreModel, DataStoreSchema
from crc.scripts.data_store_base import DataStoreBase
from crc.models.file import FileModel
def study_multi_get(study_id):
"""Get all data_store values for a given study_id study"""
@ -30,6 +30,16 @@ def user_multi_get(user_id):
return results
def file_multi_get(file_id):
"""Get all data values in the data store for a file_id"""
if file_id is None:
raise ApiError(code='unknown_file', message='Please provide a valid file id.')
dsb = DataStoreBase()
retval = dsb.get_multi_common(None, None, file_id=file_id)
results = DataStoreSchema(many=True).dump(retval)
return results
def datastore_del(id):
"""Delete a data store item for a key"""
session.query(DataStoreModel).filter_by(id=id).delete()