2021-04-26 13:41:14 +00:00
|
|
|
from flask import g
|
|
|
|
|
|
|
|
from crc.api.common import ApiError
|
2021-06-02 14:00:55 +00:00
|
|
|
from crc.services.data_store_service import DataStoreBase
|
2021-04-26 13:41:14 +00:00
|
|
|
from crc.scripts.script import Script
|
|
|
|
|
|
|
|
|
|
|
|
class FileDataGet(Script, DataStoreBase):
|
|
|
|
def get_description(self):
|
|
|
|
return """Gets user data from the data store - takes only two keyword arguments arguments: 'file_id' and 'key' """
|
|
|
|
|
|
|
|
def do_task_validate_only(self, task, study_id, workflow_id, *args, **kwargs):
|
2021-04-28 14:03:52 +00:00
|
|
|
if self.validate_kw_args(**kwargs):
|
|
|
|
myargs = [kwargs['key']]
|
|
|
|
return True
|
2021-04-26 13:41:14 +00:00
|
|
|
|
|
|
|
def validate_kw_args(self,**kwargs):
|
|
|
|
if kwargs.get('key',None) is None:
|
|
|
|
raise ApiError(code="missing_argument",
|
|
|
|
message=f"The 'file_data_get' script requires a keyword argument of 'key'")
|
|
|
|
|
|
|
|
if kwargs.get('file_id',None) is None:
|
|
|
|
raise ApiError(code="missing_argument",
|
|
|
|
message=f"The 'file_data_get' script requires a keyword argument of 'file_id'")
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
|
|
def do_task(self, task, study_id, workflow_id, *args, **kwargs):
|
|
|
|
if self.validate_kw_args(**kwargs):
|
|
|
|
myargs = [kwargs['key']]
|
2021-04-30 14:11:50 +00:00
|
|
|
if 'default' in kwargs.keys():
|
|
|
|
myargs.append(kwargs['default'])
|
2021-04-26 13:41:14 +00:00
|
|
|
|
|
|
|
return self.get_data_common(None,
|
|
|
|
None,
|
|
|
|
'file_data_get',
|
|
|
|
kwargs['file_id'],
|
|
|
|
*myargs)
|