socialwifi / RouterOS-api

Python API to RouterBoard devices produced by MikroTik.
MIT License
251 stars 100 forks source link

How can you search for an unset value? #72

Open tal-zvon opened 3 years ago

tal-zvon commented 3 years ago

Trying to get the default route on the router in the main routing table. Can't figure out how to tell .get() that I'm looking for an item where the routing_mark field is unset.

#!/usr/bin/env python3

import routeros_api

args = {
    "host": "1.2.3.4",
    "username": "admin",
    "password": "PASSWORD",
        ...
}

api_connection = routeros_api.RouterOsApiPool(**args)
api = api_connection.get_api()

routes = api.get_resource("/ip/route")
default_route = routes.get(dst_address="0.0.0.0/0", disabled="no", routing_mark=None)

None doesn't work. "none" doesn't seem to work either. Is there a way to do this?

memost commented 3 years ago

resolve this is simple just add 2 lines in resourse.py in class RouterOsBinaryResource(object): sowhere around def set(self, **kwargs):

    def unset(self, **kwargs):
        return self.call('unset', kwargs)

it is like 'set' but calling "unset". working fine for me