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

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

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 Tags

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

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 a Tag

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

Alter a Tag

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")
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 a Tag

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

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.

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 on an Object

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

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 on an Object

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.

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