UNPKG

n8n-nodes-tenable-community

Version:

n8n node for the Tenable One platform

79 lines (78 loc) 3 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Downloads = void 0; const GenericFunctions_1 = require("./GenericFunctions"); const Downloads_node_options_1 = require("./Downloads.node.options"); class Downloads { constructor() { this.description = { displayName: 'Tenable Downloads', name: 'downloads', icon: 'file:tenable.svg', group: ['transform'], version: 1, subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}', description: 'Interacts with the Tenable Downloads API', defaults: { name: 'Tenable Downloads', }, inputs: ["main" /* NodeConnectionType.Main */], outputs: ["main" /* NodeConnectionType.Main */], credentials: [ { name: 'tenableApi', required: true, }, ], properties: [ { displayName: 'Resource', name: 'resource', type: 'options', noDataExpression: true, options: [ { name: 'Pages', value: 'pages', }, ], default: 'pages', }, ...Downloads_node_options_1.downloadsOperations, ...Downloads_node_options_1.downloadsFields, ], }; } async execute() { const items = this.getInputData(); const returnData = []; const length = items.length; let responseData; for (let i = 0; i < length; i++) { const resource = this.getNodeParameter('resource', i); const operation = this.getNodeParameter('operation', i); const body = {}; const qs = {}; if (resource === 'pages') { if (operation === 'list') { // No parameters } if (operation === 'get') { const slug = this.getNodeParameter('slug', i); qs.slug = slug; } if (operation === 'download') { const slug = this.getNodeParameter('slug', i); const file = this.getNodeParameter('file', i); qs.slug = slug; qs.file = file; } } responseData = await GenericFunctions_1.downloadsApiRequest.call(this, resource, operation, body, qs); const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(responseData), { itemData: { item: i } }); returnData.push(...executionData); } return [this.helpers.returnJsonArray(returnData)]; } } exports.Downloads = Downloads;