88import json
99import random
1010import string
11- import logging
1211
1312
1413class CrowdAPI :
@@ -85,8 +84,8 @@ def get_user_groups(self, **kwargs):
8584 if "username" not in kwargs :
8685 raise ValueError ("Must pass username" )
8786
88- req = self .api_get ("/user/group/direct?username={}&max-results={}" .format (
89- kwargs ['username' ], kwargs .get ('max_results' , 1000 )))
87+ req = self .api_get ("/user/group/direct?username={}&max-results={}&start-index={} " .format (
88+ kwargs ['username' ], kwargs .get ('max_results' , 1000 ), kwargs . get ( 'start_index' , 0 ) ))
9089 if req .status_code == 200 :
9190 for group in req .json ()['groups' ]:
9291 groups .append (group ['name' ])
@@ -103,8 +102,8 @@ def get_group_users(self, **kwargs):
103102 if "groupname" not in kwargs :
104103 raise ValueError ("Must pass username" )
105104
106- req = self .api_get ("/group/user/direct?groupname={}&max-results={}" .format (
107- kwargs ['groupname' ], kwargs .get ('max_results' , 1000 )))
105+ req = self .api_get ("/group/user/direct?groupname={}&max-results={}}&start-index={} " .format (
106+ kwargs ['groupname' ], kwargs .get ('max_results' , 1000 ), kwargs . get ( 'start_index' , 0 ) ))
108107 if req .status_code == 200 :
109108 for user in req .json ()['users' ]:
110109 users .append (user ['name' ])
@@ -173,7 +172,8 @@ def get_all_groups(self, **kwargs):
173172 groups = []
174173
175174 req = self .api_get (
176- "/search?entity-type=group&max-results={}" .format (kwargs .get ('max_results' , 1000 )))
175+ "/search?entity-type=group&max-results={}&start-index={}" .format (
176+ kwargs .get ('max_results' , 1000 ), kwargs .get ('start_index' , 0 )))
177177
178178 if req .status_code == 200 :
179179 for group in req .json ()['groups' ]:
@@ -192,7 +192,8 @@ def search_group(self, **kwargs):
192192 raise ValueError ("You need to define a certian restriction" )
193193
194194 req = self .api_get (
195- "/search?entity-type=group&restriction={}&max-results={}" .format (kwargs ['restriction' ], kwargs .get ('max_results' , 1000 )))
195+ "/search?entity-type=group&restriction={}&max-results={}&start-index={}" .format (
196+ kwargs ['restriction' ], kwargs .get ('max_results' , 1000 ), kwargs .get ('start_index' , 0 )))
196197
197198 if req .status_code == 200 :
198199 for group in req .json ()['groups' ]:
@@ -208,7 +209,8 @@ def get_all_users(self, **kwargs):
208209 users = []
209210
210211 req = self .api_get (
211- "/search?entity-type=user&max-results={}" .format (kwargs .get ('max_results' , 1000 )))
212+ "/search?entity-type=user&max-results={}&start-index={}" .format (
213+ kwargs .get ('max_results' , 1000 ), kwargs .get ('start_index' , 0 )))
212214 if req .status_code == 200 :
213215 for user in req .json ()['users' ]:
214216 users .append (user ['name' ])
@@ -223,10 +225,11 @@ def search_user(self, **kwargs):
223225 users = []
224226
225227 if 'restriction' not in kwargs :
226- raise ValueError ("You need to define a certian restriction" )
228+ raise ValueError ("You need to define a certain restriction" )
227229
228230 req = self .api_get (
229- "/search?entity-type=user&restriction={}&max-results={}" .format (kwargs ['restriction' ], kwargs .get ('max_results' , 1000 )))
231+ "/search?entity-type=user&restriction={}&max-results={}&start-index={}" .format (
232+ kwargs ['restriction' ], kwargs .get ('max_results' , 1000 ), kwargs .get ('start_index' , 0 )))
230233 if req .status_code == 200 :
231234 for user in req .json ()['users' ]:
232235 users .append (user ['name' ])
@@ -237,7 +240,6 @@ def search_user(self, **kwargs):
237240 else :
238241 return {"status" : False , "code" : req .status_code , "reason" : req .content }
239242
240-
241243 def set_user_attribute (self , ** kwargs ):
242244 if "username" not in kwargs :
243245 raise ValueError ("Must pass username" )
@@ -279,7 +281,6 @@ def set_user_activity(self, **kwargs):
279281 else :
280282 return {"status" : False , "code" : req .status_code , "reason" : req .content }
281283
282-
283284 def create_user (self , ** kwargs ):
284285 user = {}
285286
0 commit comments