UNPKG

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
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getAllDot11aRadioProfiles = getAllDot11aRadioProfiles; exports.getDot11aRadioProfile = getDot11aRadioProfile; exports.updateDot11aRadioProfile = updateDot11aRadioProfile; exports.deleteDot11aRadioProfile = deleteDot11aRadioProfile; const apiRequest_1 = require("../../../helpers/apiRequest"); const responseFormatter_1 = require("../../../helpers/responseFormatter"); const pagination_1 = require("../../../helpers/pagination"); async function getAllDot11aRadioProfiles() { 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/dot11a_radio_profiles/${groupNameOrGuidOrSerial}`; // Log the request console.log('Getting all Dot11a 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: ['dot11a_list'], fallbackPaths: [['data', 'dot11a_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 Dot11a radio profiles'); return responseFormatter_1.formatResponse.call(this, response); } } catch (error) { console.log('ERROR in getAllDot11aRadioProfiles:', error); throw error; } } async function getDot11aRadioProfile() { try { // Get parameters const groupNameOrGuidOrSerial = this.getNodeParameter('groupNameOrGuidOrSerial', 0); const profileName = this.getNodeParameter('profileName', 0); // Log the request console.log('Getting Dot11a radio profile with parameters:', { groupNameOrGuidOrSerial, profileName, }); // Build the endpoint const endpoint = `/configuration/v1/dot11a_radio_profile/${groupNameOrGuidOrSerial}/${profileName}`; // Make API call const response = await apiRequest_1.apiRequest.call(this, 'GET', endpoint, {}, {}); console.log('Received Dot11a radio profile'); return responseFormatter_1.formatResponse.call(this, response); } catch (error) { console.log('ERROR in getDot11aRadioProfile:', error); throw error; } } async function updateDot11aRadioProfile() { 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 Dot11a radio profile:', { groupNameOrGuidOrSerial, profileName, radioProfile, }); // Build the endpoint const endpoint = `/configuration/v1/dot11a_radio_profile/${groupNameOrGuidOrSerial}/${profileName}`; // Make API call const response = await apiRequest_1.apiRequest.call(this, 'POST', endpoint, radioProfile, {}); console.log('Dot11a radio profile updated successfully'); return responseFormatter_1.formatResponse.call(this, response); } catch (error) { console.log('ERROR in updateDot11aRadioProfile:', error); throw error; } } async function deleteDot11aRadioProfile() { try { // Get parameters const groupNameOrGuidOrSerial = this.getNodeParameter('groupNameOrGuidOrSerial', 0); const profileName = this.getNodeParameter('profileName', 0); // Log the request console.log('Deleting Dot11a radio profile with parameters:', { groupNameOrGuidOrSerial, profileName, }); // Build the endpoint const endpoint = `/configuration/v1/dot11a_radio_profile/${groupNameOrGuidOrSerial}/${profileName}`; // Make API call const response = await apiRequest_1.apiRequest.call(this, 'DELETE', endpoint, {}, {}); console.log('Dot11a radio profile deleted successfully'); return responseFormatter_1.formatResponse.call(this, response); } catch (error) { console.log('ERROR in deleteDot11aRadioProfile:', error); throw error; } }