writeAsset #
Write an asset model.
This action acts like a create or replace
Query Syntax #
HTTP #
URL: http://kuzzle:7512/_/device-manager/models/assets
Method: POSTOther protocols #
{
"controller": "device-manager/models",
"action": "writeAsset",
"body": {
"engineGroup": "<engine group>",
"engineIds": [
// Optional. Array of engine IDs (tenant IDs) this model is scoped to.
],
"model": "<asset model>",
// Optional
"metadataMappings": {
// Metadata mappings
},
"defaultValues": {
// Default values for metadata
},
"metadataDetails": {
/*
Metadata details including tanslations, group and editor hint.
[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;
};
};
};
};
*/
},
"tooltipModels": {
/*
Tooltip models for an asset model.
[key: string]: {
tooltipLabel: string;
content: [
{
category: "metadata";
label?: {
locales: {
[locale: string]: {
friendlyName: string;
description: string;
};
};
};
metadataPath: string;
suffix?: string;
},
{
category: "measure";
label?: {
locales: {
[locale: string]: {
friendlyName: string;
description: string;
};
};
};
measureSlot: string;
measureValuePath: string;
suffix?: string;
},
{
category: "static";
label?: {
locales: {
[locale: string]: {
friendlyName: string;
description: string;
};
};
};
type: "link" | "image" | "text" | "title" | "separator";
value: string;
}
];
};
*/
},
"measures": [
// Array of measure definition with type and name
]
}
}Body properties #
engineGroup: Name of the engine groupengineIds: Optional. Array of engine IDs (tenant IDs) this model is scoped to. When set, the model is only available to the specified tenants. When absent, the model is available to all tenants in the engine group.model: Asset model namemetadataMappings: Mappings of the metadata in Elasticsearch formatdefaultValues: Default values for the metadatametadataDetails: Translations, metadata group, and editor hint (See MetadataDetails )metadataGroups: Groups list with translations for group nametooltipModels: Tooltip model list, containing each labels and tooltip content to displaymeasures: Array of measure definition. Each item define atypeandnameproperties for the measure.
Response #
{
"status": 200,
"error": null,
"controller": "device-manager/models",
"action": "writeAsset",
"requestId": "<unique request identifier>",
"result": {
"_id": "<modelId>",
"_source": {
// Asset model content
},
}
}Errors #
| error | code | cause |
|---|---|---|
| MappingsConflictsError | 409 | Writing an asset with conflicting metadata mappings |
| MeasuresNamesDuplicatesError | 400 | Defining a measure name more than once |