Community discussions

MikroTik App
 
scracha
newbie
Topic Author
Posts: 25
Joined: Fri Dec 27, 2013 3:28 am

Python API queues place-before

Fri Feb 10, 2023 4:03 am

i'm looking to place new simple queue items after the first rule.

Mikrotik CLI works fine.
/queue simple> add name="TEST" target=192.168.1.66/32 parent=none queue=UnlimUp/UnlimDown comment="test" place-before="1"

Python code works fine until I add place-before

Python code throws keyword can't be an expression syntax error.
 
api = connection.get_api()
list_queues = api.get_resource('/queue/simple')
list_queues.add(queue="UnlimUp/UnlimDown", target=ipaddress, place-before=1, comment="daily")
Is there any means of achieving this? thanks.
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11982
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Python API queues place-before

Fri Feb 10, 2023 11:43 am

What is "1"?
1 is a number, is not .id value, like *8f
You must obtain first the .id of the first queue ([find]->0) and use that value.

No matter if the queue is the first, the 10th or the last, the .id of the queue are not sorted and can have holes.

example:
.id=*2;;limit-at=0/0;max-limit=0/0;name=queue1;packet-marks=;parent=none;priority=8/8;queue=default-small/default-small;target=
.id=*c;;limit-at=0/0;max-limit=0/0;name=queue2;packet-marks=;parent=none;priority=8/8;queue=default-small/default-small;target=
.id=*3;;limit-at=0/0;max-limit=0/0;name=queue3;packet-marks=;parent=none;priority=8/8;queue=default-small/default-small;target=
.id=*7;;limit-at=0/0;max-limit=0/0;name=queue4;packet-marks=;parent=none;priority=8/8;queue=default-small/default-small;target=
.id=*5;;limit-at=0/0;max-limit=0/0;name=queue5;packet-marks=;parent=none;priority=8/8;queue=default-small/default-small;target=
.id=*6;;limit-at=0/0;max-limit=0/0;name=queue6;packet-marks=;parent=none;priority=8/8;queue=default-small/default-small;target=
.id=*a;;limit-at=0/0;max-limit=0/0;name=queue7;packet-marks=;parent=none;priority=8/8;queue=default-small/default-small;target=
.id=*8;;limit-at=0/0;max-limit=0/0;name=queue8;packet-marks=;parent=none;priority=8/8;queue=default-small/default-small;target=
.id=*9;;limit-at=0/0;max-limit=0/0;name=queue9;packet-marks=;parent=none;priority=8/8;queue=default-small/default-small;target=
 
scracha
newbie
Topic Author
Posts: 25
Joined: Fri Dec 27, 2013 3:28 am

Re: Python API queues place-before

Sun Feb 12, 2023 10:04 pm

Thanks for the response.

Reading the API notes https://pypi.org/project/RouterOS-api/ I'd missed the note about using underscores.
NOTE: Attributes with -, like max-limit use underscore _: max_limit

Following works OK.
list_queues.add(queue="UnlimUp/UnlimDown", target=ipaddress, place_before=1, comment="daily")
I could not get ([find]->0) to work I'm afraid.

Who is online

Users browsing this forum: Egate and 19 guests