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

writeDevice #

Write a device model.

This action acts like a create or replace

Query Syntax #

HTTP #

URL: http://kuzzle:7512/_/device-manager/models/devices
Method: POST

Other protocols #

{
  "controller": "device-manager/models",
  "action": "writeDevice",
  "body": {
    "model": "<device model>",

    // Optional

    "metadataMappings": {
      // Metadata mappings
    },
    "defaultValues": {
      // Default values for metadata
    },
    "metadataDetails": {
      /*
        Metadata details including tanslations and group.
          [name: string]: {
            group?: string;
            locales: {
              [locale: string]: {
                friendlyName: string;
                description: string;
              };
            };
            editorHint?: BaseEditorHint | OptionsSelectorDefinition | DatetimeEditorHint;
          };
      */
    },
    "metadataGroups": {
    /*
      Metadata groups list and details.
        {
          [groupName: string]: {
            locales: {
              [locale: string]: {
                groupFriendlyName: string;
                description: string;
              };
            };
          };
        };
    */
    },
    "measures": [
      // Array of measure definition with type and name
    ]
  }
}

Body properties #

  • model: Device model name
  • metadataMappings: Mappings of the metadata in Elasticsearch format
  • defaultValues: Default values for the metadata-
  • metadataDetails: Translations, metadata group and editor hint (See MetadataDetails )
  • metadataGroups: Groups list with translations for group name
  • measures: Array of measure definition. Each item define a type and name properties for the measure.

Response #

{
  "status": 200,
  "error": null,
  "controller": "device-manager/models",
  "action": "writeDevice",
  "requestId": "<unique request identifier>",
  "result": {
    "_id": "<modelId>",
    "_source": {
      // Device model content
    },
  }
}

Errors #

Writing a device with metadata mappings can cause conflicts, in this case a MappingsConflictsError will be thrown with the HTTP code 409.