n8n-nodes-arubacentral
Version:
n8n community node for Aruba Central API integration with comprehensive monitoring, configuration, and management capabilities
122 lines (121 loc) • 5.11 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getAllDot11gRadioProfiles = getAllDot11gRadioProfiles;
exports.getDot11gRadioProfile = getDot11gRadioProfile;
exports.updateDot11gRadioProfile = updateDot11gRadioProfile;
exports.deleteDot11gRadioProfile = deleteDot11gRadioProfile;
const apiRequest_1 = require("../../../helpers/apiRequest");
const responseFormatter_1 = require("../../../helpers/responseFormatter");
const pagination_1 = require("../../../helpers/pagination");
async function getAllDot11gRadioProfiles() {
try {
// Get parameters
const groupNameOrGuidOrSerial = this.getNodeParameter('groupNameOrGuidOrSerial', 0);
const returnAll = this.getNodeParameter('returnAll', 0, false);
let limit;
if (!returnAll) {
limit = this.getNodeParameter('limit', 0, 50);
}
// Build the endpoint
const endpoint = `/configuration/v1/dot11g_radio_profiles/${groupNameOrGuidOrSerial}`;
// Log the request
console.log('Getting all Dot11g radio profiles with parameters:', {
groupNameOrGuidOrSerial,
returnAll,
limit,
});
if (returnAll || limit) {
// Use pagination helper with a batch size of 100
return await pagination_1.handlePagination.call(this, endpoint, 'GET', {}, {}, {
path: ['dot11g_list'],
fallbackPaths: [['data', 'dot11g_list']],
}, returnAll, limit, 100);
}
else {
// Make a single API call without pagination
const response = await apiRequest_1.apiRequest.call(this, 'GET', endpoint, {}, {});
console.log('Received Dot11g radio profiles');
return responseFormatter_1.formatResponse.call(this, response);
}
}
catch (error) {
console.log('ERROR in getAllDot11gRadioProfiles:', error);
throw error;
}
}
async function getDot11gRadioProfile() {
try {
// Get parameters
const groupNameOrGuidOrSerial = this.getNodeParameter('groupNameOrGuidOrSerial', 0);
const profileName = this.getNodeParameter('profileName', 0);
// Log the request
console.log('Getting Dot11g radio profile with parameters:', {
groupNameOrGuidOrSerial,
profileName,
});
// Build the endpoint
const endpoint = `/configuration/v1/dot11g_radio_profile/${groupNameOrGuidOrSerial}/${profileName}`;
// Make API call
const response = await apiRequest_1.apiRequest.call(this, 'GET', endpoint, {}, {});
console.log('Received Dot11g radio profile');
return responseFormatter_1.formatResponse.call(this, response);
}
catch (error) {
console.log('ERROR in getDot11gRadioProfile:', error);
throw error;
}
}
async function updateDot11gRadioProfile() {
try {
// Get parameters
const groupNameOrGuidOrSerial = this.getNodeParameter('groupNameOrGuidOrSerial', 0);
const profileName = this.getNodeParameter('profileName', 0);
const radioProfileJson = this.getNodeParameter('radioProfile', 0);
// Parse the Radio Profile JSON
let radioProfile;
try {
radioProfile = JSON.parse(radioProfileJson);
}
catch (parseError) {
throw new Error(`Invalid JSON format for radio profile: ${parseError.message}`);
}
// Log the request
console.log('Updating Dot11g radio profile:', {
groupNameOrGuidOrSerial,
profileName,
radioProfile,
});
// Build the endpoint
const endpoint = `/configuration/v1/dot11g_radio_profile/${groupNameOrGuidOrSerial}/${profileName}`;
// Make API call
const response = await apiRequest_1.apiRequest.call(this, 'POST', endpoint, radioProfile, {});
console.log('Dot11g radio profile updated successfully');
return responseFormatter_1.formatResponse.call(this, response);
}
catch (error) {
console.log('ERROR in updateDot11gRadioProfile:', error);
throw error;
}
}
async function deleteDot11gRadioProfile() {
try {
// Get parameters
const groupNameOrGuidOrSerial = this.getNodeParameter('groupNameOrGuidOrSerial', 0);
const profileName = this.getNodeParameter('profileName', 0);
// Log the request
console.log('Deleting Dot11g radio profile with parameters:', {
groupNameOrGuidOrSerial,
profileName,
});
// Build the endpoint
const endpoint = `/configuration/v1/dot11g_radio_profile/${groupNameOrGuidOrSerial}/${profileName}`;
// Make API call
const response = await apiRequest_1.apiRequest.call(this, 'DELETE', endpoint, {}, {});
console.log('Dot11g radio profile deleted successfully');
return responseFormatter_1.formatResponse.call(this, response);
}
catch (error) {
console.log('ERROR in deleteDot11gRadioProfile:', error);
throw error;
}
}