Создать отчёт по истории аварий в формате CSV

Создать отчёт по истории аварий в формате CSV

Создать отчёт по истории аварий в формате CSV ​

Возвращает историю аварий в формате CSV.

Запрос ​

HTTP Запрос ​

text
GET /node/api/reports/incident-history/csv

Права ​

text
objectPermissions

Параметры пути ​

ПараметрТипОписание
fieldsArray<String>Поля, которые нужно включить в отчёт. Все возможные поля описаны в статье Авария.
filterФильтры аварииФильтр отчёта. Подробная информация о модели доступна в статье список доступных фильтров

Тело запроса ​

Тело запроса пустое.

Ответ ​

Возвращает таблицу в формате CSV со списком исторических аварий.

По умолчанию, отчёт содержит следующие поля:

  • registeredTime – 'Registered Time',
  • occurredTime – 'Occurred Time',
  • clearedTime – 'Clear Time',
  • entity – 'Object/Link',
  • state – 'Status',
  • lastState – 'Severity',
  • text – 'Text',
  • acknowledgedBy – 'Acknowledged By',
  • comment – 'Comment'

Пример ​

Запрос ​

  • Bash
  • JavaScript
  • NodeJS
  • Python
bash
login=<...>
password=<...>
saymon_hostname=<...>
url=https://$saymon_hostname/node/api/reports/incident-history/csv

curl -X GET $url -u $login:$password
javascript
let login = <...>
let password = <...>
let saymonHostname = <...>
let path = "/node/api/reports/incident-history/csv";
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 request = require("request");

let login = <...>
let password = <...>
let saymonHostname = <...>
let url = "https://" + saymonHostname + "/node/api/reports/incident-history/csv";

let auth = "Basic " + Buffer.from(login + ":" + password).toString("base64");

let options = {
    method: "GET",
    url: url,
    headers: {
        Authorization: auth
    }
};

request(options, function (error, response, body) {
    if (error) throw new Error(error);
    console.log(body);
});
python
import requests

login = <...>
password = <...>
saymon_hostname = <...>
url = "https://" + saymon_hostname + "/node/api/reports/incident-history/csv"

response = requests.request("GET", url, auth=(login, password))
print(response.text)

Ответ ​

text
Registered Time;Occurred Time;Clear Time;Object/Link;;Status;Severity;Acknowledged By;Comment
03/28/2024, 12:25:25 PM;03/28/2024, 12:25:25 PM;03/28/2024, 12:26:16 PM;"Ping";;Cleared;Alarm;"admin";"Working on it!"
03/28/2024, 11:26:03 AM;03/28/2024, 11:26:03 AM;03/28/2024, 11:26:15 AM;"Ping";;Cleared;Major;"alice";
03/28/2024, 11:26:03 AM;03/28/2024, 11:26:03 AM;03/28/2024, 11:26:15 AM;"Ping";;Cleared;Major;;
03/28/2024, 11:26:03 AM;03/28/2024, 11:26:03 AM;03/28/2024, 11:26:51 AM;"SAYMON Agent";;Cleared;Major;"bob";

Смотрите также ​