updateGroup #

Update an existing group model.

The group model is the one available for the given tenant classes: a model of these classes first, then a commons model. Its scope (tenantClasses) is kept.

affinity, icon and metadata are kept when omitted. The other body properties replace the existing ones, and default to empty when omitted.

The metadata of the existing groups of every engine of the model scope are refreshed: added metadata are set to their default value, removed metadata are deleted.

Query Syntax #

HTTP #

URL: http://kuzzle:7512/_/device-manager/models/groups/:model?tenantClasses=<tenant class>
Method: PATCH

Other protocols #

{
  "controller": "device-manager/models",
  "action": "updateGroup",
  "tenantClasses": ["<tenant class>"],
  "model": "<group model>",

  "body": {

    // Optional

    "affinity": {
      "type": ["assets", "devices"], // Array of accepted types
      "models": {
        "assets": ["AssetModelA", "AssetModelB"], // Accepted asset models
        "devices": ["DeviceModelA"] // Accepted device models
      },
      "strict": false // If true, restricts group membership to specified types/models
    },
    "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 translations and group.
          [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;
                };
              };
            };
          };
      */
    },
    "locales": {
      /*
        [locale]: {
          friendlyName: string,
          description: string
        }
      */
    }
  }
}

Arguments #

  • tenantClasses: Tenant classes the group model is available for. Defaults to ["commons"]
  • model: Group model name

Body properties #

  • affinity: Asset and device types and models accepted in the groups. Kept when omitted
  • icon: Icon representing the group model. Kept when omitted
  • 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
  • metadataGroups: Groups list with translations for group name
  • locales: Translations specific to the model

Response #

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

Errors #

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

A NotFoundError is thrown if no group model with this name is available for the tenant classes.