UNPKG

node-meraki

Version:
79 lines (71 loc) 2.88 kB
/** * Create a Meraki REST API wrapper for the SM ressource. See the * [online documentation]{@link https://dashboard.meraki.com/api_docs#sm} for more information. * * @module meraki/rest/sm * @param { string } [apiKey=''] The Meraki api key * @param { string } [target='api'] The Meraki target * @param { string } [basePath='/'] The Meraki base path for the SM ressource * @param { string } rateLimiter The rate limiter (bottleneck) configuration * @return { Object } The initialized Meraki REST API wrapper for the SM ressource * @example * const apiKey = 'secret meraki api key' * const organizationId = 'meraki organization id' * const version = 'v0' * const target = 'n12' * const basePath = `/${target}/${version}/networks` * const rateLimiter = { * enabled: true * } * const smEndpoints = require('./lib/rest/sm')({ apiKey, target, basePath, baseUrl, rateLimiter }) */ function createSMEndpoints({ apiKey = '', target = 'api', basePath = '/', baseUrl = 'https://api.meraki.com', rateLimiter }) { const axios = require('./axios')({ baseUrl, rateLimiter }); /** * Move a set of devices to a new network. * * @memberof module:meraki/rest/sm * @param { string } [apiKey] Optional custom apiKey for this request (if not set will take the inital apiKey) * @param { string } [target] Optional custom target for this request (if not set will take the inital target) * @param { string } networkId The id of the network from which to move the devices * @param { string } [wifiMacs] The wifiMacs of the devices to be moved * @param { string } [ids] The ids of the devices to be moved * @param { string } [serials] The serials of the devices to be moved * @param { string } [scope] The scope (one of all, none, withAny, withAll, withoutAny, or withoutAll) and a set of tags of the devices to be moved * @param { string } newNetwork The new network to which the devices will be moved * @return { Promise } A promise holding the success status * @example <caption>Example response</caption> * { * "success": true * } */ function moveDevices(data) { const { networkId } = data; delete data.networkId; if (!networkId) { return Promise.reject(new Error('The parameter networkId is mandatory')); } if (!data.newNetwork) { return Promise.reject(new Error('The parameter newNetwork is mandatory')); } if (!data.wifiMacs && !data.ids && !data.serials) { return Promise.reject(new Error('One of the parameters wifiMacs, ids, or serials is mandatory and must not be empty')); } return axios._put(apiKey || apiKey, target || target, `${basePath}/${networkId}/sm/devices/move`, data); } return { moveDevices }; } module.exports = createSMEndpoints;