wazuh-kibana-app/public/services/csv-request.js
2018-09-12 11:00:55 +02:00

40 lines
1.1 KiB
JavaScript

/*
* Wazuh app - API request service
* Copyright (C) 2018 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/wazuh-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/wazuh-api/csv',
{ path, id, filters }
);
return output.data;
} catch (error) {
return Promise.reject(error);
}
}
}