File tree Expand file tree Collapse file tree 2 files changed +13
-5
lines changed Expand file tree Collapse file tree 2 files changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -46,6 +46,7 @@ def __init__(
4646 num_pools : int = 10 ,
4747 retries : int = 3 ,
4848 base : str = BASE ,
49+ pagination : bool = True ,
4950 verbose : bool = False ,
5051 trace : bool = False ,
5152 custom_json : Optional [Any ] = None ,
@@ -57,6 +58,7 @@ def __init__(
5758 num_pools = num_pools ,
5859 retries = retries ,
5960 base = base ,
61+ pagination = pagination ,
6062 verbose = verbose ,
6163 trace = trace ,
6264 custom_json = custom_json ,
@@ -68,6 +70,7 @@ def __init__(
6870 num_pools = num_pools ,
6971 retries = retries ,
7072 base = base ,
73+ pagination = pagination ,
7174 verbose = verbose ,
7275 trace = trace ,
7376 custom_json = custom_json ,
Original file line number Diff line number Diff line change 1010from .models .request import RequestOptionBuilder
1111from ..logging import get_logger
1212import logging
13- from urllib .parse import urlencode
13+ from urllib .parse import urlencode , urlparse
1414from ..exceptions import AuthError , BadResponse
1515
1616logger = get_logger ("RESTClient" )
@@ -30,6 +30,7 @@ def __init__(
3030 num_pools : int ,
3131 retries : int ,
3232 base : str ,
33+ pagination : bool ,
3334 verbose : bool ,
3435 trace : bool ,
3536 custom_json : Optional [Any ] = None ,
@@ -41,6 +42,7 @@ def __init__(
4142
4243 self .API_KEY = api_key
4344 self .BASE = base
45+ self .pagination = pagination
4446
4547 self .headers = {
4648 "Authorization" : "Bearer " + self .API_KEY ,
@@ -227,11 +229,14 @@ def _paginate_iter(
227229 return []
228230 for t in decoded [result_key ]:
229231 yield deserializer (t )
230- if "next_url" in decoded :
231- path = decoded ["next_url" ].replace (self .BASE , "" )
232- params = {}
233- else :
232+ if not self .pagination or "next_url" not in decoded :
234233 return
234+ next_url = decoded ["next_url" ]
235+ parsed = urlparse (next_url )
236+ path = parsed .path
237+ if parsed .query :
238+ path += "?" + parsed .query
239+ params = {}
235240
236241 def _paginate (
237242 self ,
You can’t perform that action at this time.
0 commit comments