dot4-kpi-repository-client
v1.0.10
Published
clinet library for accessing dot4 kpi repository
Downloads
12
Readme
JavaScript Client Library for dot4 Kpi Repository
Usage - Installation
$ npm install dot4-kpi-repository-js --save
Use library in Node.js
const createClient = requires('dot4-kpi-repository-js');
const config = {
apiKey: '...', // api key created in dot4
tenant: '...' // technical mandant
}
const client = createClient(config);
await client.bind();
API
create client
Services
Get all services from kpi repository. Returns an array of all service objects known by the kpi repository.
const services = client.getServices();
// => [{ uid: '3BD256D8-CA6A-41C7-8A47-CB3F92118A85', name: 'service1', ...}]
Technical Services
The state of a service is calculated by the worst state of a technical service assigned to the service. Technical Services are normaly imported from the theGuard! BSM. But they can also be created and updated by an script.
Create a technical service
Creates a new technical Service. Each Technical Service is identified by an UUID:
const technicalService = {
uid: 'de66eab6-213b-4206-8f49-b37c2f71940b',
name: 'Technical Service',
description: "Technical Service created by a script'
}
const createdTechnicalService = client.createTechnicalService(technicalService)
Save state of a technical service
The state of a technical service can be saved for the current time. the timeseries with states of a technical service has a resolution of one Minute. This means you can send the state of the service every Minute.
const technicalServiceKpi = {
uid: 'de66eab6-213b-4206-8f49-b37c2f71940b',
state: 1
}
client.saveTechnicalServiceKpi(technicalServiceKpi);
Custom KPI definitions
Create a new custom KPI Definition:
const definition = {
name: 'paperCountBW',
label: 'Paper Count Black/White',
description: 'Kpi Definition for printer service paper count Black/White',
datatype: 'number',
storagetype: 'hour',
isSelected: true,
color: 'black',
charttype": 'line'
}
const newKpiDefinition = client.createKpiDefinition(definition);
kpis
Store cutom KPIs for the current timestamp:
const kpi = {
serviceUid: '3BD256D8-CA6A-41C7-8A47-CB3F92118A85',
paperCountBW: 10,
paperCountColor: 5,
maintenancePrinterCount: 2
}
client.saveKpi(kpi)