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

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:

{
  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 #

import { DeviceManagerPlugin } from 'kuzzle-plugin-device-manager';

const deviceManager = new DeviceManagerPlugin();

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

deviceManager.assets.registerMetadata({
  stillAlive: { type: 'boolean' }
}, { group: 'astronaut' });      // A tenant group is specified : 'astronaut'.
                                       // These are the mappings 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:

{
  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 #

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',                         // mappings 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',                         // mappings inside the 'measures' field.
      fields: {
        text: { type: 'text' }
      }
    },
    value: { type: 'float' },
  }
}, { group: 'astronaut' });

deviceManager.devices.registerQos({           // By default, every 'devices' tenant collection
  battery: { type: 'integer' }                // will have the 'battery' property with the provided  
});                                           // mappings 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
}, { group: 'astronaut' });             // mappings inside the 'qos' field.
                                              
deviceManager.devices.registerMetadata({      // By default, every 'devices' tenant collection
  group: {                                    // will have the 'group' property with the provided
    type: 'keyword',                          // mappings inside the 'metadata' field. 
    fields: {                                  
      text: { type: 'text' }
    }
  }
});