/**
* Function to update the quality and retention settings for a given camera on Cisco Meraki.
*
* @param {Object} args - Arguments for updating camera settings.
* @param {string} args.serial - The serial number of the device.
* @param {string} args.profileId - The profile ID for the camera.
* @param {boolean} args.motionBasedRetentionEnabled - Enable or disable motion-based retention.
* @param {boolean} args.audioRecordingEnabled - Enable or disable audio recording.
* @param {boolean} args.restrictedBandwidthModeEnabled - Enable or disable restricted bandwidth mode.
* @param {string} args.quality - The quality setting for the camera.
* @param {string} args.resolution - The resolution setting for the camera.
* @param {number} args.motionDetectorVersion - The version of the motion detector.
* @returns {Promise<Object>} - The result of the update operation.
*/
const executeFunction = async ({ serial, profileId, motionBasedRetentionEnabled, audioRecordingEnabled, restrictedBandwidthModeEnabled, quality, resolution, motionDetectorVersion }) => {
const baseUrl = 'https://api.meraki.com/api/v1';
const token = process.env.CISCO_MERAKI_S_PUBLIC_WORKSPACE_API_KEY;
const url = `${baseUrl}/devices/${serial}/camera/qualityAndRetention`;
const headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': `Bearer ${token}`
};
const body = JSON.stringify({
profileId,
motionBasedRetentionEnabled,
audioRecordingEnabled,
restrictedBandwidthModeEnabled,
quality,
resolution,
motionDetectorVersion
});
try {
const response = await fetch(url, {
method: 'PUT',
headers,
body
});
if (!response.ok) {
const errorData = await response.json();
throw new Error(errorData);
}
const data = await response.json();
return data;
} catch (error) {
console.error('Error updating camera settings:', error);
return { error: 'An error occurred while updating camera settings.' };
}
};
/**
* Tool configuration for updating camera quality and retention settings on Cisco Meraki.
* @type {Object}
*/
const apiTool = {
function: executeFunction,
definition: {
type: 'function',
function: {
name: 'updateDeviceCameraQualityAndRetention',
description: 'Update quality and retention settings for the given camera.',
parameters: {
type: 'object',
properties: {
serial: {
type: 'string',
description: 'The serial number of the device.'
},
profileId: {
type: 'string',
description: 'The profile ID for the camera.'
},
motionBasedRetentionEnabled: {
type: 'boolean',
description: 'Enable or disable motion-based retention.'
},
audioRecordingEnabled: {
type: 'boolean',
description: 'Enable or disable audio recording.'
},
restrictedBandwidthModeEnabled: {
type: 'boolean',
description: 'Enable or disable restricted bandwidth mode.'
},
quality: {
type: 'string',
description: 'The quality setting for the camera.'
},
resolution: {
type: 'string',
description: 'The resolution setting for the camera.'
},
motionDetectorVersion: {
type: 'integer',
description: 'The version of the motion detector.'
}
},
required: ['serial', 'profileId']
}
}
}
};
export { apiTool };