UNPKG

n8n-nodes-netbox

Version:

n8n community node for NetBox API integration with comprehensive DCIM, IPAM, Virtualization, Circuits, Wireless, and data center management operations

34 lines (33 loc) 1.49 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.listInstalledPlugins = listInstalledPlugins; exports.getInstalledPlugin = getInstalledPlugin; const apiRequest_1 = require("../../../helpers/apiRequest"); const responseFormatter_1 = require("../../../helpers/responseFormatter"); async function listInstalledPlugins() { const returnAll = this.getNodeParameter('returnAll', 0); const filters = this.getNodeParameter('filters', 0, {}); const qs = {}; Object.assign(qs, filters); if (returnAll) { const response = await apiRequest_1.apiRequestAllItems.call(this, 'GET', '/api/plugins/installed-plugins/', {}, qs); return responseFormatter_1.formatResponse.call(this, response); } else { const limit = this.getNodeParameter('limit', 0); qs.limit = limit; const response = await apiRequest_1.apiRequest.call(this, 'GET', '/api/plugins/installed-plugins/', {}, qs); return responseFormatter_1.formatResponse.call(this, response); } } async function getInstalledPlugin() { const pluginId = this.getNodeParameter('pluginId', 0); try { const endpoint = `/api/plugins/installed-plugins/${pluginId}/`; const response = await apiRequest_1.apiRequest.call(this, 'GET', endpoint); return responseFormatter_1.formatResponse.call(this, response); } catch (error) { throw new Error(`Failed to get installed plugin: ${error.message}`); } }