roryqi commented on code in PR #12549:
URL: https://github.com/apache/gravitino/pull/12549#discussion_r3851818263
##########
api/src/main/java/org/apache/gravitino/tag/TagOperations.java:
##########
@@ -115,4 +119,69 @@ Tag alterTag(String name, TagChange... changes)
* @return True if the tag is deleted, false if the tag does not exist.
*/
boolean deleteTag(String name);
+
+ /**
+ * Lists policy names directly associated with a tag.
+ *
+ * @param tagName The tag name.
+ * @return The directly associated policy names.
+ * @throws UnsupportedOperationException If listing policy-to-tag
associations is not supported.
+ */
+ default String[] listPoliciesForTag(String tagName) {
+ throw new UnsupportedOperationException("Listing policies for a tag is not
supported");
+ }
+
+ /**
+ * Lists detailed policy associations for a tag.
+ *
+ * @param tagName The tag name.
+ * @return The policy associations including selectors.
+ * @throws UnsupportedOperationException If listing policy-to-tag
associations is not supported.
+ */
+ default PolicyTagAssociation[] listPolicyAssociationsForTag(String tagName) {
+ throw new UnsupportedOperationException(
+ "Listing policy associations for a tag is not supported");
+ }
+
+ /**
+ * Adds one policy association for a tag using {@link AllValuesSelector}. It
matches by tag
+ * presence regardless of assignment values and does not replace an existing
association.
+ *
+ * @param tagName The tag name.
+ * @param policyName The policy name.
+ * @return The resulting association.
+ * @throws PolicyAlreadyAssociatedException If the policy is already
associated with the tag.
+ * @throws UnsupportedOperationException If adding policy-to-tag
associations is not supported.
+ */
+ default PolicyTagAssociation addPolicyForTag(String tagName, String
policyName)
+ throws PolicyAlreadyAssociatedException {
+ return addPolicyForTag(tagName, policyName, AllValuesSelector.get());
+ }
+
+ /**
+ * Adds one policy association for a tag. It does not replace an existing
association.
+ *
+ * @param tagName The tag name.
+ * @param policyName The policy name.
+ * @param selector The non-null policy association selector.
+ * @return The resulting association.
+ * @throws PolicyAlreadyAssociatedException If the policy is already
associated with the tag.
+ * @throws UnsupportedOperationException If adding policy-to-tag
associations is not supported.
+ */
+ default PolicyTagAssociation addPolicyForTag(
+ String tagName, String policyName, PolicyAssociationSelector selector)
+ throws PolicyAlreadyAssociatedException {
+ throw new UnsupportedOperationException("Adding a policy for a tag is not
supported");
+ }
+
+ /**
+ * Removes one policy association from a tag.
+ *
+ * @param tagName The tag name.
+ * @param policyName The policy name.
+ * @throws UnsupportedOperationException If removing policy-to-tag
associations is not supported.
+ */
+ default void removePolicyFromTag(String tagName, String policyName) {
+ throw new UnsupportedOperationException("Removing a policy from a tag is
not supported");
+ }
Review Comment:
That is not the intended identity. The unique key is (tag_id, policy_id),
and each relation contains exactly one selector. The selector is a mutable
predicate of the relation, not part of its key. If a condition needs multiple
values or clauses, one composite selector should express the AND/OR
relationship explicitly. Therefore, selector A and selector B are not separate
relations to delete: changing the condition replaces the selector, while remove
deletes the unique policy-to-tag relation. My concern with allowing multiple
selectors is that their relationship would be implicit and ambiguous: it would
be unclear whether they are combined with AND or OR, and the lifecycle would
become more complex. Is there a concrete use case that cannot be represented by
one selector with explicit AND/OR semantics?
--
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]