UNPKG

n8n-nodes-tenable-community

Version:

n8n node for the Tenable One platform

46 lines (45 loc) 1.49 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.platformApiRequest = platformApiRequest; async function platformApiRequest(resource, operation, body = {}, qs = {}) { const credentials = await this.getCredentials('tenableApi'); const baseUrl = 'https://cloud.tenable.com'; let endpoint = ''; let method = 'GET'; if (resource === 'accessControl') { if (operation === 'listAllowedIpAddresses') { endpoint = '/access-control/v1/api-security-settings'; } else if (operation === 'updateAllowedIpAddresses') { method = 'PUT'; endpoint = '/access-control/v1/api-security-settings'; } } else if (resource === 'server') { if (operation === 'getStatus') { endpoint = '/server/status'; } else if (operation === 'getProperties') { endpoint = '/server/properties'; } } const options = { headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', 'X-ApiKeys': `accessKey=${credentials.accessKey};secretKey=${credentials.secretKey}`, }, method, qs, body, url: `${baseUrl}${endpoint}`, json: true, }; if (Object.keys(body).length === 0) { delete options.body; } if (Object.keys(qs).length === 0) { delete options.qs; } return this.helpers.httpRequest(options); }