Skip to content

Commit b4e9c58

Browse files
committed
Expose create_task to allow unpublished task type creation for the python client
1 parent 69c5ea5 commit b4e9c58

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

scaleapi/__init__.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -111,14 +111,14 @@ def tasks(self, **kwargs):
111111
docs = [Task(json, self) for json in response['docs']]
112112
return Tasklist(docs, response['total'], response['limit'],
113113
response['offset'], response['has_more'])
114-
115-
116-
def _AddTaskTypeCreator(name):
117-
endpoint = 'task/' + name
118-
def createTask(self, **kwargs):
114+
def create_task(self, task_type, **kwargs):
115+
endpoint = 'task/' + task_type
119116
taskdata = self._postrequest(endpoint, payload=kwargs)
120117
return Task(taskdata, self)
121-
setattr(ScaleClient, 'create_' + name + '_task', createTask)
118+
119+
120+
def _AddTaskTypeCreator(task_type):
121+
setattr(ScaleClient, 'create_' + task_type + '_task', lambda (self, **kwargs): self.create_task(self, task_type, **kwargs))
122122

123123
for taskType in TASK_TYPES:
124124
_AddTaskTypeCreator(taskType)

0 commit comments

Comments
 (0)