Skip to content

Commit 6f66093

Browse files
author
Yuan Yao
committed
Update TaskList object
1 parent b6eb246 commit 6f66093

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

scaleapi/__init__.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,14 @@ class ScaleInvalidRequest(ScaleException, ValueError):
3333

3434

3535
class Tasklist(list):
36-
def __init__(self, docs, total, limit, offset, has_more):
36+
def __init__(self, docs, total, limit, offset, has_more, next_token=None):
3737
super(Tasklist, self).__init__(docs)
3838
self.docs = docs
3939
self.total = total
4040
self.limit = limit
4141
self.offset = offset
4242
self.has_more = has_more
43-
43+
self.next_token = next_token
4444

4545
class ScaleClient(object):
4646
def __init__(self, api_key):
@@ -110,7 +110,9 @@ def cancel_task(self, task_id):
110110

111111
def tasks(self, **kwargs):
112112
"""Returns a list of your tasks.
113-
Returns up to 100 at a time, to get more use the offset param.
113+
Returns up to 100 at a time, to get more, use the next_token param passed back.
114+
115+
Note that offset is deprecated.
114116
115117
start/end_time are ISO8601 dates, the time range of tasks to fetch.
116118
status can be 'completed', 'pending', or 'canceled'.
@@ -128,7 +130,7 @@ def tasks(self, **kwargs):
128130
response = self._getrequest('tasks', params=kwargs)
129131
docs = [Task(json, self) for json in response['docs']]
130132
return Tasklist(docs, response['total'], response['limit'],
131-
response['offset'], response['has_more'])
133+
response['offset'], response['has_more'], response.get('next_token'))
132134
def create_task(self, task_type, **kwargs):
133135
endpoint = 'task/' + task_type
134136
taskdata = self._postrequest(endpoint, payload=kwargs)

0 commit comments

Comments
 (0)