unknowntpo commented on code in PR #8545: URL: https://github.com/apache/gravitino/pull/8545#discussion_r2393360006
########## clients/client-python/gravitino/api/policy/policy.py: ########## @@ -0,0 +1,193 @@ +# 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 enum import Enum + +from gravitino.api.auditable import Auditable +from gravitino.api.metadata_object import MetadataObject +from gravitino.api.policy.policy_content import PolicyContent +from gravitino.api.policy.policy_contents import PolicyContents +from gravitino.exceptions.base import ( + IllegalArgumentException, + UnsupportedOperationException, +) +from gravitino.utils.precondition import Precondition + + +class Policy(Auditable): + """The interface of the policy. + + The policy is a set of rules that can be associated with a metadata object. + The policy can be used for data governance and so on. + """ + + BUILT_IN_TYPE_PREFIX: str = "system_" + """The prefix for built-in policy types. All built-in policy types should start with this prefix.""" + + @abstractmethod + def name(self) -> str: + """Get the name of the policy. + + Returns: + The name of the policy. + """ + + @abstractmethod + def policy_type(self) -> str: + """Get the type of the policy. + + Returns: + str: The type of the policy. + """ + + @abstractmethod + def comment(self) -> str: + """Get the comment of the policy. + + Returns: + str: The comment of the policy. + """ + + @abstractmethod + def enabled(self) -> bool: + """Whether the policy is enabled or not. + + Returns: + bool: `True` if the policy is enabled, False otherwise. + """ + + @abstractmethod + def content(self) -> PolicyContent: + """Get the content of the policy. + + Returns: + PolicyContent: The content of the policy. + """ + + @abstractmethod + def inherited(self) -> bool: Review Comment: LGTM. -- 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]
