<?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_mgmt_api_python_sdk passing &amp;quot;--format json&amp;quot; in API / CLI Discussion</title>
    <link>https://community.checkpoint.com/t5/API-CLI-Discussion/cp-mgmt-api-python-sdk-passing-quot-format-json-quot/m-p/103501#M5348</link>
    <description>&lt;P&gt;The API responds in JSON when you call it directly.&lt;BR /&gt;mgmt_cli converts the output into some sort of text output unless you call it with —format json.&lt;BR /&gt;Not sure what this Python module is doing.&lt;BR /&gt;Highly recommend looking at other examples in the community, for example:&amp;nbsp;&lt;A href="https://community.checkpoint.com/t5/API-CLI-Discussion-and-Samples/Python-tool-for-exporting-importing-a-policy-package-or-parts-of/m-p/41100#M2829" target="_blank"&gt;https://community.checkpoint.com/t5/API-CLI-Discussion-and-Samples/Python-tool-for-exporting-importing-a-policy-package-or-parts-of/m-p/41100#M2829&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 27 Nov 2020 04:28:14 GMT</pubDate>
    <dc:creator>PhoneBoy</dc:creator>
    <dc:date>2020-11-27T04:28:14Z</dc:date>
    <item>
      <title>cp_mgmt_api_python_sdk passing "--format json"</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/cp-mgmt-api-python-sdk-passing-quot-format-json-quot/m-p/103494#M5347</link>
      <description>&lt;P&gt;I started to use the&amp;nbsp;&lt;SPAN&gt;cp_mgmt_api_python_sdk in python and works great. One question though is there a way to pass the "--format json" parameter to it when using it to make an api call like show-group name "testgrp" --format json&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Example -&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;client.api_call(&lt;SPAN&gt;"show-group"&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;{&lt;SPAN&gt;"name"&lt;/SPAN&gt;: "testgrp"}, &lt;SPAN&gt;"--format &lt;/SPAN&gt;&lt;SPAN&gt;json"&lt;/SPAN&gt;)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 27 Nov 2020 02:56:48 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/cp-mgmt-api-python-sdk-passing-quot-format-json-quot/m-p/103494#M5347</guid>
      <dc:creator>bhaizlett123</dc:creator>
      <dc:date>2020-11-27T02:56:48Z</dc:date>
    </item>
    <item>
      <title>Re: cp_mgmt_api_python_sdk passing "--format json"</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/cp-mgmt-api-python-sdk-passing-quot-format-json-quot/m-p/103501#M5348</link>
      <description>&lt;P&gt;The API responds in JSON when you call it directly.&lt;BR /&gt;mgmt_cli converts the output into some sort of text output unless you call it with —format json.&lt;BR /&gt;Not sure what this Python module is doing.&lt;BR /&gt;Highly recommend looking at other examples in the community, for example:&amp;nbsp;&lt;A href="https://community.checkpoint.com/t5/API-CLI-Discussion-and-Samples/Python-tool-for-exporting-importing-a-policy-package-or-parts-of/m-p/41100#M2829" target="_blank"&gt;https://community.checkpoint.com/t5/API-CLI-Discussion-and-Samples/Python-tool-for-exporting-importing-a-policy-package-or-parts-of/m-p/41100#M2829&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 27 Nov 2020 04:28:14 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/cp-mgmt-api-python-sdk-passing-quot-format-json-quot/m-p/103501#M5348</guid>
      <dc:creator>PhoneBoy</dc:creator>
      <dc:date>2020-11-27T04:28:14Z</dc:date>
    </item>
    <item>
      <title>Re: cp_mgmt_api_python_sdk passing "--format json"</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/cp-mgmt-api-python-sdk-passing-quot-format-json-quot/m-p/103771#M5358</link>
      <description>&lt;P&gt;If you follow backward the code in the SDK, you will see that the&amp;nbsp;&lt;EM&gt;api_call&lt;/EM&gt; function returns an object back with the type of&amp;nbsp;&lt;EM&gt;APIResponse&lt;/EM&gt;. If you look at the class&amp;nbsp;&lt;EM&gt;APIResponse&lt;/EM&gt;, you will see that the variable&amp;nbsp;&lt;EM&gt;data&lt;/EM&gt; is a &lt;STRONG&gt;dict&lt;/STRONG&gt;. So load that variable with&amp;nbsp;&lt;EM&gt;json.dumps()&lt;/EM&gt;&amp;nbsp; function which will return JSON in string, then use&amp;nbsp;&lt;EM&gt;json.loads()&lt;/EM&gt; to return JSON data. Also, the default return/response (look at special variable&amp;nbsp;&lt;EM&gt;__repr__&lt;/EM&gt;) is a two-string format. You could definitely grab that output in parentheses as that is&amp;nbsp;already&amp;nbsp;&lt;EM&gt;json.dumps()&lt;/EM&gt; and preformatted.&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;def __repr__(self)
  return '%s(%s)' % (type(self).__name__, json.dumps(self.as_dict(), indent=4, sort_keys=True))&lt;/LI-CODE&gt;
&lt;P&gt;Hopefully, that helps!&lt;/P&gt;</description>
      <pubDate>Mon, 30 Nov 2020 23:54:26 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/cp-mgmt-api-python-sdk-passing-quot-format-json-quot/m-p/103771#M5358</guid>
      <dc:creator>Art_Zalenekas</dc:creator>
      <dc:date>2020-11-30T23:54:26Z</dc:date>
    </item>
    <item>
      <title>Re: cp_mgmt_api_python_sdk passing "--format json"</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/cp-mgmt-api-python-sdk-passing-quot-format-json-quot/m-p/103794#M5360</link>
      <description>&lt;P&gt;Looks like your code got emojied.&lt;BR /&gt;You might want to try again and enclose it in a code block &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 30 Nov 2020 22:21:09 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/cp-mgmt-api-python-sdk-passing-quot-format-json-quot/m-p/103794#M5360</guid>
      <dc:creator>PhoneBoy</dc:creator>
      <dc:date>2020-11-30T22:21:09Z</dc:date>
    </item>
    <item>
      <title>Re: cp_mgmt_api_python_sdk passing "--format json"</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/cp-mgmt-api-python-sdk-passing-quot-format-json-quot/m-p/103798#M5361</link>
      <description>&lt;P&gt;PhoneBoy, sorry, that was copy/paste from our Python API SDK. I put it in the code snippet now.&lt;BR /&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Mon, 30 Nov 2020 23:55:43 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/cp-mgmt-api-python-sdk-passing-quot-format-json-quot/m-p/103798#M5361</guid>
      <dc:creator>Art_Zalenekas</dc:creator>
      <dc:date>2020-11-30T23:55:43Z</dc:date>
    </item>
  </channel>
</rss>

