wazuh-kibana-app/public/services/csv-request.js
2019-01-14 17:36:47 +01:00

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);
}
}
}