Skip to content

Commit c382393

Browse files
committed
add routes function
returns the list of active routes
1 parent 61584e3 commit c382393

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

ubiquiti/unifi.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,22 @@ def events(self, filters: Dict[str, Union[str, Pattern]]=None, order_by: str=Non
197197
data = sorted(data, key=lambda x: x[order_by] if order_by in x.keys() else x['_id'])
198198

199199
return data
200+
201+
def routes(self, filters: Dict[str, Union[str, Pattern]]=None, order_by: str=None) -> list:
202+
"""
203+
List site routes.
204+
205+
:param filters: dict of k/v pairs; string is compiled to regex
206+
:param order_by: order by a key; defaults to '_id'
207+
:return: A list of routes as dicts (see below for example data)
208+
nh: [{'intf': 'eth0',
209+
't': 'C>*'
210+
}]
211+
pfx: 192.168.1.0/24
212+
"""
213+
r = self._session.get("{}/api/s/{}/stat/routing".format(self._baseurl, self._site, verify=self._verify_ssl), data="json={}")
214+
self._current_status_code = r.status_code
215+
200216
if self._current_status_code == 401:
201217
raise LoggedInException("Invalid login, or login has expired")
202218

0 commit comments

Comments
 (0)