Enable/Disable security rules via XML API

L1 Bithead

Enable/Disable security rules via XML API

Hi all,

is it possible to enable / disable an existing security rule via XML API ?

Looking at the documentation (both the XML config guide and the api on the firewall) I found no useful informations on this topic :smileysad:

thank's !

Tags (3)
bat
L5 Sessionator

Re: Enable/Disable security rules via XML API

Hi,

You can do so using the following command:

To disable:

https://<ip>/api/?type=config&action=set&xpath=/config/devices/entry[@name='localhost.localdomain']/vsys/entry[@name='vsys1']/rulebase/security/rules/entry[@name='<rule-name>']&element=<disabled>yes</disabled>

To enable:

https://<ip>/api/?type=config&action=set&xpath=/config/devices/entry[@name='localhost.localdomain']/vsys/entry[@name='vsys1']/rulebase/security/rules/entry[@name='<rule-name>']&element=<disabled>no</disabled>

L6 Presenter

Re: Enable/Disable security rules via XML API

Great Answer ...

L2 Linker

Re: Enable/Disable security rules via XML API

bat thank you for being awesome.  question: any idea why a get on the same xpath (without the element arg) won't simply return an XML object with the state of a security rule?

e.g. https://firewall/api/?type=config&action=get&xpath=%2Fconfig%2Fdevices%2Fentry%5B%40name%3D%27localh... returns something completely useless, like:

<response status="success" code="19">

     <result/>

</response>

What the deuce does that tell me?  Neither the status or the code change based on the state of the rule, so...

Highlighted
bat
L5 Sessionator

Re: Enable/Disable security rules via XML API

Hi cjsteele

To know the status of rule query should be:

https://<ip>/api/?type=config&action=get&xpath=/config/devices/entry[@name='localhost.localdomain']/vsys/entry[@name='vsys1']/rulebase/security/rules/entry[@name='<rule-name>']/disabled


Let me know if this is what you are looking for.

Like what you see?

Show your appreciation!

Click Like if a post is helpful to you or if you just want to show your support.

Click Accept as Solution to acknowledge that the answer to your question has been provided.

The button appears next to the replies on topics you’ve started. The member who gave the solution and all future visitors to this topic will appreciate it!

These simple actions take just seconds of your time, but go a long way in showing appreciation for community members and the Live Community as a whole!

The Live Community thanks you for your participation!