mchades commented on code in PR #14774:
URL: https://github.com/apache/gravitino/pull/14774#discussion_r4535711177


##########
clients/client-python/gravitino/api/metadata_object.py:
##########
@@ -75,6 +75,9 @@ class Type(Enum):
         MODEL = "model"
         """A model is mapped to the model artifact in ML."""
 
+        DOMAIN = "domain"

Review Comment:
   `get_role()` raises `KeyError` when a role contains `use_domain` or 
`manage_domain`, because `PrivilegeDTO` looks up the name in `Privilege.Name`. 
`Privileges.allow("USE_DOMAIN")` also fails before a grant can be sent. Please 
register both privileges for metalakes and domains, and include `DOMAIN` in the 
`MANAGE_GRANTS` binding set to match the server.



##########
clients/client-python/gravitino/dto/metadata_object_dto.py:
##########
@@ -61,7 +61,7 @@ def set_full_name(self, full_name: str) -> None:
         Args:
             full_name (str): The full name of the metadata object.
         """
-        index = full_name.rfind(".")
+        index = -1 if self._type == MetadataObject.Type.DOMAIN else 
full_name.rfind(".")

Review Comment:
   `SecurableObjectDTO` needs the same domain-name handling. I loaded a role 
with `MANAGE_GRANTS` on `Finance.US` and got `name() == "US"` and `parent() == 
"Finance"`. Please preserve the full name and return `None` for the parent when 
decoding a `DOMAIN` in a role response.



##########
clients/client-python/gravitino/exceptions/base.py:
##########
@@ -299,3 +299,19 @@ class NoSuchGroupException(NotFoundException):
 
 class GroupAlreadyExistsException(AlreadyExistsException):
     """An exception thrown when a group already exists."""
+
+
+class NoSuchDomainException(NotFoundException):
+    """The domain does not exist or is not visible to the caller."""
+
+
+class DomainAlreadyExistsException(AlreadyExistsException):
+    """A domain with the requested name already exists."""
+
+
+class BackingTagAlreadyBoundException(AlreadyExistsException):
+    """The backing tag conflicts with another domain's binding."""
+
+
+class NonEmptyDomainException(GravitinoRuntimeException):

Review Comment:
   `except NotEmptyException` misses a `delete_domain()` failure when the 
domain still has children. Please derive `NonEmptyDomainException` from 
`NotEmptyException`, as `NonEmptySchemaException` does, so callers can handle 
nonempty resources consistently.



##########
clients/client-python/gravitino/api/metadata_objects.py:
##########
@@ -193,8 +195,8 @@ def parse(full_name: str, type_: MetadataObject.Type) -> 
MetadataObject:
         )
 
         parts = full_name.split(MetadataObjects.DOT_SPLITTER)
-        if type_ is MetadataObject.Type.ROLE:
-            return MetadataObjects.of([full_name], MetadataObject.Type.ROLE)
+        if type_ in {MetadataObject.Type.ROLE, MetadataObject.Type.DOMAIN}:

Review Comment:
   `MetadataObjects.of("Tax", MetadataObject.Type.DOMAIN, parent="Finance")` 
produces `Finance.Tax`. Passing that object to `set_owner()` sends the request 
to `/owners/domain/Finance.Tax`, even though the subdomain is addressed as 
`Tax`. Please reject an explicit parent in the string overload for `DOMAIN`, 
while keeping literal dots valid in `parse()`.



##########
clients/client-python/gravitino/api/domain/domain_operations.py:
##########
@@ -0,0 +1,70 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+from abc import ABC, abstractmethod
+from typing import Optional
+
+from gravitino.api.domain.domain import Domain
+from gravitino.api.domain.domain_change import DomainChange
+from gravitino.api.tag.tag_value import TagValue
+
+
+class DomainOperations(ABC):
+    """Metalake domain management. Hidden drafts are omitted or return 404."""
+
+    @abstractmethod
+    def list_domains(self) -> list[str]:
+        """List visible domain names, including subdomains."""
+        raise NotImplementedError
+
+    @abstractmethod
+    def list_domains_info(self) -> list[Domain]:
+        """List visible domain snapshots, including subdomains."""
+        raise NotImplementedError
+
+    @abstractmethod
+    def get_domain(self, name: str) -> Domain:
+        """Load by name; absent or hidden drafts raise 
NoSuchDomainException."""
+        raise NotImplementedError
+
+    @abstractmethod
+    def create_domain(
+        self,
+        name: str,
+        comment: Optional[str],
+        properties: Optional[dict[str, str]],
+        backing_tag: TagValue,
+        create_backing_tag: bool,
+    ) -> Domain:
+        """Create a draft top-level domain, explicitly creating or binding its 
tag.
+
+        A new tag cannot have a value. Existing tags are never adopted 
implicitly.
+        Domain and new tag creation are atomic. Conflicts raise
+        DomainAlreadyExistsException, TagAlreadyExistsException or
+        BackingTagAlreadyBoundException; missing tags raise NoSuchTagException.
+        """
+        raise NotImplementedError
+
+    @abstractmethod
+    def alter_domain(self, name: str, *changes: DomainChange) -> Domain:

Review Comment:
   Mypy rejects `ops.alter_domain("Finance", 
DomainChange.rename("Accounting"))` because the factory returns `RenameDomain`, 
which does not inherit `DomainChange`. The other three factories have the same 
mismatch. Please give the variants a common base accepted here or annotate 
`*changes` with their union.



##########
clients/client-python/tests/unittests/test_domain_client.py:
##########
@@ -0,0 +1,721 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+import json
+import unittest
+from dataclasses import FrozenInstanceError
+from io import BytesIO
+from unittest.mock import MagicMock, patch
+from urllib.error import HTTPError
+from urllib.parse import parse_qs, urlsplit
+
+from gravitino.api.file.fileset import Fileset
+from gravitino.api.model.model import Model
+from gravitino.api.rel.table import Table
+from gravitino.api.rel.view import View
+from gravitino.api.semantic.semantic_model import SemanticModel
+from gravitino.api.domain import (
+    Domain,
+    DomainChange,
+    DomainMemberFilter,
+    DomainRelation,
+    SupportsDomains,
+)
+from gravitino.api.metadata_object import MetadataObject
+from gravitino.api.metadata_objects import MetadataObjects
+from gravitino.api.tag.tag_value import TagValue
+from gravitino.client.generic_domain import GenericDomain
+from gravitino.client.generic_fileset import GenericFileset
+from gravitino.client.generic_model import GenericModel
+from gravitino.client.generic_semantic_model import GenericSemanticModel
+from gravitino.client.generic_view import GenericView
+from gravitino.client.gravitino_metalake import GravitinoMetalake
+from gravitino.client.gravitino_client import GravitinoClient
+from gravitino.client.metadata_object_domain_operations import (
+    MetadataObjectDomainOperations,
+)
+from gravitino.client.relational_table import RelationalTable
+from gravitino.constants.error import ErrorConstants
+from gravitino.dto.domain_dto import DomainDTO
+from gravitino.dto.metadata_object_dto import MetadataObjectDTO
+from gravitino.dto.metalake_dto import MetalakeDTO
+from gravitino.dto.requests.domain_create_request import (
+    BackingTagCreate,
+    DomainCreateRequest,
+)
+from gravitino.dto.requests.domain_set_request import (
+    DomainBackingTagSetRequest,
+    DomainParentSetRequest,
+    DomainSetRequest,
+)
+from gravitino.dto.requests.domain_updates_request import DomainUpdatesRequest
+from gravitino.dto.responses.domain_response import (
+    DomainListResponse,
+    DomainNamesListResponse,
+    DomainResponse,
+)
+from gravitino.exceptions.base import (
+    BackingTagAlreadyBoundException,
+    DomainAlreadyExistsException,
+    ForbiddenException,
+    IllegalArgumentException,
+    MetalakeNotInUseException,
+    NoSuchDomainException,
+    NoSuchMetalakeException,
+    NoSuchMetadataObjectException,
+    NoSuchTagException,
+    NonEmptyDomainException,
+    OptimisticLockException,
+    RESTException,
+    TagAlreadyExistsException,
+    UnauthorizedException,
+    UnsupportedOperationException,
+)
+from gravitino.namespace import Namespace
+from gravitino.rest.rest_utils import encode_string
+from gravitino.utils.http_client import HTTPClient
+
+
+class TestDomainClient(unittest.TestCase):
+    METALAKE = "lake/with. spaces?&+%"
+    NAME = "Finance/US. East,?&+%"
+
+    def setUp(self):
+        self.client = HTTPClient("http://localhost:8090";)
+        self.metalake = GravitinoMetalake(
+            MetalakeDTO(self.METALAKE, None, {}, None), self.client
+        )
+        self.opener_patch = patch("gravitino.utils.http_client.build_opener")
+        self.opener = self.opener_patch.start().return_value
+        self.addCleanup(self.opener_patch.stop)
+        self.path = f"/api/metalakes/{encode_string(self.METALAKE)}/domains"
+
+    def _dto(self, **overrides):
+        data = {
+            "name": self.NAME,
+            "comment": "comment",
+            "properties": {"a": "b"},
+            "status": "draft",
+            "parent": None,
+            "backingTag": {"name": "department", "value": "finance"},
+            "audit": {"creator": "user", "createTime": "2026-10-01T00:00:00Z"},
+        }
+        data.update(overrides)
+        return data
+
+    def _respond(self, body):
+        response = MagicMock()
+        response.getcode.return_value = 200
+        response.read.return_value = json.dumps(body).encode()
+        self.opener.open.return_value = response
+        self.opener.open.side_effect = None
+
+    def _domain(self, **overrides):
+        return GenericDomain(
+            self.METALAKE, DomainDTO.from_dict(self._dto(**overrides)), 
self.client
+        )
+
+    def _request(self, method, path, body=None, query=None):
+        request = self.opener.open.call_args.args[0]
+        self.assertEqual(method, request.get_method())
+        self.assertEqual(path, urlsplit(request.full_url).path)
+        self.assertEqual(query or {}, 
parse_qs(urlsplit(request.full_url).query))
+        self.assertEqual(body, json.loads(request.data) if request.data else 
None)
+        return request
+
+    def test_snapshot_fields_and_defensive_copies(self):
+        dto = DomainDTO.from_dict(self._dto())
+        domain = GenericDomain(self.METALAKE, dto, self.client)
+        dto._properties["a"] = "changed"  # pylint: disable=protected-access
+        self.assertEqual(self.NAME, domain.name())
+        self.assertEqual("comment", domain.comment())
+        self.assertEqual(Domain.Status.DRAFT, domain.status())
+        self.assertIsNone(domain.parent())
+        self.assertEqual(TagValue("department", "finance"), 
domain.backing_tag())
+        self.assertEqual("user", domain.audit_info().creator())
+        domain.properties()["a"] = "changed"
+        self.assertEqual({"a": "b"}, domain.properties())
+        self.assertEqual([], domain.relations())
+        self.assertIsNone(self._domain(backingTag=None).backing_tag())
+
+    def test_create_top_level_and_subdomain(self):
+        for parent in (None, self.NAME):
+            for create, tag in (
+                (True, TagValue("new/tag")),
+                (False, TagValue("dept", "finance")),
+            ):
+                with self.subTest(parent=parent, create=create):
+                    self._respond(
+                        {"code": 0, "domain": self._dto(name="child", 
parent=parent)}
+                    )
+                    if parent is None:
+                        domain = self.metalake.create_domain(
+                            "child", None, None, tag, create
+                        )
+                    else:
+                        domain = self._domain().create_subdomain(
+                            "child", None, None, tag, create
+                        )
+                    self.assertEqual("child", domain.name())
+                    self.assertEqual(parent, domain.parent())
+                    self._request(
+                        "POST",
+                        self.path,
+                        {
+                            "name": "child",
+                            "comment": None,
+                            "properties": None,
+                            "parent": parent,
+                            "backingTag": {
+                                "name": tag.name(),
+                                "value": tag.value(),
+                                "create": create,
+                            },
+                        },
+                    )
+
+    def test_list_and_get_domains(self):
+        self._respond({"code": 0, "names": [self.NAME]})
+        self.assertEqual([self.NAME], self.metalake.list_domains())
+        self._request("GET", self.path)
+        self._respond({"code": 0, "domains": [self._dto()]})
+        self.assertEqual(self.NAME, 
self.metalake.list_domains_info()[0].name())
+        self._request("GET", self.path, query={"details": ["true"]})
+        self._respond({"code": 0, "domain": self._dto()})
+        self.assertEqual(self.NAME, self.metalake.get_domain(self.NAME).name())
+        self._request("GET", self.path + "/" + encode_string(self.NAME))
+
+    def test_list_responses_require_explicit_arrays(self):
+        for field, operation in (
+            ("names", self.metalake.list_domains),
+            ("domains", self.metalake.list_domains_info),
+            ("members", lambda: 
self._domain().list_members(DomainMemberFilter())),
+        ):
+            for payload in ({"code": 0}, {"code": 0, field: None}):
+                with self.subTest(field=field, payload=payload):
+                    self._respond(payload)
+                    with self.assertRaises(IllegalArgumentException):
+                        operation()
+            with self.subTest(field=field, value=[]):
+                self._respond({"code": 0, field: []})
+                self.assertEqual([], operation())
+
+    def test_alter_domain_serializes_all_changes(self):
+        self._respond({"code": 0, "domain": self._dto(name="renamed")})
+        result = self.metalake.alter_domain(
+            self.NAME,
+            DomainChange.rename("renamed"),
+            DomainChange.update_comment(None),
+            DomainChange.set_property("key", ""),
+            DomainChange.remove_property("old"),
+        )
+        self.assertEqual("renamed", result.name())
+        self._request(
+            "PUT",
+            self.path + "/" + encode_string(self.NAME),
+            {
+                "updates": [
+                    {"@type": "rename", "newName": "renamed"},
+                    {"@type": "updateComment", "newComment": None},
+                    {"@type": "setProperty", "property": "key", "value": ""},
+                    {"@type": "removeProperty", "property": "old"},
+                ]
+            },
+        )
+
+    def test_empty_alter_domain(self):
+        self._respond({"code": 0, "domain": self._dto()})
+        self.assertEqual(self._domain(), self.metalake.alter_domain(self.NAME))
+        self._request(
+            "PUT", self.path + "/" + encode_string(self.NAME), {"updates": []}
+        )
+
+    def test_snapshot_equality(self):
+        dto = DomainDTO.from_dict(self._dto())
+        other_client = GenericDomain(self.METALAKE, dto, MagicMock())
+        self.assertEqual({self._domain(), other_client}, {other_client})
+        self.assertNotEqual(other_client, GenericDomain("other", dto, 
self.client))
+        for changes in (
+            {"name": "new"},
+            {"comment": None},
+            {"properties": {}},
+            {"status": "published"},
+            {"parent": "parent"},
+            {"backingTag": None},
+            {"audit": {"creator": "other"}},
+            {"relations": [{"relation": "direct"}]},
+        ):
+            with self.subTest(changes=changes):
+                self.assertNotEqual(other_client, self._domain(**changes))
+
+    def test_invalid_inherited_source(self):
+        for source in (None, {"fullName": "cat.schema.table", "type": 
"table"}):
+            domain = self._domain(
+                relations=[{"relation": "inherited", "source": source}]
+            )
+            with self.assertRaises(IllegalArgumentException):
+                domain.relations()
+
+    def test_dot_segment_snapshot(self):
+        for name in (".", ".."):
+            domain = self._domain(name=name)
+            self.assertEqual(name, domain.name())
+            with self.assertRaises(IllegalArgumentException):
+                domain.publish()
+        self.opener.open.assert_not_called()
+
+    def test_delete_domain(self):
+        for dropped in (True, False):
+            self._respond({"code": 0, "dropped": dropped})
+            self.assertEqual(dropped, self.metalake.delete_domain(self.NAME))
+            self._request("DELETE", self.path + "/" + encode_string(self.NAME))
+
+    def test_mutations_return_new_snapshots_addressed_by_old_name(self):
+        old = self._domain()
+        operations = (
+            (
+                old.publish,
+                "PATCH",
+                "",
+                {"status": "published"},
+                {"status": "published"},
+            ),
+            (old.unpublish, "PATCH", "", {"status": "draft"}, {"status": 
"draft"}),
+            (
+                lambda: old.attach_to_parent("Parent/with. spaces"),
+                "PUT",
+                "/parent",
+                {"parent": "Parent/with. spaces"},
+                {"parent": "Parent/with. spaces"},
+            ),
+            (old.detach_from_parent, "DELETE", "/parent", None, {"parent": 
None}),
+            (
+                lambda: old.update_backing_tag(TagValue("tag/new", "v")),
+                "PUT",
+                "/backingTag",
+                {"backingTag": {"name": "tag/new", "value": "v"}},
+                {"backingTag": {"name": "tag/new", "value": "v"}},
+            ),
+            (
+                lambda: old.update_backing_tag(None),
+                "PUT",
+                "/backingTag",
+                {"backingTag": None},
+                {"backingTag": None},
+            ),
+        )
+        for operation, method, suffix, body, changes in operations:
+            with self.subTest(method=method, body=body):
+                self._respond({"code": 0, "domain": self._dto(**changes)})
+                result = operation()
+                self.assertIsNot(old, result)
+                self.assertEqual(Domain.Status.DRAFT, old.status())
+                self.assertIsNone(old.parent())
+                self.assertEqual(TagValue("department", "finance"), 
old.backing_tag())
+                self.assertEqual(
+                    DomainDTO.from_dict(self._dto(**changes)).status(), 
result.status()
+                )
+                self.assertEqual(changes.get("parent"), result.parent())
+                self.assertEqual(
+                    self._domain(**changes).backing_tag(), result.backing_tag()
+                )
+                self._request(
+                    method, self.path + "/" + encode_string(self.NAME) + 
suffix, body
+                )
+        # A rename result has a new name; the existing snapshot keeps 
addressing its own name.
+        self._respond(
+            {"code": 0, "domain": self._dto(name="replacement", 
status="published")}
+        )
+        self.assertEqual("replacement", old.publish().name())
+        self._request(
+            "PATCH", self.path + "/" + encode_string(self.NAME), {"status": 
"published"}
+        )
+        self.assertEqual(self.NAME, old.name())
+
+    def test_list_subdomains(self):
+        domain = self._domain()
+        self._respond({"code": 0, "names": ["Tax"]})
+        self.assertEqual(["Tax"], domain.list_subdomains())
+        path = self.path + "/" + encode_string(self.NAME) + "/subdomains"
+        self._request("GET", path)
+        self._respond({"code": 0, "domains": [self._dto(name="Tax", 
parent=self.NAME)]})
+        child = domain.list_subdomains_info()[0]
+        self.assertEqual("Tax", child.name())
+        self.assertEqual(self.NAME, child.parent())
+        self._request("GET", path, query={"details": ["true"]})
+
+    def test_members_filters_and_relations(self):
+        relations = [
+            {"relation": "direct"},
+            {
+                "relation": "inherited",
+                "source": {"fullName": "cat.schema", "type": "schema"},
+            },
+            {
+                "relation": "via_subdomain",
+                "source": {"fullName": "Trading.US/a b", "type": "domain"},
+            },
+        ]
+        self._respond(
+            {
+                "code": 0,
+                "members": [
+                    {
+                        "object": {"fullName": "cat.schema.table", "type": 
"table"},
+                        "relations": relations,
+                    }
+                ],
+            }
+        )
+        scopes = ("Tax,EU", "Trading/US. East&?+%")
+        member_filter = DomainMemberFilter(
+            types=(MetadataObject.Type.TABLE, MetadataObject.Type.VIEW),
+            name_contains="a b/&?+=%,",
+            domains=scopes,
+        )
+        reversed_filter = DomainMemberFilter(
+            types=tuple(reversed(member_filter.types)),
+            name_contains=member_filter.name_contains,
+            domains=tuple(reversed(scopes)),
+        )
+        self.assertEqual({member_filter}, {reversed_filter})
+        member = self._domain().list_members(member_filter)[0]
+        self._request(
+            "GET",
+            self.path + "/" + encode_string(self.NAME) + "/objects",
+            query={
+                "types": ["TABLE,VIEW"],
+                "nameContains": ["a b/&?+=%,"],
+                "domains": list(scopes),
+            },
+        )
+        self.assertEqual(MetadataObject.Type.TABLE, member.object().type())
+        self.assertEqual("cat.schema.table", member.object().full_name())
+        self.assertEqual(
+            [
+                DomainRelation.Type.DIRECT,
+                DomainRelation.Type.INHERITED,
+                DomainRelation.Type.VIA_SUBDOMAIN,
+            ],
+            [r.type() for r in member.relations()],
+        )
+        self.assertIsNone(member.relations()[0].source())
+        self.assertEqual("cat.schema", 
member.relations()[1].source().full_name())
+        self.assertEqual("Trading.US/a b", 
member.relations()[2].source().name())
+        self.assertIsNone(member.relations()[2].source().parent())
+        self.assertEqual(
+            MetadataObjects.parse("cat.schema.table", 
MetadataObject.Type.TABLE),
+            member.object(),
+        )
+        self.assertEqual({member}, 
{self._domain().list_members(member_filter)[0]})
+        other = GenericDomain("other", DomainDTO.from_dict(self._dto()), 
self.client)
+        self.assertNotEqual(member, other.list_members(member_filter)[0])
+        member.relations().clear()
+        self.assertEqual(3, len(member.relations()))
+        self._respond({"code": 0, "members": []})
+        self.assertEqual([], self._domain().list_members(DomainMemberFilter()))
+        self._request("GET", self.path + "/" + encode_string(self.NAME) + 
"/objects")
+
+    def test_leaf_lookup_all_six_types(self):
+        for object_type in (
+            MetadataObject.Type.TABLE,
+            MetadataObject.Type.VIEW,
+            MetadataObject.Type.FILESET,
+            MetadataObject.Type.TOPIC,
+            MetadataObject.Type.MODEL,
+            MetadataObject.Type.SEMANTIC_MODEL,
+        ):
+            with self.subTest(object_type=object_type):
+                name = "cat.schema.leaf/with spaces?&+%"
+                operations = MetadataObjectDomainOperations(

Review Comment:
   The topic case constructs the HTTP delegate directly. `as_topic_catalog()` 
currently raises `UnsupportedOperationException`, so SDK callers with a topic 
identifier have to supply the transport themselves. Could `GravitinoMetalake` 
expose this lookup for a `MetadataObject`? The topic case could then use that 
public entry point. [Python topic client 
issue](https://github.com/apache/gravitino/issues/3804)



##########
clients/client-python/gravitino/api/domain/domain_member_filter.py:
##########
@@ -0,0 +1,71 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+from dataclasses import dataclass
+from typing import Optional
+
+from gravitino.api.domain.domain_member import DomainMember
+from gravitino.api.metadata_object import MetadataObject
+from gravitino.utils.precondition import Precondition
+
+
+@dataclass(frozen=True)
+class DomainMemberFilter:
+    """Narrow a domain's scope by types, case-insensitive name text and scopes.
+
+    Empty options do not narrow the result. Domains select the union of the 
named
+    scopes: the listed domain itself (including visible children), or its 
children.
+    Unknown or invisible scope names are ignored by the server.
+    """
+
+    types: tuple[MetadataObject.Type, ...] = ()
+    name_contains: Optional[str] = None
+    domains: tuple[str, ...] = ()
+
+    def _criteria(self) -> tuple:
+        return frozenset(self.types), self.name_contains, 
frozenset(self.domains)
+
+    def __eq__(self, other: object) -> bool:
+        if not isinstance(other, DomainMemberFilter):
+            return NotImplemented
+        return self._criteria() == other._criteria()
+
+    def __hash__(self) -> int:
+        return hash(self._criteria())
+
+    def __post_init__(self) -> None:
+        Precondition.check_argument(self.types is not None, "types must not be 
None")
+        Precondition.check_argument(
+            self.domains is not None, "domains must not be None"
+        )
+        object.__setattr__(self, "types", tuple(dict.fromkeys(self.types)))
+        object.__setattr__(self, "domains", tuple(dict.fromkeys(self.domains)))

Review Comment:
   `DomainMemberFilter(domains="Tax")` silently sends 
`?domains=T&domains=a&domains=x`. A populated `Tax` scope can then appear 
empty. Please reject a bare `str` before deduplication or normalize it to a 
single domain name.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to