api: Added the ability to list devices by location in the api (#5693)

* Adding location based filter for api-device calls

* I agree to the conditions of the Contributor Agreement contained in doc/General/Contributing.md.

* configured linting etc, now pr should pass

* rebase and add entry to docs
This commit is contained in:
gilrim 2017-02-08 22:57:15 +01:00 committed by Neil Lathwood
parent 8559137587
commit 8b401fd05b
3 changed files with 7 additions and 0 deletions

View File

@ -171,10 +171,14 @@ LibreNMS contributors:
- Robert Towster <rnt-github at towster.com> (towster)
- Rocky Luke <rockyluke@offline.net> (rockyluke)
- Tim Jackson <jackson.tim@gmail.com> (jackson-tim)
<<<<<<< HEAD
- Jørn-Stian Lønsetteig <jeg@glemte.no> (gilrim)
=======
- Viktoria Rei Bauer <vbauer@stargazer.at> (ToeiRei)
- Ryan Eno <ryaneno@gmail.com> (VimCommando)
- Matt Peterson <matt@peterson.org> (dorkmatt)
- William George <wrgeorge1983@gmail.com> (wrgeorge1983)
>>>>>>> 665f9e902e31a70c05ceae9f3589db4fd76107a7
Observium was written by:
- Adam Armstrong

View File

@ -729,6 +729,7 @@ Input:
- mac: search by mac address
- ipv4: search by IPv4 address
- ipv6: search by IPv6 address (compressed or uncompressed)
- location: search by location
- query: If searching by, then this will be used as the input.
Example:
```curl

View File

@ -210,6 +210,8 @@ function list_devices()
if ($type == 'all' || empty($type)) {
$sql = '1';
} elseif ($type == 'location') {
$sql = "`location` LIKE '%".$query."%'";
} elseif ($type == 'ignored') {
$sql = "`ignore`='1' AND `disabled`='0'";
} elseif ($type == 'up') {