Attributes consist of a path and a value, and can be of any type, with a flat or a nested structure.
The following examples show you how to create, get, set, list and delete attributes. We have shown how to perform these operations with devices, however, you can use the same approach for directories, tags and filters.
Create an attribute
The following code snippet illustrates how to create an attribute:
Attribute<?> attribute = Attribute.newBuilder().path(
Get an attribute
Get a single attribute's value, providing the attribute's path:
The following example illustrates how to set a single attribute to a device. Please, consider that if this is an existing attribute, its value will be replaced with the new one you are setting.
If it doesn't exist, it will be added to the other existing attributes of the device, if any.
The code snippet below illustrates how to set all attributes to a device. Please, consider that the newly set attributes - even if it is just one attribute - will replace all existing attributes of the device, therefore you may potentially delete some as a result.
List<Attribute<?>> attributes = ...;
List all attributes defined for a particular device:
Delete a single attribute defined for a particular device, providing the attribute's path:
Delete all attributes defined for a particular device: