/**
* Function to get camera quality and retention settings for a specific device.
*
* @param {Object} args - Arguments for the request.
* @param {string} args.serial - The serial number of the device.
* @returns {Promise<Object>} - The camera quality and retention settings for the device.
*/
const executeFunction = async ({ serial }) => {
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 request
const url = `${baseUrl}/devices/${serial}/camera/qualityAndRetention`;
// Set up headers for the request
const headers = {
'Accept': 'application/json',
'Authorization': `Bearer ${token}`
};
// Perform the fetch request
const response = await fetch(url, {
method: 'GET',
headers
});
// 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 fetching camera quality and retention settings:', error);
return { error: 'An error occurred while fetching camera settings.' };
}
};
/**
* Tool configuration for getting camera quality and retention settings.
* @type {Object}
*/
const apiTool = {
function: executeFunction,
definition: {
type: 'function',
function: {
name: 'getDeviceCameraQualityAndRetention',
description: 'Returns quality and retention settings for the given camera.',
parameters: {
type: 'object',
properties: {
serial: {
type: 'string',
description: 'The serial number of the device.'
}
},
required: ['serial']
}
}
}
};
export { apiTool };