goal, single API command that matches and set parameters on multiple items
A couple of example commands that I want to work, but don’t…
/radius/set
=src-address=1.2.3.4
?service=PPP
/queue/tree/set
=limit-at=1000
=max-limit=10000
?parent=ParentQueue
Any idea how to do this without first doing something like this and getting all the IDs listed:
/radius/print
=.proplist=.id
?service=PPP
then looping through the results and running something that looks like this (non denominational psudo code syntax):
For Each $ID In IDlist
/radius/set
=src-address=1.2.3.4
=.id=$ID
Next
executing one API command to update a group of settings is clearly more efficient than the way shown that I’ve actually gotten to work, particularly when there may be 50-100 IDs to update on some of the loops that I run through.
Even in CLI, you need two commands. Just because you write them on a single line doesn’t mean there aren’t two of them being executed.
In CLI, you use
/queue tree set [find where parent=ParentQueue] limit-at=1000 max-limit=10000
which first does “/queue tree find where parent=ParentQueue” and then gives the return value of that to the “numbers” argument at “/queue tree set”.
It’s the same thing with the API, but more explicit.
If, in the future, you could do from CLI
/queue tree set limit-at=1000 max-limit=10000 where parent=ParentQueue
that’s when
/queue/tree/set
=limit-at=1000
=max-limit=10000
?parent=ParentQueue
will become valid, and equivalent of that.
(That’s a feature request for MikroTik though)
Some API clients, like the one from my signature, try to abstract this away so that from the outside, it feels like a single call, but on a protocol level, it just can’t be done. RouterOS itself doesn’t support that.