socialwifi / RouterOS-api

Python API to RouterBoard devices produced by MikroTik.
MIT License
258 stars 98 forks source link

There is a way to remove elements massively? #49

Open rogerarjona opened 5 years ago

rogerarjona commented 5 years ago

Hello. I would like to know if there is a way to delete elements sending a list of ids.

Normally we delete many elements like this:

id_list = ['*1', '*2', '*3', '*4']
for id_queue in id_list:
    list_queues.remove(id=id_queue)

But, there is, or is possible something like this?

id_list = ['*1', '*2', '*3', '*4']
list_queues.remove(id_list)

@jgoclawski , @stevehaskew

stevehaskew commented 5 years ago

As far as I am aware there is not a way to do that currently. All my contributions so far have been around the initial connection etc. and I haven't delved into the resource objects and how to work with/modify them. Unfortunately I don't have the time at the moment to do so.

I like the idea - it makes sense to be able to provide a list and the remove function detect it and act accordingly. Feel free to make a contribution yourself if you are able!

jiri-lunacek commented 3 years ago

Hello. I would like to know if there is a way to delete elements sending a list of ids.

Normally we delete many elements like this:

id_list = ['*1', '*2', '*3', '*4']
for id_queue in id_list:
  list_queues.remove(id=id_queue)

But, there is, or is possible something like this?

id_list = ['*1', '*2', '*3', '*4']
list_queues.remove(id_list)

@jgoclawski , @stevehaskew

Hello. I just came to this project. And found that the following approach works:

id_list = ['*1', '*2', '*3', '*4']
list_queues.remove(','.join(id_list))
stevehaskew commented 3 years ago

Thanks for taking the time to share this solution, it's much appreciated!