diff --git a/CHANGELOG.md b/CHANGELOG.md index adccd13..28d07a5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/ipfabric/api.py b/ipfabric/api.py index 2b722c3..c92863f 100644 --- a/ipfabric/api.py +++ b/ipfabric/api.py @@ -286,7 +286,6 @@ def _ipf_pager( self, url: str, payload: dict, - data: Optional[Union[list, None]] = None, limit: int = 1000, start: int = 0, ): @@ -294,17 +293,22 @@ def _ipf_pager( 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 diff --git a/poetry.lock b/poetry.lock index 34e06c0..f9d43b8 100644 --- a/poetry.lock +++ b/poetry.lock @@ -314,7 +314,7 @@ python-versions = ">=3.7" [[package]] name = "platformdirs" -version = "2.5.4" +version = "2.6.0" description = "A small Python package for determining appropriate platform-specific dirs, e.g. a \"user data dir\"." category = "dev" optional = false @@ -803,8 +803,8 @@ pathspec = [ {file = "pathspec-0.10.2.tar.gz", hash = "sha256:8f6bf73e5758fd365ef5d58ce09ac7c27d2833a8d7da51712eac6e27e35141b0"}, ] platformdirs = [ - {file = "platformdirs-2.5.4-py3-none-any.whl", hash = "sha256:af0276409f9a02373d540bf8480021a048711d572745aef4b7842dad245eba10"}, - {file = "platformdirs-2.5.4.tar.gz", hash = "sha256:1006647646d80f16130f052404c6b901e80ee4ed6bef6792e1f238a8969106f7"}, + {file = "platformdirs-2.6.0-py3-none-any.whl", hash = "sha256:1a89a12377800c81983db6be069ec068eee989748799b946cce2a6e80dcc54ca"}, + {file = "platformdirs-2.6.0.tar.gz", hash = "sha256:b46ffafa316e6b83b47489d240ce17173f123a9b9c83282141c3daf26ad9ac2e"}, ] pluggy = [ {file = "pluggy-1.0.0-py2.py3-none-any.whl", hash = "sha256:74134bbf457f031a36d68416e1509f34bd5ccc019f0bcc952c7b909d06b37bd3"},