<?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: API set-access-rule Adding / removing Source or destination in API / CLI Discussion</title>
    <link>https://community.checkpoint.com/t5/API-CLI-Discussion/API-set-access-rule-Adding-removing-Source-or-destination/m-p/183030#M7771</link>
    <description>&lt;P&gt;All works,&amp;nbsp; one observation I wanted to add a section heading as well, and noted that you have do this last, keeping in mind you want everything to be added under and existing uid.&lt;/P&gt;
&lt;P&gt;session=`mgmt_cli -r true login --format json| jq -r '.sid'`&lt;BR /&gt;mgmt_cli --session-id $session add group name "GROUP1" color "Sea Green" comments "Test Group"&lt;/P&gt;
&lt;P&gt;mgmt_cli --session-id $session set group name "GROUP1" members.add.1 HOST1&lt;/P&gt;
&lt;P&gt;mgmt_cli --session-id $session add access-rule name "Test Rule" layer "Network" position.below "7216a217-6d28-449a-9e04-eb6e6aa4b01b" source "HOST2" destination "GROUP1" action "accept" service.1 "microsoft-ds" service.2 "nbsession" track "log" comments "New rule added"&lt;/P&gt;
&lt;P&gt;mgmt_cli --session-id $session add access-section layer "Network" position.below "7216a217-6d28-449a-9e04-eb6e6aa4b01b" name "Section for new rule"&lt;/P&gt;
&lt;P&gt;mgmt_cli --session-id $session publish&lt;/P&gt;</description>
    <pubDate>Fri, 02 Jun 2023 10:03:21 GMT</pubDate>
    <dc:creator>genisis__</dc:creator>
    <dc:date>2023-06-02T10:03:21Z</dc:date>
    <item>
      <title>API set-access-rule Adding / removing Source or destination</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/API-set-access-rule-Adding-removing-Source-or-destination/m-p/81145#M4684</link>
      <description>&lt;P&gt;I done the following with mgmt_cli:&lt;/P&gt;&lt;P&gt;set access-rule rule-number 1 layer "Test Network" source.add "Test_Host1"&lt;/P&gt;&lt;P&gt;set access-rule rule-number 1 layer "Test Network" source.add "Test_Host2"&lt;/P&gt;&lt;P&gt;set access-rule rule-number 1 layer "Test Network" source.add "Test_Host3"&lt;/P&gt;&lt;P&gt;set access-rule rule-number 1 layer "Test Network" source.add "Test_Host4"&lt;/P&gt;&lt;P&gt;set access-rule rule-number 1 layer "Test Network" destination.remove "Test_Host1"&lt;/P&gt;&lt;P&gt;set access-rule rule-number 1 layer "Test Network" destination.remove "Test_Host2"&lt;/P&gt;&lt;P&gt;set access-rule rule-number 1 layer "Test Network" destination.remove "Test_Host3"&lt;/P&gt;&lt;P&gt;set access-rule rule-number 1 layer "Test Network" destination.remove "Test_Host4"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I do the same with curl?&lt;/P&gt;&lt;P&gt;source.add as well destination.remove gets the error&lt;/P&gt;&lt;P&gt;"code" : "generic_err_invalid_syntax",&lt;BR /&gt;"message" : "Payload is not a valid JSON"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Apr 2020 14:00:14 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/API-set-access-rule-Adding-removing-Source-or-destination/m-p/81145#M4684</guid>
      <dc:creator>PeterH</dc:creator>
      <dc:date>2020-04-07T14:00:14Z</dc:date>
    </item>
    <item>
      <title>Re: API set-access-rule Adding / removing Source or destination</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/API-set-access-rule-Adding-removing-Source-or-destination/m-p/81229#M4690</link>
      <description>What precisely did you try?</description>
      <pubDate>Wed, 08 Apr 2020 00:31:15 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/API-set-access-rule-Adding-removing-Source-or-destination/m-p/81229#M4690</guid>
      <dc:creator>PhoneBoy</dc:creator>
      <dc:date>2020-04-08T00:31:15Z</dc:date>
    </item>
    <item>
      <title>Re: API set-access-rule Adding / removing Source or destination</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/API-set-access-rule-Adding-removing-Source-or-destination/m-p/81262#M4692</link>
      <description>&lt;P&gt;Hi PhoneBoy&lt;/P&gt;&lt;P&gt;As you can see I added Test_Host1 to Test_Host4 into the source column of the existing Rule 1 in Policy Package Test, as well removing Test_Host1 to Test_Host4 from the destination column in the same Rule and Policy. I did that successful within the mgmt_cli tool, but would like to do the same with curl or curl_cli.&lt;/P&gt;&lt;P&gt;The problem is the syntax in the curly brackets of curl&amp;nbsp; ...set-access-rule -d '{"rule-number" : "1", "layer" : "Test Network", "source.add" : "Test_Host5"}'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Apr 2020 06:49:37 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/API-set-access-rule-Adding-removing-Source-or-destination/m-p/81262#M4692</guid>
      <dc:creator>PeterH</dc:creator>
      <dc:date>2020-04-08T06:49:37Z</dc:date>
    </item>
    <item>
      <title>Re: API set-access-rule Adding / removing Source or destination</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/API-set-access-rule-Adding-removing-Source-or-destination/m-p/81312#M4697</link>
      <description>&lt;P&gt;Hi PhoneBoy&lt;/P&gt;&lt;P&gt;In the meantime I found a workarround for the problem.&lt;BR /&gt;Simply list all sources or destinations in the rule and then add or remove selectiv.&lt;/P&gt;&lt;P&gt;- add Test_Host1 to Test_Host4 into source column&lt;BR /&gt;set-access-rule -d '{"rule-number" : "1", "layer" : "Test Network", "source" : ["Test_Host1","Test_Host2","Test_Host3","Test_Host4"]}&lt;/P&gt;&lt;P&gt;- remove Test_Host1 from source column&lt;BR /&gt;set-access-rule -d '{"rule-number" : "1", "layer" : "Test Network", "source" : ["Test_Host2","Test_Host3","Test_Host4"]}&lt;/P&gt;&lt;P&gt;The same for destionation.&lt;/P&gt;&lt;P&gt;I think there should be a simpler solution for that.&lt;/P&gt;</description>
      <pubDate>Wed, 08 Apr 2020 11:18:41 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/API-set-access-rule-Adding-removing-Source-or-destination/m-p/81312#M4697</guid>
      <dc:creator>PeterH</dc:creator>
      <dc:date>2020-04-08T11:18:41Z</dc:date>
    </item>
    <item>
      <title>Re: API set-access-rule Adding / removing Source or destination</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/API-set-access-rule-Adding-removing-Source-or-destination/m-p/81325#M4698</link>
      <description>&lt;P&gt;For the source/destination/service fields we can use the add/remove functions of the set-access-rule api call.&lt;/P&gt;
&lt;P&gt;Here is an example in JSON of adding hosts as a source to a rule.&amp;nbsp; This will add the three hosts to the source of the rule without having to specify all of the sources that are there already.&lt;/P&gt;
&lt;P&gt;{&lt;BR /&gt;"name" : "Test Rule",&lt;BR /&gt;"layer" : "Network",&lt;BR /&gt;"source" : { "add" : ["host1", "host2", "host3"]&lt;BR /&gt;&amp;nbsp; &amp;nbsp;}&lt;BR /&gt;}&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this helps.&lt;/P&gt;</description>
      <pubDate>Wed, 08 Apr 2020 13:26:00 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/API-set-access-rule-Adding-removing-Source-or-destination/m-p/81325#M4698</guid>
      <dc:creator>Ryan_Darst</dc:creator>
      <dc:date>2020-04-08T13:26:00Z</dc:date>
    </item>
    <item>
      <title>Re: API set-access-rule Adding / removing Source or destination</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/API-set-access-rule-Adding-removing-Source-or-destination/m-p/81330#M4699</link>
      <description>Many thanks, much easier than my workarround</description>
      <pubDate>Wed, 08 Apr 2020 14:37:28 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/API-set-access-rule-Adding-removing-Source-or-destination/m-p/81330#M4699</guid>
      <dc:creator>PeterH</dc:creator>
      <dc:date>2020-04-08T14:37:28Z</dc:date>
    </item>
    <item>
      <title>Re: API set-access-rule Adding / removing Source or destination</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/API-set-access-rule-Adding-removing-Source-or-destination/m-p/182730#M7746</link>
      <description>&lt;P&gt;I'm trying to do something similar where I want to use a single command to add a new rule which contains a few sources and destination below an existing rule.&lt;/P&gt;
&lt;P&gt;I did this:&lt;BR /&gt;mgmt_cli add access-rule uid &amp;lt;uid reference&amp;gt; layer "Standard Network" position.below "&amp;lt;uid reference&amp;gt;" name "Test Rule" source "HOST1","HOST2" destination "GROUP1" service "http" action "Accept" track type "Log"&lt;BR /&gt;&lt;BR /&gt;This does not work, and I cannot find an example on the Checkpoint API reference site.&amp;nbsp; The site does not show example of all the parameters you can use for a given action ie. in this case 'add access-rule'.&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2023 14:11:05 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/API-set-access-rule-Adding-removing-Source-or-destination/m-p/182730#M7746</guid>
      <dc:creator>genisis__</dc:creator>
      <dc:date>2023-05-31T14:11:05Z</dc:date>
    </item>
    <item>
      <title>Re: API set-access-rule Adding / removing Source or destination</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/API-set-access-rule-Adding-removing-Source-or-destination/m-p/182764#M7749</link>
      <description>&lt;P&gt;I got this working in a test environment.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;[Expert@cptestenv:0]# mgmt_cli -r true add access-rule name "Access to GROUP1" layer "Network" position.below "44b0b0fc-524b-40c4-b0a2-581312446dc8" source.1 "HOST1" source.2 "HOST2" destination "GROUP
1" action "accept" service.1 "http" service.2 "https" track "log"


---------------------------------------------
Time: [18:12:14] 31/5/2023
---------------------------------------------
"Publish operation"  succeeded  (100%)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Looking at &lt;EM&gt;set access-rule&lt;/EM&gt;&amp;nbsp;there is the .add action you can append to either source, destination or objects to make a batch import but it doesn't seem to be present in &lt;EM&gt;add access-rule&lt;/EM&gt;. So depending of the size of your list to import you could create a rule with&amp;nbsp;&lt;EM&gt;add access-rule&lt;/EM&gt; then batch import sources or destinations in it with a CSV by calling &lt;EM&gt;set access-rule source.add&lt;/EM&gt;, &lt;EM&gt;destination.add, service.add&lt;/EM&gt; in one call referencing the name or uid of the rule in question.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2023 16:43:04 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/API-set-access-rule-Adding-removing-Source-or-destination/m-p/182764#M7749</guid>
      <dc:creator>Alex-</dc:creator>
      <dc:date>2023-05-31T16:43:04Z</dc:date>
    </item>
    <item>
      <title>Re: API set-access-rule Adding / removing Source or destination</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/API-set-access-rule-Adding-removing-Source-or-destination/m-p/182777#M7751</link>
      <description>&lt;P&gt;Thanks Alex.&lt;BR /&gt;&lt;BR /&gt;Would use .csv for large imports, for small changes the above is great.&amp;nbsp; I'll certainly give this ago.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What frustrates me is there are no examples for the different action you can have on the API reference pages, would&amp;nbsp; be nice if Checkpoint provided an example for every parameter scenario (I know this is allot) it would save allot of time.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2023 17:34:44 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/API-set-access-rule-Adding-removing-Source-or-destination/m-p/182777#M7751</guid>
      <dc:creator>genisis__</dc:creator>
      <dc:date>2023-05-31T17:34:44Z</dc:date>
    </item>
    <item>
      <title>Re: API set-access-rule Adding / removing Source or destination</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/API-set-access-rule-Adding-removing-Source-or-destination/m-p/183030#M7771</link>
      <description>&lt;P&gt;All works,&amp;nbsp; one observation I wanted to add a section heading as well, and noted that you have do this last, keeping in mind you want everything to be added under and existing uid.&lt;/P&gt;
&lt;P&gt;session=`mgmt_cli -r true login --format json| jq -r '.sid'`&lt;BR /&gt;mgmt_cli --session-id $session add group name "GROUP1" color "Sea Green" comments "Test Group"&lt;/P&gt;
&lt;P&gt;mgmt_cli --session-id $session set group name "GROUP1" members.add.1 HOST1&lt;/P&gt;
&lt;P&gt;mgmt_cli --session-id $session add access-rule name "Test Rule" layer "Network" position.below "7216a217-6d28-449a-9e04-eb6e6aa4b01b" source "HOST2" destination "GROUP1" action "accept" service.1 "microsoft-ds" service.2 "nbsession" track "log" comments "New rule added"&lt;/P&gt;
&lt;P&gt;mgmt_cli --session-id $session add access-section layer "Network" position.below "7216a217-6d28-449a-9e04-eb6e6aa4b01b" name "Section for new rule"&lt;/P&gt;
&lt;P&gt;mgmt_cli --session-id $session publish&lt;/P&gt;</description>
      <pubDate>Fri, 02 Jun 2023 10:03:21 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/API-set-access-rule-Adding-removing-Source-or-destination/m-p/183030#M7771</guid>
      <dc:creator>genisis__</dc:creator>
      <dc:date>2023-06-02T10:03:21Z</dc:date>
    </item>
  </channel>
</rss>

