UNPKG

@daedalus/wso2

Version:

This is a set of tools to help connect and manage interactions with various WSO2 products. Please see README.MD for more details.

129 lines (120 loc) 3.19 kB
const https = require("https"); const axios = require("axios").create({ httpsAgent: new https.Agent({ rejectUnauthorized: false }), proxy: false }); const serviceResource = "bpmn/repository/deployments/"; //const parseXML = require("xml2js").parseString; //const utils = require('../../utils'); /* data = { server: { url: "" }, auth: { username: "", password: "" } } */ //GET //https://<Host Name>:<Port>/bpmn/repository/deployments //This request retrieves all the deployments from the server. const getAll = (data, callback) => { let size = data.size ? data.size : 500; let url = data.server.url + serviceResource + '?size=' + size; let options = { auth: data.auth }; axios .get(url, options) .then(response => { callback(null, response.data); }) .catch(error => { if (error.response && error.response.data) { callback(null, { success: false, msg: error.response.data}); } else { callback(null, { success: false, msg: 'Uknown Error from Axios'}); } }); }; //GET //https://<Host Name>:<Port>/bpmn/repository/deployments/{deploymentId} //This request retrieves a specific deployment from the server. const get = (deploymentId, data, callback) => { let url = data.server.url + serviceResource + deploymentId; let options = { auth: data.auth }; axios .get(url, options) .then(response => { callback(null, response.data); }) .catch(error => { if (error.response && error.response.data) { callback(null, { success: false, msg: error.response.data}); } else { callback(null, { success: false, msg: 'Uknown Error from Axios'}); } }); }; /* const getResources = (deploymentId, data, callback) => { let url = data.server.url + serviceResource + deploymentId + '/resources'; let options = { auth: data.auth }; axios .get(url, options) .then(response => { callback(null, response.data); }) .catch(error => { callback(error.response.data, null); }); } const getResource = (deploymentId, resourceId, data, callback) => { let url = data.server.url + serviceResource + deploymentId + '/resources/' + resourceId; let options = { auth: data.auth }; axios .get(url, options) .then(response => { callback(null, response.data); }) .catch(error => { callback(error.response.data, null); }); } const getResourceData = (deploymentId, resourceId, data, callback) => { let url = data.server.url + serviceResource + deploymentId + '/resourcedata/' + resourceId; let options = { auth: data.auth }; axios .get(url, options) .then(response => { if(utils.parser.isXml(response.data)){ parseXML(response.data, callback); } else{ callback(null, response.data); } }) .catch(error => { callback(error.response.data, null); }); } */ module.exports = { getAll, get //getResources, //getResource, //getResourceData };