mchades commented on code in PR #7187: URL: https://github.com/apache/gravitino/pull/7187#discussion_r2114087534
########## api/src/main/java/org/apache/gravitino/policy/SupportsPolicies.java: ########## @@ -0,0 +1,65 @@ +/* + * 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. + */ +package org.apache.gravitino.policy; + +import org.apache.gravitino.annotation.Evolving; +import org.apache.gravitino.exceptions.NoSuchPolicyException; +import org.apache.gravitino.exceptions.PolicyAlreadyAppliedException; + +/** + * The interface for supporting getting or applying policies to a metadata object. This interface + * will be mixed with metadata objects to provide policy operations. + */ +@Evolving +public interface SupportsPolicies { + /** @return List all the policy names for the specific object. */ + String[] listPolicies(); + + /** @return List all the policies with details for the specific object. */ + Policy[] listPolicyInfos(); + + /** + * Get a policy by its name for the specific object. + * + * @param name The name of the policy. + * @return The policy. + * @throws NoSuchPolicyException If the policy does not associate with the object. + */ + Policy getPolicy(String name) throws NoSuchPolicyException; + + /** + * Apply policies to the specific object. The policiesToApply will be applied to the object and + * the policiesToRemove will be removed from the object. Note that: + * + * <ol> + * <li>Applying or removing policies that are not existed will be ignored. + * <li>If the same name policy is in both policiesToApply and policiesToRemove, it will be + * ignored. + * <li>If the policy is already applied to the object, it will throw {@link + * PolicyAlreadyAppliedException} + * </ol> + * + * @param policiesToApply The policies to apply. + * @param policiesToRemove The policies to remove. + * @return The list of applied policies. + * @throws PolicyAlreadyAppliedException If the policy is already applied to the object. + */ + String[] applyPolicies(String[] policiesToApply, String[] policiesToRemove) Review Comment: change all to `associate` -- 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]
