Official Plugins (Kuzzle v2.x)
Device Manager v1.x
2

This plugin is part of the Kuzzle Enterprise Plan. If you are interested, please contact us.

Mappings #

"assets" collection #

At startup of your application, the plugin will store default mappings for the assets collection which is meant to be loaded when you create an engine:

Copied to clipboard!
{
  dynamic: 'strict',
  properties: {
    type: {
      type: 'keyword',
      fields: {
        text: { type: 'text' }
      }
    },
    model: {
      type: 'keyword',
      fields: {
        text: { type: 'text' }
      }
    },
    reference: {
      type: 'keyword',
      fields: {
        text: { type: 'text' }
      }
    },
    measures: {
      properties: {
        // autogenerated from devices mappings
      }
    },
    metadata: {
      dynamic: 'false',
      properties: {}
    }
  }
}

Customize #

Through the plugin, it is possible to add custom properties to:

It allows you to store your custom metadata properties for a specific tenant, and/or setting some by default.

Example #

Copied to clipboard!
import { DeviceManagerPlugin } from 'kuzzle-plugin-device-manager';

const deviceManager = new DeviceManagerPlugin();

deviceManager.assets.registerMetadata({
  warranty: {
    type: 'keyword',                   // Since no tenant group is specified,
    fields: {                          // this mapping will be applied to every
      text: { type: 'text' }           // tenant by default
    }
  }
});

deviceManager.assets.registerMetadata({
  stillAlive: { type: 'boolean' }
}, { tenantGroup: 'astronaut' });      // A tenant group is specified : 'astronaut'.
                                       // This mapping definition for the `metadata` field
                                       // of the `assets` collection will only be applied for
                                       // the 'astronaut' tenant.

"devices" collection #

Same as the assets collection, the devices collection has its default mappings loaded when you create an engine:

Copied to clipboard!
{
  dynamic: 'strict',
  properties: {
    reference: {
      type: 'keyword',
      fields: {
        text: { type: 'text' }
      }
    },
    model: {
      type: 'keyword',
      fields: {
        text: { type: 'text' }
      }
    },
    measures: {
      properties: {
        temperature: {
          properties: {
            updatedAt: { type: 'date' },
            payloadUuid: {
              type: 'keyword',
              fields: {
                text: { type: 'text' }
              }
            },
            degree: { type: 'float' }
          }
        },
        position: {
          properties: {
            updatedAt: { type: 'date' },
            payloadUuid: {
              type: 'keyword',
              fields: {
                text: { type: 'text' }
              }
            },
            point: { type: 'geo_point' },
            altitude: { type: 'float' },
            accuracy: { type: 'integer' },
          }
        },
        movement: {
          properties: {
            payloadUuid: {
              type: 'keyword',
              fields: {
                text: { type: 'text' }
              }
            },
            updatedAt: { type: 'date' },
            moving: { type: 'boolean' },
          }
        }
      }
    },
    qos: {
      dynamic: 'false',
      properties: {},
    },
    metadata: {
      dynamic: 'false',
      properties: {},
    },
    assetId: {
      type: 'keyword',
      fields: {
        text: { type: 'text' }
      }
    },
    tenantId: {
      type: 'keyword',
      fields: {
        text: { type: 'text' }
      }
    }
  }
}

Customize #

Through the plugin, it is possible to add custom properties to:

Those methods allow you to store custom properties into those fields for a specific tenant, and/or setting some by default.

Example #

Copied to clipboard!
import { DeviceManagerPlugin } from 'kuzzle-plugin-device-manager';

const deviceManager = new DeviceManagerPlugin();

deviceManager.devices.registerMeasure('humidity', {
  properties: {
    updatedAt: { type: 'date' },               // By default, every 'devices' tenant collection
    payloadUuid: {                             // will have the 'humidity' property with the provided
      type: 'keyword',                         // mapping inside the 'measures' field.
      fields: {
        text: { type: 'text' }
      }
    },
    value: { type: 'float' },
  }
});

deviceManager.devices.registerMeasure('gravity', {
  properties: {
    updatedAt: { type: 'date' },               // The 'devices' collection of the 'astronaut' tenant
    payloadUuid: {                             // will have the 'gravity' property with the provided
      type: 'keyword',                         // mapping inside the 'measures' field.
      fields: {
        text: { type: 'text' }
      }
    },
    value: { type: 'float' },
  }
}, { tenantGroup: 'astronaut' });

deviceManager.devices.registerQos({           // By default, every 'devices' tenant collection
  battery: { type: 'integer' }                // will have the 'battery' property with the provided  
});                                           // mapping inside the 'qod' field.
                                              

deviceManager.devices.registerQos({           // The 'devices' collection of the 'astronaut' tenant
  durability: { type: 'float' }               // will have the 'durability' property with the provided
}, { tenantGroup: 'astronaut' });             // mapping inside the 'qos' field.
                                              
deviceManager.devices.registerMetadata({      // By default, every 'devices' tenant collection
  group: {                                    // will have the 'group' property with the provided
    type: 'keyword',                          // mapping inside the 'metadata' field. 
    fields: {                                  
      text: { type: 'text' }
    }
  }
});