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: POSTOther 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 namemetadataMappings: Mappings of the metadata in Elasticsearch formatdefaultValues: Default values for the metadata-metadataDetails: Translations, metadata group and editor hint (See MetadataDetails )metadataGroups: Groups list with translations for group namemeasures: Array of measure definition. Each item define atypeandnameproperties 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.