UNPKG

n8n-nodes-tenable-community

Version:

n8n node for the Tenable One platform

47 lines (46 loc) 1.52 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.identityExposureApiRequest = identityExposureApiRequest; async function identityExposureApiRequest(resource, operation, body = {}, qs = {}) { const credentials = await this.getCredentials('tenableApi'); const baseUrl = credentials.baseUrl || 'https://customer.tenable.ad'; let endpoint = ''; let method = 'GET'; if (resource === 'adObjects') { if (operation === 'get') { endpoint = `/api/directories/${qs.directoryId}/ad-objects/${qs.id}`; } else if (operation === 'search') { method = 'POST'; endpoint = `/api/profiles/${qs.profileId}/checkers/${qs.checkerId}/ad-objects/search`; } } else if (resource === 'alerts') { if (operation === 'get') { endpoint = `/api/alerts/${qs.id}`; } else if (operation === 'update') { method = 'PATCH'; endpoint = `/api/alerts/${qs.id}`; } } const options = { headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', 'X-API-Key': credentials.apiKey, }, 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); }