Unable to fetch Firewall Rules via firewall-plugin API

Started by Hele, July 03, 2020, 03:11:51 PM

Previous topic - Next topic
Ho posto la seguente domanda anche su github, la copio qui sotto, è in inglese, se crea problemi traduco.

--------------
I'm having some troubles trying to fetch fw rules. I read the dock and looked at the examples at the page https://docs.opnsense.org/development/api/plugins/firewall.html but i still have problems. I'm trying to use the searchRule API via python, and i can't get anything back with a simple call without any attributes, here's my code

import json, requests


KEY = "my_key"
SECRET = "my_secret"

url = "https://192.168.2.1/api/firewall/filter/searchRule"
r = requests.get(url, verify=False, auth=(KEY, SECRET))
print(r.text)

result is always

{"rows":[],"rowCount":0,"total":0,"current":1}

Well, i've tryed to add some attributes to the call, but nothing changes, notice that i setted "icmp_dummies_rule" as the rule description cause i thought taht searchPhrase matches that field (also there's no unique name filed available, as far as i can see) I tryed:

url = 'https://192.168.2.1/api/firewall/filter/searchRule?searchPhrase=icmp_dummies_rule'
url = 'https://192.168.2.1/api/firewall/filter/searchRule?current=1&searchPhrase=icmp_dummies_rule'

Also i can't pass any UUID cause i don't know the rule UUID (but i prefere to retrive all the rules for flexibility reason and cleaner code).

Any idea here?
Thanks.
--------------

I too have the same problem and would like to know if you got any solution for this ?

Il plugin crea una nuova sezione sotto Firewall > Automation
Le regole di riferimento vanno inserite lì.