UNPKG

n8n-nodes-tenable-community

Version:

n8n node for the Tenable One platform

42 lines (41 loc) 1.27 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.downloadsApiRequest = downloadsApiRequest; async function downloadsApiRequest(resource, operation, body = {}, qs = {}) { const credentials = await this.getCredentials('tenableApi'); const baseUrl = 'https://www.tenable.com/downloads/api/v2'; let endpoint = ''; const method = 'GET'; if (resource === 'pages') { if (operation === 'list') { endpoint = '/pages'; } else if (operation === 'get') { endpoint = `/pages/${qs.slug}`; } else if (operation === 'download') { endpoint = `/pages/${qs.slug}/files/${qs.file}`; } } const options = { headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', }, method, qs, body, url: `${baseUrl}${endpoint}`, json: true, }; if (credentials.apiKey) { options.headers['Authorization'] = `Bearer ${credentials.apiKey}`; } if (Object.keys(body).length === 0) { delete options.body; } if (Object.keys(qs).length === 0) { delete options.qs; } return this.helpers.httpRequest(options); }