UNPKG

n8n-nodes-arubacentral

Version:

n8n community node for Aruba Central API integration with comprehensive monitoring, configuration, and management capabilities

58 lines (57 loc) 2.35 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.setComplianceVersion = setComplianceVersion; const apiRequest_1 = require("../../../../helpers/apiRequest"); const logger_1 = require("../../../../helpers/logger"); const errorHandler_1 = require("../../../../helpers/errorHandler"); /** * Sets firmware compliance version for a device type * POST /firmware/v1/compliance * * @param this The n8n execution context * @returns Result of setting compliance version */ async function setComplianceVersion() { try { const deviceType = this.getNodeParameter('deviceType', 0); const firmwareVersion = this.getNodeParameter('firmwareVersion', 0); const options = this.getNodeParameter('options', 0, {}); // Create request body const body = { device_type: deviceType, firmware_compliance_version: firmwareVersion, }; // Add optional parameters if (options.group) { body.group = options.group; } if (options.reboot !== undefined) { body.reboot = options.reboot; } if (options.allowUnsupportedVersion !== undefined) { body.allow_unsupported_version = options.allowUnsupportedVersion; } if (options.complianceScheduledAt) { body.compliance_scheduled_at = options.complianceScheduledAt; } // Log the request for debugging logger_1.logger.debug('firmware:upgrade:setComplianceVersion:request', { url: '/firmware/v1/compliance', body: JSON.stringify(body), }); // Make the API request const responseData = await apiRequest_1.apiRequest.call(this, 'POST', '/firmware/v1/compliance', body, {}); // Log the response for debugging logger_1.logger.debug('firmware:upgrade:setComplianceVersion:response', { responseData: JSON.stringify(responseData).substring(0, 500), // Truncate for logging }); return [{ json: responseData }]; } catch (error) { logger_1.logger.error('firmware:upgrade:setComplianceVersion:error', { message: error.message, stack: error.stack, }); return errorHandler_1.handleApiError.call(this, error, 'Failed to set firmware compliance version'); } }