From d091788f28f7187e485919f12bea1c2d0211a31e Mon Sep 17 00:00:00 2001 From: Andy Norwood <2754635+bonzo81@users.noreply.github.com> Date: Thu, 15 Dec 2022 14:25:11 +0000 Subject: [PATCH] API list_devices update with sysName, location_id and type (#14731) * Add sysName, location_id, type to list_devices * Add new list_devices type --- doc/API/Devices.md | 3 +++ includes/html/api_functions.inc.php | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/doc/API/Devices.md b/doc/API/Devices.md index 514b00cf65..bfbb79a049 100644 --- a/doc/API/Devices.md +++ b/doc/API/Devices.md @@ -1014,8 +1014,11 @@ Input: - ipv4: search by IPv4 address - ipv6: search by IPv6 address (compressed or uncompressed) - location: search by location + - location_id: serach by locaiton_id - hostname: search by hostname + - sysName: search by sysName - device_id: exact match by device-id + - type: search by device type - query: If searching by, then this will be used as the input. Example: diff --git a/includes/html/api_functions.inc.php b/includes/html/api_functions.inc.php index 7b49f2a4ef..e678f70e66 100644 --- a/includes/html/api_functions.inc.php +++ b/includes/html/api_functions.inc.php @@ -341,6 +341,15 @@ function list_devices(Illuminate\Http\Request $request) $sql = 'a.`ipv6_address`=? OR a.`ipv6_compressed`=?'; $select .= ',p.* '; $param = [$query, $query]; + } elseif ($type == 'sysName') { + $sql = '`d`.`sysName`=?'; + $param[] = $query; + } elseif ($type == 'location_id') { + $sql = '`d`.`location_id`=?'; + $param[] = $query; + } elseif ($type == 'type') { + $sql = '`d`.`type`=?'; + $param[] = $query; } else { $sql = '1'; }