Attribute-Group Objects#
An Attribute Group object represents a set of attributes that will be attached to a node based on its membership in the group. A node can be a member of several groups, arranged in a hierarchical list. For example, a node that is a member of group1 and group2 will inherit group1’s attributes, which may then be overwritten by group2’s attributes.
When issuing requests, the UID
field in the URL can be either the actual UID of the object or the
name of the object as given in the “name” field.
Data Fields#
The Attribute Group fields are:
name
Required: The name for the group
description
Optional: A text string with descriptive information
attributes
Optional: A JSON-object containing key-value pairs of attributes
While the attributes
field accepts a generic JSON object, it can only reference one level into that
key-value store.
Additional Endpoints#
Several endpoints can be used to directly manipulate the attribute key-value store instead of going
through the Attribute object first. The PATCH /attribs/<UID>
command allows for overwriting the
entire attributes
field, but cannot be used to add or append attributes one at a time.
The PATCH /attribs/<UID>/attributes
endpoint allows for that kind of direct update.
GET /attrib/<UID>/attributes
Returns a JSON object containing the key-value pairs
PUT /attrib/<UID>/attributes
Replaces the current set of key-value pairs with the sent data; any keys not in
the sent data will be removed from the Attribute Group
PATCH /attrib/<UID>/attributes
Updates the current set of key-value pairs with the sent data; only the keys that
are sent will be modified in the Attribute Group’s data; any other keys will be
left as-is
DELETE /attrib/<UID>/attributes
Accepts one key or a list of keys to be removed from the Attribute Group’s data;
note that a node can still show that attribute key as present if a node-specific
attribute has been set, or if the node is joined to another Attribute Group where
it is set
Example#
Create a new Attribute Group:
curl -X POST https://head1.cluster.local/api/v1/attribs --data '{"name":"MyAttribs"}' \
-H "Authorization: Bearer eyJhbGciOiJIUzI1Ni…"
{"success": true, "data": "5997e993e0bb49568bef18536614b733"}
Read the basic information:
curl -X GET https://head1.cluster.local/api/v1/attrib/MyAttribs -H \
"Authorization: Bearer eyJhbGciOiJIUzI1Ni…"
{"success": true, "data": {"name": "MyAttribs", "last_modified": 1721852251.1698143, \
"last_modified_on": "head23.cluster.local", "last_modified_by": "admin1", \
"uid": "5997e993e0bb49568bef18536614b733", "attributes": {}}}
Update the attributes key-value store through the main record:
curl -X PATCH https://head1.cluster.local/api/v1/attrib/MyAttribs --data \
'{"attributes":{"foo":"bar"}}' -H "Authorization: Bearer eyJhbGciOiJIUzI1Ni…"
{"success": true}
Verify that the update worked:
curl -X GET https://head1.cluster.local/api/v1/attrib/MyAttribs -H \
"Authorization: Bearer eyJhbGciOiJIUzI1Ni…"
{"success": true, "data": {"name": "MyAttribs", "last_modified": 1721852433.4113355, \
"last_modified_on": "head23.cluster.local", "last_modified_by": "admin1", \
"attributes": {"foo": "bar"}, "uid": "5997e993e0bb49568bef18536614b733"}}
To get just the attributes and not the whole record:
curl -X GET https://head1.cluster.local/api/v1/attrib/MyAttribs/attributes -H \
"Authorization: Bearer eyJhbGciOiJIUzI1Ni…"
{"success": true, "data": {"foo": "bar"}}
Directly manipulate the attributes key-value store to add new data:
curl -X PATCH https://head1.cluster.local/api/v1/attrib/MyAttribs/attributes --data \
'{"abc":"def"}' -H "Authorization: Bearer eyJhbGciOiJIUzI1Ni…"
{"success": true}
Verify the new data:
curl -X GET https://head1.cluster.local/api/v1/attrib/MyAttribs/attributes -H \
"Authorization: Bearer eyJhbGciOiJIUzI1Ni…"
{"success": true, "data": {"foo": "bar", "abc": "def", "last_modified": \
1721852648.6145608, "last_modified_on": "533a8c21fd5642c38138214d7ad783ae", \
"last_modified_by": "admin1"}}
Directly delete one key out of the key-value store (send a list of keys to delete):
curl -X DELETE https://head1.cluster.local/api/v1/attrib/MyAttribs/attributes --data \
'["abc"]' -H "Authorization: Bearer eyJhbGciOiJIUzI1Ni…"
{"success": true}
And verify that the key is gone:
curl -X GET https://head1.cluster.local/api/v1/attrib/MyAttribs/attributes -H \
"Authorization: Bearer eyJhbGciOiJIUzI1Ni…"
{"success": true, "data": {"foo": "bar", "last_modified": 1721852648.6145608, \
last_modified_on": "533a8c21fd5642c38138214d7ad783ae", "last_modified_by": \
"admin1"}}
To delete the object entirely:
curl -X DELETE https://head1.cluster.local/api/v1/attrib/MyAttribs -H \
"Authorization: Bearer eyJhbGciOiJIUzI1Ni…"
{"success": true}