mirror of
https://github.com/valitydev/wazuh-kibana-app.git
synced 2024-11-06 01:45:18 +00:00
40 lines
1.1 KiB
JavaScript
40 lines
1.1 KiB
JavaScript
/*
|
|
* Wazuh app - API request service
|
|
* Copyright (C) 2015-2019 Wazuh, Inc.
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* Find more information about this on the LICENSE file.
|
|
*/
|
|
export class CSVRequest {
|
|
/**
|
|
* Constructor
|
|
* @param {*} genericReq Service to make requests to our server
|
|
*/
|
|
constructor(genericReq) {
|
|
this.genericReq = genericReq;
|
|
}
|
|
|
|
/**
|
|
* It fetchs data from /api/csv route using the below parameters.
|
|
* @param {string} path Wazuh API route
|
|
* @param {number|string} id Elasticsearch document ID
|
|
* @param {*} filters Array of Wazuh API filters. Optional
|
|
*/
|
|
async fetch(path, id, filters = null) {
|
|
try {
|
|
const output = await this.genericReq.request('POST', '/api/csv', {
|
|
path,
|
|
id,
|
|
filters
|
|
});
|
|
return output.data;
|
|
} catch (error) {
|
|
return Promise.reject(error);
|
|
}
|
|
}
|
|
}
|