Set Link Stat Rules

PUT /node/api/links/:link_id/stat-rules

Set stat rules for a link with the specified ID.
Permissions: linkPermissions & manage-links.

Request parameters

Path parameters

Parameter
Type
Description
link_id
string
required
The ID of a link whose stat rules should be set.

Body parameters

...

Response description

...

Examples

Request examples

Bash
JavaScript
NodeJS
Python
1
login=<...>
2
password=<...>
3
saymon_hostname=<...>
4
link_id=<...>
5
url=https://$saymon_hostname/node/api/links/$link_id/stat-rules
6
7
curl -X PUT $url -u $login:$password \
8
-H "Content-Type: application/json" \
9
-d @- <<EOF
10
[
11
{
12
"conditions": [{ "x": 1 }],
13
"rules": [{"type": "extend"}],
14
"actions": []
15
}
16
]
17
EOF
Copied!
1
let login = <...>
2
let password = <...>
3
let saymonHostname = <...>
4
let linkId = <...>
5
let path = "/node/api/links/" + linkId + "/stat-rules";
6
let auth = "Basic " + btoa(login + ":" + password);
7
8
let headers = new Headers();
9
headers.append("Content-Type", "application/json");
10
headers.append("Authorization", auth);
11
12
let data = JSON.stringify([
13
{
14
"conditions": [{ "x": 1 }],
15
"rules": [{ "type": "extend" }],
16
"actions": []
17
}
18
]);
19
20
let requestOptions = {
21
method: "PUT",
22
headers: headers,
23
body: data
24
};
25
26
fetch(saymonHostname + path, requestOptions)
27
.then(response => response.text())
28
.then(result => console.log(result))
29
.catch(error => console.log("error", error));
Copied!
1
const http = require("http");
2
3
let login = <...>
4
let password = <...>
5
let saymonHostname = <...>
6
let linkId = <...>
7
let path = "/node/api/links/" + linkId + "/stat-rules";
8
let auth = "Basic " + Buffer.from(login + ":" + password).toString("base64");
9
10
let options = {
11
"method": "PUT",
12
"hostname": saymonHostname,
13
"path": path,
14
"headers": {
15
"Authorization": auth,
16
"Content-Type": "application/json"
17
}
18
};
19
20
let req = http.request(options, function (res) {
21
let chunks = [];
22
23
res.on("data", function (chunk) {
24
chunks.push(chunk);
25
});
26
27
res.on("end", function (chunk) {
28
let body = Buffer.concat(chunks);
29
console.log(body.toString());
30
});
31
32
res.on("error", function (error) {
33
console.error(error);
34
});
35
});
36
37
let data = JSON.stringify([
38
{
39
"conditions": [{ "x": 1 }],
40
"rules": [{ "type": "extend" }],
41
"actions": []
42
}
43
]);
44
45
req.write(data);
46
req.end();
Copied!
1
import requests
2
3
login = <...>
4
password = <...>
5
link_id = <...>
6
saymon_hostname = <...>
7
url = "https://" + saymon_hostname + "/node/api/links/" + \
8
link_id + "/stat-rules"
9
10
body = [
11
{
12
"conditions": [{"x": 1}],
13
"rules": [{"type": "extend"}],
14
"actions": []
15
}
16
]
17
18
response = requests.request("PUT", url, json=body, auth=(login, password))
19
print(response.text)
Copied!

Response example

1
[
2
{
3
"conditions": [{ "x": 1 }],
4
"rules": [{ "type": "extend" }],
5
"actions": []
6
}
7
]
Copied!
Last modified 1yr ago