The cloud service exposes meta data that can provide additional information about the various properties that might be returned.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. Note that this is the list of properties used by the supplied resource key, rather than all properties that can be returned by the cloud service.
In addition, the evidence keys that are accepted by the service are listed. These are the keys that, when added to the evidence collection in flow data, could have some impact on the result that is returned.
Bear in mind that this is a list of ALL evidence keys accepted by all products offered by the cloud. If you are only using a single product (for example - device detection) then not all of these keys will be relevant.
const path = require('path');
const require51 = (requestedPackage) => {
try {
return require(path.join(__dirname, '/../../../node_modules/', requestedPackage));
} catch (e) {
return require(path.join(__dirname, '/../../../../', requestedPackage));
}
};
const ExampleUtils = require(path.join(__dirname,
'/../exampleUtils'));
const outputProperties = function (engine, output) {
for (let property in engine.properties) {
property = engine.properties[property];
output.write(`
Property - ${
property.name}`);
output.write(`[Category: ${property.category}] (${property.type})\n`);
}
};
const outputEvidenceKeyDetails = 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 (resourceKey, output) {
resourceKey
}).build();
const device = pipeline.getElement('device');
device.ready().then(function () {
outputProperties(device, output);
outputEvidenceKeyDetails(pipeline.getElement('cloud'), output);
}).catch(function (error) {
throw error;
});
};
if (process.env.JEST_WORKER_ID === undefined) {
const args = process.argv.slice(2);
const resourceKey = args.length > 0 ? args[0] : process.env[
ExampleUtils.RESOURCE_KEY_ENV_VAR];
if (resourceKey) {
run(resourceKey, process.stdout);
} else {
console.error('No resource key specified on the command line or in the ' +
`the environment variable '${ExampleUtils.RESOURCE_KEY_ENV_VAR}'. ` +
'The 51Degrees cloud service is accessed using a \'ResourceKey\'. ' +
'For more information ' +
'see https://51degrees.com/documentation/_info__resource_keys.html. ' +
'Native model lookup is not available as a free service. This means that ' +
'you will first need a license key, which can be purchased from our ' +
'pricing page: https://51degrees.com/pricing. Once this is done, a resource ' +
'key with the properties required by this example can be created at ' +
'https://configure.51degrees.com/1QWJwHxl. You can now populate the ' +
'environment variable mentioned at the start of this message with the ' +
'resource key or pass it as the first argument on the command line.');
}
};
module.exports = {
run
};