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: POST

Other protocols #

{
  "controller": "device-manager/models",
  "action": "writeAsset",
  "body": {
    "tenantClasses": ["<tenant class>"],
    "indexes": [
      // Optional. Array of engine IDs (tenant IDs) this model is scoped to.
    ],
    "model": "<asset model>",

    // Optional

    "icon": "<icon>", // Free-form string, e.g. a FontAwesome icon name, a URL to a PNG/SVG image, or inline SVG markup
    "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;
            icon?: string;
          };
      */
    },
    "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 #

  • tenantClasses: names of the tenant classes
  • indexes: 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 tenant class.
  • model: Asset model name
  • icon: Optional. Icon representing the asset model. Free-form string, e.g. a FontAwesome icon name, a URL to a PNG/SVG image, or inline SVG markup — the format is up to the application. This field is not indexed for search.
  • metadataMappings: Mappings of the metadata in Elasticsearch format. Use { "referential": true } for a metadata of the metadata referential: its details and default value are filled from the referential when missing
  • defaultValues: Default values for the metadata
  • metadataDetails: Translations, metadata group, and editor hint (See MetadataDetails )
  • metadataGroups: Groups list with translations for group name
  • tooltipModels: Tooltip model list, containing each labels and tooltip content to display
  • 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": "writeAsset",
  "requestId": "<unique request identifier>",
  "result": {
    "_id": "<modelId>",
    "_source": {
      // Asset model content
    },
  }
}

Errors #

errorcodecause
MappingsConflictsError 409Writing an asset with conflicting metadata mappings
MeasuresNamesDuplicatesError 400Defining a measure name more than once