mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
api: Added retrieve BGP sessions by ID (#7825)
* add support for retrieving BGP sessions via id * fix syntax, use router params * use count properly * add get_bgp docs * streamlined get_bgp sql query
This commit is contained in:
committed by
Neil Lathwood
parent
5871ee1c67
commit
e3082873f6
@ -506,6 +506,31 @@ function list_bgp()
|
||||
}
|
||||
|
||||
|
||||
function get_bgp()
|
||||
{
|
||||
check_is_read();
|
||||
|
||||
$app = \Slim\Slim::getInstance();
|
||||
$router = $app->router()->getCurrentRoute()->getParams();
|
||||
|
||||
$bgpPeerId = $router['id'];
|
||||
if (!is_numeric($bgpPeerId)) {
|
||||
api_error(400, 'Invalid id has been provided');
|
||||
}
|
||||
|
||||
$bgp_session = dbFetchRows("SELECT * FROM `bgpPeers` WHERE `bgpPeerState` IS NOT NULL AND `bgpPeerState` != '' AND bgpPeer_id = ?", array($bgpPeerId));
|
||||
$bgp_session_count = count($bgp_session);
|
||||
if (!is_numeric($bgp_session_count)) {
|
||||
api_error(500, 'Error retrieving BGP peer');
|
||||
}
|
||||
if ($bgp_session_count == 0) {
|
||||
api_error(404, "BGP peer $bgpPeerId does not exist");
|
||||
}
|
||||
|
||||
api_success($bgp_session, 'bgp_session');
|
||||
}
|
||||
|
||||
|
||||
function list_ospf()
|
||||
{
|
||||
check_is_read();
|
||||
|
Reference in New Issue
Block a user