mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Adds API to fetch all inventory items for a given device (#10885)
Adds API to fetch all inventory items for a given device
This commit is contained in:
committed by
Jellyfrog
parent
acfc2e7c81
commit
ae7eee438f
@@ -1209,6 +1209,21 @@ function get_inventory(\Illuminate\Http\Request $request)
|
||||
}
|
||||
|
||||
|
||||
function get_inventory_for_device(\Illuminate\Http\Request $request)
|
||||
{
|
||||
$hostname = $request->route('hostname');
|
||||
// use hostname as device_id if it's all digits
|
||||
$device_id = ctype_digit($hostname) ? $hostname : getidbyname($hostname);
|
||||
return check_device_permission($device_id, function ($device_id) use ($request) {
|
||||
$params = [];
|
||||
$sql = 'SELECT * FROM `entPhysical` WHERE device_id = ?';
|
||||
$params[] = $device_id;
|
||||
$inventory = dbFetchRows($sql, $params);
|
||||
return api_success($inventory, 'inventory');
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function search_oxidized(\Illuminate\Http\Request $request)
|
||||
{
|
||||
$search_in_conf_textbox = $request->route('searchstring');
|
||||
|
@@ -133,6 +133,7 @@ Route::group(['prefix' => 'v0', 'namespace' => '\App\Api\Controllers'], function
|
||||
});
|
||||
|
||||
Route::get('inventory/{hostname}', 'LegacyApiController@get_inventory')->name('get_inventory');
|
||||
Route::get('inventory/{hostname}/all', 'LegacyApiController@get_inventory_for_device')->name('get_inventory_for_device');
|
||||
|
||||
|
||||
// Route not found
|
||||
|
Reference in New Issue
Block a user