n8n-nodes-arubacentral
Version:
n8n community node for Aruba Central API integration with comprehensive monitoring, configuration, and management capabilities
48 lines (47 loc) • 1.89 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.cancelUpgrade = cancelUpgrade;
const apiRequest_1 = require("../../../../helpers/apiRequest");
const logger_1 = require("../../../../helpers/logger");
const errorHandler_1 = require("../../../../helpers/errorHandler");
/**
* Cancels a scheduled firmware upgrade
* POST /firmware/v1/cancel_upgrade
*
* @param this The n8n execution context
* @returns Result of the cancel operation
*/
async function cancelUpgrade() {
try {
const deviceType = this.getNodeParameter('deviceType', 0);
const targetType = this.getNodeParameter('targetType', 0);
const targetValue = this.getNodeParameter('targetValue', 0);
// Create request body
const body = {
device_type: deviceType,
};
// Add target parameter based on target type
if (targetType && targetValue) {
body[targetType] = targetValue;
}
// Log the request for debugging
logger_1.logger.debug('firmware:upgrade:cancelUpgrade:request', {
url: '/firmware/v1/cancel_upgrade',
body: JSON.stringify(body),
});
// Make the API request
const responseData = await apiRequest_1.apiRequest.call(this, 'POST', '/firmware/v1/cancel_upgrade', body, {});
// Log the response for debugging
logger_1.logger.debug('firmware:upgrade:cancelUpgrade:response', {
responseData: JSON.stringify(responseData).substring(0, 500), // Truncate for logging
});
return [{ json: responseData }];
}
catch (error) {
logger_1.logger.error('firmware:upgrade:cancelUpgrade:error', {
message: error.message,
stack: error.stack,
});
return errorHandler_1.handleApiError.call(this, error, 'Failed to cancel firmware upgrade');
}
}