@@ -33,14 +33,14 @@ class ScaleInvalidRequest(ScaleException, ValueError):
33
33
34
34
35
35
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 ):
37
37
super (Tasklist , self ).__init__ (docs )
38
38
self .docs = docs
39
39
self .total = total
40
40
self .limit = limit
41
41
self .offset = offset
42
42
self .has_more = has_more
43
-
43
+ self . next_token = next_token
44
44
45
45
class ScaleClient (object ):
46
46
def __init__ (self , api_key ):
@@ -110,24 +110,28 @@ def cancel_task(self, task_id):
110
110
111
111
def tasks (self , ** kwargs ):
112
112
"""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.
114
116
115
117
start/end_time are ISO8601 dates, the time range of tasks to fetch.
116
118
status can be 'completed', 'pending', or 'canceled'.
117
119
type is the task type.
118
120
limit is the max number of results to display per page,
119
- offset is the number of results to skip (for showing more pages).
121
+ next_token can be use to fetch the next page of tasks.
122
+ offset (deprecated) is the number of results to skip (for showing more pages).
120
123
"""
121
124
allowed_kwargs = {'start_time' , 'end_time' , 'status' , 'type' , 'project' ,
122
- 'batch' , 'limit' , 'offset' , 'completed_before' , 'completed_after' }
125
+ 'batch' , 'limit' , 'offset' , 'completed_before' , 'completed_after' ,
126
+ 'next_token' }
123
127
for key in kwargs :
124
128
if key not in allowed_kwargs :
125
129
raise ScaleInvalidRequest ('Illegal parameter %s for ScaleClient.tasks()'
126
130
% key , None )
127
131
response = self ._getrequest ('tasks' , params = kwargs )
128
132
docs = [Task (json , self ) for json in response ['docs' ]]
129
133
return Tasklist (docs , response ['total' ], response ['limit' ],
130
- response ['offset' ], response ['has_more' ])
134
+ response ['offset' ], response ['has_more' ], response . get ( 'next_token' ) )
131
135
def create_task (self , task_type , ** kwargs ):
132
136
endpoint = 'task/' + task_type
133
137
taskdata = self ._postrequest (endpoint , payload = kwargs )
0 commit comments