/**
* Function to update the attributes of an MR SSID in a Cisco Meraki network.
*
* @param {Object} args - Arguments for the update.
* @param {string} args.networkId - The ID of the network.
* @param {number} args.number - The SSID number to update.
* @param {Object} args.ssidData - The SSID configuration data.
* @returns {Promise<Object>} - The result of the update operation.
*/
const executeFunction = async ({ networkId, number, ssidData }) => {
const baseUrl = 'https://api.meraki.com/api/v1';
const token = process.env.CISCO_MERAKI_S_PUBLIC_WORKSPACE_API_KEY;
try {
// Construct the URL for the PUT request
const url = `${baseUrl}/networks/${networkId}/wireless/ssids/${number}`;
// Set up headers for the request
const headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'X-Cisco-Meraki-API-Key': token
};
// Perform the fetch request
const response = await fetch(url, {
method: 'PUT',
headers,
body: JSON.stringify(ssidData)
});
// Check if the response was successful
if (!response.ok) {
const errorData = await response.json();
throw new Error(errorData);
}
// Parse and return the response data
const data = await response.json();
return data;
} catch (error) {
console.error('Error updating SSID:', error);
return { error: 'An error occurred while updating the SSID.' };
}
};
/**
* Tool configuration for updating an MR SSID in a Cisco Meraki network.
* @type {Object}
*/
const apiTool = {
function: executeFunction,
definition: {
type: 'function',
function: {
name: 'updateNetworkWirelessSsid',
description: 'Update the attributes of an MR SSID in a Cisco Meraki network.',
parameters: {
type: 'object',
properties: {
networkId: {
type: 'string',
description: 'The ID of the network.'
},
number: {
type: 'integer',
description: 'The SSID number to update.'
},
ssidData: {
type: 'object',
description: 'The SSID configuration data.'
}
},
required: ['networkId', 'number', 'ssidData']
}
}
}
};
export { apiTool };