@devoinc/alerts-api-client
Version:
Typescript client for devo alerts API
1,220 lines • 52.1 kB
JavaScript
//----------------------
// <auto-generated>
// Generated using the NSwag toolchain v13.15.10.0 (NJsonSchema v10.6.10.0 (Newtonsoft.Json v12.0.0.0)) (http://NSwag.org)
// </auto-generated>
//----------------------
/* tslint:disable */
/* eslint-disable */
// ReSharper disable InconsistentNaming
class ClientBase {
constructor(config) {
this.config = config;
}
transformOptions(options) {
options.headers = {
...options.headers,
standAloneToken: this.config.getAuthorization(),
};
return Promise.resolve(options);
}
transformResult(url, response, processor) {
console.log('Service call: ' + url);
return processor(response);
}
}
class Client extends ClientBase {
constructor(configuration, baseUrl, http) {
super(configuration);
this.jsonParseReviver = undefined;
this.http = http ? http : window;
this.baseUrl = baseUrl !== undefined && baseUrl !== null ? baseUrl : "";
}
/**
* Add Alert comment
* @param body Add comment to one alert
*/
addComment(body) {
let url_ = this.baseUrl + "/v1/comments/add";
url_ = url_.replace(/[?&]$/, "");
const content_ = JSON.stringify(body);
let options_ = {
body: content_,
method: "POST",
headers: {
"Content-Type": "application/json",
"Accept": "application/json"
}
};
return this.transformOptions(options_).then(transformedOptions_ => {
return this.http.fetch(url_, transformedOptions_);
}).then((_response) => {
return this.processAddComment(_response);
});
}
processAddComment(response) {
const status = response.status;
let _headers = {};
if (response.headers && response.headers.forEach) {
response.headers.forEach((v, k) => _headers[k] = v);
}
if (status === 200) {
return response.text().then((_responseText) => {
let result200 = null;
result200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver);
return result200;
});
}
else if (status === 400) {
return response.text().then((_responseText) => {
return throwException("Alert comment error", status, _responseText, _headers);
});
}
else if (status !== 200 && status !== 204) {
return response.text().then((_responseText) => {
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
});
}
return Promise.resolve(null);
}
/**
* Add comment to multiple Alerts
* @param body Comment to add to several alert ids
*/
addComments(body) {
let url_ = this.baseUrl + "/v1/comments/bulk/add";
url_ = url_.replace(/[?&]$/, "");
const content_ = JSON.stringify(body);
let options_ = {
body: content_,
method: "POST",
headers: {
"Content-Type": "application/json",
"Accept": "application/json"
}
};
return this.transformOptions(options_).then(transformedOptions_ => {
return this.http.fetch(url_, transformedOptions_);
}).then((_response) => {
return this.processAddComments(_response);
});
}
processAddComments(response) {
const status = response.status;
let _headers = {};
if (response.headers && response.headers.forEach) {
response.headers.forEach((v, k) => _headers[k] = v);
}
if (status === 200) {
return response.text().then((_responseText) => {
let result200 = null;
result200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver);
return result200;
});
}
else if (status === 400) {
return response.text().then((_responseText) => {
return throwException("Alert comments error", status, _responseText, _headers);
});
}
else if (status !== 200 && status !== 204) {
return response.text().then((_responseText) => {
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
});
}
return Promise.resolve(null);
}
/**
* Delete Alert comment
* @param body List of ID comments to delete
*/
deleteComment(body) {
let url_ = this.baseUrl + "/v1/comments/delete";
url_ = url_.replace(/[?&]$/, "");
const content_ = JSON.stringify(body);
let options_ = {
body: content_,
method: "DELETE",
headers: {
"Content-Type": "application/json",
"Accept": "application/json"
}
};
return this.transformOptions(options_).then(transformedOptions_ => {
return this.http.fetch(url_, transformedOptions_);
}).then((_response) => {
return this.processDeleteComment(_response);
});
}
processDeleteComment(response) {
const status = response.status;
let _headers = {};
if (response.headers && response.headers.forEach) {
response.headers.forEach((v, k) => _headers[k] = v);
}
if (status === 200) {
return response.text().then((_responseText) => {
let result200 = null;
result200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver);
return result200;
});
}
else if (status === 400) {
return response.text().then((_responseText) => {
return throwException("Invalid parameters", status, _responseText, _headers);
});
}
else if (status !== 200 && status !== 204) {
return response.text().then((_responseText) => {
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
});
}
return Promise.resolve(null);
}
/**
* Get all Alert comments
* @param body Alert ID lists
*/
getList(body) {
let url_ = this.baseUrl + "/v1/comments/list";
url_ = url_.replace(/[?&]$/, "");
const content_ = JSON.stringify(body);
let options_ = {
body: content_,
method: "POST",
headers: {
"Content-Type": "application/json",
"Accept": "application/json"
}
};
return this.transformOptions(options_).then(transformedOptions_ => {
return this.http.fetch(url_, transformedOptions_);
}).then((_response) => {
return this.processGetList(_response);
});
}
processGetList(response) {
const status = response.status;
let _headers = {};
if (response.headers && response.headers.forEach) {
response.headers.forEach((v, k) => _headers[k] = v);
}
if (status === 200) {
return response.text().then((_responseText) => {
let result200 = null;
result200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver);
return result200;
});
}
else if (status === 400) {
return response.text().then((_responseText) => {
return throwException("Alert comment error", status, _responseText, _headers);
});
}
else if (status !== 200 && status !== 204) {
return response.text().then((_responseText) => {
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
});
}
return Promise.resolve(null);
}
/**
* Update Alert comment
* @param commentId Comment id
* @param body Updated comment
*/
updateComment(commentId, body) {
let url_ = this.baseUrl + "/v1/comments/update?";
if (commentId === undefined || commentId === null)
throw new Error("The parameter 'commentId' must be defined and cannot be null.");
else
url_ += "commentId=" + encodeURIComponent("" + commentId) + "&";
url_ = url_.replace(/[?&]$/, "");
const content_ = JSON.stringify(body);
let options_ = {
body: content_,
method: "PUT",
headers: {
"Content-Type": "application/json",
"Accept": "application/json"
}
};
return this.transformOptions(options_).then(transformedOptions_ => {
return this.http.fetch(url_, transformedOptions_);
}).then((_response) => {
return this.processUpdateComment(_response);
});
}
processUpdateComment(response) {
const status = response.status;
let _headers = {};
if (response.headers && response.headers.forEach) {
response.headers.forEach((v, k) => _headers[k] = v);
}
if (status === 200) {
return response.text().then((_responseText) => {
let result200 = null;
result200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver);
return result200;
});
}
else if (status === 400) {
return response.text().then((_responseText) => {
return throwException("Invalid parameters", status, _responseText, _headers);
});
}
else if (status !== 200 && status !== 204) {
return response.text().then((_responseText) => {
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
});
}
return Promise.resolve(null);
}
/**
* Update bulk Alert comments
* @param body Bulk comment update resource
*/
updateComments(body) {
let url_ = this.baseUrl + "/v1/comments/bulk/update";
url_ = url_.replace(/[?&]$/, "");
const content_ = JSON.stringify(body);
let options_ = {
body: content_,
method: "PUT",
headers: {
"Content-Type": "application/json",
"Accept": "application/json"
}
};
return this.transformOptions(options_).then(transformedOptions_ => {
return this.http.fetch(url_, transformedOptions_);
}).then((_response) => {
return this.processUpdateComments(_response);
});
}
processUpdateComments(response) {
const status = response.status;
let _headers = {};
if (response.headers && response.headers.forEach) {
response.headers.forEach((v, k) => _headers[k] = v);
}
if (status === 200) {
return response.text().then((_responseText) => {
let result200 = null;
result200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver);
return result200;
});
}
else if (status === 400) {
return response.text().then((_responseText) => {
return throwException("Invalid parameters", status, _responseText, _headers);
});
}
else if (status !== 200 && status !== 204) {
return response.text().then((_responseText) => {
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
});
}
return Promise.resolve(null);
}
/**
* Get Alert without context
* @param id Alert ID
* @param tags (optional) If the parameter exists and the value is TRUE all the alert tags will be included in the response.
* @param annotations (optional) If the parameter exists and the value is TRUE all the alert annotations will be included in the response.
*/
get(id, tags, annotations) {
let url_ = this.baseUrl + "/v1/alerts/get?";
if (id === undefined || id === null)
throw new Error("The parameter 'id' must be defined and cannot be null.");
else
url_ += "id=" + encodeURIComponent("" + id) + "&";
if (tags === null)
throw new Error("The parameter 'tags' cannot be null.");
else if (tags !== undefined)
url_ += "tags=" + encodeURIComponent("" + tags) + "&";
if (annotations === null)
throw new Error("The parameter 'annotations' cannot be null.");
else if (annotations !== undefined)
url_ += "annotations=" + encodeURIComponent("" + annotations) + "&";
url_ = url_.replace(/[?&]$/, "");
let options_ = {
method: "GET",
headers: {
"Accept": "application/json"
}
};
return this.transformOptions(options_).then(transformedOptions_ => {
return this.http.fetch(url_, transformedOptions_);
}).then((_response) => {
return this.processGet(_response);
});
}
processGet(response) {
const status = response.status;
let _headers = {};
if (response.headers && response.headers.forEach) {
response.headers.forEach((v, k) => _headers[k] = v);
}
if (status === 200) {
return response.text().then((_responseText) => {
let result200 = null;
result200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver);
return result200;
});
}
else if (status === 400) {
return response.text().then((_responseText) => {
return throwException("There are no matching alerts for this ID", status, _responseText, _headers);
});
}
else if (status !== 200 && status !== 204) {
return response.text().then((_responseText) => {
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
});
}
return Promise.resolve(null);
}
/**
* Get Alerts
* @param limit The limit, max number of elements returned
* @param offset The offset, start element in the element number
* @param from The date from in epoch time,with milliseconds obtain from new Date(Long.parseLong(from))
* @param to The date to in epoch time,with milliseconds,obtain from new Date(Long.parseLong(from))
* @param orderby (optional) Field to order, must be:
id,
domain,
priority,
context,
category,
srcPort,
srcIp,
srcHost,
dstIp,
dstPort,
dstHost,
protocol,
username,
application,
engine,
extraData,
status,
ack_status_date,
createDate,
updateDate.
* @param orderasc (optional) Order Ascending
* @param showAll (optional) Obtain all (false positive and close status included) Default:False
*/
getListByCriterias(limit, offset, from, to, orderby, orderasc, showAll) {
let url_ = this.baseUrl + "/v1/alerts/list?";
if (limit === undefined || limit === null)
throw new Error("The parameter 'limit' must be defined and cannot be null.");
else
url_ += "limit=" + encodeURIComponent("" + limit) + "&";
if (offset === undefined || offset === null)
throw new Error("The parameter 'offset' must be defined and cannot be null.");
else
url_ += "offset=" + encodeURIComponent("" + offset) + "&";
if (from === undefined || from === null)
throw new Error("The parameter 'from' must be defined and cannot be null.");
else
url_ += "from=" + encodeURIComponent("" + from) + "&";
if (to === undefined || to === null)
throw new Error("The parameter 'to' must be defined and cannot be null.");
else
url_ += "to=" + encodeURIComponent("" + to) + "&";
if (orderby === null)
throw new Error("The parameter 'orderby' cannot be null.");
else if (orderby !== undefined)
url_ += "orderby=" + encodeURIComponent("" + orderby) + "&";
if (orderasc === null)
throw new Error("The parameter 'orderasc' cannot be null.");
else if (orderasc !== undefined)
url_ += "orderasc=" + encodeURIComponent("" + orderasc) + "&";
if (showAll === null)
throw new Error("The parameter 'showAll' cannot be null.");
else if (showAll !== undefined)
url_ += "showAll=" + encodeURIComponent("" + showAll) + "&";
url_ = url_.replace(/[?&]$/, "");
let options_ = {
method: "GET",
headers: {
"Accept": "application/json"
}
};
return this.transformOptions(options_).then(transformedOptions_ => {
return this.http.fetch(url_, transformedOptions_);
}).then((_response) => {
return this.processGetListByCriterias(_response);
});
}
processGetListByCriterias(response) {
const status = response.status;
let _headers = {};
if (response.headers && response.headers.forEach) {
response.headers.forEach((v, k) => _headers[k] = v);
}
if (status === 200) {
return response.text().then((_responseText) => {
let result200 = null;
result200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver);
return result200;
});
}
else if (status === 400) {
return response.text().then((_responseText) => {
return throwException("There are no matching alerts for this period", status, _responseText, _headers);
});
}
else if (status !== 200 && status !== 204) {
return response.text().then((_responseText) => {
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
});
}
return Promise.resolve(null);
}
/**
* Get Alert Statistics
* @param showAll (optional) Obtain all (false positive and close status included) Default:False
* @deprecated
*/
getListByCriteriasOverview(showAll) {
let url_ = this.baseUrl + "/v1/alerts/listOverview?";
if (showAll === null)
throw new Error("The parameter 'showAll' cannot be null.");
else if (showAll !== undefined)
url_ += "showAll=" + encodeURIComponent("" + showAll) + "&";
url_ = url_.replace(/[?&]$/, "");
let options_ = {
method: "GET",
headers: {
"Accept": "application/json"
}
};
return this.transformOptions(options_).then(transformedOptions_ => {
return this.http.fetch(url_, transformedOptions_);
}).then((_response) => {
return this.processGetListByCriteriasOverview(_response);
});
}
processGetListByCriteriasOverview(response) {
const status = response.status;
let _headers = {};
if (response.headers && response.headers.forEach) {
response.headers.forEach((v, k) => _headers[k] = v);
}
if (status === 200) {
return response.text().then((_responseText) => {
let result200 = null;
result200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver);
return result200;
});
}
else if (status === 400) {
return response.text().then((_responseText) => {
return throwException("Invalid parameters", status, _responseText, _headers);
});
}
else if (status !== 200 && status !== 204) {
return response.text().then((_responseText) => {
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
});
}
return Promise.resolve(null);
}
/**
* Get Alert statistics
* @param hours (optional) Hours back to obtain data
* @param from (optional) From to obtain data
* @param type (optional) Type of result, may be 'raw', 'funnel, 'list'
* @param filterName (optional) filter by name context
* @param showAll (optional) Obtain all (false positive and close status included) Default:False
*/
getStatistics(hours, from, type, filterName, showAll) {
let url_ = this.baseUrl + "/v1/alerts/statistics?";
if (hours === null)
throw new Error("The parameter 'hours' cannot be null.");
else if (hours !== undefined)
url_ += "hours=" + encodeURIComponent("" + hours) + "&";
if (from === null)
throw new Error("The parameter 'from' cannot be null.");
else if (from !== undefined)
url_ += "from=" + encodeURIComponent("" + from) + "&";
if (type === null)
throw new Error("The parameter 'type' cannot be null.");
else if (type !== undefined)
url_ += "type=" + encodeURIComponent("" + type) + "&";
if (filterName === null)
throw new Error("The parameter 'filterName' cannot be null.");
else if (filterName !== undefined)
url_ += "filterName=" + encodeURIComponent("" + filterName) + "&";
if (showAll === null)
throw new Error("The parameter 'showAll' cannot be null.");
else if (showAll !== undefined)
url_ += "showAll=" + encodeURIComponent("" + showAll) + "&";
url_ = url_.replace(/[?&]$/, "");
let options_ = {
method: "GET",
headers: {
"Accept": "application/json"
}
};
return this.transformOptions(options_).then(transformedOptions_ => {
return this.http.fetch(url_, transformedOptions_);
}).then((_response) => {
return this.processGetStatistics(_response);
});
}
processGetStatistics(response) {
const status = response.status;
let _headers = {};
if (response.headers && response.headers.forEach) {
response.headers.forEach((v, k) => _headers[k] = v);
}
if (status === 200) {
return response.text().then((_responseText) => {
let result200 = null;
result200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver);
return result200;
});
}
else if (status === 400) {
return response.text().then((_responseText) => {
return throwException("Error in parameters", status, _responseText, _headers);
});
}
else if (status !== 200 && status !== 204) {
return response.text().then((_responseText) => {
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
});
}
return Promise.resolve(null);
}
/**
* Get Alert statuses
* @param from (optional) The date from in epoch time, with miliseconds. Default value 24 hours before petition
*/
listStatus(from) {
let url_ = this.baseUrl + "/v1/alerts/listStatus?";
if (from === null)
throw new Error("The parameter 'from' cannot be null.");
else if (from !== undefined)
url_ += "from=" + encodeURIComponent("" + from) + "&";
url_ = url_.replace(/[?&]$/, "");
let options_ = {
method: "GET",
headers: {
"Accept": "application/json"
}
};
return this.transformOptions(options_).then(transformedOptions_ => {
return this.http.fetch(url_, transformedOptions_);
}).then((_response) => {
return this.processListStatus(_response);
});
}
processListStatus(response) {
const status = response.status;
let _headers = {};
if (response.headers && response.headers.forEach) {
response.headers.forEach((v, k) => _headers[k] = v);
}
if (status === 200) {
return response.text().then((_responseText) => {
let result200 = null;
result200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver);
return result200;
});
}
else if (status === 400) {
return response.text().then((_responseText) => {
return throwException("There are no matching alerts for this period", status, _responseText, _headers);
});
}
else if (status !== 200 && status !== 204) {
return response.text().then((_responseText) => {
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
});
}
return Promise.resolve(null);
}
/**
* Update Alert status
* @param id Alert ID
* @param status Alert status with this possible values:
UNREAD = 0;
UPDATED = 1;
FALSE POSTIVE = 2;
WATCHED = 100;
CLOSED = 300;
REMINDER = 500;
RECOVERY = 600;
ANTI FLOOD = 700;
*/
updateStatus(id, status) {
let url_ = this.baseUrl + "/v1/alerts/updateStatus?";
if (id === undefined || id === null)
throw new Error("The parameter 'id' must be defined and cannot be null.");
else
url_ += "id=" + encodeURIComponent("" + id) + "&";
if (status === undefined || status === null)
throw new Error("The parameter 'status' must be defined and cannot be null.");
else
url_ += "status=" + encodeURIComponent("" + status) + "&";
url_ = url_.replace(/[?&]$/, "");
let options_ = {
method: "PUT",
headers: {
"Accept": "application/json"
}
};
return this.transformOptions(options_).then(transformedOptions_ => {
return this.http.fetch(url_, transformedOptions_);
}).then((_response) => {
return this.processUpdateStatus(_response);
});
}
processUpdateStatus(response) {
const status = response.status;
let _headers = {};
if (response.headers && response.headers.forEach) {
response.headers.forEach((v, k) => _headers[k] = v);
}
if (status === 200) {
return response.text().then((_responseText) => {
let result200 = null;
result200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver);
return result200;
});
}
else if (status === 400) {
return response.text().then((_responseText) => {
return throwException("There are no matching alerts for this ID", status, _responseText, _headers);
});
}
else if (status !== 200 && status !== 204) {
return response.text().then((_responseText) => {
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
});
}
return Promise.resolve(null);
}
/**
* Update Alert status
* @param status Alert status with this possible values:
UNREAD = 0;
UPDATED = 1;
FALSE POSTIVE = 2;
WATCHED = 100;
CLOSED = 300;
REMINDER = 500;
RECOVERY = 600;
ANTI FLOOD = 700;
* @param body (optional)
*/
updateStatusLists(status, body) {
let url_ = this.baseUrl + "/v1/alerts/updateStatusList?";
if (status === undefined || status === null)
throw new Error("The parameter 'status' must be defined and cannot be null.");
else
url_ += "status=" + encodeURIComponent("" + status) + "&";
url_ = url_.replace(/[?&]$/, "");
const content_ = body;
let options_ = {
body: content_,
method: "PUT",
headers: {
"Content-Type": "text/plain",
"Accept": "application/json"
}
};
return this.transformOptions(options_).then(transformedOptions_ => {
return this.http.fetch(url_, transformedOptions_);
}).then((_response) => {
return this.processUpdateStatusLists(_response);
});
}
processUpdateStatusLists(response) {
const status = response.status;
let _headers = {};
if (response.headers && response.headers.forEach) {
response.headers.forEach((v, k) => _headers[k] = v);
}
if (status === 200) {
return response.text().then((_responseText) => {
let result200 = null;
result200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver);
return result200;
});
}
else if (status === 400) {
return response.text().then((_responseText) => {
return throwException("One of the alerts does not exist with this id. Return list of not updated alerts. Not returned ids was updated", status, _responseText, _headers);
});
}
else if (status !== 200 && status !== 204) {
return response.text().then((_responseText) => {
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
});
}
return Promise.resolve(null);
}
/**
* Get Alert definitions
* @param nameFilter (optional) Alert name to filter
* @param idFilter (optional) Alert id to filter
* @param body (optional)
*/
getAlerts(nameFilter, idFilter, pagination) {
let url_ = this.baseUrl + "/v1/alertDefinitions?";
if (nameFilter === null)
throw new Error("The parameter 'nameFilter' cannot be null.");
else if (nameFilter !== undefined)
url_ += "nameFilter=" + encodeURIComponent("" + nameFilter) + "&";
if (idFilter === null)
throw new Error("The parameter 'idFilter' cannot be null.");
else if (idFilter !== undefined)
url_ += "idFilter=" + encodeURIComponent("" + idFilter) + "&";
if (pagination) {
if (pagination.pageSize != undefined) {
url_ += "size=" + pagination.pageSize + "&";
}
if (pagination.pageNumber != undefined) {
url_ += "page=" + pagination.pageNumber + "&";
}
}
url_ = url_.replace(/[?&]$/, "");
let options_ = {
method: "GET",
headers: {
"Content-Type": "application/json",
"Accept": "application/json"
}
};
return this.transformOptions(options_).then(transformedOptions_ => {
return this.http.fetch(url_, transformedOptions_);
}).then((_response) => {
return this.processGetAlerts(_response);
});
}
processGetAlerts(response) {
const status = response.status;
let _headers = {};
if (response.headers && response.headers.forEach) {
response.headers.forEach((v, k) => _headers[k] = v);
}
if (status === 200) {
return response.text().then((_responseText) => {
let result200 = null;
result200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver);
return result200;
});
}
else if (status === 400) {
return response.text().then((_responseText) => {
return throwException("Alerts definition error", status, _responseText, _headers);
});
}
else if (status !== 200 && status !== 204) {
return response.text().then((_responseText) => {
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
});
}
return Promise.resolve(null);
}
/**
* Updated Alert definitions
* @param body (optional)
*/
putAlerts(body) {
let url_ = this.baseUrl + "/v1/alertDefinitions";
url_ = url_.replace(/[?&]$/, "");
const content_ = JSON.stringify(body);
let options_ = {
body: content_,
method: "PUT",
headers: {
"Content-Type": "application/json",
"Accept": "application/json"
}
};
return this.transformOptions(options_).then(transformedOptions_ => {
return this.http.fetch(url_, transformedOptions_);
}).then((_response) => {
return this.processPutAlerts(_response);
});
}
processPutAlerts(response) {
const status = response.status;
let _headers = {};
if (response.headers && response.headers.forEach) {
response.headers.forEach((v, k) => _headers[k] = v);
}
if (status === 200) {
return response.text().then((_responseText) => {
let result200 = null;
result200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver);
return result200;
});
}
else if (status === 400) {
return response.text().then((_responseText) => {
return throwException("Alerts definition error", status, _responseText, _headers);
});
}
else if (status === 500) {
return response.text().then((_responseText) => {
return throwException("Unexpected internal error", status, _responseText, _headers);
});
}
else if (status !== 200 && status !== 204) {
return response.text().then((_responseText) => {
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
});
}
return Promise.resolve(null);
}
/**
* Create Alert definition
* @param body (optional)
*/
postAlerts(body) {
let url_ = this.baseUrl + "/v1/alertDefinitions";
url_ = url_.replace(/[?&]$/, "");
const content_ = JSON.stringify(body);
let options_ = {
body: content_,
method: "POST",
headers: {
"Content-Type": "application/json",
"Accept": "application/json"
}
};
return this.transformOptions(options_).then(transformedOptions_ => {
return this.http.fetch(url_, transformedOptions_);
}).then((_response) => {
return this.processPostAlerts(_response);
});
}
processPostAlerts(response) {
const status = response.status;
let _headers = {};
if (response.headers && response.headers.forEach) {
response.headers.forEach((v, k) => _headers[k] = v);
}
if (status === 200) {
return response.text().then((_responseText) => {
let result200 = null;
result200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver);
return result200;
});
}
else if (status === 400) {
return response.text().then((_responseText) => {
return throwException("Alerts definition error", status, _responseText, _headers);
});
}
else if (status === 500) {
return response.text().then((_responseText) => {
return throwException("Unexpected internal error", status, _responseText, _headers);
});
}
else if (status !== 200 && status !== 204) {
return response.text().then((_responseText) => {
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
});
}
return Promise.resolve(null);
}
/**
* Delete Alert definitions
* @param alertIds List of alert definitions IDs
* @return Deletion was successful
*/
deleteAlerts(alertIds) {
let url_ = this.baseUrl + "/v1/alertDefinitions?";
if (alertIds === undefined || alertIds === null)
throw new Error("The parameter 'alertIds' must be defined and cannot be null.");
else
alertIds && alertIds.forEach(item => { url_ += "alertIds=" + encodeURIComponent("" + item) + "&"; });
url_ = url_.replace(/[?&]$/, "");
let options_ = {
method: "DELETE",
headers: {}
};
return this.transformOptions(options_).then(transformedOptions_ => {
return this.http.fetch(url_, transformedOptions_);
}).then((_response) => {
return this.processDeleteAlerts(_response);
});
}
processDeleteAlerts(response) {
const status = response.status;
let _headers = {};
if (response.headers && response.headers.forEach) {
response.headers.forEach((v, k) => _headers[k] = v);
}
if (status === 200) {
return response.text().then((_responseText) => {
return;
});
}
else if (status === 400) {
return response.text().then((_responseText) => {
return throwException("Alerts definition error", status, _responseText, _headers);
});
}
else if (status === 500) {
return response.text().then((_responseText) => {
return throwException("Unexpected internal error", status, _responseText, _headers);
});
}
else if (status !== 200 && status !== 204) {
return response.text().then((_responseText) => {
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
});
}
return Promise.resolve(null);
}
/**
* Updates a batch of Alert definitions
* @param body (optional)
*/
putAlertsBatch(body) {
let url_ = this.baseUrl + "/v1/alertDefinitions/batch";
url_ = url_.replace(/[?&]$/, "");
const content_ = JSON.stringify(body);
let options_ = {
body: content_,
method: "PUT",
headers: {
"Content-Type": "application/json",
"Accept": "application/json"
}
};
return this.transformOptions(options_).then(transformedOptions_ => {
return this.http.fetch(url_, transformedOptions_);
}).then((_response) => {
return this.processPutAlertsBatch(_response);
});
}
processPutAlertsBatch(response) {
const status = response.status;
let _headers = {};
if (response.headers && response.headers.forEach) {
response.headers.forEach((v, k) => _headers[k] = v);
}
if (status === 200) {
return response.text().then((_responseText) => {
let result200 = null;
result200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver);
return result200;
});
}
else if (status === 400) {
return response.text().then((_responseText) => {
return throwException("Alerts definition error", status, _responseText, _headers);
});
}
else if (status === 500) {
return response.text().then((_responseText) => {
return throwException("Unexpected internal error", status, _responseText, _headers);
});
}
else if (status !== 200 && status !== 204) {
return response.text().then((_responseText) => {
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
});
}
return Promise.resolve(null);
}
/**
* Create batch of Alert definitions
* @param body (optional)
*/
postAlertsBatch(body) {
let url_ = this.baseUrl + "/v1/alertDefinitions/batch";
url_ = url_.replace(/[?&]$/, "");
const content_ = JSON.stringify(body);
let options_ = {
body: content_,
method: "POST",
headers: {
"Content-Type": "application/json",
"Accept": "application/json"
}
};
return this.transformOptions(options_).then(transformedOptions_ => {
return this.http.fetch(url_, transformedOptions_);
}).then((_response) => {
return this.processPostAlertsBatch(_response);
});
}
processPostAlertsBatch(response) {
const status = response.status;
let _headers = {};
if (response.headers && response.headers.forEach) {
response.headers.forEach((v, k) => _headers[k] = v);
}
if (status === 200) {
return response.text().then((_responseText) => {
let result200 = null;
result200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver);
return result200;
});
}
else if (status === 400) {
return response.text().then((_responseText) => {
return throwException("Alerts definition error", status, _responseText, _headers);
});
}
else if (status === 500) {
return response.text().then((_responseText) => {
return throwException("Unexpected internal error", status, _responseText, _headers);
});
}
else if (status !== 200 && status !== 204) {
return response.text().then((_responseText) => {
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
});
}
return Promise.resolve(null);
}
/**
* Update Alert definition statuses
* @param alertIds List of alert definitions IDs
* @param enable Enable/disable alert definitions
*/
putAlertStatus(alertIds, enable) {
let url_ = this.baseUrl + "/v1/alertDefinitions/status?";
if (alertIds === undefined || alertIds === null)
throw new Error("The parameter 'alertIds' must be defined and cannot be null.");
else
alertIds && alertIds.forEach(item => { url_ += "alertIds=" + encodeURIComponent("" + item) + "&"; });
if (enable === undefined || enable === null)
throw new Error("The parameter 'enable' must be defined and cannot be null.");
else
url_ += "enable=" + encodeURIComponent("" + enable) + "&";
url_ = url_.replace(/[?&]$/, "");
let options_ = {
method: "PUT",
headers: {
"Accept": "application/json"
}
};
return this.transformOptions(options_).then(transformedOptions_ => {
return this.http.fetch(url_, transformedOptions_);
}).then((_response) => {
return this.processPutAlertStatus(_response);
});
}
processPutAlertStatus(response) {
const status = response.status;
let _headers = {};
if (response.headers && response.headers.forEach) {
response.headers.forEach((v, k) => _headers[k] = v);
}
if (status === 200) {
return response.text().then((_responseText) => {
let result200 = null;
result200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver);
return result200;
});
}
else if (status === 400) {
return response.text().then((_responseText) => {
return throwException("Alerts definition error", status, _responseText, _headers);
});
}
else if (status !== 200 && status !== 204) {
return response.text().then((_responseText) => {
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
});
}
return Promise.resolve(null);
}
/**
* Assign Tag to Alert
* @param body Alert IDs and tags to be set to the alerts
*/
setTags(body) {
let url_ = this.baseUrl + "/v1/tags";
url_ = url_.replace(/[?&]$/, "");
const content_ = JSON.stringify(body);
let options_ = {
body: content_,
method: "PUT",
headers: {
"Content-Type": "application/json",
"Accept": "application/json"
}
};
return this.transformOptions(options_).then(transformedOptions_ => {
return this.http.fetch(url_, transformedOptions_);
}).then((_response) => {
return this.processSetTags(_response);
});
}
processSetTags(response) {
const status = response.status;
let _headers = {};
if (response.headers && response.headers.forEach) {
response.headers.forEach((v, k) => _headers[k] = v);
}
if (status === 200) {
return response.text().then((_responseText) => {
let result200 = null;
result200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver);
return result200;
});
}
else if (status === 400) {
return response.text().then((_responseText) => {
return throwException("Invalid parameters", status, _responseText, _headers);
});
}
else if (status !== 200 && status !== 204) {
return response.text().then((_responseText) => {
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
});
}
return Promise.resolve(null);
}
}
var AlertCommentSecOpsCommentType;
(function (AlertCommentSecOpsCommentType) {
AlertCommentSecOpsCommentType["ALERT"] = "ALERT";
AlertCommentSecOpsCommentType["REPLY"] = "REPLY";
})(AlertCommentSecOpsCommentType || (AlertCommentSecOpsCommentType = {}));
var AlertCommentSecOpsBulkCommentType;
(function (AlertCommentSecOpsBulkCommentType) {
AlertCommentSecOpsBulkCommentType["ALERT"] = "ALERT";
AlertCommentSecOpsBulkCommentType["REPLY"] = "REPLY";
})(AlertCommentSecOpsBulkCommentType || (AlertCommentSecOpsBulkCommentType = {}));
var AlertCommentSecOpsBulkUpdateCommentType;
(function (AlertCommentSecOpsBulkUpdateCommentType) {
AlertCommentSecOpsBulkUpdateCommentType["ALERT"] = "ALERT";
AlertCommentSecOpsBulkUpdateCommentType["REPLY"] = "REPLY";
})(AlertCommentSecOpsBulkUpdateCommentType || (AlertCommentSecOpsBulkUpdateCommentType = {}));
var EntityType;
(function (EntityType) {
EntityType["SOURCEIP"] = "SOURCEIP";
EntityType["DSTIP"] = "DSTIP";
EntityType["SOURCEDOMAIN"] = "SOURCEDOMAIN";
EntityType["DSTDOMAIN"] = "DSTDOMAIN";
EntityType["SOURCEHOST"] = "SOURCEHOST";
EntityType["DSTHOST"] = "DSTHOST";
EntityType["SOURCESYSTEMLOCATIONCOUNTRY"] = "SOURCESYSTEMLOCATIONCOUNTRY";
EntityType["SOURCESYSTEMLOCATIONCITY"] = "SOURCESYSTEMLOCATIONCITY";
EntityType["SOURCESYSTEMLOCATIONSTATE"] = "SOURCESYSTEMLOCATIONSTATE";
EntityType["SOURCESYSTEMLOCATIONLAT"] = "SOURCESYSTEMLOCATIONLAT";
EntityType["SOURCESYSTEMLOCATIONLON"] = "SOURCESYSTEMLOCATIONLON";
EntityType["DSTLOCATION"] = "DSTLOCATION";
EntityType["SOURCEUSER"] = "SOURCEUSER";
EntityType["DSTUSER"] = "DSTUSER";
EntityType["SOURCEUSERDOMAIN"] = "SOURCEUSERDOMAIN";
EntityType["DSTUSERDOMAIN"] = "DSTUSERDOMAIN";
EntityType["SOURCEUSERNAME"] = "SOURCEUSERNAME";
EntityType["DSTUSERNAME"] = "DSTUSERNAME";
EntityType["SOURCEURL"] = "SOURCEURL";
EntityType["DSTURL"] = "DSTURL";
EntityTy