...
Rules can be managed using Websocket API or REST API.
Rule creation
A new rule can be created with REST API query /api/rule/create
...
request
API | Request | Response | Response status |
---|
WS API | |
...
SEND
destination:/app/api/rule/create
content-length:150
{
"requestId":"41bf9d28-5dbe-45cc-9add-ff443997e1d5",
"realm":"/api/rule/create",
"payload":
{
|
|
...
...
...
...
...
"value":"test*",
"profiles":["1"]
}
} |
| Code Block |
---|
| MESSAGE
destination:/user/service
content-type:application/json;charset=UTF-8
subscription:sub-1
message-id:3-17
content-length:84
{
"requestId":"41bf9d28-5dbe-45cc-9add-ff443997e1d5",
"status":200,
"reason":"SUCCESS"
} |
| 200 OK 400 Object not found 500 Persist exception |
REST API | |
...
/api/rule/create "application/json; charset=utf-8"
{
"type":"0",
"name":"rule2",
"value":"test*",
|
|
...
...
| Code Block |
---|
| {
"status":200,
"reason":"SUCCESS"
} |
| 200 OK 400 Object not found 500 Persist exception |
Where
- type – rule type:
- 0 – stream name template
- 1 - reservedmedia session id template
- name – rule name
- value – rule value (template for type 0)
- profiles – list of identifiers of profiles, to which the rule should be applied
...
A rule can be changed with REST API query /api/rule/update
...
request
API | Request | Response | Response status |
---|
WS API | |
...
...
app/api/rule/update
content-length:163
{
"requestId":"cc2605d6-ef85-4a7e-9a8f-04733c413b3d",
"realm":"/api/rule/update",
"payload":
{
|
|
...
...
...
...
...
...
...
test*",
"profiles":["1","2"]
}
} |
| Code Block |
---|
| MESSAGE
destination:/user/service
content-type:application/json;charset=UTF-8
subscription:sub-1
message-id:3-20
content-length:84
{
"requestId":"cc2605d6-ef85-4a7e-9a8f-04733c413b3d",
"status":200,
"reason":"SUCCESS"
} |
| 200 OK 400 Object not found 500 Persist exception |
REST API | Code Block |
---|
| POST: /api/rule/update "application/json; charset=utf-8"
{
"id":"3",
"type":"0",
"name":"rule2",
"value":"test*",
"profiles":[ |
|
...
| Code Block |
---|
| {
"status":200,
"reason":"SUCCESS"
} |
| 200 OK 400 Object not found 500 Persist exception |
Where
- id – rule identifier
- type – rule type (0 or 1)
- name – rule name
- value – rule value (template for type 0)
- profiles – list of identifiers of profiles, to which the rule should be applied
...
A rule can be deleted with REST API query /api/rule/delete
...
request
API | Request | Response | Response status |
---|
WS API | Code Block |
---|
| SEND
destination:/app/api/rule/delete
content-length:100
{
"requestId":"a1887fc3-c674-4951-b5b8-ff1d69fed097",
"realm":"/api/rule/delete",
"payload":
{
"id":"2"
}
} |
| |
...
MESSAGE
destination:/user/ |
|
...
service
content-type:application/json;charset=UTF-8
subscription:sub-1
message-id:3-21
content-length:84
{
"requestId":"a1887fc3-c674-4951-b5b8-ff1d69fed097",
"status":200,
"reason":"SUCCESS"
} |
| 200 OK 400 Object not found 500 Persist exception |
REST API | Code Block |
---|
| POST: /api/rule/delete "application/json; charset=utf-8"
{
|
|
...
| Code Block |
---|
| {
"status":200,
"reason":" |
|
...
| 200 OK 400 Object not found 500 Persist exception |
Where
...
A rule information can be obtained with REST API query /api/rule/list request
...
...
Response | Response status |
---|
WS API | Code Block |
---|
| SEND
destination:/app/api/rule/list
content-length:111
{
"requestId":"e9a2ce8c-ad2a-49c0-9c38-6ba8e4817fdd",
"realm":"/api/rule/list",
"payload":
{
"id":"1",
"profile":""
}
} |
| |
...
MESSAGE
destination:/user/ |
|
...
service
content-type:application/json;charset=UTF-8
subscription:sub-1
message-id:3-22
content-length:161
{
"requestId":"e9a2ce8c-ad2a-49c0-9c38-6ba8e4817fdd",
"status":200,
"reason":"SUCCESS",
"payload": [
{
"id":1,
"profiles":[1,2],
"type":0,
"name":"default",
"value":".*"
}
]
} |
| 200 OK 400 Object not found 500 Persist exception |
REST API | Code Block |
---|
| POST: /api/rule/list "application/json; charset=utf-8"
{
"id":"1",
"profile":""
} |
| Code Block |
---|
| {
"status": 200,
"reason": "SUCCESS",
"payload": [
|
|
...
{
"id": 1,
"profiles": [
1,
2
],
"type": 0,
"name": " |
|
...
...
...
...
| 200 OK 400 Object not found 500 Persist exception |
Where
- id – rule identifier
- profile - profile identifier
If rule Id is set, the response will contain this contain only that rule information only. If profile Id is set, the response will contain information only about the rules applied to this that profile metrics only. If none of Ids is set, the response will contain list with all the rules on backend server.
The For every rule, the response contains the same fields for a rule as /api/rule/update queryrequest.