Abyss-lord commented on code in PR #9378: URL: https://github.com/apache/gravitino/pull/9378#discussion_r2621959974
########## clients/client-python/gravitino/api/authorization/privileges.py: ########## @@ -0,0 +1,197 @@ +# 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 __future__ import annotations + +from abc import ABC, abstractmethod +from enum import Enum +from typing import TYPE_CHECKING + +from gravitino.api.metadata_object import MetadataObject + +if TYPE_CHECKING: + pass + + +class Privilege(ABC): + """The interface of a privilege. The privilege represents the ability to execute + kinds of operations for kinds of entities + """ + + @abstractmethod + def name(self) -> Privilege.Name: + """ + Return the generic name of the privilege. + + Raises: + NotImplementedError: If the method is not implemented. + + Returns: + Privilege.Name: The generic name of the privilege. + """ + raise NotImplementedError() + + @abstractmethod + def simple_string(self) -> str: + """ + Return a simple string representation of the privilege. + + Raises: + NotImplementedError: If the method is not implemented. + + Returns: + str: A readable string representation for the privilege. + """ + raise NotImplementedError() + + @abstractmethod + def condition(self) -> "Privilege.Condition": + """ + Return the condition of the privilege. + + raises: + NotImplementedError: If the method is not implemented. + + Returns: + Privilege.Condition: The condition of the privilege. + `ALLOW` means that you are allowed to use the privilege, + `DENY` means that you are denied to use the privilege + """ + raise NotImplementedError() + + @abstractmethod + def can_bind_to(self, obj_type: MetadataObject.Type) -> bool: + """ + Check whether this privilege can bind to a securable object type. + + Args: + obj_type: The securable object's metadata type. + + Returns: + True if this privilege can bind to the given type, otherwise False. + """ + raise NotImplementedError() + + class Name(Enum): + """The name of this privilege.""" + + # The privilege to create a catalog. Review Comment: fix -- 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]
