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


##########
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:
   Fixed in d66fe9395d. `NonEmptyDomainException` now extends 
`NotEmptyException`. A regression test calls `delete_domain()` and checks that 
catching the base exception preserves the specific domain exception.



##########
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:
   Fixed in d66fe9395d. `alter_domain()` now accepts the union of the four 
types returned by the `DomainChange` factories. I verified the rename example 
and the other three factory calls with mypy.



##########
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:
   Fixed in d66fe9395d. `DomainMemberFilter(domains="Tax")` now treats the 
string as a single scope. The regression test checks that `list_members()` 
sends exactly one `domains=Tax` query parameter.



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