77import requests
88from atomx .version import API_VERSION , VERSION
99from atomx import models
10- from atomx .utils import get_model_name
10+ from atomx .utils import (
11+ get_model_name ,
12+ model_name_to_rest ,
13+ )
1114from atomx .exceptions import (
1215 APIError ,
1316 ModelNotFoundError ,
@@ -213,7 +216,7 @@ def report_status(self, report):
213216 raise APIError (r .json ()['error' ])
214217 return r .json ()['report' ]
215218
216- def report_get (self , report ):
219+ def report_get (self , report , limit = None , sort = None ):
217220 """Get the content (csv) of a :class:`.models.Report`
218221
219222 Typically used by calling :meth:`.models.Report.content` or
@@ -229,7 +232,13 @@ def report_get(self, report):
229232 else :
230233 report_id = report
231234
232- r = self .session .get (self .api_endpoint + 'report/' + report_id )
235+ params = {}
236+ if limit :
237+ params ['limit' ] = int (limit )
238+ if sort :
239+ params ['sort' ] = sort
240+
241+ r = self .session .get (self .api_endpoint + 'report/' + report_id , params = params )
233242 if not r .ok :
234243 raise APIError (r .json ()['error' ])
235244 return r .content .decode ()
@@ -286,6 +295,9 @@ def get(self, resource, **kwargs):
286295 model = get_model_name (model_name )
287296 if model :
288297 if isinstance (res , list ):
298+ if model_name .endswith ('_list' ):
299+ # special case for _list requests
300+ res = [{'id' : id , 'name' : name } for id , name in res ]
289301 return [getattr (models , model )(self , ** m ) for m in res ]
290302 return getattr (models , model )(self , ** res )
291303 return res
0 commit comments