/**
* Function to get an overview of current device statuses in a Cisco Meraki organization.
*
* @param {Object} args - Arguments for the device statuses overview.
* @param {string} args.organizationId - The ID of the organization.
* @param {string} [args.productTypes] - An optional parameter to filter device statuses by product type.
* @param {string} [args.networkIds] - An optional parameter to filter device statuses by network.
* @returns {Promise<Object>} - The result of the device statuses overview.
*/
const executeFunction = async ({ organizationId, productTypes, networkIds }) => {
const baseUrl = 'https://api.meraki.com/api/v1';
const token = process.env.CISCO_MERAKI_S_PUBLIC_WORKSPACE_API_KEY;
try {
// Construct the URL with path and query parameters
const url = new URL(`${baseUrl}/organizations/${organizationId}/devices/statuses/overview`);
if (productTypes) {
url.searchParams.append('productTypes', productTypes);
}
if (networkIds) {
url.searchParams.append('networkIds', networkIds);
}
// Set up headers for the request
const headers = {
'Accept': 'application/json',
'Authorization': `Bearer ${token}`
};
// Perform the fetch request
const response = await fetch(url.toString(), {
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 getting device statuses overview:', error);
return { error: 'An error occurred while retrieving device statuses overview.' };
}
};
/**
* Tool configuration for getting device statuses overview in Cisco Meraki.
* @type {Object}
*/
const apiTool = {
function: executeFunction,
definition: {
type: 'function',
function: {
name: 'getOrganizationDevicesStatusesOverview',
description: 'Get an overview of current device statuses in a Cisco Meraki organization.',
parameters: {
type: 'object',
properties: {
organizationId: {
type: 'string',
description: 'The ID of the organization.'
},
productTypes: {
type: 'string',
description: 'An optional parameter to filter device statuses by product type.'
},
networkIds: {
type: 'string',
description: 'An optional parameter to filter device statuses by network.'
}
},
required: ['organizationId']
}
}
}
};
export { apiTool };