mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Implement Oxidized "config search" as an API (#10648)
* Implement Oxidized config search as API * Add Oxidized config search DOC. * Update Devices.md * change /configsearch/{searchstring} to /config/search/{searchstring} * Update Devices.md
This commit is contained in:
@@ -1174,3 +1174,39 @@ Output:
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
### `search_oxidized`
|
||||||
|
|
||||||
|
search all oxidized device configs for a string.
|
||||||
|
|
||||||
|
Route: `api/v0/oxidized/config/search/:searchstring`
|
||||||
|
|
||||||
|
- searchstring is the specific string you would like to search for.
|
||||||
|
|
||||||
|
Input:
|
||||||
|
|
||||||
|
-
|
||||||
|
|
||||||
|
Example:
|
||||||
|
```curl
|
||||||
|
curl -H 'X-Auth-Token: YOURAPITOKENHERE' https://librenms.org/api/v0/oxidized/configsearch/vlan10
|
||||||
|
```
|
||||||
|
|
||||||
|
Output:
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"status": "ok",
|
||||||
|
"nodes": [
|
||||||
|
{
|
||||||
|
"node": "asr9k.librenms.org",
|
||||||
|
"full_name": "cisco\/ASR9K.Librenms.org"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"node": "ios.Librenms.org",
|
||||||
|
"full_name": "cisco\/ios.Librenms.org"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"count": 2
|
||||||
|
}
|
||||||
|
```
|
||||||
|
@@ -1186,6 +1186,18 @@ function get_inventory(\Illuminate\Http\Request $request)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function search_oxidized(\Illuminate\Http\Request $request)
|
||||||
|
{
|
||||||
|
$search_in_conf_textbox = $request->route('searchstring');
|
||||||
|
$result = search_oxidized_config($search_in_conf_textbox);
|
||||||
|
|
||||||
|
if (!$result) {
|
||||||
|
return api_error(404, "Received no data from Oxidized");
|
||||||
|
} else {
|
||||||
|
return api_success($result, 'nodes');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function list_oxidized(\Illuminate\Http\Request $request)
|
function list_oxidized(\Illuminate\Http\Request $request)
|
||||||
{
|
{
|
||||||
$hostname = $request->route('hostname');
|
$hostname = $request->route('hostname');
|
||||||
|
@@ -73,6 +73,7 @@ Route::group(['prefix' => 'v0', 'namespace' => '\App\Api\Controllers'], function
|
|||||||
Route::put('rules', 'LegacyApiController@add_edit_rule')->name('edit_rule');
|
Route::put('rules', 'LegacyApiController@add_edit_rule')->name('edit_rule');
|
||||||
Route::delete('rules/{id}', 'LegacyApiController@delete_rule')->name('delete_rule');
|
Route::delete('rules/{id}', 'LegacyApiController@delete_rule')->name('delete_rule');
|
||||||
Route::post('services/{hostname}', 'LegacyApiController@add_service_for_host')->name('add_service_for_host');
|
Route::post('services/{hostname}', 'LegacyApiController@add_service_for_host')->name('add_service_for_host');
|
||||||
|
Route::get('oxidized/config/search/{searchstring}', 'LegacyApiController@search_oxidized')->name('search_oxidized');
|
||||||
});
|
});
|
||||||
|
|
||||||
// restricted by access
|
// restricted by access
|
||||||
|
Reference in New Issue
Block a user