The IP intelligence data file contains meta data that can provide additional information about the various records in the data model.
The IP intelligence data file contains meta data that can provide additional information about the various records in the data model.This example shows how to access this data and display the values available.
A list of the properties will be displayed, along with some additional information about each property.
Finally, the evidence keys that are accepted by IP intelligence are listed. These are the keys that, when added to the evidence collection in flow data, could have some impact on the result returned by the IP intelligence engine.
const path = require('path');
const require51 = (requestedPackage) => {
try {
return require(path.join(__dirname, '/../../../node_modules/', requestedPackage));
} catch (e) {
return require(requestedPackage);
}
};
require51('fiftyone.ipintelligence.onpremise').IpIntelligenceOnPremisePipelineBuilder;
const ExampleUtils = require(path.join(__dirname,
'/../exampleUtils')).ExampleUtils;
const LITE_V_4_1_IPI = '51Degrees-LiteV41.ipi';
const CONTACT_US = '/contact-us?utm_source=code&utm_medium=example&utm_campaign=51degrees-node&utm_content=fiftyone.ipintelligence.onpremise-examples-onpremise-metadata-console-metadata.js&utm_term=enterprise-data-file';
const truncateToNl = function (string) {
const lines = string.split('\n');
let result = '';
let i = 0;
for (; i < lines.length; i++) {
if (lines[i]) {
result = lines[i];
break;
}
}
if (i < lines.length) {
result += ' ...';
}
return result;
};
const outputProperties = function (component, output) {
const properties = component.getProperties();
for (const property of properties) {
output.write(`\x1b[31mProperty - ${property.name}\x1b[89m\x1b[0m\n`);
output.write(
`[Category: ${property.category}](${property.type} - ${property.description})\n`);
let valuesStr = 'Possible values: ';
const values = property.getValues();
let count = 0;
for (const value of values) {
valuesStr += truncateToNl(value.getName());
const description = value.getDescription();
if (description) {
valuesStr += `(${description})`;
}
valuesStr += ',';
if (++count >= 20) {
break;
}
}
if (property.getNumberOfValues() > 20) {
valuesStr += ` + ${property.getNumberOfValues() - 20} more ...`;
}
output.write(valuesStr);
output.write('\n');
}
};
const outputComponents = function (engine, output) {
const components = engine.components;
for (const value of Object.values(components)) {
output.write(`\x1b[34mComponent - ${value.name}\x1b[89m\x1b[0m\n`);
outputProperties(value, output);
output.write('\n');
}
};
const outputEvidenceKeyDetails = async function (engine, output) {
output.write('\n');
output.write('Accepted evidence keys:\n');
for (const evidence of engine.evidenceKeyFilter.list) {
output.write(`\t${evidence}\n`);
}
};
const run = async function (dataFile, output) {
dataFile,
performanceProfile: 'Balanced',
shareUsage: false,
autoUpdate: false,
updateOnStart: false,
fileSystemWatcher: false
}).build();
const ip = pipeline.getElement('ip');
await outputComponents(ip, output);
await outputEvidenceKeyDetails(ip, output);
output.write(`\n${
ExampleUtils.
getEnterpriseOffer(CONTACT_US)}\n`);
}
};
if (process.env.JEST_WORKER_ID === undefined) {
const args = process.argv.slice(2);
const dataFile = args.length > 0 ? args[0] : ExampleUtils.findDataFile(LITE_V_4_1_IPI);
if (dataFile !== undefined) {
run(dataFile, process.stdout);
} else {
console.error('Failed to find an IP intelligence ' +
'data file. Make sure the cxx/data submodule ' +
'has been fetched by running ' +
'`git submodule update --init --recursive`. By default, the \'lite\' file ' +
'included with this code will be used. A different file can be ' +
'specified by supplying the full path as a command line argument');
}
};
module.exports = {
run
};
Definition fiftyone.ipintelligence.onpremise/examples/onpremise/exampleUtils.js:203
Definition ipIntelligenceOnPremisePipelineBuilder.js:35