-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsimilarIncidentsService.js
67 lines (63 loc) · 1.96 KB
/
similarIncidentsService.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
const axios = require("axios");
const getCEGroups = async (apiKey) => {
try {
const res = await axios({
method: "get",
url: "https://api.dev.moogsoft.cloud/v2/correlation/groups?inline-definitions=true",
headers: {
Accept: "application/json",
apiKey: apiKey
}
});
return res?.data;
} catch (e) {
if (e.response?.status === 403) {
console.error("API Key invalid. Get new one from your instance.");
process.exit();
}
console.log("Caught an error: ", e);
};
};
const editCEGroup = async (apiKey, id, params) => {
try {
const res = await axios({
method: "patch",
url: `https://api.dev.moogsoft.cloud/v2/correlation/groups/${id}`,
data: params,
headers: {
Accept: "application/json",
"Content-Type": "application/json",
apiKey: apiKey
}
});
return res?.data;
} catch (e) {
if (e.response.status === 403) {
console.error("API Key invalid. Get new one from your instance.");
process.exit();
}
console.log("Caught an error: ", e);
};
};
const createNewDef = async (apiKey, params) => {
try {
const res = await axios({
method: "post",
url: `https://api.dev.moogsoft.cloud/v2/correlation/definitions`,
data: params,
headers: {
Accept: "application/json",
"Content-Type": "application/json",
apiKey: apiKey
}
});
return res?.data;
} catch (e) {
if (e.response.status === 403) {
console.error("API Key invalid. Get new one from your instance.");
process.exit();
}
console.log("Caught an error: ", e);
};
};
module.exports = { getCEGroups, editCEGroup, createNewDef };