Skip to main content

Manage tags

Introduction​

This page covers the Gravitino API for tags. For what a tag is, which object types can carry one, how inheritance resolves, and how to work with tags in the UI, see Tags.

Tag operations​

Create​

A tag needs a name, and can carry a comment and properties.

Create a tag
curl -X POST -H "Accept: application/vnd.gravitino.v1+json" \
-H "Content-Type: application/json" -d '{
"name": "pii",
"comment": "Personally identifiable information",
"properties": {"owner": "data-governance"}
}' http://localhost:8090/api/metalakes/test/tags

List​

Listing returns names, or full tag objects when details=true is set.

List tags in a metalake
curl -X GET -H "Accept: application/vnd.gravitino.v1+json" \
http://localhost:8090/api/metalakes/test/tags

curl -X GET -H "Accept: application/vnd.gravitino.v1+json" \
"http://localhost:8090/api/metalakes/test/tags?details=true"

Get​

Get a tag
curl -X GET -H "Accept: application/vnd.gravitino.v1+json" \
http://localhost:8090/api/metalakes/test/tags/pii

Alter​

Changes are applied as a list in one request.

ChangeJSONJavaPython
Rename{"@type":"rename","newName":"tag_renamed"}TagChange.rename("tag_renamed")TagChange.rename("tag_renamed")
Update the comment{"@type":"updateComment","newComment":"new_comment"}TagChange.updateComment("new_comment")TagChange.update_comment("new_comment")
Set a property{"@type":"setProperty","property":"key1","value":"value1"}TagChange.setProperty("key1", "value1")TagChange.set_property("key1", "value1")
Remove a property{"@type":"removeProperty","property":"key1"}TagChange.removeProperty("key1")TagChange.remove_property("key1")
Update a tag comment and property
curl -X PUT -H "Accept: application/vnd.gravitino.v1+json" \
-H "Content-Type: application/json" -d '{
"updates": [
{"@type": "updateComment", "newComment": "Reviewed quarterly"},
{"@type": "setProperty", "property": "owner", "value": "privacy-office"}
]
}' http://localhost:8090/api/metalakes/test/tags/pii

Delete​

Deleting a tag also removes it from every object it was attached to.

Delete a tag
curl -X DELETE -H "Accept: application/vnd.gravitino.v1+json" \
http://localhost:8090/api/metalakes/test/tags/pii

Object operations​

Attach and detach tags​

Both happen in one request, and either list can be omitted. The object type and full name go in the path, so the same call covers catalogs, schemas, tables, views, columns, filesets, topics, models, and functions.

Attach and detach tags
curl -X POST -H "Accept: application/vnd.gravitino.v1+json" \
-H "Content-Type: application/json" -d '{
"tagsToAdd": ["pii"],
"tagsToRemove": ["unreviewed"]
}' http://localhost:8090/api/metalakes/test/objects/table/catalog1.schema1.customers/tags

curl -X POST -H "Accept: application/vnd.gravitino.v1+json" \
-H "Content-Type: application/json" -d '{
"tagsToAdd": ["pii"]
}' http://localhost:8090/api/metalakes/test/objects/fileset/catalog1.schema1.raw_events/tags

List tags​

The response includes tags inherited from ancestors. With details=true each tag carries an inherited field, which a plain name listing does not.

List tags on a table
curl -X GET -H "Accept: application/vnd.gravitino.v1+json" \
"http://localhost:8090/api/metalakes/test/objects/table/catalog1.schema1.customers/tags?details=true"

Get one tag​

Get one tag on a table
curl -X GET -H "Accept: application/vnd.gravitino.v1+json" \
http://localhost:8090/api/metalakes/test/objects/table/catalog1.schema1.customers/tags/pii

List objects carrying a tag​

The response lists direct attachments only, so a tag attached to a catalog returns that catalog rather than the objects beneath it.

List objects carrying a tag
curl -X GET -H "Accept: application/vnd.gravitino.v1+json" \
http://localhost:8090/api/metalakes/test/tags/pii/objects