<?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: Random API Methodology thoughts in API / CLI Discussion</title>
    <link>https://community.checkpoint.com/t5/API-CLI-Discussion/Random-API-Methodology-thoughts/m-p/2207#M53</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'd suggest the following flow:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1) call add-host (without checking if another object with the same ip-address already exists).&lt;/P&gt;&lt;P&gt;2) If the server responds with an error message, check the message&lt;/P&gt;&lt;P&gt;2.1) If an object with the same name already exist, call "show-host" and provide it with the object name - if it has the correct IP address - you're done. If it has a different IP address, you should probably give your new host a different name.&lt;/P&gt;&lt;P&gt;2.2) If you get a "duplicate ip-address warning", you can search the objects database like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'arial black', 'avant garde';"&gt;POST {{server}}/show-objects&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'arial black', 'avant garde';"&gt;Content-Type: application/json&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'arial black', 'avant garde';"&gt;X-chkp-sid: {{session}}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'arial black', 'avant garde';"&gt;{&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'arial black', 'avant garde';"&gt;&amp;nbsp; "in" : [ "text", "192.168.0.1" ],&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'arial black', 'avant garde';"&gt;&amp;nbsp; "details-level" : "full"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'arial black', 'avant garde';"&gt;}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;or in mgmt_cli syntax:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'arial black', 'avant garde';"&gt;mgmt_cli show objects in.0 text in.1 &lt;SPAN style="font-family: 'arial black', 'avant garde';"&gt;192.168.0.1 details-level full&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This search should have the same results as searching the objects list in the GUI.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 17 Apr 2016 13:06:30 GMT</pubDate>
    <dc:creator>Uri_Bialik</dc:creator>
    <dc:date>2016-04-17T13:06:30Z</dc:date>
    <item>
      <title>Random API Methodology thoughts</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/Random-API-Methodology-thoughts/m-p/2206#M52</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Disclaimer:&amp;nbsp; not a hard core programmer , so I might say crazy things.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I thought I would just share my initial impressions and feedback on a simple proof of concept I've been working on with the new R80 API.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Adding a host.&amp;nbsp;&amp;nbsp;&amp;nbsp; On the surface this is simple....format a JSON query with a couple of fields and you can add an object to Smartcenter,&amp;nbsp; awesome.&amp;nbsp; That works.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now I've complicated it by purposely sending a duplicate object IP address.&amp;nbsp;&amp;nbsp; Now I get a HTTP 500 back.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ok I think,&amp;nbsp;&amp;nbsp; I need to check for dupe, before adding the object.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ok I cant search for a match via the API (unless I've missed that),&amp;nbsp; so I can dump a list of hosts.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ok that just gives me a list of object names back,&amp;nbsp; so now I start recursively doing a show host on every host object to suck in all the ip addresses into my perl script to decide if I'm about to dupe.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;This feels like alot of work I'm creating,&amp;nbsp; anyone want to share any thoughts on the API methodology here ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;EDIT: ok so I realized there was a "show more" link in the API docs for "show-hosts" and I can send "details-level":"full" to get the ip addresses of the host objects ... awesome.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Apr 2016 13:42:56 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/Random-API-Methodology-thoughts/m-p/2206#M52</guid>
      <dc:creator>Andy_Bretten</dc:creator>
      <dc:date>2016-04-15T13:42:56Z</dc:date>
    </item>
    <item>
      <title>Re: Random API Methodology thoughts</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/Random-API-Methodology-thoughts/m-p/2207#M53</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'd suggest the following flow:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1) call add-host (without checking if another object with the same ip-address already exists).&lt;/P&gt;&lt;P&gt;2) If the server responds with an error message, check the message&lt;/P&gt;&lt;P&gt;2.1) If an object with the same name already exist, call "show-host" and provide it with the object name - if it has the correct IP address - you're done. If it has a different IP address, you should probably give your new host a different name.&lt;/P&gt;&lt;P&gt;2.2) If you get a "duplicate ip-address warning", you can search the objects database like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'arial black', 'avant garde';"&gt;POST {{server}}/show-objects&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'arial black', 'avant garde';"&gt;Content-Type: application/json&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'arial black', 'avant garde';"&gt;X-chkp-sid: {{session}}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'arial black', 'avant garde';"&gt;{&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'arial black', 'avant garde';"&gt;&amp;nbsp; "in" : [ "text", "192.168.0.1" ],&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'arial black', 'avant garde';"&gt;&amp;nbsp; "details-level" : "full"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'arial black', 'avant garde';"&gt;}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;or in mgmt_cli syntax:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'arial black', 'avant garde';"&gt;mgmt_cli show objects in.0 text in.1 &lt;SPAN style="font-family: 'arial black', 'avant garde';"&gt;192.168.0.1 details-level full&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This search should have the same results as searching the objects list in the GUI.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 17 Apr 2016 13:06:30 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/Random-API-Methodology-thoughts/m-p/2207#M53</guid>
      <dc:creator>Uri_Bialik</dc:creator>
      <dc:date>2016-04-17T13:06:30Z</dc:date>
    </item>
    <item>
      <title>Re: Random API Methodology thoughts</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/Random-API-Methodology-thoughts/m-p/2208#M54</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Typing this (long) line in "expert-mode", shows the names of all the objects that match the search for "192.168.0.1":&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;&lt;SPAN style="color: #3334ca;"&gt;[Expert@gw-8b3711:0]#&lt;/SPAN&gt; &lt;SPAN style="color: #7ed529;"&gt;mgmt_cli show objects in.0 text in.1 192.168.0.1&amp;nbsp; -r true --format json| $CPDIR/jq/jq ".objects[] | .name"&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #e23d39; font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;"host1"&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3334ca; font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;[Expert@gw-8b3711:0]#&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 17 Apr 2016 13:16:30 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/Random-API-Methodology-thoughts/m-p/2208#M54</guid>
      <dc:creator>Uri_Bialik</dc:creator>
      <dc:date>2016-04-17T13:16:30Z</dc:date>
    </item>
  </channel>
</rss>

