Merge pull request #2611 from laf/issue-2451

Added new API calls to support device groups
This commit is contained in:
Daniel Preussker
2015-12-20 17:35:27 +00:00
4 changed files with 247 additions and 7 deletions

View File

@@ -19,6 +19,10 @@
- [`add_device`](#api-route-11)
- [`list_oxidized`](#api-route-21)
- [`update_device_field`](#api-route-update_device_field)
- [`get_device_groups`](#api-route-get_device_groups)
- [`devicegroups`](#api-devicegroups)
- [`get_devicegroups`](#api-route-get_devicegroups)
- [`get_devices_by_group`](#api-route-get_devices_by_group)
- [`routing`](#api-routing)
- [`list_bgp`](#api-route-1)
- [`switching`](#api-switching)
@@ -470,6 +474,8 @@ Update devices field in the database.
Route: /api/v0/devices/:hostname
- hostname can be either the device hostname or id
Input (JSON):
- field: The column name within the database
@@ -491,6 +497,154 @@ Output:
]
```
### <a name="api-route-get_device_groups">Function `get_device_groups`</a> [`top`](#top)
List the device groups that a device is matched on.
Route: /api/v0/devices/:hostname/groups
- hostname can be either the device hostname or id
Input (JSON):
-
Examples:
```curl
curl -H 'X-Auth-Token: YOURAPITOKENHERE' https://librenms.org/api/v0/devices/localhost/groups
```
Output:
```text
[
{
"status": "ok",
"message": "Found 1 device groups",
"count": 1,
"groups": [
{
"id": "1",
"name": "Testing",
"desc": "Testing",
"pattern": "%devices.status = \"1\" &&"
}
]
}
]
```
## <a name="api-devicegroups">`Device Groups`</a> [`top`](#top)
### <a name="api-route-get_devicegroups">Function `get_devicegroups`</a> [`top`](#top)
List all device groups.
Route: /api/v0/devicegroups
Input (JSON):
-
Examples:
```curl
curl -H 'X-Auth-Token: YOURAPITOKENHERE' https://librenms.org/api/v0/devicegroups
```
Output:
```text
[
{
"status": "ok",
"message": "Found 1 device groups",
"count": 1,
"groups": [
{
"id": "1",
"name": "Testing",
"desc": "Testing",
"pattern": "%devices.status = \"1\" &&"
}
]
}
]
```
### <a name="api-route-get_devices_by_group">Function `get_devices_by_group`</a> [`top`](#top)
List all devices matching the group provided.
Route: /api/v0/devicegroups/:name
- name Is the name of the device group which can be obtained using [`get_devicegroups`](#api-route-get_devicegroups). Please ensure that the name is urlencoded if it needs to be (i.e Linux Servers would need to be urlencoded.
Input (JSON):
-
Examples:
```curl
curl -H 'X-Auth-Token: YOURAPITOKENHERE' https://librenms.org/api/v0/devicegroups/LinuxServers
```
Output:
```text
[
{
"status": "error",
"message": "Found 1 in group LinuxServers",
"count": 1,
"devices": [
{
"device_id": "1",
"hostname": "localhost",
"sysName": "hostname",
"community": "librenms",
"authlevel": null,
"authname": null,
"authpass": null,
"authalgo": null,
"cryptopass": null,
"cryptoalgo": null,
"snmpver": "v2c",
"port": "161",
"transport": "udp",
"timeout": null,
"retries": null,
"bgpLocalAs": null,
"sysObjectID": ".1.3.6.1.4.1.8072.3.2.10",
"sysDescr": "Linux li1045-133.members.linode.com 4.1.5-x86_64-linode61 #7 SMP Mon Aug 24 13:46:31 EDT 2015 x86_64",
"sysContact": "",
"version": "4.1.5-x86_64-linode61",
"hardware": "Generic x86 64-bit",
"features": "CentOS 7.1.1503",
"location": "",
"os": "linux",
"status": "1",
"status_reason": "",
"ignore": "0",
"disabled": "0",
"uptime": "4615964",
"agent_uptime": "0",
"last_polled": "2015-12-12 13:20:04",
"last_poll_attempted": null,
"last_polled_timetaken": "1.90",
"last_discovered_timetaken": "79.53",
"last_discovered": "2015-12-12 12:34:21",
"last_ping": "2015-12-12 13:20:04",
"last_ping_timetaken": "0.08",
"purpose": null,
"type": "server",
"serial": null,
"icon": null,
"poller_group": "0",
"override_sysLocation": "0",
"notes": "Nope"
}
]
}
]
```
## <a name="api-routing">`Routing`</a> [`top`](#top)
### <a name="api-route-1">Function: `list_bgp`</a> [`top`](#top)