node-red-contrib-meraki-dashboard-api
Version:
Node-RED node for meraki-dashboard-api
834 lines (677 loc) • 1.01 MB
JavaScript
'use strict';
var lib = require('./lib.js');
/*
DISABLES Console.log for production
*/
console.log = function() {};
module.exports = function (RED) {
function MerakiDashboardApiNode(config) {
RED.nodes.createNode(this, config);
this.service = RED.nodes.getNode(config.service);
console.log('node.js.mustache this.service.host ', this.service.host);
console.log('node.js.mustache config.host ', config.host);
this.method = config.method;
this.storedParams = config.storedParams;
var node = this;
console.log('first run: node = this', node);
node.on('input', function (msg) {
var node = this;
var errorFlag = false;
//console.log("this.service.host", this.service.host);
//console.log("node.js.mustache config", config);
//console.log("node.js.mustache this", this);
var client;
if (this.service && this.service.host) {
if(msg.service){
if (msg.service.host) {
// override apiUrl with input msg
client = new lib.MerakiDashboardApi({ domain: msg.service.host });
}
}else{
client = new lib.MerakiDashboardApi({ domain: this.service.host });
}
} else {
node.error('Host in configuration node is not specified.', msg);
errorFlag = true;
}
if (!errorFlag && this.service && this.service.credentials && this.service.credentials.secureApiKeyValue) {
if(msg.service){
if (msg.service.apiKey) {
// override apiKey with input msg
client.setApiKey(msg.service.apiKey,
this.service.secureApiKeyHeaderOrQueryName, false);
}
}else{
if (this.service.secureApiKeyIsQuery) {
client.setApiKey(this.service.credentials.secureApiKeyValue,
this.service.secureApiKeyHeaderOrQueryName, true);
} else {
client.setApiKey(this.service.credentials.secureApiKeyValue,
this.service.secureApiKeyHeaderOrQueryName, false);
}
}
}
if (!errorFlag) {
client.body = msg.payload;
}
var result;
if(!node.storedParams){
node.storedParams = [];
}
console.log('node.js node', node);
var storedParamValsMap = {};
node.storedParams.forEach(p =>{
storedParamValsMap[p.camelCaseName] = p.value;
})
var storedParamTypeMap = {};
node.storedParams.forEach(p =>{
storedParamTypeMap[p.camelCaseName] = p.type;
})
node.method = node.method || RED.util.getMessageProperty(msg, "operationId");
if (!errorFlag && node.method === 'getDeviceCameraAnalyticsLive') {
var getDeviceCameraAnalyticsLive_parameters = [];
var getDeviceCameraAnalyticsLive_nodeParam;
var getDeviceCameraAnalyticsLive_nodeParamType;
console.log('check if body param msg.payload, ', msg.payload);
getDeviceCameraAnalyticsLive_nodeParam = storedParamValsMap['serial'] ||
RED.util.getMessageProperty(msg, "serial");
getDeviceCameraAnalyticsLive_nodeParamType = storedParamTypeMap['serial'] ||
RED.util.getMessageProperty(msg, "serial");
// Check if its the body param
// notBodyParam
if (getDeviceCameraAnalyticsLive_nodeParamType === 'str') {
console.log('getDeviceCameraAnalyticsLive_nodeParamType is "str"');
getDeviceCameraAnalyticsLive_parameters.serial = getDeviceCameraAnalyticsLive_nodeParam || undefined;
} else {
console.log('getDeviceCameraAnalyticsLive_nodeParamType is not "str"')
getDeviceCameraAnalyticsLive_parameters.serial = RED.util.getMessageProperty(msg, "serial");
}
result = client.getDeviceCameraAnalyticsLive(getDeviceCameraAnalyticsLive_parameters);
console.log('result', result);
}
if (!errorFlag && node.method === 'getDeviceCameraAnalyticsOverview') {
var getDeviceCameraAnalyticsOverview_parameters = [];
var getDeviceCameraAnalyticsOverview_nodeParam;
var getDeviceCameraAnalyticsOverview_nodeParamType;
console.log('check if body param msg.payload, ', msg.payload);
getDeviceCameraAnalyticsOverview_nodeParam = storedParamValsMap['serial'] ||
RED.util.getMessageProperty(msg, "serial");
getDeviceCameraAnalyticsOverview_nodeParamType = storedParamTypeMap['serial'] ||
RED.util.getMessageProperty(msg, "serial");
// Check if its the body param
// notBodyParam
if (getDeviceCameraAnalyticsOverview_nodeParamType === 'str') {
console.log('getDeviceCameraAnalyticsOverview_nodeParamType is "str"');
getDeviceCameraAnalyticsOverview_parameters.serial = getDeviceCameraAnalyticsOverview_nodeParam || undefined;
} else {
console.log('getDeviceCameraAnalyticsOverview_nodeParamType is not "str"')
getDeviceCameraAnalyticsOverview_parameters.serial = RED.util.getMessageProperty(msg, "serial");
}
getDeviceCameraAnalyticsOverview_nodeParam = storedParamValsMap['t0'] ||
RED.util.getMessageProperty(msg, "t0");
getDeviceCameraAnalyticsOverview_nodeParamType = storedParamTypeMap['t0'] ||
RED.util.getMessageProperty(msg, "t0");
// Check if its the body param
// notBodyParam
if (getDeviceCameraAnalyticsOverview_nodeParamType === 'str') {
console.log('getDeviceCameraAnalyticsOverview_nodeParamType is "str"');
getDeviceCameraAnalyticsOverview_parameters.t0 = getDeviceCameraAnalyticsOverview_nodeParam || undefined;
} else {
console.log('getDeviceCameraAnalyticsOverview_nodeParamType is not "str"')
getDeviceCameraAnalyticsOverview_parameters.t0 = RED.util.getMessageProperty(msg, "t0");
}
getDeviceCameraAnalyticsOverview_nodeParam = storedParamValsMap['t1'] ||
RED.util.getMessageProperty(msg, "t1");
getDeviceCameraAnalyticsOverview_nodeParamType = storedParamTypeMap['t1'] ||
RED.util.getMessageProperty(msg, "t1");
// Check if its the body param
// notBodyParam
if (getDeviceCameraAnalyticsOverview_nodeParamType === 'str') {
console.log('getDeviceCameraAnalyticsOverview_nodeParamType is "str"');
getDeviceCameraAnalyticsOverview_parameters.t1 = getDeviceCameraAnalyticsOverview_nodeParam || undefined;
} else {
console.log('getDeviceCameraAnalyticsOverview_nodeParamType is not "str"')
getDeviceCameraAnalyticsOverview_parameters.t1 = RED.util.getMessageProperty(msg, "t1");
}
getDeviceCameraAnalyticsOverview_nodeParam = storedParamValsMap['timespan'] ||
RED.util.getMessageProperty(msg, "timespan");
getDeviceCameraAnalyticsOverview_nodeParamType = storedParamTypeMap['timespan'] ||
RED.util.getMessageProperty(msg, "timespan");
// Check if its the body param
// notBodyParam
if (getDeviceCameraAnalyticsOverview_nodeParamType === 'str') {
console.log('getDeviceCameraAnalyticsOverview_nodeParamType is "str"');
getDeviceCameraAnalyticsOverview_parameters.timespan = getDeviceCameraAnalyticsOverview_nodeParam || undefined;
} else {
console.log('getDeviceCameraAnalyticsOverview_nodeParamType is not "str"')
getDeviceCameraAnalyticsOverview_parameters.timespan = RED.util.getMessageProperty(msg, "timespan");
}
getDeviceCameraAnalyticsOverview_nodeParam = storedParamValsMap['objectType'] ||
RED.util.getMessageProperty(msg, "objectType");
getDeviceCameraAnalyticsOverview_nodeParamType = storedParamTypeMap['objectType'] ||
RED.util.getMessageProperty(msg, "objectType");
// Check if its the body param
// notBodyParam
if (getDeviceCameraAnalyticsOverview_nodeParamType === 'str') {
console.log('getDeviceCameraAnalyticsOverview_nodeParamType is "str"');
getDeviceCameraAnalyticsOverview_parameters.objectType = getDeviceCameraAnalyticsOverview_nodeParam || undefined;
} else {
console.log('getDeviceCameraAnalyticsOverview_nodeParamType is not "str"')
getDeviceCameraAnalyticsOverview_parameters.objectType = RED.util.getMessageProperty(msg, "objectType");
}
result = client.getDeviceCameraAnalyticsOverview(getDeviceCameraAnalyticsOverview_parameters);
console.log('result', result);
}
if (!errorFlag && node.method === 'getDeviceCameraAnalyticsRecent') {
var getDeviceCameraAnalyticsRecent_parameters = [];
var getDeviceCameraAnalyticsRecent_nodeParam;
var getDeviceCameraAnalyticsRecent_nodeParamType;
console.log('check if body param msg.payload, ', msg.payload);
getDeviceCameraAnalyticsRecent_nodeParam = storedParamValsMap['serial'] ||
RED.util.getMessageProperty(msg, "serial");
getDeviceCameraAnalyticsRecent_nodeParamType = storedParamTypeMap['serial'] ||
RED.util.getMessageProperty(msg, "serial");
// Check if its the body param
// notBodyParam
if (getDeviceCameraAnalyticsRecent_nodeParamType === 'str') {
console.log('getDeviceCameraAnalyticsRecent_nodeParamType is "str"');
getDeviceCameraAnalyticsRecent_parameters.serial = getDeviceCameraAnalyticsRecent_nodeParam || undefined;
} else {
console.log('getDeviceCameraAnalyticsRecent_nodeParamType is not "str"')
getDeviceCameraAnalyticsRecent_parameters.serial = RED.util.getMessageProperty(msg, "serial");
}
getDeviceCameraAnalyticsRecent_nodeParam = storedParamValsMap['objectType'] ||
RED.util.getMessageProperty(msg, "objectType");
getDeviceCameraAnalyticsRecent_nodeParamType = storedParamTypeMap['objectType'] ||
RED.util.getMessageProperty(msg, "objectType");
// Check if its the body param
// notBodyParam
if (getDeviceCameraAnalyticsRecent_nodeParamType === 'str') {
console.log('getDeviceCameraAnalyticsRecent_nodeParamType is "str"');
getDeviceCameraAnalyticsRecent_parameters.objectType = getDeviceCameraAnalyticsRecent_nodeParam || undefined;
} else {
console.log('getDeviceCameraAnalyticsRecent_nodeParamType is not "str"')
getDeviceCameraAnalyticsRecent_parameters.objectType = RED.util.getMessageProperty(msg, "objectType");
}
result = client.getDeviceCameraAnalyticsRecent(getDeviceCameraAnalyticsRecent_parameters);
console.log('result', result);
}
if (!errorFlag && node.method === 'getDeviceCameraAnalyticsZones') {
var getDeviceCameraAnalyticsZones_parameters = [];
var getDeviceCameraAnalyticsZones_nodeParam;
var getDeviceCameraAnalyticsZones_nodeParamType;
console.log('check if body param msg.payload, ', msg.payload);
getDeviceCameraAnalyticsZones_nodeParam = storedParamValsMap['serial'] ||
RED.util.getMessageProperty(msg, "serial");
getDeviceCameraAnalyticsZones_nodeParamType = storedParamTypeMap['serial'] ||
RED.util.getMessageProperty(msg, "serial");
// Check if its the body param
// notBodyParam
if (getDeviceCameraAnalyticsZones_nodeParamType === 'str') {
console.log('getDeviceCameraAnalyticsZones_nodeParamType is "str"');
getDeviceCameraAnalyticsZones_parameters.serial = getDeviceCameraAnalyticsZones_nodeParam || undefined;
} else {
console.log('getDeviceCameraAnalyticsZones_nodeParamType is not "str"')
getDeviceCameraAnalyticsZones_parameters.serial = RED.util.getMessageProperty(msg, "serial");
}
result = client.getDeviceCameraAnalyticsZones(getDeviceCameraAnalyticsZones_parameters);
console.log('result', result);
}
if (!errorFlag && node.method === 'getDeviceCameraAnalyticsZoneHistory') {
var getDeviceCameraAnalyticsZoneHistory_parameters = [];
var getDeviceCameraAnalyticsZoneHistory_nodeParam;
var getDeviceCameraAnalyticsZoneHistory_nodeParamType;
console.log('check if body param msg.payload, ', msg.payload);
getDeviceCameraAnalyticsZoneHistory_nodeParam = storedParamValsMap['serial'] ||
RED.util.getMessageProperty(msg, "serial");
getDeviceCameraAnalyticsZoneHistory_nodeParamType = storedParamTypeMap['serial'] ||
RED.util.getMessageProperty(msg, "serial");
// Check if its the body param
// notBodyParam
if (getDeviceCameraAnalyticsZoneHistory_nodeParamType === 'str') {
console.log('getDeviceCameraAnalyticsZoneHistory_nodeParamType is "str"');
getDeviceCameraAnalyticsZoneHistory_parameters.serial = getDeviceCameraAnalyticsZoneHistory_nodeParam || undefined;
} else {
console.log('getDeviceCameraAnalyticsZoneHistory_nodeParamType is not "str"')
getDeviceCameraAnalyticsZoneHistory_parameters.serial = RED.util.getMessageProperty(msg, "serial");
}
getDeviceCameraAnalyticsZoneHistory_nodeParam = storedParamValsMap['zoneId'] ||
RED.util.getMessageProperty(msg, "zoneId");
getDeviceCameraAnalyticsZoneHistory_nodeParamType = storedParamTypeMap['zoneId'] ||
RED.util.getMessageProperty(msg, "zoneId");
// Check if its the body param
// notBodyParam
if (getDeviceCameraAnalyticsZoneHistory_nodeParamType === 'str') {
console.log('getDeviceCameraAnalyticsZoneHistory_nodeParamType is "str"');
getDeviceCameraAnalyticsZoneHistory_parameters.zoneId = getDeviceCameraAnalyticsZoneHistory_nodeParam || undefined;
} else {
console.log('getDeviceCameraAnalyticsZoneHistory_nodeParamType is not "str"')
getDeviceCameraAnalyticsZoneHistory_parameters.zoneId = RED.util.getMessageProperty(msg, "zoneId");
}
getDeviceCameraAnalyticsZoneHistory_nodeParam = storedParamValsMap['t0'] ||
RED.util.getMessageProperty(msg, "t0");
getDeviceCameraAnalyticsZoneHistory_nodeParamType = storedParamTypeMap['t0'] ||
RED.util.getMessageProperty(msg, "t0");
// Check if its the body param
// notBodyParam
if (getDeviceCameraAnalyticsZoneHistory_nodeParamType === 'str') {
console.log('getDeviceCameraAnalyticsZoneHistory_nodeParamType is "str"');
getDeviceCameraAnalyticsZoneHistory_parameters.t0 = getDeviceCameraAnalyticsZoneHistory_nodeParam || undefined;
} else {
console.log('getDeviceCameraAnalyticsZoneHistory_nodeParamType is not "str"')
getDeviceCameraAnalyticsZoneHistory_parameters.t0 = RED.util.getMessageProperty(msg, "t0");
}
getDeviceCameraAnalyticsZoneHistory_nodeParam = storedParamValsMap['t1'] ||
RED.util.getMessageProperty(msg, "t1");
getDeviceCameraAnalyticsZoneHistory_nodeParamType = storedParamTypeMap['t1'] ||
RED.util.getMessageProperty(msg, "t1");
// Check if its the body param
// notBodyParam
if (getDeviceCameraAnalyticsZoneHistory_nodeParamType === 'str') {
console.log('getDeviceCameraAnalyticsZoneHistory_nodeParamType is "str"');
getDeviceCameraAnalyticsZoneHistory_parameters.t1 = getDeviceCameraAnalyticsZoneHistory_nodeParam || undefined;
} else {
console.log('getDeviceCameraAnalyticsZoneHistory_nodeParamType is not "str"')
getDeviceCameraAnalyticsZoneHistory_parameters.t1 = RED.util.getMessageProperty(msg, "t1");
}
getDeviceCameraAnalyticsZoneHistory_nodeParam = storedParamValsMap['timespan'] ||
RED.util.getMessageProperty(msg, "timespan");
getDeviceCameraAnalyticsZoneHistory_nodeParamType = storedParamTypeMap['timespan'] ||
RED.util.getMessageProperty(msg, "timespan");
// Check if its the body param
// notBodyParam
if (getDeviceCameraAnalyticsZoneHistory_nodeParamType === 'str') {
console.log('getDeviceCameraAnalyticsZoneHistory_nodeParamType is "str"');
getDeviceCameraAnalyticsZoneHistory_parameters.timespan = getDeviceCameraAnalyticsZoneHistory_nodeParam || undefined;
} else {
console.log('getDeviceCameraAnalyticsZoneHistory_nodeParamType is not "str"')
getDeviceCameraAnalyticsZoneHistory_parameters.timespan = RED.util.getMessageProperty(msg, "timespan");
}
getDeviceCameraAnalyticsZoneHistory_nodeParam = storedParamValsMap['resolution'] ||
RED.util.getMessageProperty(msg, "resolution");
getDeviceCameraAnalyticsZoneHistory_nodeParamType = storedParamTypeMap['resolution'] ||
RED.util.getMessageProperty(msg, "resolution");
// Check if its the body param
// notBodyParam
if (getDeviceCameraAnalyticsZoneHistory_nodeParamType === 'str') {
console.log('getDeviceCameraAnalyticsZoneHistory_nodeParamType is "str"');
getDeviceCameraAnalyticsZoneHistory_parameters.resolution = getDeviceCameraAnalyticsZoneHistory_nodeParam || undefined;
} else {
console.log('getDeviceCameraAnalyticsZoneHistory_nodeParamType is not "str"')
getDeviceCameraAnalyticsZoneHistory_parameters.resolution = RED.util.getMessageProperty(msg, "resolution");
}
getDeviceCameraAnalyticsZoneHistory_nodeParam = storedParamValsMap['objectType'] ||
RED.util.getMessageProperty(msg, "objectType");
getDeviceCameraAnalyticsZoneHistory_nodeParamType = storedParamTypeMap['objectType'] ||
RED.util.getMessageProperty(msg, "objectType");
// Check if its the body param
// notBodyParam
if (getDeviceCameraAnalyticsZoneHistory_nodeParamType === 'str') {
console.log('getDeviceCameraAnalyticsZoneHistory_nodeParamType is "str"');
getDeviceCameraAnalyticsZoneHistory_parameters.objectType = getDeviceCameraAnalyticsZoneHistory_nodeParam || undefined;
} else {
console.log('getDeviceCameraAnalyticsZoneHistory_nodeParamType is not "str"')
getDeviceCameraAnalyticsZoneHistory_parameters.objectType = RED.util.getMessageProperty(msg, "objectType");
}
result = client.getDeviceCameraAnalyticsZoneHistory(getDeviceCameraAnalyticsZoneHistory_parameters);
console.log('result', result);
}
if (!errorFlag && node.method === 'getDeviceCameraQualityAndRetentionSettings') {
var getDeviceCameraQualityAndRetentionSettings_parameters = [];
var getDeviceCameraQualityAndRetentionSettings_nodeParam;
var getDeviceCameraQualityAndRetentionSettings_nodeParamType;
console.log('check if body param msg.payload, ', msg.payload);
getDeviceCameraQualityAndRetentionSettings_nodeParam = storedParamValsMap['serial'] ||
RED.util.getMessageProperty(msg, "serial");
getDeviceCameraQualityAndRetentionSettings_nodeParamType = storedParamTypeMap['serial'] ||
RED.util.getMessageProperty(msg, "serial");
// Check if its the body param
// notBodyParam
if (getDeviceCameraQualityAndRetentionSettings_nodeParamType === 'str') {
console.log('getDeviceCameraQualityAndRetentionSettings_nodeParamType is "str"');
getDeviceCameraQualityAndRetentionSettings_parameters.serial = getDeviceCameraQualityAndRetentionSettings_nodeParam || undefined;
} else {
console.log('getDeviceCameraQualityAndRetentionSettings_nodeParamType is not "str"')
getDeviceCameraQualityAndRetentionSettings_parameters.serial = RED.util.getMessageProperty(msg, "serial");
}
result = client.getDeviceCameraQualityAndRetentionSettings(getDeviceCameraQualityAndRetentionSettings_parameters);
console.log('result', result);
}
if (!errorFlag && node.method === 'updateDeviceCameraQualityAndRetentionSettings') {
var updateDeviceCameraQualityAndRetentionSettings_parameters = [];
var updateDeviceCameraQualityAndRetentionSettings_nodeParam;
var updateDeviceCameraQualityAndRetentionSettings_nodeParamType;
console.log('check if body param msg.payload, ', msg.payload);
updateDeviceCameraQualityAndRetentionSettings_nodeParam = storedParamValsMap['serial'] ||
RED.util.getMessageProperty(msg, "serial");
updateDeviceCameraQualityAndRetentionSettings_nodeParamType = storedParamTypeMap['serial'] ||
RED.util.getMessageProperty(msg, "serial");
// Check if its the body param
// notBodyParam
if (updateDeviceCameraQualityAndRetentionSettings_nodeParamType === 'str') {
console.log('updateDeviceCameraQualityAndRetentionSettings_nodeParamType is "str"');
updateDeviceCameraQualityAndRetentionSettings_parameters.serial = updateDeviceCameraQualityAndRetentionSettings_nodeParam || undefined;
} else {
console.log('updateDeviceCameraQualityAndRetentionSettings_nodeParamType is not "str"')
updateDeviceCameraQualityAndRetentionSettings_parameters.serial = RED.util.getMessageProperty(msg, "serial");
}
updateDeviceCameraQualityAndRetentionSettings_nodeParam = storedParamValsMap['updateDeviceCameraQualityAndRetentionSettings'] ||
RED.util.getMessageProperty(msg, "updateDeviceCameraQualityAndRetentionSettings");
updateDeviceCameraQualityAndRetentionSettings_nodeParamType = storedParamTypeMap['updateDeviceCameraQualityAndRetentionSettings'] ||
RED.util.getMessageProperty(msg, "updateDeviceCameraQualityAndRetentionSettings");
// Check if its the body param
// isBodyParam
if (typeof msg.payload === 'object') {
updateDeviceCameraQualityAndRetentionSettings_parameters.updateDeviceCameraQualityAndRetentionSettings = msg.payload;
} else {
node.error('Unsupported type: \'' + (typeof msg.payload) + '\', ' + 'msg.payload must be JSON object or buffer.', msg);
errorFlag = true;
}
result = client.updateDeviceCameraQualityAndRetentionSettings(updateDeviceCameraQualityAndRetentionSettings_parameters);
console.log('result', result);
}
if (!errorFlag && node.method === 'getDeviceCellularGatewaySettings') {
var getDeviceCellularGatewaySettings_parameters = [];
var getDeviceCellularGatewaySettings_nodeParam;
var getDeviceCellularGatewaySettings_nodeParamType;
console.log('check if body param msg.payload, ', msg.payload);
getDeviceCellularGatewaySettings_nodeParam = storedParamValsMap['serial'] ||
RED.util.getMessageProperty(msg, "serial");
getDeviceCellularGatewaySettings_nodeParamType = storedParamTypeMap['serial'] ||
RED.util.getMessageProperty(msg, "serial");
// Check if its the body param
// notBodyParam
if (getDeviceCellularGatewaySettings_nodeParamType === 'str') {
console.log('getDeviceCellularGatewaySettings_nodeParamType is "str"');
getDeviceCellularGatewaySettings_parameters.serial = getDeviceCellularGatewaySettings_nodeParam || undefined;
} else {
console.log('getDeviceCellularGatewaySettings_nodeParamType is not "str"')
getDeviceCellularGatewaySettings_parameters.serial = RED.util.getMessageProperty(msg, "serial");
}
result = client.getDeviceCellularGatewaySettings(getDeviceCellularGatewaySettings_parameters);
console.log('result', result);
}
if (!errorFlag && node.method === 'updateDeviceCellularGatewaySettings') {
var updateDeviceCellularGatewaySettings_parameters = [];
var updateDeviceCellularGatewaySettings_nodeParam;
var updateDeviceCellularGatewaySettings_nodeParamType;
console.log('check if body param msg.payload, ', msg.payload);
updateDeviceCellularGatewaySettings_nodeParam = storedParamValsMap['serial'] ||
RED.util.getMessageProperty(msg, "serial");
updateDeviceCellularGatewaySettings_nodeParamType = storedParamTypeMap['serial'] ||
RED.util.getMessageProperty(msg, "serial");
// Check if its the body param
// notBodyParam
if (updateDeviceCellularGatewaySettings_nodeParamType === 'str') {
console.log('updateDeviceCellularGatewaySettings_nodeParamType is "str"');
updateDeviceCellularGatewaySettings_parameters.serial = updateDeviceCellularGatewaySettings_nodeParam || undefined;
} else {
console.log('updateDeviceCellularGatewaySettings_nodeParamType is not "str"')
updateDeviceCellularGatewaySettings_parameters.serial = RED.util.getMessageProperty(msg, "serial");
}
updateDeviceCellularGatewaySettings_nodeParam = storedParamValsMap['updateDeviceCellularGatewaySettings'] ||
RED.util.getMessageProperty(msg, "updateDeviceCellularGatewaySettings");
updateDeviceCellularGatewaySettings_nodeParamType = storedParamTypeMap['updateDeviceCellularGatewaySettings'] ||
RED.util.getMessageProperty(msg, "updateDeviceCellularGatewaySettings");
// Check if its the body param
// isBodyParam
if (typeof msg.payload === 'object') {
updateDeviceCellularGatewaySettings_parameters.updateDeviceCellularGatewaySettings = msg.payload;
} else {
node.error('Unsupported type: \'' + (typeof msg.payload) + '\', ' + 'msg.payload must be JSON object or buffer.', msg);
errorFlag = true;
}
result = client.updateDeviceCellularGatewaySettings(updateDeviceCellularGatewaySettings_parameters);
console.log('result', result);
}
if (!errorFlag && node.method === 'getDeviceCellularGatewaySettingsPortForwardingRules') {
var getDeviceCellularGatewaySettingsPortForwardingRules_parameters = [];
var getDeviceCellularGatewaySettingsPortForwardingRules_nodeParam;
var getDeviceCellularGatewaySettingsPortForwardingRules_nodeParamType;
console.log('check if body param msg.payload, ', msg.payload);
getDeviceCellularGatewaySettingsPortForwardingRules_nodeParam = storedParamValsMap['serial'] ||
RED.util.getMessageProperty(msg, "serial");
getDeviceCellularGatewaySettingsPortForwardingRules_nodeParamType = storedParamTypeMap['serial'] ||
RED.util.getMessageProperty(msg, "serial");
// Check if its the body param
// notBodyParam
if (getDeviceCellularGatewaySettingsPortForwardingRules_nodeParamType === 'str') {
console.log('getDeviceCellularGatewaySettingsPortForwardingRules_nodeParamType is "str"');
getDeviceCellularGatewaySettingsPortForwardingRules_parameters.serial = getDeviceCellularGatewaySettingsPortForwardingRules_nodeParam || undefined;
} else {
console.log('getDeviceCellularGatewaySettingsPortForwardingRules_nodeParamType is not "str"')
getDeviceCellularGatewaySettingsPortForwardingRules_parameters.serial = RED.util.getMessageProperty(msg, "serial");
}
result = client.getDeviceCellularGatewaySettingsPortForwardingRules(getDeviceCellularGatewaySettingsPortForwardingRules_parameters);
console.log('result', result);
}
if (!errorFlag && node.method === 'updateDeviceCellularGatewaySettingsPortForwardingRules') {
var updateDeviceCellularGatewaySettingsPortForwardingRules_parameters = [];
var updateDeviceCellularGatewaySettingsPortForwardingRules_nodeParam;
var updateDeviceCellularGatewaySettingsPortForwardingRules_nodeParamType;
console.log('check if body param msg.payload, ', msg.payload);
updateDeviceCellularGatewaySettingsPortForwardingRules_nodeParam = storedParamValsMap['serial'] ||
RED.util.getMessageProperty(msg, "serial");
updateDeviceCellularGatewaySettingsPortForwardingRules_nodeParamType = storedParamTypeMap['serial'] ||
RED.util.getMessageProperty(msg, "serial");
// Check if its the body param
// notBodyParam
if (updateDeviceCellularGatewaySettingsPortForwardingRules_nodeParamType === 'str') {
console.log('updateDeviceCellularGatewaySettingsPortForwardingRules_nodeParamType is "str"');
updateDeviceCellularGatewaySettingsPortForwardingRules_parameters.serial = updateDeviceCellularGatewaySettingsPortForwardingRules_nodeParam || undefined;
} else {
console.log('updateDeviceCellularGatewaySettingsPortForwardingRules_nodeParamType is not "str"')
updateDeviceCellularGatewaySettingsPortForwardingRules_parameters.serial = RED.util.getMessageProperty(msg, "serial");
}
updateDeviceCellularGatewaySettingsPortForwardingRules_nodeParam = storedParamValsMap['updateDeviceCellularGatewaySettingsPortForwardingRules'] ||
RED.util.getMessageProperty(msg, "updateDeviceCellularGatewaySettingsPortForwardingRules");
updateDeviceCellularGatewaySettingsPortForwardingRules_nodeParamType = storedParamTypeMap['updateDeviceCellularGatewaySettingsPortForwardingRules'] ||
RED.util.getMessageProperty(msg, "updateDeviceCellularGatewaySettingsPortForwardingRules");
// Check if its the body param
// isBodyParam
if (typeof msg.payload === 'object') {
updateDeviceCellularGatewaySettingsPortForwardingRules_parameters.updateDeviceCellularGatewaySettingsPortForwardingRules = msg.payload;
} else {
node.error('Unsupported type: \'' + (typeof msg.payload) + '\', ' + 'msg.payload must be JSON object or buffer.', msg);
errorFlag = true;
}
result = client.updateDeviceCellularGatewaySettingsPortForwardingRules(updateDeviceCellularGatewaySettingsPortForwardingRules_parameters);
console.log('result', result);
}
if (!errorFlag && node.method === 'getDeviceClients') {
var getDeviceClients_parameters = [];
var getDeviceClients_nodeParam;
var getDeviceClients_nodeParamType;
console.log('check if body param msg.payload, ', msg.payload);
getDeviceClients_nodeParam = storedParamValsMap['serial'] ||
RED.util.getMessageProperty(msg, "serial");
getDeviceClients_nodeParamType = storedParamTypeMap['serial'] ||
RED.util.getMessageProperty(msg, "serial");
// Check if its the body param
// notBodyParam
if (getDeviceClients_nodeParamType === 'str') {
console.log('getDeviceClients_nodeParamType is "str"');
getDeviceClients_parameters.serial = getDeviceClients_nodeParam || undefined;
} else {
console.log('getDeviceClients_nodeParamType is not "str"')
getDeviceClients_parameters.serial = RED.util.getMessageProperty(msg, "serial");
}
getDeviceClients_nodeParam = storedParamValsMap['t0'] ||
RED.util.getMessageProperty(msg, "t0");
getDeviceClients_nodeParamType = storedParamTypeMap['t0'] ||
RED.util.getMessageProperty(msg, "t0");
// Check if its the body param
// notBodyParam
if (getDeviceClients_nodeParamType === 'str') {
console.log('getDeviceClients_nodeParamType is "str"');
getDeviceClients_parameters.t0 = getDeviceClients_nodeParam || undefined;
} else {
console.log('getDeviceClients_nodeParamType is not "str"')
getDeviceClients_parameters.t0 = RED.util.getMessageProperty(msg, "t0");
}
getDeviceClients_nodeParam = storedParamValsMap['timespan'] ||
RED.util.getMessageProperty(msg, "timespan");
getDeviceClients_nodeParamType = storedParamTypeMap['timespan'] ||
RED.util.getMessageProperty(msg, "timespan");
// Check if its the body param
// notBodyParam
if (getDeviceClients_nodeParamType === 'str') {
console.log('getDeviceClients_nodeParamType is "str"');
getDeviceClients_parameters.timespan = getDeviceClients_nodeParam || undefined;
} else {
console.log('getDeviceClients_nodeParamType is not "str"')
getDeviceClients_parameters.timespan = RED.util.getMessageProperty(msg, "timespan");
}
result = client.getDeviceClients(getDeviceClients_parameters);
console.log('result', result);
}
if (!errorFlag && node.method === 'cycleDeviceSwitchPorts') {
var cycleDeviceSwitchPorts_parameters = [];
var cycleDeviceSwitchPorts_nodeParam;
var cycleDeviceSwitchPorts_nodeParamType;
console.log('check if body param msg.payload, ', msg.payload);
cycleDeviceSwitchPorts_nodeParam = storedParamValsMap['serial'] ||
RED.util.getMessageProperty(msg, "serial");
cycleDeviceSwitchPorts_nodeParamType = storedParamTypeMap['serial'] ||
RED.util.getMessageProperty(msg, "serial");
// Check if its the body param
// notBodyParam
if (cycleDeviceSwitchPorts_nodeParamType === 'str') {
console.log('cycleDeviceSwitchPorts_nodeParamType is "str"');
cycleDeviceSwitchPorts_parameters.serial = cycleDeviceSwitchPorts_nodeParam || undefined;
} else {
console.log('cycleDeviceSwitchPorts_nodeParamType is not "str"')
cycleDeviceSwitchPorts_parameters.serial = RED.util.getMessageProperty(msg, "serial");
}
cycleDeviceSwitchPorts_nodeParam = storedParamValsMap['cycleDeviceSwitchPorts'] ||
RED.util.getMessageProperty(msg, "cycleDeviceSwitchPorts");
cycleDeviceSwitchPorts_nodeParamType = storedParamTypeMap['cycleDeviceSwitchPorts'] ||
RED.util.getMessageProperty(msg, "cycleDeviceSwitchPorts");
// Check if its the body param
// isBodyParam
if (typeof msg.payload === 'object') {
cycleDeviceSwitchPorts_parameters.cycleDeviceSwitchPorts = msg.payload;
} else {
node.error('Unsupported type: \'' + (typeof msg.payload) + '\', ' + 'msg.payload must be JSON object or buffer.', msg);
errorFlag = true;
}
result = client.cycleDeviceSwitchPorts(cycleDeviceSwitchPorts_parameters);
console.log('result', result);
}
if (!errorFlag && node.method === 'getDeviceSwitchPortStatuses') {
var getDeviceSwitchPortStatuses_parameters = [];
var getDeviceSwitchPortStatuses_nodeParam;
var getDeviceSwitchPortStatuses_nodeParamType;
console.log('check if body param msg.payload, ', msg.payload);
getDeviceSwitchPortStatuses_nodeParam = storedParamValsMap['serial'] ||
RED.util.getMessageProperty(msg, "serial");
getDeviceSwitchPortStatuses_nodeParamType = storedParamTypeMap['serial'] ||
RED.util.getMessageProperty(msg, "serial");
// Check if its the body param
// notBodyParam
if (getDeviceSwitchPortStatuses_nodeParamType === 'str') {
console.log('getDeviceSwitchPortStatuses_nodeParamType is "str"');
getDeviceSwitchPortStatuses_parameters.serial = getDeviceSwitchPortStatuses_nodeParam || undefined;
} else {
console.log('getDeviceSwitchPortStatuses_nodeParamType is not "str"')
getDeviceSwitchPortStatuses_parameters.serial = RED.util.getMessageProperty(msg, "serial");
}
getDeviceSwitchPortStatuses_nodeParam = storedParamValsMap['t0'] ||
RED.util.getMessageProperty(msg, "t0");
getDeviceSwitchPortStatuses_nodeParamType = storedParamTypeMap['t0'] ||
RED.util.getMessageProperty(msg, "t0");
// Check if its the body param
// notBodyParam
if (getDeviceSwitchPortStatuses_nodeParamType === 'str') {
console.log('getDeviceSwitchPortStatuses_nodeParamType is "str"');
getDeviceSwitchPortStatuses_parameters.t0 = getDeviceSwitchPortStatuses_nodeParam || undefined;
} else {
console.log('getDeviceSwitchPortStatuses_nodeParamType is not "str"')
getDeviceSwitchPortStatuses_parameters.t0 = RED.util.getMessageProperty(msg, "t0");
}
getDeviceSwitchPortStatuses_nodeParam = storedParamValsMap['timespan'] ||
RED.util.getMessageProperty(msg, "timespan");
getDeviceSwitchPortStatuses_nodeParamType = storedParamTypeMap['timespan'] ||
RED.util.getMessageProperty(msg, "timespan");
// Check if its the body param
// notBodyParam
if (getDeviceSwitchPortStatuses_nodeParamType === 'str') {
console.log('getDeviceSwitchPortStatuses_nodeParamType is "str"');
getDeviceSwitchPortStatuses_parameters.timespan = getDeviceSwitchPortStatuses_nodeParam || undefined;
} else {
console.log('getDeviceSwitchPortStatuses_nodeParamType is not "str"')
getDeviceSwitchPortStatuses_parameters.timespan = RED.util.getMessageProperty(msg, "timespan");
}
result = client.getDeviceSwitchPortStatuses(getDeviceSwitchPortStatuses_parameters);
console.log('result', result);
}
if (!errorFlag && node.method === 'getDeviceSwitchPortStatusesPackets') {
var getDeviceSwitchPortStatusesPackets_parameters = [];
var getDeviceSwitchPortStatusesPackets_nodeParam;
var getDeviceSwitchPortStatusesPackets_nodeParamType;
console.log('check if body param msg.payload, ', msg.payload);
getDeviceSwitchPortStatusesPackets_nodeParam = storedParamValsMap['serial'] ||
RED.util.getMessageProperty(msg, "serial");
getDeviceSwitchPortStatusesPackets_nodeParamType = storedParamTypeMap['serial'] ||
RED.util.getMessageProperty(msg, "serial");
// Check if its the body param
// notBodyParam
if (getDeviceSwitchPortStatusesPackets_nodeParamType === 'str') {
console.log('getDeviceSwitchPortStatusesPackets_nodeParamType is "str"');
getDeviceSwitchPortStatusesPackets_parameters.serial = getDeviceSwitchPortStatusesPackets_nodeParam || undefined;
} else {
console.log('getDeviceSwitchPortStatusesPackets_nodeParamType is not "str"')
getDeviceSwitchPortStatusesPackets_parameters.serial = RED.util.getMessageProperty(msg, "serial");
}
getDeviceSwitchPortStatusesPackets_nodeParam = storedParamValsMap['t0'] ||
RED.util.getMessageProperty(msg, "t0");
getDeviceSwitchPortStatusesPackets_nodeParamType = storedParamTypeMap['t0'] ||
RED.util.getMessageProperty(msg, "t0");
// Check if its the body param
// notBodyParam
if (getDeviceSwitchPortStatusesPackets_nodeParamType === 'str') {
console.log('getDeviceSwitchPortStatusesPackets_nodeParamType is "str"');
getDeviceSwitchPortStatusesPackets_parameters.t0 = getDeviceSwitchPortStatusesPackets_nodeParam || undefined;
} else {
console.log('getDeviceSwitchPortStatusesPackets_nodeParamType is not "str"')
getDeviceSwitchPortStatusesPackets_parameters.t0 = RED.util.getMessageProperty(msg, "t0");
}
getDeviceSwitchPortStatusesPackets_nodeParam = storedParamValsMap['timespan'] ||
RED.util.getMessageProperty(msg, "timespan");
getDeviceSwitchPortStatusesPackets_nodeParamType = storedParamTypeMap['timespan'] ||
RED.util.getMessageProperty(msg, "timespan");
// Check if its the body param
// notBodyParam
if (getDeviceSwitchPortStatusesPackets_nodeParamType === 'str') {
console.log('getDeviceSwitchPortStatusesPackets_nodeParamType is "str"');
getDeviceSwitchPortStatusesPackets_parameters.timespan = getDeviceSwitchPortStatusesPackets_nodeParam || undefined;
} else {
console.log('getDeviceSwitchPortStatusesPackets_nodeParamType is not "str"')
getDeviceSwitchPortStatusesPackets_parameters.timespan = RED.util.getMessageProperty(msg, "timespan");
}
result = client.getDeviceSwitchPortStatusesPackets(getDeviceSwitchPortStatusesPackets_parameters);
console.log('result', result);
}
if (!errorFlag && node.method === 'getDeviceSwitchPorts') {
var getDeviceSwitchPorts_parameters = [];
var getDeviceSwitchPorts_nodeParam;
var getDeviceSwitchPorts_nodeParamType;
console.log('check if body param msg.payload, ', msg.payload);
getDeviceSwitchPorts_nodeParam = storedParamValsMap['serial'] ||
RED.util.getMessageProperty(msg, "serial");
getDeviceSwitchPorts_nodeParamType = storedParamTypeMap['serial'] ||
RED.util.getMessageProperty(msg, "serial");
// Check if its the body param
// notBodyParam
if (getDeviceSwitchPorts_nodeParamType === 'str') {
console.log('getDeviceSwitchPorts_nodeParamType is "str"');
getDeviceSwitchPorts_parameters.serial = getDeviceSwitchPorts_nodeParam || undefined;
} else {
console.log('getDeviceSwitchPorts_nodeParamType is not "str"')
getDeviceSwitchPorts_parameters.serial = RED.util.getMessageProperty(msg, "serial");
}
result = client.getDeviceSwitchPorts(getDeviceSwitchPorts_parameters);
console.log('result', result);
}
if (!errorFlag && node.method === 'getDeviceSwitchPort') {
var ge