Получить историю аварий
Возвращает массив исторических аварий, доступных текущему пользователю.
Запрос
HTTP Запрос
text
GET /node/api/incident-historyПараметры пути
Параметры не требуются.
Параметры запроса
| Параметр | Тип | Описание |
|---|---|---|
| limit | Integer | Максимальное количество возвращаемых записей. |
| skip | Integer | Сколько записей с начала списка нужно пропустить. |
| sortField | String | Имя поля, используемого для сортировки записей. |
| sortDirection | String | Тип сортировки. asc сортировка по возрастанию, desc – по убыванию. По умолчанию – asc. |
| ownerFilter | String | Дополнительные фильтры для данных владельца. |
| filter | Фильтры аварии | Набор фильтров. Подробная информация о модели доступна в статье Фильтры аварии. |
Тело запроса
Тело запроса пустое.
Ответ
Возвращает массив исторических аварий, доступных текущему пользователю. Подробная информация о модели доступна в статье Авария.
NOTE
Этот запрос не возвращает поле аварии type .
Пример
Запрос
- Bash
- JavaScript
- NodeJS
- Python
bash
login=<...>
password=<...>
saymon_hostname=<...>
url=https://$saymon_hostname/node/api/incident-history
curl -X GET $url -u $login:$password \
-G --data-urlencode "limit=2"javascript
let login = <...>
let password = <...>
let saymonHostname = <...>
let queryParams = "limit=2";
let path = "/node/api/incident-history" + "?" + queryParams;
let auth = "Basic " + btoa(login + ":" + password);
let headers = new Headers();
headers.append("Authorization", auth);
let requestOptions = {
method: "GET",
headers: headers
};
fetch(saymonHostname + path, requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log("error", error));javascript
const http = require("http");
let login = <...>
let password = <...>
let saymonHostname = <...>
let queryParams = "limit=2";
let path = "/node/api/incident-history" + "?" + queryParams;
let auth = "Basic " + Buffer.from(login + ":" + password).toString("base64");
let options = {
"method": "GET",
"hostname": saymonHostname,
"headers": {
"Authorization": auth
},
"path": path
};
let req = http.request(options, function (res) {
let chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function (chunk) {
let body = Buffer.concat(chunks);
console.log(body.toString());
});
res.on("error", function (error) {
console.error(error);
});
});
req.end();python
import requests
login = <...>
password = <...>
saymon_hostname = <...>
url = "https://" + saymon_hostname + "/node/api/incident-history"
params = {
"limit": 2
}
response = requests.request("GET", url, auth=(login, password), params=params)
print(response.text)Ответ
json
[
{
"entityId": "5e21b85b308c3c66d64e07d2",
"entityType": 1,
"type": 1,
"parentChainId": "5e21b85b308c3c66d64e07d2",
"data": "...",
"text": "No data",
"localTimestamp": 1579614817826,
"timestamp": 1579614817826,
"clearTimestamp": 1579614894499,
"id": "5e270329f5d0b555d592e938",
"count": 1
},
{
"entityId": "5e21b85b308c3c66d64e07df",
"entityType": 1,
"type": 1,
"parentChainId": "5e21b85b308c3c66d64e07df",
"data": "...",
"text": "No data",
"localTimestamp": 1579614817887,
"timestamp": 1579614817887,
"clearTimestamp": 1579614894504,
"id": "5e270329f5d0b555d592e939",
"count": 1
},
...
]