Flow Classification API
Use the Flow Classification API to update, create, or delete flow classification rules.
If not otherwise specified, the Content-Type of the response is application/json .
|
GETs (Reading Data)
Resource | Description |
---|---|
|
Retrieve a list of all enabled rules.
The request is limited to |
|
Retrieve the rule identified by |
|
Retrieve all existing groups.
The request is limited to |
|
Retrieve the group identified by |
|
Retrieve all supported TCP protocols. |
The /classifications
endpoint supports the following URL parameters:
The given filters are combined using a logical AND .
There is no support for using OR logic, or combinations thereof.
|
Name | Default | Comment |
---|---|---|
groupFilter |
(none) |
The group by which to filter the rules.
Should be the |
query |
(none) |
A |
Examples
curl -X GET -u admin:admin http://localhost:8980/opennms/rest/classifications
[
{
"group": {
"description": "Classification rules defined by the user",
"enabled": true,
"id": 2,
"name": "user-defined",
"position": 10,
"readOnly": false,
"ruleCount": 1
},
"id": 1,
"ipAddress": null,
"name": "http",
"port": "80",
"position": 0,
"protocols": [
"TCP"
]
}
]
curl -X GET -u admin:admin http://localhost:8980/opennms/rest/classifications/groups
[
{
"description": "Classification rules defined by OpenNMS",
"enabled": false,
"id": 1,
"name": "pre-defined",
"priority": 0,
"readOnly": true,
"ruleCount": 6248
},
{
"description": "Classification rules defined by the user",
"enabled": true,
"id": 2,
"name": "user-defined",
"priority": 10,
"readOnly": false,
"ruleCount": 1
}
]
curl -X GET -u admin:admin http://localhost:8980/opennms/rest/classifications/1
{
"group": {
"description": "Classification rules defined by the user",
"enabled": true,
"id": 2,
"name": "user-defined",
"priority": 10,
"readOnly": false,
"ruleCount": 1
},
"id": 1,
"ipAddress": null,
"name": "http",
"port": "80",
"position": 0,
"protocols": [
"TCP"
]
}
curl -X GET -H "Accept: application/json" -u admin:admin http://localhost:8980/opennms/rest/classifications/groups/1
{
"description": "Classification rules defined by OpenNMS",
"enabled": false,
"id": 1,
"name": "pre-defined",
"priority": 0,
"readOnly": true,
"ruleCount": 6248
}
curl -X GET -H "Accept: text/comma-separated-values" -u admin:admin http://localhost:8980/opennms/rest/classifications/groups/2
name;ipAddress;port;protocol
http;;80;TCP
POSTs (Creating Data)
Resource | Description |
---|---|
|
Post a new rule or import rules from CSV. If multiple rules are imported (to user-defined group) from a CSV file all existing rules are deleted. |
|
Classify the given request based on all enabled rules. |
Examples
curl -X POST -H "Content-Type: application/json" -u admin:admin -d '{"name": "http", "port":"80,8080", "protocols":["tcp", "udp"]}' http://localhost:8980/opennms/rest/classifications
HTTP/1.1 201 Created
Date: Thu, 08 Feb 2018 14:44:27 GMT
Location: http://localhost:8980/opennms/rest/classifications/6616
curl -X POST -H "Content-Type: application/json" -u admin:admin -d '{"protocol": "tcp", "ipAddress": "192.168.0.1", "port" :"80"}' http://localhost:8980/opennms/rest/classifications/classify
{
"classification":"http"
}
curl -X POST -H "Content-Type: application/json" -u admin:admin -d '{"protocol": "tcp", "ipAddress": "192.168.0.1", "port" :"8980"}' http://localhost:8980/opennms/rest/classifications/classify
HTTP/1.1 204 No Content
curl -X POST -H "Content-Type: text/comma-separated-values" -u admin:admin -d $'name;ipAddress;port;protocol\nOpenNMS;;8980;tcp,udp\n' http://localhost:8980/opennms/rest/classifications/groups/\{id}\?hasHeader\=true
HTTP/1.1 204 No Content
curl -X POST -H "Content-Type: text/comma-separated-values" -u admin:admin -d $'OpenNMS;;INCORRECT;tcp,udp\nhttp;;80,8080;ULF' http://localhost:8980/opennms/rest/classifications\?hasHeader\=false
{
"errors": {
"1": {
"context": "port",
"key": "rule.port.definition.invalid",
"message": "Please provide a valid port definition. Allowed values are numbers between 0 and 65536. A range can be provided, e.g. \"4000-5000\", multiple values are allowed, e.g. \"80,8080\""
},
"2": {
"context": "protocol",
"key": "rule.protocol.doesnotexist",
"message": "The defined protocol 'ULF' does not exist"
}
},
"success": false
}