/**
* Function to update video settings for a given camera in the Meraki Dashboard.
*
* @param {Object} args - Arguments for updating the camera video settings.
* @param {string} args.serial - The serial number of the camera.
* @param {boolean} args.externalRtspEnabled - Enable or disable external RTSP.
* @returns {Promise<Object>} - The result of the update operation.
*/
const executeFunction = async ({ serial, externalRtspEnabled }) => {
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 API request
const url = `${baseUrl}/devices/${serial}/camera/video/settings`;
// Set up headers for the request
const headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': `Bearer ${token}`
};
// Prepare the request body
const body = JSON.stringify({ externalRtspEnabled });
// Perform the fetch request
const response = await fetch(url, {
method: 'PUT',
headers,
body
});
// 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 camera video settings:', error);
return { error: 'An error occurred while updating camera video settings.' };
}
};
/**
* Tool configuration for updating camera video settings in the Meraki Dashboard.
* @type {Object}
*/
const apiTool = {
function: executeFunction,
definition: {
type: 'function',
function: {
name: 'updateDeviceCameraVideoSettings',
description: 'Update video settings for the given camera.',
parameters: {
type: 'object',
properties: {
serial: {
type: 'string',
description: 'The serial number of the camera.'
},
externalRtspEnabled: {
type: 'boolean',
description: 'Enable or disable external RTSP.'
}
},
required: ['serial', 'externalRtspEnabled']
}
}
}
};
export { apiTool };