<?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: Find out if an object exists for a network with mgmt_cli in API / CLI Discussion</title>
    <link>https://community.checkpoint.com/t5/API-CLI-Discussion/Find-out-if-an-object-exists-for-a-network-with-mgmt-cli/m-p/58987#M3738</link>
    <description>&lt;P&gt;Hello Zhou&lt;/P&gt;&lt;P&gt;Thanks for sharing the information. It is very useful.&lt;/P&gt;&lt;P&gt;Do you have a way to do this for a list of networks?&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
    <pubDate>Thu, 25 Jul 2019 19:04:09 GMT</pubDate>
    <dc:creator>venkata_marutur</dc:creator>
    <dc:date>2019-07-25T19:04:09Z</dc:date>
    <item>
      <title>Find out if an object exists for a network with mgmt_cli</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/Find-out-if-an-object-exists-for-a-network-with-mgmt-cli/m-p/50996#M3344</link>
      <description>&lt;P&gt;I am trying to find out if an object exists for a network with exact match. But "mgmt_cli show objects" gives more than I wanted. For example I need to find if an object exist for network "52.0.0.0/15" exist. I tried the following.&lt;/P&gt;&lt;P&gt;mgmt_cli show objects type network filter "52.0.0.0/15" -f json -r true -d Internet&lt;/P&gt;&lt;P&gt;and&lt;/P&gt;&lt;P&gt;mgmt_cli show objects type network filter "52.0.0.0" -f json -r true -d Internet&lt;/P&gt;&lt;P&gt;They all give the same output with additional info for 52.0.0.0/8. Is there a way to get a result with the exact match?&lt;/P&gt;&lt;P&gt;{&lt;BR /&gt;"from" : 1,&lt;BR /&gt;"to" : 2,&lt;BR /&gt;"total" : 2,&lt;BR /&gt;"objects" : [ {&lt;BR /&gt;"uid" : "0bbb18f7-9d3d-49c7-bfc4-e4c569dcd5bb",&lt;BR /&gt;"name" : "Net52.0.0.0-15",&lt;BR /&gt;"type" : "network",&lt;BR /&gt;"domain" : {&lt;BR /&gt;"uid" : "aa6cae9a-7dd9-4a6d-b5bd-4d6bcedb25d4",&lt;BR /&gt;"name" : "Internet",&lt;BR /&gt;"domain-type" : "domain"&lt;BR /&gt;},&lt;BR /&gt;"subnet4" : "52.0.0.0",&lt;BR /&gt;"mask-length4" : 15,&lt;BR /&gt;"subnet-mask" : "255.254.0.0"&lt;BR /&gt;}, {&lt;BR /&gt;"uid" : "085626b1-8c50-40c9-8c8d-a924b96ce62a",&lt;BR /&gt;"name" : "net52.0.0.0-8",&lt;BR /&gt;"type" : "network",&lt;BR /&gt;"domain" : {&lt;BR /&gt;"uid" : "aa6cae9a-7dd9-4a6d-b5bd-4d6bcedb25d4",&lt;BR /&gt;"name" : "Internet",&lt;BR /&gt;"domain-type" : "domain"&lt;BR /&gt;},&lt;BR /&gt;"subnet4" : "52.0.0.0",&lt;BR /&gt;"mask-length4" : 8,&lt;BR /&gt;"subnet-mask" : "255.0.0.0"&lt;BR /&gt;} ]&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Apr 2019 20:43:31 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/Find-out-if-an-object-exists-for-a-network-with-mgmt-cli/m-p/50996#M3344</guid>
      <dc:creator>Jin_Zhou</dc:creator>
      <dc:date>2019-04-15T20:43:31Z</dc:date>
    </item>
    <item>
      <title>Re: Find out if an object exists for a network with mgmt_cli</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/Find-out-if-an-object-exists-for-a-network-with-mgmt-cli/m-p/51075#M3345</link>
      <description>&lt;P&gt;Anyone has any idea? Now I am trying to use jq to get the exact match. The following works.&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;mgmt_cli show objects type network filter "52.0.0.0/15" -f json |&amp;nbsp; jq -r '.objects[]|select(."mask-length4" == 15)'&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;but if I try to pass a variable it won't work. There is no error but just no output. Tried the following.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;LEN=15&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;mgmt_cli show objects type network filter "52.0.0.0/15" -f json |&amp;nbsp; jq -- arg v1 $LEN&amp;nbsp;-r '.objects[]|select(."mask-length4" == $v1)'&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;or&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;mgmt_cli show objects type network filter "52.0.0.0/15" -f json |&amp;nbsp; jq -- arg v1 15 -r '.objects[]|select(."mask-length4" == $v1)'&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I wonder if jq on GAIA is not a full version.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Apr 2019 14:26:02 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/Find-out-if-an-object-exists-for-a-network-with-mgmt-cli/m-p/51075#M3345</guid>
      <dc:creator>Jin_Zhou</dc:creator>
      <dc:date>2019-04-16T14:26:02Z</dc:date>
    </item>
    <item>
      <title>Re: Find out if an object exists for a network with mgmt_cli</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/Find-out-if-an-object-exists-for-a-network-with-mgmt-cli/m-p/51102#M3346</link>
      <description>&lt;P&gt;Figured out the problem and a workaround.&amp;nbsp;&lt;/P&gt;&lt;P&gt;jq --arg variable only passed as a string. So the select test is always false. There is another option jq --argjson but version 1.4 does not support it. The workaround is to echo the whole mgmt_cli command line to a file and make the file executable and run it.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Apr 2019 20:05:18 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/Find-out-if-an-object-exists-for-a-network-with-mgmt-cli/m-p/51102#M3346</guid>
      <dc:creator>Jin_Zhou</dc:creator>
      <dc:date>2019-04-16T20:05:18Z</dc:date>
    </item>
    <item>
      <title>Re: Find out if an object exists for a network with mgmt_cli</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/Find-out-if-an-object-exists-for-a-network-with-mgmt-cli/m-p/58987#M3738</link>
      <description>&lt;P&gt;Hello Zhou&lt;/P&gt;&lt;P&gt;Thanks for sharing the information. It is very useful.&lt;/P&gt;&lt;P&gt;Do you have a way to do this for a list of networks?&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jul 2019 19:04:09 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/Find-out-if-an-object-exists-for-a-network-with-mgmt-cli/m-p/58987#M3738</guid>
      <dc:creator>venkata_marutur</dc:creator>
      <dc:date>2019-07-25T19:04:09Z</dc:date>
    </item>
  </channel>
</rss>

