<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: CP python SDK - api_query function in API / CLI Discussion</title>
    <link>https://community.checkpoint.com/t5/API-CLI-Discussion/CP-python-SDK-api-query-function/m-p/62342#M3921</link>
    <description>I figured it out - you need to use the correct 'container key'. By default it will pass a json container of "objects" but in the case of show-access-rulebase the container is 'rulebase' - once I set the correct container it works as I would expect. thxs &lt;a href="https://community.checkpoint.com/t5/user/viewprofilepage/user-id/186"&gt;@Amiad_Stern&lt;/a&gt;</description>
    <pubDate>Tue, 10 Sep 2019 01:20:42 GMT</pubDate>
    <dc:creator>Richard_Carson</dc:creator>
    <dc:date>2019-09-10T01:20:42Z</dc:date>
    <item>
      <title>CP python SDK - api_query function</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/CP-python-SDK-api-query-function/m-p/61947#M3903</link>
      <description>&lt;P&gt;As i understand it in the python sdk, api_query should return all objects and handle all the require API paging. This seems to work for show-host\show objects&lt;/P&gt;&lt;P&gt;"to": 45766,&lt;BR /&gt;"total": 45766&lt;BR /&gt;},&lt;BR /&gt;"status_code": 200&lt;/P&gt;&lt;P&gt;however for show-access-rules&lt;/P&gt;&lt;P&gt;client.api_query(command="show-access-rulebase",payload={"name" : "MyPolicy Security"})&lt;/P&gt;&lt;P&gt;This does not seem to work - it only returns objects up to the default page limit for that api call&lt;/P&gt;&lt;P&gt;"to": 50, client.api_query(command="show-access-rulebase",payload={"name" : sl})&lt;BR /&gt;"total": 52,&lt;/P&gt;&lt;P&gt;Do i misunderstand something here?&lt;/P&gt;&lt;P&gt;Also -&amp;nbsp;include-container-key doesnt seem to have any affect - whether True or False it always returns a dict, never a list. Not a problem for me but the documentation is misleading?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;"""&lt;BR /&gt;The APIs that return a list of objects are limited by the number of objects that they return.&lt;BR /&gt;To get the full list of objects, there's a need to make repeated API calls each time using a different offset&lt;BR /&gt;until all the objects are returned.&lt;BR /&gt;This API makes such repeated API calls and return the full list objects.&lt;BR /&gt;note: this function calls gen_api_query and iterates over the generator until it gets all the objects,&lt;BR /&gt;then returns.&lt;/P&gt;&lt;P&gt;:param command: name of API command. This command should be an API that returns an array of&lt;BR /&gt;objects (for example: show-hosts, show networks, ...)&lt;BR /&gt;:param details_level: query APIs always take a details-level argument.&lt;BR /&gt;possible values are "standard", "full", "uid"&lt;BR /&gt;:param container_key: name of the key that holds the objects in the JSON response (usually "objects").&lt;BR /&gt;:param include_container_key: If set to False the 'data' field of the APIResponse object&lt;BR /&gt;will be a list of the wanted objects.&lt;BR /&gt;Otherwise, the date field of the APIResponse will be a dictionary in the following&lt;BR /&gt;format: { container_key: [ List of the wanted objects], "total": size of the list}&lt;BR /&gt;:param payload: a JSON object (or a string representing a JSON object) with the command arguments&lt;BR /&gt;:return: if include-container-key is False:&lt;BR /&gt;an APIResponse object whose .data member contains a list of the objects requested: [ , , , ...]&lt;BR /&gt;if include-container-key is True:&lt;BR /&gt;an APIResponse object whose .data member contains a dict: { container_key: [...], "total": n }&lt;BR /&gt;"""&lt;/P&gt;</description>
      <pubDate>Thu, 05 Sep 2019 12:25:54 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/CP-python-SDK-api-query-function/m-p/61947#M3903</guid>
      <dc:creator>Richard_Carson</dc:creator>
      <dc:date>2019-09-05T12:25:54Z</dc:date>
    </item>
    <item>
      <title>Re: CP python SDK - api_query function</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/CP-python-SDK-api-query-function/m-p/62336#M3919</link>
      <description>&lt;P&gt;That appears to be what the source code says.&lt;BR /&gt;Possible this is a bug.&lt;BR /&gt;&lt;a href="https://community.checkpoint.com/t5/user/viewprofilepage/user-id/186"&gt;@Amiad_Stern&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Sep 2019 22:32:28 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/CP-python-SDK-api-query-function/m-p/62336#M3919</guid>
      <dc:creator>PhoneBoy</dc:creator>
      <dc:date>2019-09-09T22:32:28Z</dc:date>
    </item>
    <item>
      <title>Re: CP python SDK - api_query function</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/CP-python-SDK-api-query-function/m-p/62342#M3921</link>
      <description>I figured it out - you need to use the correct 'container key'. By default it will pass a json container of "objects" but in the case of show-access-rulebase the container is 'rulebase' - once I set the correct container it works as I would expect. thxs &lt;a href="https://community.checkpoint.com/t5/user/viewprofilepage/user-id/186"&gt;@Amiad_Stern&lt;/a&gt;</description>
      <pubDate>Tue, 10 Sep 2019 01:20:42 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/CP-python-SDK-api-query-function/m-p/62342#M3921</guid>
      <dc:creator>Richard_Carson</dc:creator>
      <dc:date>2019-09-10T01:20:42Z</dc:date>
    </item>
  </channel>
</rss>

