n8n-nodes-tenable-community
Version:
n8n node for the Tenable One platform
106 lines (105 loc) • 4.12 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ProductStatus = void 0;
const n8n_workflow_1 = require("n8n-workflow");
const GenericFunctions_1 = require("./GenericFunctions");
class ProductStatus {
constructor() {
this.description = {
displayName: 'Tenable Product Status',
name: 'tenableProductStatus',
icon: 'file:tenable.svg',
group: ['transform'],
version: 1,
subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
description: 'Get Tenable Product Status',
defaults: {
name: 'Tenable Product Status',
},
inputs: ["main" /* NodeConnectionType.Main */],
outputs: ["main" /* NodeConnectionType.Main */],
properties: [
{
displayName: 'Resource',
name: 'resource',
type: 'options',
noDataExpression: true,
options: [
{
name: 'Component',
value: 'component',
},
{
name: 'Incident',
value: 'incident',
},
{
name: 'Maintenance',
value: 'maintenance',
},
{
name: 'Status',
value: 'status',
},
],
default: 'component',
},
{
displayName: 'Operation',
name: 'operation',
type: 'options',
noDataExpression: true,
displayOptions: {
show: {
resource: ['component', 'incident', 'maintenance'],
},
},
options: [
{
name: 'Get Many',
value: 'getAll',
action: 'Get many components',
description: 'Get many components',
},
{
name: 'Get',
value: 'get',
action: 'Get a component',
description: 'Get a component',
},
],
default: 'getAll',
},
// ... other properties based on resource and operation
],
};
}
async execute() {
const items = this.getInputData();
const returnData = [];
const resource = this.getNodeParameter('resource', 0);
for (let i = 0; i < items.length; i++) {
try {
if (resource === 'status') {
const response = await GenericFunctions_1.productStatusApiRequest.call(this, 'GET', '/summary.json');
returnData.push({ json: response });
}
else {
// Logic for other resources and operations
const response = await GenericFunctions_1.productStatusApiRequest.call(this, 'GET', `/${resource}s.json`);
returnData.push({ json: response });
}
}
catch (error) {
if (this.continueOnFail()) {
const nodeError = new n8n_workflow_1.NodeOperationError(this.getNode(), error, { itemIndex: i });
returnData.push({ json: { error: nodeError.message }, error: nodeError });
continue;
}
throw error;
}
}
return [this.helpers.returnJsonArray(returnData)];
}
}
exports.ProductStatus = ProductStatus;