2.2.3 • Published 5 years ago
@interlink-sa/strings-api v2.2.3
strings-api v2.0
The API allows you to use the Strings Services
How to use
Devices Functions
import {createDevices, getDevice, listDevices, deleteDevice} from './api';
let devices = [
{
"device_type" : "cmts",
"short_name" : "DEV001",
"name" : "Device Name",
"ip" : "127.0.0.1",
"password" : "snmp-community",
"region" : "Santa Fe",
"city" : "Rosario",
"location" : {
"latitude" : -32.9580172,
"longitude" : -60.6326825
},
"extra_data" : {
"mark" : "CASA Systems",
"model" : "C40G",
"docsis" : 3
},
string: null
}
];
/**
* Create devices
*
* @param {array} devices - Array with devices objects
*/
createDevices(devices)
.then((result) => {console.log(result);})
.catch((error) => {console.log(error);});
/**
* Get a device
*
* @param {string} deviceId
*/
getDevice("5c9e534dbf29163a949eaa5a")
.then((result) => {console.log(result);})
.catch((error) => {console.log(error);});
/**
* Search for devices
*
* @param {object} filter -> Object with filter
* @param {number} offset -> Start from
* @param {number} limit -> Total of registers
* @param {string} sort -> Field to sort by (`fieldname` for asc and `-fieldname` for desc)
* @param {boolean} aggregate -> Aggregate the String and Parent Device if any
*/
listDevices({city: "Rosario"}, 0, 20, '+ip')
.then((result) => {console.log(result);})
.catch((error) => {console.log(error);});
/**
* Search for devices executing complex filters
*
* @param {object} filter -> Object with filter
* @param {number} offset -> Start from
* @param {number} limit -> Total of registers
* @param {string} sort -> Field to sort by (`fieldname` for asc and `-fieldname` for desc)
*/
let filter = {device_type: 'cmts', $or: [ { 'stats_powers.rx': {$gte: 20} }, { 'stats_powers.rx': {$lte: 15} } ]};
listDevices(filter, 0, 20)
.then((result) => {console.log(result)})
.catch((error) => {console.log(error)});
/**
* Delete a device
*
* @param {string} deviceId
*/
deleteDevice("5c9e534dbf29163a949eaa5a")
.then((result) => {console.log(result);})
.catch((error) => {console.log(error);});
Metrics Functions
import {saveMetrics, getMetrics, deleteMetrics} from './api';
/* {d:device, t:tags, v: values({time: {tag1:value, tag2:value}})} */
const metrics = [
{
"d" : "cmts:EX01",
"t" : ["aux_xx","aux_yy"],
"v" : [
{"1548268817" : {"aux_xx" : 254102, "aux_yy" : 125410}},
{"1548269117" : {"aux_xx" : 286185, "aux_yy" : 135200}}
]
},{
"d" : "cmts:EX01",
"t" : ["aux_yy","aux_xx"],
"v" : [
{"1548272817" : {"aux_xx" : 254102, "aux_yy" : 125410}},
{"1548275117" : {"aux_xx" : 386185, "aux_yy" : 155200}},
{"1548278117" : {"aux_xx" : 296185, "aux_yy" : 165200}}
]
},
"cmts:EX01 aux_xx:254103,aux_yy:125025 1548308117",
"cmts:EX01 aux_xx:true,aux_yy:false 1548308118",
"cmts:EX01 aux_xx:null,aux_yy:null 1548308119",
"cmts:EX01 aux_xx:000.45,aux_yy:125.52 1548308120",
"cmts:EX01 aux_xx:false,aux_yy:125.52 1548308130",
"cmts:EX01 aux_xx:25 1548308125"
];
/**
* Save metrics
*
* @param {array} metrics - Array with metrics objects
*/
saveMetrics(metrics)
.then((result) => {console.log(result);})
.catch((error) => {console.log(error);});
/**
* Get metrics
*
* @param {array} series - Array with series objects
*/
let series = [{"d" : "cmts:EX01", "t" : ["aux_xx","aux_yy"], "from" : 1548268817, "to" : 1548308240000}];
getMetrics(series)
.then((result) => {
let series = result.series;
console.log(series['cmts:EX01']['aux_xx']);
console.log(result);
})
.catch((error) => {console.log(error); process.exit(0);})
/**
* Delete metrics
*
* @param {array} metrics - Array with metrics objects
*/
deleteMetrics(series)
.then((result) => {console.log(result); process.exit(0);})
.catch((error) => {console.log(error); process.exit(0);})
Strings Functions
import {devicesToString, listStrings, createString, getString, getDevicesWithoutString, deleteString} from './api';
let variable = Date.now();
let stringNname = `New string ${variable}`;
/**
* Create a string
*
* @param {array} string - Object of string
*/
createString({name: stringNname})
.then((result) => {console.log(result)})
.catch((error) => {console.log(error)});
/**
* Update a string
*
* @param {string} stringId
* @param {Object} string - Object of string
*/
updateString("5c9e54e3719ace3c59f0fec9", {name: stringNname})
.then((result) => {console.log(result)})
.catch((error) => {console.log(error)});
/**
* Get a string
*
* @param {string} stringId
*/
getString("5c9e54e3719ace3c59f0fec9")
.then((result) => {console.log(result);})
.catch((error) => {console.log(error);});
/**
* Search for strings
*
* @param {object} filter -> Object with filter
* @param {number} offset -> Start from
* @param {number} limit -> Total of registers
* @param {string} sort -> Field to sort by (`fieldname` for asc and `-fieldname` for desc)
*/
listStrings({name: stringName}, 0, 20)
.then((result) => {console.log(result);})
.catch((error) => {console.log(error);});
/**
* Get Status of a string
*
* @param {array} stringId
*/
getStatusOfString(["5c9e54e3719ace3c59f0fec9"])
.then((result) => {console.log(result);})
.catch((error) => {console.log(error);});
/**
* Get Status of a device
*
* @param {array} deviceId
*/
getStatusOfDevice(["5c9e534dbf29163a949eaa5a"])
.then((result) => {console.log(result);})
.catch((error) => {console.log(error);});
/**
* Get Strings attached to a device or a parent device
*
* @param {array} deviceId
* @param {object} filter -> Object with filter
* @param {number} offset -> Start from
* @param {number} limit -> Total of registers
* @param {string} sort -> Field to sort by (`fieldname` for asc and `-fieldname` for desc)
*/
getStringsOfDevice(["5c9e534dbf29163a949eaa5a"])
.then((result) => {console.log(result);})
.catch((error) => {console.log(error);});
/**
* Delete a string
*
* @param {string} stringId
*/
deleteString("5c9e54e3719ace3c59f0fec9")
.then((result) => {console.log(result);})
.catch((error) => {console.log(error);});
/**
* Attach devices to a string
*
* @param {string} stringId
* @param {array} devices - Array with devicesIds
*/
attachDevicesToString('5c9e54e3719ace3c59f0fec9',['5c9e534dbf29163a949eaa5a','5c9e534dbf29163a949eaa5b'])
.then((result) => {console.log(result);})
.catch((error) => {console.log(error);});
/**
* Detach devices of string
*
* @param {string} stringId
* @param {array} devices - Array with devicesIds
*/
detachDevicesOfString('5c9e54e3719ace3c59f0fec9',['5c9e534dbf29163a949eaa5a','5c9e534dbf29163a949eaa5b'])
.then((result) => {console.log(result);})
.catch((error) => {console.log(error);});
/**
* Search for devices without a string configured
*
* @param {object} filter -> Object with filter
* @param {number} offset -> Start from
* @param {number} limit -> Total of registers
* @param {string} sort -> Field to sort by (`fieldname` for asc and `-fieldname` for desc)
*/
getDevicesWithoutString({}, 0, 20)
.then((result) => {console.log(result);})
.catch((error) => {console.log(error);});
Anomalies Functions
/**
* Search types of anomalies for cablemodems
*
* @param {object} filter -> Object with filter
* @param {number} offset -> Start from
* @param {number} limit -> Total of registers
* @param {string} sort -> Field to sort by (`fieldname` for asc and `-fieldname` for desc)
*/
getAnomalies({device_type:'cm'}, 0, 20)
.then((result) => {console.log(result);})
.catch((error) => {console.log(error);});
2.2.3
5 years ago
2.2.2
5 years ago
2.2.1
5 years ago
2.2.0
5 years ago
2.1.0
5 years ago
2.0.10
5 years ago
2.0.9
5 years ago
2.0.8
5 years ago
2.0.7
5 years ago
2.0.6
5 years ago
2.0.5
5 years ago
2.0.4
5 years ago
2.0.3
5 years ago
2.0.2
5 years ago
2.0.1
5 years ago
2.0.0
5 years ago
1.0.26
5 years ago
1.0.25
5 years ago
1.0.24
6 years ago
1.0.23
6 years ago
1.0.22
6 years ago
1.0.21
6 years ago
1.0.20
6 years ago
1.0.19
6 years ago
1.0.18
6 years ago
1.0.17
6 years ago
1.0.16
6 years ago
1.0.15
6 years ago
1.0.14
6 years ago
1.0.9
6 years ago
1.0.8
6 years ago
1.0.7
6 years ago
1.0.6
6 years ago
1.0.5
6 years ago
1.0.4
6 years ago
1.0.3
6 years ago
1.0.2
6 years ago
1.0.13
6 years ago
1.0.12
6 years ago
1.0.11
6 years ago
1.0.10
6 years ago
1.0.1
6 years ago
1.0.0
6 years ago