@interlink-sa/strings-api
API for Strings Services
Last updated 8 months ago by pierre.santana.interlink .
ISC · Repository · Original npm · Tarball · package.json
$ cnpm install @interlink-sa/strings-api 
SYNC missed versions from official npm registry.

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);});

Current Tags

  • 2.2.3                                ...           latest (8 months ago)

29 Versions

  • 2.2.3                                ...           8 months ago
  • 2.2.2                                ...           8 months ago
  • 2.2.1                                ...           9 months ago
  • 2.2.0                                ...           9 months ago
  • 2.1.0                                ...           9 months ago
  • 2.0.10                                ...           9 months ago
  • 2.0.9                                ...           9 months ago
  • 2.0.8                                ...           10 months ago
  • 2.0.7                                ...           10 months ago
  • 2.0.6                                ...           10 months ago
  • 2.0.5                                ...           a year ago
  • 2.0.4                                ...           a year ago
  • 2.0.3                                ...           a year ago
  • 2.0.2                                ...           a year ago
  • 2.0.1                                ...           a year ago
  • 2.0.0                                ...           a year ago
  • 1.0.26                                ...           a year ago
  • 1.0.25                                ...           a year ago
  • 1.0.24                                ...           a year ago
  • 1.0.23                                ...           a year ago
  • 1.0.22                                ...           a year ago
  • 1.0.21                                ...           a year ago
  • 1.0.20                                ...           a year ago
  • 1.0.19                                ...           a year ago
  • 1.0.18                                ...           a year ago
  • 1.0.17                                ...           a year ago
  • 1.0.16                                ...           a year ago
  • 1.0.15                                ...           a year ago
  • 1.0.14                                ...           a year ago
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 30
Last Month 32
Dependencies (6)
Dev Dependencies (0)
None
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |