Skip to content

Commit 7508cd0

Browse files
committed
Add limit option for api_query
In cases you would like to control the page size in api_query you need to control limit param. Use case: i would like to do show-access-rulebase in UID level and it will be faster if i will use limit=500 rather than limit=50 (less API commands to server)
1 parent fab9dff commit 7508cd0

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

cpapi/mgmt_api.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ def gen_api_query(self, command, details_level="standard", container_keys=None,
376376
:param payload: a JSON object (or a string representing a JSON object) with the command arguments
377377
:yields: an APIResponse object as detailed above
378378
"""
379-
limit = 50 # each time get no more than 50 objects
379+
380380
finished = False # will become true after getting all the data
381381
all_objects = {} # accumulate all the objects from all the API calls
382382

@@ -395,8 +395,11 @@ def gen_api_query(self, command, details_level="standard", container_keys=None,
395395
for key in container_keys:
396396
all_objects[key] = []
397397
iterations = 0 # number of times we've made an API call
398+
limit = 50 # page size to get for each api call
398399
if payload is None:
399400
payload = {}
401+
else:
402+
limit = int(payload.get("limit", limit))
400403

401404
payload.update({"limit": limit, "offset": iterations * limit, "details-level": details_level})
402405
api_res = self.api_call(command, payload)

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
setup(
55
name="cpapi",
6-
version="1.0.1",
6+
version="1.0.2",
77
author="API team",
88
author_email="[email protected]",
99
description="Check Point Management API SDK",

0 commit comments

Comments
 (0)