librenms/librenms — pull request #356 by laf (2014-11-30 15:46:48+00:00)
Title: Added new API route to obtain available ports for a device

Call:

curl -H "X-Auth-Token: APITOKEN" http://librenms.org/api/v0/devices/localhost/ports

curl -H "X-Auth-Token: APITOKEN" http://librenms.org/api/v0/devices/localhost/ports?columns=port_id,ifDescr,ifName,ifOperStatus,ifAdminStatus

Output:

{
"status": "ok",
"err-msg": "",
"count": 5,
"ports": [
{
"ifName": "lo"
},
{
"ifName": "eth0"
},
{
"ifName": "eth1"
},
{
"ifName": "eth2"
},
{
"ifName": "eth3"
}
]
}

{
"status": "ok",
"err-msg": "",
"count": 5,
"ports": [
{
"port_id": "126",
"ifDescr": "lo",
"ifName": "lo",
"ifOperStatus": "up",
"ifAdminStatus": "up"
},
{
"port_id": "127",
"ifDescr": "eth0",
"ifName": "eth0",
"ifOperStatus": "up",
"ifAdminStatus": "up"
},
{
"port_id": "128",
"ifDescr": "eth1",
"ifName": "eth1",
"ifOperStatus": "down",
"ifAdminStatus": "down"
},
{
"port_id": "129",
"ifDescr": "eth2",
"ifName": "eth2",
"ifOperStatus": "down",
"ifAdminStatus": "down"
},
{
"port_id": "130",
"ifDescr": "eth3",
"ifName": "eth3",
"ifOperStatus": "up",
"ifAdminStatus": "up"
}
]
}