ip firewall address-list remove [/ip firewall address-list find list=list_1 ]
this command from cli delete address list quickly.
i try, without success:
$API->write(‘/ip/firewall/address-list/remove’,false);
$API->write(‘[/ip/firewall/address-list/print]’,false);
$API->write(‘?list=’ . $address_list,true);
now i read address list =.proplist=.id and then delete in cycle.
This is long enough.
Last I checked, API’s “find” command doesn’t support queries. It can only give you the IDs of all items at a menu. Only “print” supports queries.
So yeah, the only way currently is to first do a “print” API call with “.proplist=.id”, loop through the results, gather them into a single comma separated list, and pass that list into the “numbers” argument of another API call to the “remove” command.
With my API client, the above is automated into a single PHP method call, but that’s what happens under the hood.
loop through the results, gather them into a single comma separated list, and pass that list into the “numbers” argument of another API call to the “remove” command.
please give me example for this comma separated list and how to write this via API ?
now in cycle, i doing this:
$API->write(‘/ip/firewall/address-list/remove’,false);
$API->write(‘=.id=’. $id ,true);
$READ = $API->read(false);
it is possible delete all items in addr. list with one API->write command ?
i add to address list with this commnad:
$ARRAY = $API->comm(‘/ip/firewall/address-list/add’, array(
“address” => “1.1.1.20”,
“disabled” => “no”,
“list” => “test1”,
“comment” => “comment1”,
));
is it possible add more than 1 record in $API->comm …
same as multiple/multidimensional array ?
No. There’s no way even on the command line, and thus no way in the API.
Again, with my own API client, there’s a way to add multiple items with one PHP method call, but under the hood, that gets translated to multiple consecutive “add” calls.