This is an automated email from the ASF dual-hosted git repository. jerryshao pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/gravitino.git
commit 1fa94ed3a80f644c920f2e7b49e81d894a632261 Author: Jerry Shao <[email protected]> AuthorDate: Thu Nov 12 21:04:12 2026 +0800 [#14909] docs: Add Domain user documentation (#14910) ### What changes were proposed in this pull request? Add a Domain overview and a management guide organized by operation, with REST, Java, and Python examples in tabs. Link both guides from the documentation index and update the related access control, MCP, migration, and OpenAPI references. ### Why are the changes needed? Users need instructions for creating Domains, managing membership, and understanding which assets and Domains they can discover. Depends on #14893. Fixes #14909. ### Does this PR introduce _any_ user-facing change? Yes. It adds user guides and updates the published API reference. ### How was this patch tested? `./gradlew :docs:build` and `git diff --check` both passed. --- docs/domains.md | 137 +++++ docs/glossary.md | 5 + docs/gravitino-mcp-server.md | 11 +- docs/how-to-use-gravitino-client.md | 7 +- docs/how-to-use-python-client.md | 6 +- docs/index.md | 5 + docs/manage-domains-in-gravitino.md | 990 ++++++++++++++++++++++++++++++++++++ docs/manage-tags-in-gravitino.md | 3 + docs/metalakes.md | 3 +- docs/migration-guide.md | 12 + docs/open-api/domains.yaml | 68 ++- docs/open-api/owners.yaml | 3 +- docs/open-api/roles.yaml | 3 +- docs/security/access-control.md | 61 ++- docs/tags.md | 5 + 15 files changed, 1288 insertions(+), 31 deletions(-) diff --git a/docs/domains.md b/docs/domains.md new file mode 100644 index 0000000000..e3317af9fd --- /dev/null +++ b/docs/domains.md @@ -0,0 +1,137 @@ +--- +title: "Domains" +slug: "/domains" +keyword: "domain, subdomain, metadata discovery, membership" +license: "This software is licensed under the Apache License version 2." +--- + +## Domains in a metalake + +A Domain is a business grouping of metadata in a metalake. For example, `Finance` can bring together +a table in an Iceberg catalog, a Kafka topic and a registered model. Domains organize discovery; +they do not change catalog structure, move data or grant data access. + +Names are unique across all domains in a metalake, including subdomains. Two parents cannot each +have a child with the same name. Domain names must match `[A-Za-z0-9_][A-Za-z0-9_-]{0,63}`. +The names `*` and `system` (in any letter case) are reserved. Valid names retain their spelling: +a child named `Planning_US` under `Finance` is addressed by `Planning_US`, not `Finance.Planning_US`. +A domain is either top-level or the child of exactly one top-level domain. There is only one level +of subdomains. A top-level domain's scope includes its own members and those of its visible children. + +Every domain starts as `DRAFT`. Only its managers and owners (including inherited managers/owners) +can see it until publication. `PUBLISHED` domains are visible to users with `USE_DOMAIN`. +Publication does not make metadata public. A child can be published only under a published parent; +a parent cannot be unpublished while a child is published. See the +[Domain guide](./manage-domains-in-gravitino.md) for lifecycle and snapshot behavior. + +## Membership through tags + +A domain explicitly binds a backing tag, optionally with one value. Membership is derived from +existing [tag assignments and inheritance](./tags.md), rather than maintained in a separate list. +Use the [tag API](./manage-tags-in-gravitino.md) to assign/remove a backing tag on a leaf, schema or +catalog. There is no Domain add-member or remove-member API. + +Only these leaf types are members: **table, view, fileset, topic, model and semantic model**. +Tagged catalogs and schemas contribute their recorded leaves; they are never members themselves. +Only objects already recorded by Gravitino are enumerated: a tag on an external catalog is not a +request to crawl its backend. Empty results do not establish that external objects are absent. + +For the same tag, the assignment nearest the leaf wins: leaf before schema before catalog. +Assignments are replaced as a whole at each nearer level, not combined with ancestor values. +For example, `department=hr` on a table masks `department=finance` on its schema, so the table does +not belong to the domain backed by `department=finance`. A binding without a value matches any +effective assignment of that tag; a valued binding tests exact, case-sensitive containment in the +assignment's values. Different tags resolve independently, allowing membership in multiple domains. + +Removing a tag from a leaf changes only its own assignment; it is not an opt-out from inheritance. +If its schema or catalog still assigns that backing tag, the leaf remains a member through +inheritance. Removing the last directly assigned value can also reveal an ancestor assignment and +move the leaf back into a different valued domain. To remove inherited membership, change the +assignment at its source or use a nearer assignment that does not match the valued binding. +A valueless backing-tag binding matches any assignment of that tag, so assigning another value +cannot exclude the leaf from that domain. + +## Relations and sources + +A member query lists each object once, with **all** applicable relations relative to the queried +domain. The same relations appear on detailed object-to-domain lookup. Relations have no precedence; +clients must preserve their whole array. + +| SDK relation | REST `relation` | `source` | +| --- | --- | --- | +| `DIRECT` | `direct` | Omitted: the leaf itself carries the backing tag. | +| `INHERITED` | `inherited` | The nearest assigned catalog or schema, with its complete `fullName` and `type`. | +| `VIA_SUBDOMAIN` | `via_subdomain` | The contributing child's literal name as `fullName`, with `type: domain`. | + +For example, a schema `ice.sales` carries Finance's backing tag and its table +`ice.sales.forecast` carries Planning's separate backing tag. Querying Finance, whose child is +Planning, returns the table with both `inherited` from `ice.sales` and `via_subdomain` from Planning. +A direct assignment of Finance's tag masks its inherited assignment of that same tag, but the +independent Planning relation remains. Multiple contributing children produce multiple +`via_subdomain` relations. A child scope selected by a filter still reports relations relative to +the domain addressed in the query. Filtering to one child selects matching objects but does not +trim their relations: a selected object can still report the queried domain's own relation and +relations through other visible children. + +Moving or detaching Planning changes parent roll-ups without changing any object assignment. +Renaming Planning changes the child source name on subsequent queries. See +[Backing tag operations](./manage-domains-in-gravitino.md#backing-tag-operations) for binding conflicts, +tag renames, tag identity and removal behavior. + +## Membership filters + +Java uses `DomainMemberFilter.builder()`; Python uses `DomainMemberFilter(...)`. +REST uses `GET /api/metalakes/{metalake}/domains/{domain}/objects`. +All supplied options intersect; an unset option does not narrow the result. + +| Option | Meaning | +| --- | --- | +| `types` | Union of supported leaf types; REST accepts comma-separated, case-insensitive names with whitespace trimmed. Omit for all six types. | +| `nameContains` (Python `name_contains`) | Case-insensitive substring of the full object name, including catalog/schema text. No wildcard or regex interpretation. Omit for any name; blank text is invalid. | +| `domains` | Union of selected scopes within the queried domain. Omit or use an empty SDK collection for its whole scope. | + +For Finance with children Tax and Planning: + +- Unset `domains`, or selecting `Finance`, includes Finance, Tax and Planning (subject to visibility). +- Selecting `Tax` includes only Tax's scope; selecting Tax and Planning includes their union. +- Selecting Finance does **not** mean only Finance's own members. To retain those, inspect relations + for `DIRECT` or `INHERITED` in the returned members. +- Well-formed unknown names, unrelated domains and invisible children are ignored. If every supplied name is + ignored, the result is empty. Duplicate names do not duplicate members. + +REST `domains` is a **repeated query parameter**, not a comma-separated list. For example, +`?domains=Planning_US&domains=Tax` selects the child named `Planning_US` plus Tax. +Use `curl --get --data-urlencode 'domains=Planning_US' --data-urlencode 'domains=Tax' ...`. +In contrast, `types=TABLE,VIEW` selects two types. Empty/unsupported type tokens, invalid domain scope +names and blank `nameContains` return 400. Empty successful member responses are +`{"code":0,"members":[]}`; domain names and details return `names: []` and `domains: []` respectively. +No paging or total count is provided. The current implementation sorts members by metadata type +name and then full object name; clients should use object identity rather than array position. + +## Object-to-domain lookup + +The REST `type` spellings are: + +| Leaf resource | REST `type` | +| --- | --- | +| Table | `table` | +| View | `view` | +| Fileset | `fileset` | +| Topic | `topic` | +| Model | `model` | +| Semantic model | `semantic_model` | + +All six leaf resources expose Java `supportsDomains().listDomains()` and `listDomainsInfo()`. +In Python, tables, views, filesets, models and semantic models expose +`supports_domains().list_domains()` and `list_domains_info()`. For topics, use the REST endpoint +with `type=topic`, for example `GET /api/metalakes/test/objects/topic/kafka.sales.orders/domains`. +REST uses `/api/metalakes/{metalake}/objects/{type}/{fullName}/domains`, with `details=true` for +snapshots and complete relations. Encode `fullName` as one path segment. Catalogs and schemas are +not valid leaf types for this endpoint. A leaf may belong to multiple domains and their parents; +no membership returns an empty list. Normal domain listings omit `relations`, while detailed +reverse lookups include them. SDK `relations()` is empty on ordinary snapshots. + +Queries respect [Domain permissions](./security/access-control.md#domain-permissions) and ordinary +metadata access. They grant no right to read data. The read-only +[MCP Domain tools](./gravitino-mcp-server.md#domains-read-only) expose these same discovery semantics. +Domain UI and Domain-based data authorization are outside this feature. diff --git a/docs/glossary.md b/docs/glossary.md index cf5241b6de..71e2afe18f 100644 --- a/docs/glossary.md +++ b/docs/glossary.md @@ -16,6 +16,11 @@ license: "This software is licensed under the Apache License version 2." - A compatible implementation of the Hive Metastore Service (HMS). +## Domain + +- A business grouping of metadata within a metalake, derived from an explicit backing tag and + optionally one level of subdomains. See [Domains](./domains.md). + ## GPG/GnuPG - Gnu Privacy Guard or GnuPG is an open-source implementation of the OpenPGP standard. diff --git a/docs/gravitino-mcp-server.md b/docs/gravitino-mcp-server.md index 7de9314eae..7b8ab6e18e 100644 --- a/docs/gravitino-mcp-server.md +++ b/docs/gravitino-mcp-server.md @@ -242,6 +242,9 @@ indicating whether it was dropped. It removes semantic metadata without deleting ### Domains (read-only) +See [Domains](./domains.md) for membership semantics and the +[Domain guide](./manage-domains-in-gravitino.md) for SDK and REST mutations. + Use `--include-tool-tags domain` to expose the five Domain tools. All are annotated as read-only and idempotent and issue only GET requests. @@ -270,10 +273,12 @@ For example, call `list_domain_members` with: } ``` -`types` is a list of leaf object types; `domains` filters source domain names -using repeated query parameters. +`types` is a list of leaf object types; `domains` selects the union of named scopes using repeated query parameters. +Selecting the requested domain includes its visible children. Well-formed names outside that scope are ignored. `name_contains` matches a case-insensitive substring of the full metadata object name. -Omitted or blank values leave this filter unset. +If `name_contains` is omitted, empty, or contains only whitespace, MCP omits the +`nameContains` query parameter. Sending an empty or whitespace-only `nameContains` +directly to the REST endpoint returns HTTP 400. Omitted or empty type/domain lists leave those filters unset. Leaf lookups support tables, filesets, topics, models, views and semantic models; use the REST object type spelling (for example `table` or `semantic_model`). diff --git a/docs/how-to-use-gravitino-client.md b/docs/how-to-use-gravitino-client.md index 6c7dc2a4b6..f1512c58c9 100644 --- a/docs/how-to-use-gravitino-client.md +++ b/docs/how-to-use-gravitino-client.md @@ -206,4 +206,9 @@ from gravitino.exceptions.base import OptimisticLockException Catch this exception, reload the latest metadata, reconsider your intended change, and retry with a bounded number of attempts. Do not replay a stale update unchanged or retry every HTTP 409 response, since other conflicts may require a different action. -For a model-version read conflict, retry the read with a bounded number of attempts. \ No newline at end of file +For a model-version read conflict, retry the read with a bounded number of attempts. + +## Domains + +See [Manage domains](./manage-domains-in-gravitino.md) for a complete executable example +covering creation, publication, tag membership, reverse lookup and cleanup. diff --git a/docs/how-to-use-python-client.md b/docs/how-to-use-python-client.md index 695f6558bf..053bab69c7 100644 --- a/docs/how-to-use-python-client.md +++ b/docs/how-to-use-python-client.md @@ -247,7 +247,11 @@ Process finished with exit code 0 + User documentation: https://gravitino.apache.org/docs/ + Slack Community: [https://the-asf.slack.com#gravitino](https://the-asf.slack.com/archives/C078RESTT19) +## Domains + +See [Manage domains](./manage-domains-in-gravitino.md) for a complete executable example +covering creation, publication, tag membership, reverse lookup and cleanup. + ## License Gravitino is under the Apache License Version 2.0, See the [LICENSE](https://github.com/apache/gravitino/blob/main/LICENSE) for the details. - diff --git a/docs/index.md b/docs/index.md index ea844087e4..43c38dcc8d 100644 --- a/docs/index.md +++ b/docs/index.md @@ -58,6 +58,9 @@ Use either to manage metadata. See * [Manage metalake using Gravitino](./manage-metalake-using-gravitino.md) to learn how to manage metalakes. +* [Manage domains in Gravitino](./manage-domains-in-gravitino.md) to learn how to create domains, + manage backing tags, and query membership using REST and the Java/Python clients. Start with + [Domains](./domains.md) for concepts, hierarchy, and membership semantics. * [Manage relational metadata using Gravitino](./manage-relational-metadata-using-gravitino.md) to learn how to manage relational metadata. * [Manage view metadata using Gravitino](./manage-view-metadata-using-gravitino.md) @@ -164,6 +167,8 @@ Gravitino supports different catalogs to manage the metadata in different source Gravitino provides governance features to manage metadata in a unified way. See: +* [Domains](./domains.md): business groupings, membership and hierarchy. +* [Manage domains in Gravitino](./manage-domains-in-gravitino.md): Java/Python examples, REST lifecycle and backing tags. * [Manage tags in Gravitino](./manage-tags-in-gravitino.md): a complete guide to using Gravitino to manage tags. * [Manage policies in Gravitino](./manage-policies-in-gravitino.md): a complete guide to using Gravitino diff --git a/docs/manage-domains-in-gravitino.md b/docs/manage-domains-in-gravitino.md new file mode 100644 index 0000000000..0b09ffa39a --- /dev/null +++ b/docs/manage-domains-in-gravitino.md @@ -0,0 +1,990 @@ +--- +title: "Manage Domains" +slug: "/manage-domains-in-gravitino" +keyword: "domain, subdomain, membership, backing tag, Gravitino" +license: "This software is licensed under the Apache License version 2." +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + +## Introduction + +A Domain groups metadata across catalogs in one metalake under a business name, such as +`Finance`. Domains provide discovery and organization; they do not grant access to the data. +A domain has a name, optional comment, string properties, status, optional parent, backing tag, +and audit information. See [Domains](./domains.md) for membership and hierarchy semantics, +[Access control](./security/access-control.md#domain-permissions) for authorization, and the +[Domain OpenAPI specification](./open-api/domains.yaml) for request and response schemas. + +Use a server and Java/Python clients built from the same version that supports Domains. +Follow [Java client setup](./how-to-use-gravitino-client.md) or +[Python client setup](./how-to-use-python-client.md) first. The examples below use simple +authentication as `anonymous`, a configured service administrator, on a local server at +`http://127.0.0.1:8090`. They create an isolated metalake and use the built-in model catalog, +so they need no external catalog service. Use unique names on a shared server and configure +authentication for your deployment. See [Authentication](./security/how-to-authenticate.md). + +## Deployment prerequisites + +For an existing deployment, complete the database schema upgrade for the server version before +using Domain APIs. The 1.3-to-2.0 upgrade scripts for H2, MySQL and PostgreSQL add the Domain +metadata and hierarchy tables; installing a new client alone does not upgrade the server's store. +Follow [Upgrade Gravitino](./how-to-upgrade.md) for the supported backup and upgrade procedure and +[Relational backend storage](./how-to-use-relational-backend-storage.md) for backend setup. +Existing tags do not automatically create domains: bind them explicitly using the operations below. + +## API examples + +Each operation below provides REST, Java and Python examples. They assume an existing metalake +named `test`, with clients connected to that metalake. Java uses `lake` (`GravitinoMetalake`); +Python uses `lake` (`GravitinoClient`). `domain` refers to a loaded Finance domain. Import Java +Domain types from `org.apache.gravitino.domain`, `TagValue` from `org.apache.gravitino.tag`, and +`MetadataObject` from `org.apache.gravitino`. Python uses `gravitino.api.domain`, +`gravitino.api.tag` and `gravitino.api.metadata_object` respectively. +REST examples use simple authentication as the configured administrator `anonymous`. +These are independent operation examples; the [complete examples](#complete-java-example) below +show a runnable sequence with setup and cleanup. + +All loaded Domain objects are snapshots. Mutations return a fresh snapshot and leave old objects +unchanged. An operation on an old snapshot applies to current server state (last write wins), using +the snapshot's name. After rename it can fail with not-found; if another domain reuses that old name, +the operation targets that new domain. Reload by name after changes; snapshots are not revision locks. + +## Domain Operations + +### Create a Domain + +Create a top-level draft with an explicit backing tag. Here a new valueless tag is created +atomically with the domain. See [Backing Tag Operations](#backing-tag-operations) for existing-tag +bindings and constraints. + +<Tabs groupId='language' queryString> +<TabItem value="shell" label="REST"> + +```shell +curl --fail-with-body -u anonymous:dummy -X POST -H 'Content-Type: application/json' \ + -d '{"name":"Finance","comment":"Financial assets","properties":{},"backingTag":{"name":"finance","create":true}}' \ + "http://127.0.0.1:8090/api/metalakes/test/domains" +``` + +</TabItem> +<TabItem value="java" label="Java"> + +```java +Domain domain = lake.createDomain( + "Finance", "Financial assets", Collections.emptyMap(), + TagValue.noValue("finance"), true); +``` + +</TabItem> +<TabItem value="python" label="Python"> + +```python +domain = lake.create_domain("Finance", "Financial assets", {}, TagValue("finance"), True) +``` + +</TabItem> +</Tabs> + +Import `java.util.Collections` for the Java examples that use `Collections.emptyMap()`. + +### Get a Domain + +Load a snapshot by its literal name. The snapshot exposes name, comment, properties, status, +parent, backing tag and audit information. Ordinary snapshots have no object membership relations. + +<Tabs groupId='language' queryString> +<TabItem value="shell" label="REST"> + +```shell +curl --fail-with-body -u anonymous:dummy \ + "http://127.0.0.1:8090/api/metalakes/test/domains/Finance" +``` + +</TabItem> +<TabItem value="java" label="Java"> + +```java +Domain domain = lake.getDomain("Finance"); +``` + +</TabItem> +<TabItem value="python" label="Python"> + +```python +domain = lake.get_domain("Finance") +``` + +</TabItem> +</Tabs> + +### List Domains + +Lists include visible top-level domains and subdomains. Names-only and detailed variants are +shown below; an empty result contains an empty array. + +<Tabs groupId='language' queryString> +<TabItem value="shell" label="REST"> + +```shell +curl --fail-with-body -u anonymous:dummy \ + "http://127.0.0.1:8090/api/metalakes/test/domains" +``` + +</TabItem> +<TabItem value="java" label="Java"> + +```java +String[] names = lake.listDomains(); +``` + +</TabItem> +<TabItem value="python" label="Python"> + +```python +names = lake.list_domains() +``` + +</TabItem> +</Tabs> + +### List Domains with Details + +Set `details=true` to retrieve snapshots instead of names. + +<Tabs groupId='language' queryString> +<TabItem value="shell" label="REST"> + +```shell +curl --fail-with-body -u anonymous:dummy \ + "http://127.0.0.1:8090/api/metalakes/test/domains?details=true" +``` + +</TabItem> +<TabItem value="java" label="Java"> + +```java +Domain[] domains = lake.listDomainsInfo(); +``` + +</TabItem> +<TabItem value="python" label="Python"> + +```python +domains = lake.list_domains_info() +``` + +</TabItem> +</Tabs> + +### Alter a Domain + +Rename, update/clear the comment, or set/remove properties. Renaming preserves tags and hierarchy. +Use `null` / `None` to clear the comment. Reload snapshots addressed by the former name. + +<Tabs groupId='language' queryString> +<TabItem value="shell" label="REST"> + +```shell +curl --fail-with-body -u anonymous:dummy -X PUT -H 'Content-Type: application/json' \ + -d '{"updates":[{"@type":"rename","newName":"Corporate_Finance"},{"@type":"updateComment","newComment":"Finance metadata"},{"@type":"setProperty","property":"contact","value":"finance-team"},{"@type":"removeProperty","property":"obsolete"}]}' \ + "http://127.0.0.1:8090/api/metalakes/test/domains/Finance" +``` + +</TabItem> +<TabItem value="java" label="Java"> + +```java +Domain renamed = lake.alterDomain("Finance", + DomainChange.rename("Corporate_Finance"), + DomainChange.updateComment("Finance metadata"), + DomainChange.setProperty("contact", "finance-team"), + DomainChange.removeProperty("obsolete")); +``` + +</TabItem> +<TabItem value="python" label="Python"> + +```python +renamed = lake.alter_domain( + "Finance", + DomainChange.rename("Corporate_Finance"), + DomainChange.update_comment("Finance metadata"), + DomainChange.set_property("contact", "finance-team"), + DomainChange.remove_property("obsolete"), +) +``` + +</TabItem> +</Tabs> + +### Publish a Domain + +Publish the parent before publishing children. Repeating the current status is a no-op. +Publication exposes the domain to users who can use it; it does not grant data access. + +<Tabs groupId='language' queryString> +<TabItem value="shell" label="REST"> + +```shell +curl --fail-with-body -u anonymous:dummy -X PATCH -H 'Content-Type: application/json' \ + -d '{"status":"published"}' \ + "http://127.0.0.1:8090/api/metalakes/test/domains/Finance" +``` + +</TabItem> +<TabItem value="java" label="Java"> + +```java +Domain published = domain.publish(); +``` + +</TabItem> +<TabItem value="python" label="Python"> + +```python +published = domain.publish() +``` + +</TabItem> +</Tabs> + +### Unpublish a Domain + +Unpublish children before their parent. A draft is visible only to its managers and owners. + +<Tabs groupId='language' queryString> +<TabItem value="shell" label="REST"> + +```shell +curl --fail-with-body -u anonymous:dummy -X PATCH -H 'Content-Type: application/json' \ + -d '{"status":"draft"}' \ + "http://127.0.0.1:8090/api/metalakes/test/domains/Finance" +``` + +</TabItem> +<TabItem value="java" label="Java"> + +```java +Domain draft = domain.unpublish(); +``` + +</TabItem> +<TabItem value="python" label="Python"> + +```python +draft = domain.unpublish() +``` + +</TabItem> +</Tabs> + +### Delete a Domain + +Delete or detach children before deleting their parent. Members alone do not prevent deletion. +The operation keeps backing tags and object assignments and returns false if the domain is absent. + +<Tabs groupId='language' queryString> +<TabItem value="shell" label="REST"> + +```shell +curl --fail-with-body -u anonymous:dummy -X DELETE \ + "http://127.0.0.1:8090/api/metalakes/test/domains/Finance" +``` + +</TabItem> +<TabItem value="java" label="Java"> + +```java +boolean deleted = lake.deleteDomain("Finance"); +``` + +</TabItem> +<TabItem value="python" label="Python"> + +```python +deleted = lake.delete_domain("Finance") +``` + +</TabItem> +</Tabs> + +## Subdomain Operations + +There is one level of subdomains. Names are unique across the metalake, including children. +A child is addressed by its own literal name, without a parent prefix. + +### Create a Subdomain + +Create a draft and its parent link atomically. `domain` is the top-level Finance parent. +The explicit backing-tag creation and binding rules are the same as for a top-level domain. + +<Tabs groupId='language' queryString> +<TabItem value="shell" label="REST"> + +```shell +curl --fail-with-body -u anonymous:dummy -X POST -H 'Content-Type: application/json' \ + -d '{"name":"Planning_US","parent":"Finance","backingTag":{"name":"planning","create":true}}' \ + "http://127.0.0.1:8090/api/metalakes/test/domains" +``` + +</TabItem> +<TabItem value="java" label="Java"> + +```java +Domain child = domain.createSubdomain( + "Planning_US", null, null, TagValue.noValue("planning"), true); +``` + +</TabItem> +<TabItem value="python" label="Python"> + +```python +child = domain.create_subdomain("Planning_US", None, None, TagValue("planning"), True) +``` + +</TabItem> +</Tabs> + +### List Subdomains + +List the names of immediate children visible to the caller. + +<Tabs groupId='language' queryString> +<TabItem value="shell" label="REST"> + +```shell +curl --fail-with-body -u anonymous:dummy \ + "http://127.0.0.1:8090/api/metalakes/test/domains/Finance/subdomains" +``` + +</TabItem> +<TabItem value="java" label="Java"> + +```java +String[] children = domain.listSubdomains(); +``` + +</TabItem> +<TabItem value="python" label="Python"> + +```python +children = domain.list_subdomains() +``` + +</TabItem> +</Tabs> + +### List Subdomains with Details + +Retrieve visible child snapshots rather than names. + +<Tabs groupId='language' queryString> +<TabItem value="shell" label="REST"> + +```shell +curl --fail-with-body -u anonymous:dummy \ + "http://127.0.0.1:8090/api/metalakes/test/domains/Finance/subdomains?details=true" +``` + +</TabItem> +<TabItem value="java" label="Java"> + +```java +Domain[] children = domain.listSubdomainsInfo(); +``` + +</TabItem> +<TabItem value="python" label="Python"> + +```python +children = domain.list_subdomains_info() +``` + +</TabItem> +</Tabs> + +### Attach or Move a Domain + +Attach Planning_US under Finance, replacing any current parent. The destination must be top-level +and cannot be the domain itself. A domain with children cannot become a child; a published child +requires a published destination. Tags and assignments remain intact; membership roll-ups and +inherited permissions follow the new parent immediately. Attaching to the current parent is a no-op. + +<Tabs groupId='language' queryString> +<TabItem value="shell" label="REST"> + +```shell +curl --fail-with-body -u anonymous:dummy -X PUT -H 'Content-Type: application/json' \ + -d '{"parent":"Finance"}' \ + "http://127.0.0.1:8090/api/metalakes/test/domains/Planning_US/parent" +``` + +</TabItem> +<TabItem value="java" label="Java"> + +```java +Domain child = lake.getDomain("Planning_US"); +Domain attached = child.attachToParent("Finance"); +``` + +</TabItem> +<TabItem value="python" label="Python"> + +```python +child = lake.get_domain("Planning_US") +attached = child.attach_to_parent("Finance") +``` + +</TabItem> +</Tabs> + +### Detach a Domain + +Make the child top-level without retagging its members. Former parent permissions and membership +roll-ups stop applying. Detaching a top-level domain is a no-op. + +<Tabs groupId='language' queryString> +<TabItem value="shell" label="REST"> + +```shell +curl --fail-with-body -u anonymous:dummy -X DELETE \ + "http://127.0.0.1:8090/api/metalakes/test/domains/Planning_US/parent" +``` + +</TabItem> +<TabItem value="java" label="Java"> + +```java +Domain child = lake.getDomain("Planning_US"); +Domain detached = child.detachFromParent(); +``` + +</TabItem> +<TabItem value="python" label="Python"> + +```python +child = lake.get_domain("Planning_US") +detached = child.detach_from_parent() +``` + +</TabItem> +</Tabs> + +## Backing Tag Operations + +Creation always requires an explicit backing tag: + +| Intent | Java | Python | REST `backingTag` | +| --- | --- | --- | --- | +| Create a new valueless tag | `TagValue.noValue("finance"), true` | `TagValue("finance"), True` | `{"name":"finance","create":true}` | +| Bind an existing tag, any assignment | `TagValue.noValue("department"), false` | `TagValue("department"), False` | `{"name":"department","create":false}` | +| Bind an existing tag value | `TagValue.of("department", "finance"), false` | `TagValue("department", "finance"), False` | `{"name":"department","value":"finance","create":false}` | + +New backing tags allow no values and are owned by the creator. Creation never implicitly adopts an +existing tag: `create=true` with an existing name conflicts. Supplying a value with `create=true` is +invalid. For an existing tag, the value must satisfy its immutable allowed-values constraint. See +[Tag value constraints](./manage-tags-in-gravitino.md#create-a-tag-with-a-value-constraint). + +A tag can back one domain without a value, or multiple domains with distinct values. A valueless +binding conflicts with every other binding of the same tag; two bindings of the same exact value +also conflict. Bindings with distinct values are allowed, even between a parent and its child. +A valueless binding matches every effective assignment of that tag, including assignments with values; +a valued binding matches when the effective assignment contains that exact, case-sensitive value. + +`domain.updateBackingTag(TagValue.of("department", "finance"))` or Python +`domain.update_backing_tag(TagValue("department", "finance"))` replaces the binding with an existing +tag. Pass `null` / `None` to remove it. Repeating a binding is a no-op. Removing a binding does not +delete the tag, change assignments, or remove child membership roll-ups. Replacing it does not migrate +members: only effective assignments matching the new binding contribute the domain's own members. + +Bindings use tag identity (ID), not its name. Renaming a tag preserves membership and exposes the new +tag name on a freshly loaded domain. Deleting it leaves the domain without a backing tag. Recreating +a tag with the old name does not rebind the domain; explicitly update the binding if that is intended. +Domain rename, move, detach and deletion never rename or delete its backing tag. + +### Create a Domain with an Existing Backing Tag + +Assume `department` already exists and allows the value `finance`. Bind it explicitly with +`create=false`; omit the value to match any effective assignment of that tag. Binding requires +ownership of the existing tag or metalake when authorization is enabled. + +<Tabs groupId='language' queryString> +<TabItem value="shell" label="REST"> + +```shell +curl --fail-with-body -u anonymous:dummy -X POST -H 'Content-Type: application/json' \ + -d '{"name":"Finance","backingTag":{"name":"department","value":"finance","create":false}}' \ + "http://127.0.0.1:8090/api/metalakes/test/domains" +``` + +</TabItem> +<TabItem value="java" label="Java"> + +```java +Domain domain = lake.createDomain( + "Finance", null, null, TagValue.of("department", "finance"), false); +``` + +</TabItem> +<TabItem value="python" label="Python"> + +```python +domain = lake.create_domain( + "Finance", None, None, TagValue("department", "finance"), False +) +``` + +</TabItem> +</Tabs> + +### Replace a Backing Tag + +Bind an existing tag, optionally with a value. Members are not migrated and previous assignments +remain unchanged. Repeating the current binding is a no-op. + +<Tabs groupId='language' queryString> +<TabItem value="shell" label="REST"> + +```shell +curl --fail-with-body -u anonymous:dummy -X PUT -H 'Content-Type: application/json' \ + -d '{"backingTag":{"name":"department","value":"finance"}}' \ + "http://127.0.0.1:8090/api/metalakes/test/domains/Finance/backingTag" +``` + +</TabItem> +<TabItem value="java" label="Java"> + +```java +Domain updated = domain.updateBackingTag(TagValue.of("department", "finance")); +``` + +</TabItem> +<TabItem value="python" label="Python"> + +```python +updated = domain.update_backing_tag(TagValue("department", "finance")) +``` + +</TabItem> +</Tabs> + +### Remove a Backing Tag + +Remove the binding without deleting the tag or assignments. Visible child membership still rolls +up to this domain. Removing a binding needs no tag privilege. + +<Tabs groupId='language' queryString> +<TabItem value="shell" label="REST"> + +```shell +curl --fail-with-body -u anonymous:dummy -X PUT -H 'Content-Type: application/json' \ + -d '{"backingTag":null}' \ + "http://127.0.0.1:8090/api/metalakes/test/domains/Finance/backingTag" +``` + +</TabItem> +<TabItem value="java" label="Java"> + +```java +Domain unbound = domain.updateBackingTag(null); +``` + +</TabItem> +<TabItem value="python" label="Python"> + +```python +unbound = domain.update_backing_tag(None) +``` + +</TabItem> +</Tabs> + +## Membership Operations + +Members are managed through the existing tag API. There is no separate Domain add/remove-member +endpoint. In the assignment examples, `model` is a loaded model named `models.sales.forecast` and +`department` is an existing tag allowing `finance`. See [tag operations](./manage-tags-in-gravitino.md) +for creating constrained tags and assigning them to catalogs or schemas. + +### Assign a Backing Tag to an Object + +Assign the Finance backing-tag value to the model using normal tag permissions. The same API +works for leaf, schema and catalog assignments; the latter contribute recorded leaf members. +Tag-value requests use `application/vnd.gravitino.v2+json`; Domain endpoints use the v1 API. + +<Tabs groupId='language' queryString> +<TabItem value="shell" label="REST"> + +```shell +curl --fail-with-body -u anonymous:dummy -X POST -H 'Accept: application/vnd.gravitino.v2+json' \ + -H 'Content-Type: application/vnd.gravitino.v2+json' \ + -d '{"tagsToAdd":[{"name":"department","value":"finance"}],"tagsToRemove":[]}' \ + "http://127.0.0.1:8090/api/metalakes/test/objects/model/models.sales.forecast/tags" +``` + +</TabItem> +<TabItem value="java" label="Java"> + +```java +model.supportsTags().associateTags( + new TagValue[] {TagValue.of("department", "finance")}, new TagValue[0]); +``` + +</TabItem> +<TabItem value="python" label="Python"> + +```python +model.supports_tags().assign_tags( + tags_to_add=[{"name": "department", "value": "finance"}] +) +``` + +</TabItem> +</Tabs> + +### Remove a Backing Tag Assignment + +Remove the value assigned directly to the model. An ancestor assignment can then become +effective again, so this does not necessarily remove inherited Domain membership. + +<Tabs groupId='language' queryString> +<TabItem value="shell" label="REST"> + +```shell +curl --fail-with-body -u anonymous:dummy -X POST -H 'Accept: application/vnd.gravitino.v2+json' \ + -H 'Content-Type: application/vnd.gravitino.v2+json' \ + -d '{"tagsToAdd":[],"tagsToRemove":[{"name":"department","value":"finance"}]}' \ + "http://127.0.0.1:8090/api/metalakes/test/objects/model/models.sales.forecast/tags" +``` + +</TabItem> +<TabItem value="java" label="Java"> + +```java +model.supportsTags().associateTags( + new TagValue[0], new TagValue[] {TagValue.of("department", "finance")}); +``` + +</TabItem> +<TabItem value="python" label="Python"> + +```python +model.supports_tags().assign_tags( + tags_to_remove=[{"name": "department", "value": "finance"}] +) +``` + +</TabItem> +</Tabs> + +### List Domain Members + +List accessible recorded leaves in the domain and its visible children. Each object occurs once +with all applicable relations and complete sources. An empty query returns an empty member array. + +<Tabs groupId='language' queryString> +<TabItem value="shell" label="REST"> + +```shell +curl --fail-with-body -u anonymous:dummy \ + "http://127.0.0.1:8090/api/metalakes/test/domains/Finance/objects" +``` + +</TabItem> +<TabItem value="java" label="Java"> + +```java +DomainMember[] members = domain.listMembers(DomainMemberFilter.builder().build()); +``` + +</TabItem> +<TabItem value="python" label="Python"> + +```python +members = domain.list_members(DomainMemberFilter()) +``` + +</TabItem> +</Tabs> + +### Filter Domain Members + +Filters intersect. `domains` selects the union of scopes, using one REST parameter per domain name. Selecting a child filters members but retains their full relations relative +to the queried domain. See [membership filters](./domains.md#membership-filters) for exact semantics. + +<Tabs groupId='language' queryString> +<TabItem value="shell" label="REST"> + +```shell +curl --fail-with-body -u anonymous:dummy --get \ + --data-urlencode 'types=MODEL,TABLE' \ + --data-urlencode 'nameContains=forecast' \ + --data-urlencode 'domains=Planning_US' --data-urlencode 'domains=Tax' \ + "http://127.0.0.1:8090/api/metalakes/test/domains/Finance/objects" +``` + +</TabItem> +<TabItem value="java" label="Java"> + +```java +DomainMember[] members = domain.listMembers( + DomainMemberFilter.builder() + .withTypes(MetadataObject.Type.MODEL, MetadataObject.Type.TABLE) + .withNameContains("forecast") + .withDomains("Planning_US", "Tax") + .build()); +``` + +</TabItem> +<TabItem value="python" label="Python"> + +```python +members = domain.list_members( + DomainMemberFilter( + types=[MetadataObject.Type.MODEL, MetadataObject.Type.TABLE], + name_contains="forecast", + domains=["Planning_US", "Tax"], + ) +) +``` + +</TabItem> +</Tabs> + +### List Domains for an Object + +Reverse lookup supports tables, views, filesets, topics, models and semantic models. It returns +visible matching domains and their visible parents. For Topic lookups from Python, use REST with +`topic` as the object type. Here `model` is the loaded forecast model. + +<Tabs groupId='language' queryString> +<TabItem value="shell" label="REST"> + +```shell +curl --fail-with-body -u anonymous:dummy \ + "http://127.0.0.1:8090/api/metalakes/test/objects/model/models.sales.forecast/domains" +``` + +</TabItem> +<TabItem value="java" label="Java"> + +```java +String[] names = model.supportsDomains().listDomains(); +``` + +</TabItem> +<TabItem value="python" label="Python"> + +```python +names = model.supports_domains().list_domains() +``` + +</TabItem> +</Tabs> + +### List Domains for an Object with Details + +Detailed reverse lookup includes every applicable relation on each domain snapshot. Ordinary +domain snapshots have empty SDK `relations()` and omit the REST `relations` field. + +<Tabs groupId='language' queryString> +<TabItem value="shell" label="REST"> + +```shell +curl --fail-with-body -u anonymous:dummy \ + "http://127.0.0.1:8090/api/metalakes/test/objects/model/models.sales.forecast/domains?details=true" +``` + +</TabItem> +<TabItem value="java" label="Java"> + +```java +Domain[] domains = model.supportsDomains().listDomainsInfo(); +``` + +</TabItem> +<TabItem value="python" label="Python"> + +```python +domains = model.supports_domains().list_domains_info() +``` + +</TabItem> +</Tabs> + +## Complete Java example + +Save this as `DomainExample.java` in a Java application with the Gravitino Java client dependency. +Run its `main` method using the application's dependency classpath. Assertions below throw even +when JVM assertions are disabled. With the client and its dependencies in +`GRAVITINO_CLIENT_CLASSPATH`, compile with `javac -cp "$GRAVITINO_CLIENT_CLASSPATH" DomainExample.java` +and run with `java -cp ".:$GRAVITINO_CLIENT_CLASSPATH" DomainExample`. Add the server URI as the +last argument to use another port. The example creates metadata, assigns a tag, publishes a domain, +queries membership in both directions, and cleans up the metalake and its contents. + +```java +import java.util.Arrays; +import java.util.Collections; +import org.apache.gravitino.Catalog; +import org.apache.gravitino.NameIdentifier; +import org.apache.gravitino.client.GravitinoAdminClient; +import org.apache.gravitino.client.GravitinoMetalake; +import org.apache.gravitino.domain.Domain; +import org.apache.gravitino.domain.DomainMember; +import org.apache.gravitino.domain.DomainMemberFilter; +import org.apache.gravitino.domain.DomainRelation; +import org.apache.gravitino.model.Model; +import org.apache.gravitino.tag.TagValue; + +/** Demonstrates Domain discovery and cleanup on a local Gravitino server. */ +public class DomainExample { + /** Runs the example, optionally using the server URI supplied as the first argument. */ + public static void main(String[] args) throws Exception { + String uri = args.length == 0 ? "http://127.0.0.1:8090" : args[0]; + String lakeName = "domain_java_" + Long.toUnsignedString(System.nanoTime()); + try (GravitinoAdminClient admin = + GravitinoAdminClient.builder(uri).withSimpleAuth("anonymous").build()) { + GravitinoMetalake lake = admin.createMetalake(lakeName, "Domain example", Collections.emptyMap()); + try { + Catalog catalog = lake.createCatalog( + "models", Catalog.Type.MODEL, "model", "", Collections.emptyMap()); + catalog.asSchemas().createSchema("sales", "", Collections.emptyMap()); + Model model = catalog.asModelCatalog().registerModel( + NameIdentifier.of("sales", "forecast"), "", Collections.emptyMap()); + Domain draft = lake.createDomain( + "Finance", "Financial assets", Collections.emptyMap(), TagValue.noValue("finance"), true); + Domain child = draft.createSubdomain( + "Planning_US", null, null, TagValue.noValue("planning"), true); + model.supportsTags().associateTags(new String[] {"planning"}, new String[0]); + Domain published = draft.publish(); + child = child.publish(); + if (draft.status() != Domain.Status.DRAFT || published.status() != Domain.Status.PUBLISHED) { + throw new IllegalStateException("Expected independent snapshots"); + } + DomainMember[] members = published.listMembers( + DomainMemberFilter.builder().withNameContains("FORECAST") + .withDomains("Planning_US").build()); + if (members.length != 1 + || members[0].relations()[0].type() != DomainRelation.Type.VIA_SUBDOMAIN + || !members[0].relations()[0].source().orElseThrow().fullName().equals("Planning_US")) { + throw new IllegalStateException("Expected the child membership and its complete source"); + } + if (!Arrays.asList(model.supportsDomains().listDomains()).contains("Finance")) { + throw new IllegalStateException("Expected the parent in reverse lookup"); + } + Domain[] domains = model.supportsDomains().listDomainsInfo(); + if (domains.length != 2) { + throw new IllegalStateException("Expected parent and child"); + } + child = child.detachFromParent(); + if (Arrays.asList(model.supportsDomains().listDomains()).contains("Finance")) { + throw new IllegalStateException("Detached membership must stop rolling up"); + } + lake.deleteDomain(child.name()); + lake.deleteDomain(published.name()); + // Domain deletion keeps tags and assignments. Remove the assignment explicitly. + model.supportsTags().associateTags(new String[0], new String[] {"planning"}); + lake.deleteTag("planning"); + lake.deleteTag("finance"); + } finally { + admin.dropMetalake(lakeName, true); + } + } + } +} +``` + +## Complete Python example + +Save this as `domain_example.py` and run `python domain_example.py`, with the Python client installed. +An optional first argument supplies a different server URI. + +```python +import os +import sys +import uuid + +from gravitino import Catalog, GravitinoAdminClient, GravitinoClient, NameIdentifier +from gravitino.api.domain import Domain, DomainMemberFilter, DomainRelation +from gravitino.api.tag import TagValue +from gravitino.auth.simple_auth_provider import SimpleAuthProvider + +os.environ["GRAVITINO_USER"] = "anonymous" +uri = sys.argv[1] if len(sys.argv) > 1 else "http://127.0.0.1:8090" +lake_name = "domain_python_" + uuid.uuid4().hex +admin = GravitinoAdminClient(uri, auth_data_provider=SimpleAuthProvider()) +lake = None +created = False +try: + admin.create_metalake(lake_name, "Domain example", {}) + created = True + lake = GravitinoClient(uri, lake_name, auth_data_provider=SimpleAuthProvider()) + catalog = lake.create_catalog("models", Catalog.Type.MODEL, "model", "", {}) + catalog.as_schemas().create_schema("sales", "", {}) + model = catalog.as_model_catalog().register_model( + NameIdentifier.of("sales", "forecast"), "", {} + ) + draft = lake.create_domain("Finance", "Financial assets", {}, TagValue("finance"), True) + child = draft.create_subdomain("Planning_US", None, None, TagValue("planning"), True) + model.supports_tags().associate_tags(["planning"], []) + published = draft.publish() + child = child.publish() + assert draft.status() == Domain.Status.DRAFT + assert published.status() == Domain.Status.PUBLISHED + members = published.list_members( + DomainMemberFilter(name_contains="FORECAST", domains=["Planning_US"]) + ) + assert len(members) == 1 + assert members[0].relations()[0].type() == DomainRelation.Type.VIA_SUBDOMAIN + assert members[0].relations()[0].source().full_name() == "Planning_US" + assert "Finance" in model.supports_domains().list_domains() + assert len(model.supports_domains().list_domains_info()) == 2 + child = child.detach_from_parent() + assert "Finance" not in model.supports_domains().list_domains() + lake.delete_domain(child.name()) + lake.delete_domain(published.name()) + model.supports_tags().associate_tags([], ["planning"]) + lake.delete_tag("planning") + lake.delete_tag("finance") +finally: + if lake is not None: + lake.close() + if created: + admin.drop_metalake(lake_name, True) + admin.close() +``` + +## Path encoding and errors + +Domain names must match `[A-Za-z0-9_][A-Za-z0-9_-]{0,63}`. The server reserves `*` and +`system` (in any letter case) and preserves the spelling of valid names. The same rules apply +to subdomains, rename targets, parent names and each name in the `domains` member filter. +Use the child's own name as one path segment. Percent-encoding a space, dot or slash does +not make it a valid domain name. Pass raw names to SDK methods. SDK path builders can reject +unsafe segments before sending a request; the server enforces the full naming rules. + +Backing tags, metadata object names and `nameContains` search text have separate rules. +Encode metadata path parameters individually and supply query values with `--data-urlencode`. + +| HTTP status | Typical Domain behavior | +| --- | --- | +| 200 | Success with `code: 0`; empty queries return empty arrays; deleting an absent domain returns `dropped: false`. | +| 400 | Invalid request: invalid domain names or filters, unsupported member types, illegal hierarchy/status transition, disallowed tag value, or a value supplied while creating a new backing tag. | +| 403 | Insufficient permission on a published domain, a required backing tag, or a reverse-lookup object. | +| 404 | Missing metalake/domain/parent/tag/object, or a draft hidden from the caller. | +| 409 | Duplicate domain/tag name, backing-tag binding conflict, deleting a parent with children, disabled metalake, or an optimistic lock conflict during domain alteration or deletion. | +| 415 | Unsupported request Content-Type; the error response uses `application/json`. | +| 5xx | Server failure; inspect the error response and server log. | + +Authentication failures follow the configured authenticator. The JSON error response contains the +exception type and message; do not infer authorization from empty lists alone. Validation and +visibility checks can run before existence checks, so the first failing check determines the error. + +## MCP access + +The [existing read-only Domain MCP tools](./gravitino-mcp-server.md#domains-read-only) expose discovery, +subdomain listing, member queries and object-to-domain lookup with the same server-side visibility. +Use REST or the Java/Python clients for Domain mutations. Domain UI, pagination/counts and Domain-based +data authorization are not provided by this feature. diff --git a/docs/manage-tags-in-gravitino.md b/docs/manage-tags-in-gravitino.md index 1d23f832c2..f7489b2040 100644 --- a/docs/manage-tags-in-gravitino.md +++ b/docs/manage-tags-in-gravitino.md @@ -16,6 +16,9 @@ resolves, and how to work with tags in the UI, see [Tags](./tags.md). Policies can be associated with tags to govern objects carrying those tags. See [Policy-to-Tag Associations](./manage-policies-in-gravitino.md#policy-to-tag-associations). +Domains derive membership from explicit backing tags and existing assignments. See +[Manage domains](./manage-domains-in-gravitino.md) for binding, ownership and conflict rules. + ## Tag Operations ### Create a Tag diff --git a/docs/metalakes.md b/docs/metalakes.md index 52b5c02888..81a4ac5d53 100644 --- a/docs/metalakes.md +++ b/docs/metalakes.md @@ -9,7 +9,8 @@ license: "This software is licensed under the Apache License version 2." A metalake is the top of the Gravitino hierarchy and the boundary everything else lives inside. Catalogs, schemas, tables, filesets, topics, models, and functions all sit beneath one, and so do the -users, groups, roles, tags, policies, and jobs that apply to them. +users, groups, roles, tags, policies, domains, and jobs that apply to them. +[Domains](./domains.md) group metadata from catalogs within this same metalake using backing tags. Nothing crosses that boundary: diff --git a/docs/migration-guide.md b/docs/migration-guide.md index c30d4a257e..3f24482b98 100644 --- a/docs/migration-guide.md +++ b/docs/migration-guide.md @@ -11,6 +11,18 @@ existing deployments. For database backup, schema scripts, and rollback commands ## Upgrading from Gravitino 1.3 to 2.0 +### Domains + +- Domains add business groupings within a metalake, backed by explicit tag bindings. Existing tags + and assignments are preserved; they are not automatically converted into domains. +- Complete the standard 1.3-to-2.0 database schema upgrade before using Domain APIs. The H2, MySQL + and PostgreSQL upgrade scripts include the Domain metadata and hierarchy tables. Use matching + server and client versions; a client upgrade alone does not add server-side Domain support. +- With authorization enabled, grant `MANAGE_DOMAIN` or `USE_DOMAIN` separately from tag and data + permissions. Existing tag/data privileges do not grant Domain management or discovery. +- See [Manage domains](./manage-domains-in-gravitino.md) for the workflow and + [Upgrade Gravitino](./how-to-upgrade.md) for the database upgrade procedure. + ### Audit client address behind a reverse proxy - Gravitino 1.3 used the first `X-Forwarded-For` entry as the audit client address whenever diff --git a/docs/open-api/domains.yaml b/docs/open-api/domains.yaml index bf398c688a..bd512b1c30 100644 --- a/docs/open-api/domains.yaml +++ b/docs/open-api/domains.yaml @@ -27,7 +27,7 @@ paths: summary: List domains operationId: listDomains description: >- - List domains. Published domains require USE_DOMAIN; drafts require MANAGE_DOMAIN or inherited ownership. Hidden drafts return 404 and are omitted from lists. + List all visible top-level domains and subdomains in this metalake. Names are unique across both levels and are literal strings, not hierarchy paths. Published domains require USE_DOMAIN; drafts require MANAGE_DOMAIN or inherited ownership. Hidden drafts return 404 and are omitted from lists. parameters: - name: details in: query @@ -69,7 +69,7 @@ paths: summary: Create a domain operationId: createDomain description: >- - Creates a DRAFT domain, its optional parent edge and an optional new backing tag atomically. A failure leaves no new domain or tag behind. Requires MANAGE_DOMAIN on the metalake and, when specified, the parent. A new tag additionally requires CREATE_TAG on the metalake; an existing tag requires ownership of that tag or the metalake. Hidden drafts return 404; other permission failures return 403. + Creates a DRAFT domain, its optional parent edge and an optional new backing tag atomically. A failure leaves no new domain or tag behind. Requires MANAGE_DOMAIN on the metalake and, when specified, the parent. The backing tag must be explicit: create=true never adopts an existing tag and cannot include a value. Bindings use tag identity, so tag rename preserves a binding while delete/recreate does not. A tag can back one domain without a value, or multiple domains with distinct [...] requestBody: required: true content: @@ -98,11 +98,13 @@ paths: schema: $ref: "./openapi.yaml#/components/schemas/ErrorModel" "409": - description: The metalake is disabled, the name or backing tag conflicts, the domain has subdomains, or a concurrent update could not complete. + description: The metalake is disabled, the domain or new tag name already exists, or the backing-tag binding conflicts. content: application/json: schema: $ref: "./openapi.yaml#/components/schemas/ErrorModel" + "415": + $ref: "#/components/responses/UnsupportedMediaTypeResponse" "5XX": $ref: "#/components/responses/ServerErrorResponse" @@ -148,7 +150,7 @@ paths: summary: Alter a domain operationId: alterDomain description: >- - Alter a domain. Requires MANAGE_DOMAIN or ownership of the domain, its current parent, or the metalake. + Alter name, comment or properties and return a fresh snapshot. A rename preserves the backing tag and hierarchy. Old SDK snapshots remain unchanged and address future operations by their old name. Requires MANAGE_DOMAIN or ownership of the domain, its current parent, or the metalake. requestBody: required: true content: @@ -177,11 +179,13 @@ paths: schema: $ref: "./openapi.yaml#/components/schemas/ErrorModel" "409": - description: The metalake is disabled, the name or backing tag conflicts, the domain has subdomains, or a concurrent update could not complete. + description: The metalake is disabled, the new domain name already exists, or the alteration conflicts with a concurrent update. content: application/json: schema: $ref: "./openapi.yaml#/components/schemas/ErrorModel" + "415": + $ref: "#/components/responses/UnsupportedMediaTypeResponse" "5XX": $ref: "#/components/responses/ServerErrorResponse" patch: @@ -218,11 +222,13 @@ paths: schema: $ref: "./openapi.yaml#/components/schemas/ErrorModel" "409": - description: The metalake is disabled, the name or backing tag conflicts, the domain has subdomains, or a concurrent update could not complete. + description: The metalake is disabled. content: application/json: schema: $ref: "./openapi.yaml#/components/schemas/ErrorModel" + "415": + $ref: "#/components/responses/UnsupportedMediaTypeResponse" "5XX": $ref: "#/components/responses/ServerErrorResponse" delete: @@ -257,7 +263,7 @@ paths: schema: $ref: "./openapi.yaml#/components/schemas/ErrorModel" "409": - description: The metalake is disabled, the name or backing tag conflicts, the domain has subdomains, or a concurrent update could not complete. + description: The metalake is disabled, the domain has subdomains, or the deletion conflicts with a concurrent update. content: application/json: schema: @@ -274,7 +280,7 @@ paths: summary: Attach or move a domain operationId: setDomainParent description: >- - Attaches the child addressed by this path under a top-level parent, replacing its current parent. The backing tag is unchanged. Requires MANAGE_DOMAIN on both the domain and the new parent, inherited from their current scopes. Hidden drafts return 404; other permission failures return 403. + Attaches the child addressed by this path under a top-level parent, replacing its current parent. The backing tag and member assignments are unchanged; inherited permissions and membership roll-ups follow the new parent. The destination must be top-level, not this domain, and published if the child is published. A domain with children cannot be attached. Requires MANAGE_DOMAIN on both the domain and the new parent, inherited from their current scopes. Hidden drafts return 404; ot [...] requestBody: required: true content: @@ -303,11 +309,13 @@ paths: schema: $ref: "./openapi.yaml#/components/schemas/ErrorModel" "409": - description: The metalake is disabled, the name or backing tag conflicts, the domain has subdomains, or a concurrent update could not complete. + description: The metalake is disabled. content: application/json: schema: $ref: "./openapi.yaml#/components/schemas/ErrorModel" + "415": + $ref: "#/components/responses/UnsupportedMediaTypeResponse" "5XX": $ref: "#/components/responses/ServerErrorResponse" delete: @@ -338,7 +346,7 @@ paths: schema: $ref: "./openapi.yaml#/components/schemas/ErrorModel" "409": - description: The metalake is disabled, the name or backing tag conflicts, the domain has subdomains, or a concurrent update could not complete. + description: The metalake is disabled. content: application/json: schema: @@ -384,11 +392,13 @@ paths: schema: $ref: "./openapi.yaml#/components/schemas/ErrorModel" "409": - description: The metalake is disabled, the name or backing tag conflicts, the domain has subdomains, or a concurrent update could not complete. + description: The metalake is disabled or the backing-tag binding conflicts. content: application/json: schema: $ref: "./openapi.yaml#/components/schemas/ErrorModel" + "415": + $ref: "#/components/responses/UnsupportedMediaTypeResponse" "5XX": $ref: "#/components/responses/ServerErrorResponse" @@ -457,8 +467,9 @@ paths: in: query description: >- Repeated domain names selecting the union of their scopes. Omit to select the whole - scope. Selecting the listed domain also selects its subdomains. Unknown names are - ignored; if all supplied names are unknown, the result is empty. + scope. Selecting the listed domain also selects its subdomains. Well-formed names outside the visible scope are + ignored. If none match, the result is empty. Invalid domain names return 400. + Relations are reported relative to the domain in the path. style: form explode: true schema: @@ -467,7 +478,7 @@ paths: $ref: "#/components/schemas/DomainName" - name: types in: query - description: Comma-separated leaf types, case-insensitive. Omit to include all supported types. + description: Comma-separated leaf types, case-insensitive, with whitespace around each token trimmed. Omit to include all supported types. Blank tokens and unsupported types return 400. style: form explode: false schema: @@ -476,7 +487,7 @@ paths: $ref: "#/components/schemas/MemberType" - name: nameContains in: query - description: Nonblank substring of the member's full name, matched case-insensitively. + description: Nonblank substring of the member's complete full name, matched case-insensitively; no wildcard or regex interpretation. Omit for any name. Blank text returns 400. schema: type: string minLength: 1 @@ -532,7 +543,7 @@ paths: description: >- Lists domains whose scopes contain the leaf object, including parents of directly matched subdomains. Detailed responses carry every applicable relation without precedence. - Only visible domains and accessible objects are returned; hidden subdomains contribute no roll-up relations. No tag privilege is required. No paging or counts are provided. + The leaf must exist and be accessible; an inaccessible leaf returns 403. Only visible domains are returned; hidden subdomains contribute no roll-up relations. No tag privilege is required. No paging or counts are provided. parameters: - name: details in: query @@ -574,6 +585,16 @@ paths: components: responses: + UnsupportedMediaTypeResponse: + description: The request Content-Type is not supported by this operation. + content: + application/json: + schema: + $ref: "./openapi.yaml#/components/schemas/ErrorModel" + example: + code: 1000 + type: RESTException + message: HTTP 415 Unsupported Media Type BadRequestResponse: description: Invalid JSON or domain request parameters. content: @@ -612,7 +633,7 @@ components: DomainRelation: type: object - description: One applicable membership relation, with no precedence over other relations. + description: One applicable membership relation relative to the queried domain, with no precedence over other relations. All applicable relations are returned; a direct assignment masks inheritance of the same tag. required: [relation] properties: relation: @@ -621,7 +642,7 @@ components: source: description: >- Omitted for DIRECT; the nearest tagged catalog or schema for INHERITED; - the subdomain metadata object for VIA_SUBDOMAIN. + the subdomain metadata object for VIA_SUBDOMAIN. Sources carry the complete fullName and type. A hidden subdomain contributes no relation; an inherited source is retained for an accessible leaf without a separate source access check. allOf: - $ref: "#/components/schemas/RelationSource" @@ -659,6 +680,7 @@ components: $ref: "#/components/schemas/DomainRelation" Domain: + description: A snapshot of a domain in one metalake. A domain is top-level or a child of one top-level domain. type: object required: [name, properties, status, audit] properties: @@ -680,12 +702,12 @@ components: - type: string nullable: true enum: [null] - description: Parent domain name, or null for a top-level domain. + description: Parent domain name, or null for a top-level domain. A child can name a parent hidden from the caller. backingTag: type: object nullable: true required: [name] - description: Null when unbound or when the backing tag has been deleted. + description: Null or omitted when unbound or when the backing tag has been deleted. A renamed tag is returned with its current name; recreating a deleted tag name does not restore the binding. properties: name: type: string @@ -696,6 +718,7 @@ components: audit: $ref: "./openapi.yaml#/components/schemas/Audit" relations: + description: Present only on detailed object-to-domain lookup; omitted from ordinary domain snapshots. type: array minItems: 1 items: @@ -709,7 +732,6 @@ components: fullName: cat.schema.table type: table relations: - - relation: direct - relation: inherited source: fullName: cat.schema @@ -850,7 +872,9 @@ components: properties: status: type: string - enum: [draft, published, DRAFT, PUBLISHED] + pattern: "^([dD][rR][aA][fF][tT]|[pP][uU][bB][lL][iI][sS][hH][eE][dD])$" + description: Accepts draft or published, case-insensitively; responses use lowercase. + example: published DomainParentSetRequest: type: object diff --git a/docs/open-api/owners.yaml b/docs/open-api/owners.yaml index 8df387d7a3..763e70d512 100644 --- a/docs/open-api/owners.yaml +++ b/docs/open-api/owners.yaml @@ -178,12 +178,13 @@ components: metadataObjectTypeOfOwner: name: metadataObjectType in: path - description: The type of the metadata object + description: The type of the metadata object. DOMAIN ownership applies to the domain and its current subdomains; encode its literal name as one path segment. required: true schema: type: string enum: - "METALAKE" + - "DOMAIN" - "CATALOG" - "SCHEMA" - "TABLE" diff --git a/docs/open-api/roles.yaml b/docs/open-api/roles.yaml index 9e3da5f9a6..b95040143c 100644 --- a/docs/open-api/roles.yaml +++ b/docs/open-api/roles.yaml @@ -261,11 +261,12 @@ components: properties: fullName: type: string - description: The full name of the securable object + description: The full name of the securable object. For DOMAIN, use the domain name, without its parent or metalake prefix. type: type: string enum: - "METALAKE" + - "DOMAIN" - "CATALOG" - "SCHEMA" - "TABLE" diff --git a/docs/security/access-control.md b/docs/security/access-control.md index bff258eba8..86669fcafc 100755 --- a/docs/security/access-control.md +++ b/docs/security/access-control.md @@ -105,6 +105,8 @@ Metalake (top level) │ ├── Model │ ├── Function │ └── Semantic Model +├── Domain +│ └── Subdomain ├── Tag ├── Policy ├── Job Template @@ -142,7 +144,7 @@ catalog, or schema, never to a table. Whoever creates a role owns it, and can al Ownership can be held by a group as well as a user, in which case every member of that group holds it, and it can be transferred at any time. It applies to metalakes, catalogs, schemas, tables, views, -topics, filesets, models, semantic models, functions, roles, tags, policies, job templates, and jobs. +topics, filesets, models, semantic models, functions, domains, roles, tags, policies, job templates, and jobs. ### Resolution @@ -853,3 +855,60 @@ client.setOwner(schema, "analyst", Owner.Type.USER); data source or to an external system such as Apache Ranger - [How to Authenticate](how-to-authenticate.md), for establishing who the caller is - [Local users and groups](local-users-and-groups.md) + + +## Domain permissions + +Domains have two privileges, bindable to a metalake or a domain: + +| Privilege | Operations | +| --- | --- | +| `USE_DOMAIN` | Read published domains, list their visible subdomains and accessible members, and discover them from accessible leaf metadata. | +| `MANAGE_DOMAIN` | Create, alter, delete, publish/unpublish, change parent and change backing tag; also use domains and see drafts. | + +A top-level domain is created with `MANAGE_DOMAIN` on the metalake. Creating a subdomain requires +management on both the metalake and parent. Attaching/moving requires management on the child +(using its current scopes) and the new parent. Other mutations require management on the domain. +Privileges are evaluated over the metalake, current parent (if any), and domain. An allow on any +scope suffices only when no scope denies that privilege. An explicit `USE_DOMAIN` deny prevents +use even with an allowed `MANAGE_DOMAIN`. Owners of the domain, current parent or metalake bypass +these privilege denies. Service administrators retain administrative access. + +A draft is omitted from lists for callers who cannot manage it; direct access returns +`NoSuchDomainException` (404). A published domain without use permission is omitted from lists, +but direct access returns `ForbiddenException` (403). A child snapshot can still name a hidden +draft parent; this does not authorize loading the parent. Moving/detaching changes the inherited +scopes immediately, without rewriting grants: former parent permissions stop applying. + +Domain visibility and data visibility are separate. Member lists filter out leaf objects the caller +cannot access under ordinary metadata authorization. Reverse lookup of an inaccessible object +returns 403. `USE_DOMAIN` and `MANAGE_DOMAIN` do not grant catalog/schema use, table selection, +fileset access, model access or any backend data permission. A hidden child contributes no +`VIA_SUBDOMAIN` relation, in either query direction. Relations with no visible membership path +are removed. An `INHERITED` relation for an accessible leaf retains the complete source catalog or +schema name; the source is explanatory metadata and is not separately authorized by this query. + +Tag privileges are also separate. Creating a new backing tag requires `CREATE_TAG` on the metalake +in addition to Domain management. Binding an existing tag requires ownership of that tag or the +metalake; Domain ownership alone does not confer tag ownership. Removing a binding requires no tag +privilege. Assigning/removing tags on member metadata uses the existing tag authorization rules; +Domain management does not confer assignment rights. Reading Domain membership does not require +`VIEW_TAG`, `APPLY_TAG` or tag ownership. + +For example, after creating user `domain_reader`, grant a role over a published Finance domain: + +```shell +curl --fail-with-body -u anonymous:dummy -H 'Content-Type: application/json' \ + -d '{"name":"finance_reader","properties":{},"securableObjects":[{"fullName":"Finance","type":"domain","privileges":[{"name":"USE_DOMAIN","condition":"ALLOW"}]}]}' \ + http://127.0.0.1:8090/api/metalakes/test/roles +curl --fail-with-body -u anonymous:dummy -X PUT -H 'Content-Type: application/json' \ + -d '{"roleNames":["finance_reader"]}' \ + http://127.0.0.1:8090/api/metalakes/test/permissions/users/domain_reader/grant +``` + +Use the role/user APIs from the walkthrough above to create the user first. This role permits +published Finance discovery and inherited use of its published children, but a member list can +still be empty until the user has ordinary access to member objects. Replacing `USE_DOMAIN` with +`MANAGE_DOMAIN` grants management and draft visibility. A child `USE_DOMAIN` deny can exclude that +child from the reader's inherited access. See the [Domain guide](../manage-domains-in-gravitino.md) +for executable SDK examples, lifecycle constraints, tag rules and REST errors. diff --git a/docs/tags.md b/docs/tags.md index f35a3d5cc5..b47ce9744b 100644 --- a/docs/tags.md +++ b/docs/tags.md @@ -175,3 +175,8 @@ user is allowed to read. Tags can be created, attached, and read over REST and through the Java and Python clients, which is also the only way to tag views, filesets, topics, models, and functions today. Endpoints, payload shapes, and worked examples are in [Manage Tags](./manage-tags-in-gravitino.md). + +[Domains](./domains.md) use explicit backing tags to derive business membership from these same +assignments, including catalog/schema inheritance. See +[Manage domains](./manage-domains-in-gravitino.md#backing-tag-operations) for binding conflicts, +tag identity and the separation of Domain and tag permissions.
