Skip to content

Commit 4f6e780

Browse files
author
Joseph Zanini
authored
Merge pull request #169 from oOraph/fix_pagination
Bug regarding pagination when listing rest resources
2 parents 9a420ae + d055632 commit 4f6e780

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

webexteamssdk/restsession.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060

6161

6262
# Helper Functions
63-
def _fix_next_url(next_url):
63+
def _fix_next_url(next_url, params):
6464
"""Remove max=null parameter from URL.
6565
6666
Patch for Webex Teams Defect: "next" URL returned in the Link headers of
@@ -96,6 +96,10 @@ def _fix_next_url(next_url):
9696
query_list.remove("max=null")
9797
warnings.warn("`max=null` still present in next-URL returned "
9898
"from Webex Teams", RuntimeWarning)
99+
if params:
100+
for k, v in params.items():
101+
if not any(p.startswith('{}='.format(k)) for p in query_list):
102+
query_list.append('{}={}'.format(k, v))
99103
new_query = "&".join(query_list)
100104
parsed_url = list(parsed_url)
101105
parsed_url[4] = new_query
@@ -151,7 +155,7 @@ def user_agent(be_geo_id=None, caller=None):
151155
data["cpu"] = platform.machine()
152156

153157
data["organization"] = {}
154-
158+
155159
# Add self-identified organization information to the User-Agent Header.
156160
if be_geo_id:
157161
data["organization"]["be_geo_id"] = be_geo_id
@@ -231,7 +235,6 @@ def __init__(self, access_token, base_url,
231235
if disable_ssl_verify:
232236
self._req_session.verify = False
233237

234-
235238
if proxies is not None:
236239
self._req_session.proxies.update(proxies)
237240

@@ -424,11 +427,13 @@ def get_pages(self, url, params=None, **kwargs):
424427
if response.links.get("next"):
425428
next_url = response.links.get("next").get("url")
426429

427-
# Patch for Webex Teams "max=null" in next URL bug.
430+
# Patch for Webex Teams "max=null" in next URL bug + missing
431+
# params, like mentionedPeople, which can be mandatory for
432+
# bots
428433
# Testing shows that patch is no longer needed; raising a
429434
# warnning if it is still taking effect;
430435
# considering for future removal
431-
next_url = _fix_next_url(next_url)
436+
next_url = _fix_next_url(next_url, params)
432437

433438
# Subsequent requests
434439
response = self.request("GET", next_url, erc, **kwargs)

0 commit comments

Comments
 (0)