Skip to content
This repository has been archived by the owner on Feb 6, 2023. It is now read-only.

Commit

Permalink
Merge pull request #196 from community-fabric/recursion_fix
Browse files Browse the repository at this point in the history
Fix for RecursionError for large tables.
  • Loading branch information
Justin Jeffery authored Dec 7, 2022
2 parents 82f13c9 + db4e8ec commit 2e07081
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 12 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## 6.0.6 (2022-12-07)

### Fix

* Updated dependencies
* Fix for RecursionError for large tables.

## 6.0.5 (2022-12-02)

### Fix
Expand Down
22 changes: 13 additions & 9 deletions ipfabric/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,25 +286,29 @@ def _ipf_pager(
self,
url: str,
payload: dict,
data: Optional[Union[list, None]] = None,
limit: int = 1000,
start: int = 0,
):
"""
Loops through and collects all the data from the tables
:param url: str: Full URL to post to
:param payload: dict: Data to submit to IP Fabric
:param data: list: List of data to append subsequent calls
:param start: int: Where to start for the data
:return: list: List of dictionaries
"""
data = data or list()
payload["pagination"] = dict(limit=limit)
data = list()

payload["pagination"] = dict(limit=limit, start=start)
r = self.post(url, json=payload)
r.raise_for_status()
r_data = r.json()["data"]
def page(s):
payload["pagination"]["start"] = s
r = self.post(url, json=payload)
r.raise_for_status()
return r.json()["data"]

r_data = page(start)
data.extend(r_data)
if limit == len(r_data):
self._ipf_pager(url, payload, data, limit=limit, start=start + limit)
while limit == len(r_data):
start = start + limit
r_data = page(start)
data.extend(r_data)
return data
6 changes: 3 additions & 3 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 2e07081

Please sign in to comment.