n8n-nodes-arubacentral
Version:
n8n community node for Aruba Central API integration with comprehensive monitoring, configuration, and management capabilities
105 lines (104 loc) • 4.36 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getGroupSshCredentials = getGroupSshCredentials;
exports.updateGroupSshCredentials = updateGroupSshCredentials;
exports.getDeviceSshCredentials = getDeviceSshCredentials;
exports.updateDeviceSshCredentials = updateDeviceSshCredentials;
const apiRequest_1 = require("../../../helpers/apiRequest");
const responseFormatter_1 = require("../../../helpers/responseFormatter");
async function getGroupSshCredentials() {
try {
// Get parameters
const groupName = this.getNodeParameter('groupName', 0);
// Log the request
console.log('Getting group SSH credentials with parameters:', { groupName });
// Build the endpoint
const endpoint = `/configuration/v1/group/ssh_credential/${groupName}`;
// Make API call
const response = await apiRequest_1.apiRequest.call(this, 'GET', endpoint, {}, {});
console.log('Received group SSH credentials');
return responseFormatter_1.formatResponse.call(this, response);
}
catch (error) {
console.log('ERROR in getGroupSshCredentials:', error);
throw error;
}
}
async function updateGroupSshCredentials() {
try {
// Get parameters
const groupName = this.getNodeParameter('groupName', 0);
const sshCredentialsJson = this.getNodeParameter('sshCredentials', 0);
// Parse the SSH credentials JSON
let sshCredentials;
try {
sshCredentials = JSON.parse(sshCredentialsJson);
}
catch (parseError) {
throw new Error(`Invalid JSON format for SSH credentials: ${parseError.message}`);
}
// Log the request
console.log('Updating group SSH credentials:', {
groupName,
username: sshCredentials.username,
});
// Build the endpoint
const endpoint = `/configuration/v1/group/ssh_credential/${groupName}`;
// Make API call
const response = await apiRequest_1.apiRequest.call(this, 'POST', endpoint, sshCredentials, {});
console.log('Group SSH credentials updated successfully');
return responseFormatter_1.formatResponse.call(this, response);
}
catch (error) {
console.log('ERROR in updateGroupSshCredentials:', error);
throw error;
}
}
async function getDeviceSshCredentials() {
try {
// Get parameters
const serialNumberOrGuid = this.getNodeParameter('serialNumberOrGuid', 0);
// Log the request
console.log('Getting device SSH credentials with parameters:', { serialNumberOrGuid });
// Build the endpoint
const endpoint = `/configuration/v1/device/ssh_credential/${serialNumberOrGuid}`;
// Make API call
const response = await apiRequest_1.apiRequest.call(this, 'GET', endpoint, {}, {});
console.log('Received device SSH credentials');
return responseFormatter_1.formatResponse.call(this, response);
}
catch (error) {
console.log('ERROR in getDeviceSshCredentials:', error);
throw error;
}
}
async function updateDeviceSshCredentials() {
try {
// Get parameters
const serialNumberOrGuid = this.getNodeParameter('serialNumberOrGuid', 0);
const sshCredentialsJson = this.getNodeParameter('sshCredentials', 0);
// Parse the SSH credentials JSON
let sshCredentials;
try {
sshCredentials = JSON.parse(sshCredentialsJson);
}
catch (parseError) {
throw new Error(`Invalid JSON format for SSH credentials: ${parseError.message}`);
}
// Log the request
console.log('Updating device SSH credentials:', {
serialNumberOrGuid,
username: sshCredentials.username,
});
// Build the endpoint
const endpoint = `/configuration/v1/device/ssh_credential/${serialNumberOrGuid}`;
// Make API call
const response = await apiRequest_1.apiRequest.call(this, 'POST', endpoint, sshCredentials, {});
console.log('Device SSH credentials updated successfully');
return responseFormatter_1.formatResponse.call(this, response);
}
catch (error) {
console.log('ERROR in updateDeviceSshCredentials:', error);
throw error;
}
}