<?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: R80 Management API tips and tricks - &amp;quot;show-domains&amp;quot; command in API / CLI Discussion</title>
    <link>https://community.checkpoint.com/t5/API-CLI-Discussion/R80-Management-API-tips-and-tricks-quot-show-domains-quot/m-p/59055#M3741</link>
    <description>&lt;P&gt;Is there a way to get this to return the global domain as well.&lt;/P&gt;&lt;P&gt;Currently, I have to define a variable manually, as I need the global to be in it as well as the rest of the domains.&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;PG&lt;/P&gt;</description>
    <pubDate>Fri, 26 Jul 2019 23:09:34 GMT</pubDate>
    <dc:creator>Paul_Gademsky</dc:creator>
    <dc:date>2019-07-26T23:09:34Z</dc:date>
    <item>
      <title>R80 Management API tips and tricks - "show-domains" command</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/R80-Management-API-tips-and-tricks-quot-show-domains-quot/m-p/40511#M2706</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;On Multi-Domain management server you may query for a list of domains in your environment by using a &lt;A href="https://sc1.checkpoint.com/documents/latest/APIs/index.html#cli/show-domains~v1.1%20"&gt;"show-domains" API command&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;The response of this command contains a list of domain objects, defined by the user. This list does NOT contain a Global domain, User-Data domain or MDS.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is an example bash script that retrieves and stores in a variable a list of domains names -&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="language-none"&gt;&lt;CODE&gt;#!/bin/sh&lt;BR /&gt;&lt;BR /&gt;JQ=${CPDIR}/jq/jq&lt;BR /&gt;&lt;BR /&gt;DOMAINS_FILE="domains.json"&lt;BR /&gt;&lt;BR /&gt;echo 'Getting a list of domains...'&lt;BR /&gt;mgmt_cli -r true -d MDS show domains limit 500 --format json &amp;gt; $DOMAINS_FILE&lt;BR /&gt;if [ $? -eq 1 ]; then&lt;BR /&gt; echo "Error getting list of domains. Aborting!"&lt;BR /&gt; exit 1&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;DOMAINS_NAMES=($($JQ -r ".objects[] | .name" $DOMAINS_FILE))‍‍‍‍‍‍‍‍‍‍‍‍‍‍&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is an example bash script that iterates over the list of above domains and prints all access policy packages and layers -&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;PACKAGES_FILE="packages.json"&lt;BR /&gt;PACKAGE_FILE="package.json"&lt;BR /&gt;&lt;BR /&gt;for DOMAIN in ${DOMAINS_NAMES[@]}&lt;BR /&gt;do&lt;BR /&gt;&amp;nbsp; echo 'Searching in domain '"$DOMAIN"'...'&lt;BR /&gt;&amp;nbsp; mgmt_cli -r true -d "$DOMAIN" show packages limit 500 --format json &amp;gt; $PACKAGES_FILE&lt;BR /&gt;&amp;nbsp; if [ $? -ne 1 ]; then&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PACKAGES_NAMES=($($JQ -r ".packages[] | .name" $PACKAGES_FILE))&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for PACKAGE in ${PACKAGES_NAMES[@]}&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; do&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; echo 'Searching in package '"$PACKAGE"'...'&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mgmt_cli -r true -d "$DOMAIN" show-package name $PACKAGE --format json &amp;gt; $PACKAGE_FILE&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if [ $? -ne 1 ]; then&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ACCESS_LAYERS=($($JQ '.["access-layers"][] | .name' -r $PACKAGE_FILE))&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for LAYER in ${ACCESS_LAYERS[@]}&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; do&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; echo 'Policy layer: '"$LAYER"&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; done&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fi&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; done&lt;BR /&gt;&amp;nbsp; fi&lt;BR /&gt;done&lt;BR /&gt;‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Robert.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Mar 2018 11:33:48 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/R80-Management-API-tips-and-tricks-quot-show-domains-quot/m-p/40511#M2706</guid>
      <dc:creator>Robert_Decker</dc:creator>
      <dc:date>2018-03-26T11:33:48Z</dc:date>
    </item>
    <item>
      <title>Re: R80 Management API tips and tricks - "show-domains" command</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/R80-Management-API-tips-and-tricks-quot-show-domains-quot/m-p/40512#M2707</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;this is an easier way for R77 and R80.x &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new, courier, monospace;"&gt;[Expert@MDS-R80.10:0]# $MDSVERUTIL AllCMAs&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new, courier, monospace;"&gt;Domain1&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new, courier, monospace;"&gt;Domain2&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new, courier, monospace;"&gt;[Expert@MDS-R80.10:0]#&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Sep 2018 11:57:07 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/R80-Management-API-tips-and-tricks-quot-show-domains-quot/m-p/40512#M2707</guid>
      <dc:creator>Sebastian_Gxxx</dc:creator>
      <dc:date>2018-09-26T11:57:07Z</dc:date>
    </item>
    <item>
      <title>Re: R80 Management API tips and tricks - "show-domains" command</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/R80-Management-API-tips-and-tricks-quot-show-domains-quot/m-p/40513#M2708</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;As a rule of thumb, when writing a script on R8X versions, it is recommended to work with official APIs (if exist) to make sure scripts will not "break" in the future.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Oct 2018 04:45:26 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/R80-Management-API-tips-and-tricks-quot-show-domains-quot/m-p/40513#M2708</guid>
      <dc:creator>Amiad_Stern</dc:creator>
      <dc:date>2018-10-02T04:45:26Z</dc:date>
    </item>
    <item>
      <title>Re: R80 Management API tips and tricks - "show-domains" command</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/R80-Management-API-tips-and-tricks-quot-show-domains-quot/m-p/40514#M2709</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="color: #333333; background-color: #ffffff;"&gt;$MDSVERUTIL AllCMAs will show the CMA names, not the Domain names as the "mgmt_cli show domains" command does.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example getting CMA's and Domain's:&lt;/P&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;CPPROD_UTIL="$CPDIR/bin/cpprod_util"&lt;BR /&gt;&lt;BR /&gt;for CMA in $($MDSVERUTIL AllCMAs); do&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;mdsenv $CMA&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;DOMAIN_NAME=$(${CPPROD_UTIL} CPPROD_GetValue FW1 CustomerName 1)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if [[ -z "$DOMAIN_NAME" ]]; then&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;echo "Can not get Domain name"&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;fi&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;echo "CMA: $CMA"&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;echo "Domain: $DOMAIN_NAME"&lt;BR /&gt;done‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As Amiad said, best to use the API instead in case the&amp;nbsp;&lt;SPAN style="color: #333333; background-color: #ffffff;"&gt;$MDSVERUTIL&amp;nbsp;commands change in a later version.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Oct 2018 13:40:45 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/R80-Management-API-tips-and-tricks-quot-show-domains-quot/m-p/40514#M2709</guid>
      <dc:creator>Russell_Seifert</dc:creator>
      <dc:date>2018-10-05T13:40:45Z</dc:date>
    </item>
    <item>
      <title>Re: R80 Management API tips and tricks - "show-domains" command</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/R80-Management-API-tips-and-tricks-quot-show-domains-quot/m-p/59055#M3741</link>
      <description>&lt;P&gt;Is there a way to get this to return the global domain as well.&lt;/P&gt;&lt;P&gt;Currently, I have to define a variable manually, as I need the global to be in it as well as the rest of the domains.&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;PG&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jul 2019 23:09:34 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/R80-Management-API-tips-and-tricks-quot-show-domains-quot/m-p/59055#M3741</guid>
      <dc:creator>Paul_Gademsky</dc:creator>
      <dc:date>2019-07-26T23:09:34Z</dc:date>
    </item>
    <item>
      <title>Re: R80 Management API tips and tricks - "show-domains" command</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/R80-Management-API-tips-and-tricks-quot-show-domains-quot/m-p/59057#M3742</link>
      <description>&lt;P&gt;Hi Robert,&lt;/P&gt;&lt;P&gt;When running this script, I'm getting this as part of the jq&lt;/P&gt;&lt;P&gt;Searching in package Standard...&lt;BR /&gt;jq: error: Cannot iterate over null&lt;/P&gt;&lt;P&gt;I've seen the jq error before in other scripts, and haven't been able to track down what is causing it.&lt;/P&gt;&lt;P&gt;It seems to happen in some domains (though not with every search, but some searches), and other domains seem exempt from it.&lt;/P&gt;&lt;P&gt;Do you have a good resource when this happens with a mgmt_cli command that calls jq?&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;Paul G.&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jul 2019 23:42:44 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/R80-Management-API-tips-and-tricks-quot-show-domains-quot/m-p/59057#M3742</guid>
      <dc:creator>Paul_Gademsky</dc:creator>
      <dc:date>2019-07-26T23:42:44Z</dc:date>
    </item>
    <item>
      <title>Re: R80 Management API tips and tricks - "show-domains" command</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/R80-Management-API-tips-and-tricks-quot-show-domains-quot/m-p/59195#M3753</link>
      <description>&lt;P&gt;I figured out what was causing the jq to return the error.&lt;/P&gt;&lt;P&gt;I had an 'network' defined in the domain that was giving an error, that had been an invalid network mask (carried in from an ASA import via confwiz).&amp;nbsp; Once this fixed, the jq error went away.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jul 2019 23:15:29 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/R80-Management-API-tips-and-tricks-quot-show-domains-quot/m-p/59195#M3753</guid>
      <dc:creator>Paul_Gademsky</dc:creator>
      <dc:date>2019-07-29T23:15:29Z</dc:date>
    </item>
  </channel>
</rss>

