Hello.
I am looking for a way to get all objects from the Smart-1 management server (for example, all hosts and networks, all rules, etc.) At the moment, the api allows you to get only 500 items per request, which can be thousands. Is there a way to get all the objects?
Moreover, when I'm start manipulating the offset parameter increasing it value by 500 with each subsequent request and the database contains 510 hosts, then the second request with offset=500 will return 500 hosts instead of 10. So I can't get all the objects even in a loop.
Here is an example of the code I use to get hosts.
def cp_api_call(command, payload, cp_session):
if cp_session == '':
headers = {'Content-Type': 'application/json'}
else:
headers = {'Content-Type': 'application/json', 'X-chkp-sid': cp_session}
try:
r = requests.post(cp_url + command, json = payload, headers = headers, verify = False)
code = r.status_code
if code == 200:
return r.json()
else:
print(r.json())
except ConnectionError:
print('ERROR: Connection error, retry after 10 seconds.')
sleep(10)
r = requests.post(cp_url + command, json = payload, headers = headers, verify = False)
return r.json()
def cp_show_hosts(cp_session):
payload = {
'limit' : 500,
'offset' : 0,
'details-level' : 'standard'
}
r = cp_api_call('show-hosts', payload, cp_session)