@@ -600,6 +600,14 @@ def add_policies(self, rules):
600600 with self ._wl :
601601 return self ._e .add_policies (rules )
602602
603+ def add_policies_ex (self , rules ):
604+ """Adds authorization rules to the current policy,skipping existing rules instead of returning an error.
605+
606+ If a rule already exists, it will be skipped,
607+ and other non-existent rules will be added."""
608+ with self ._wl :
609+ return self ._e .add_policies_ex (rules )
610+
603611 def add_named_policies (self , ptype , rules ):
604612 """adds authorization rules to the current named policy.
605613
@@ -608,6 +616,15 @@ def add_named_policies(self, ptype, rules):
608616 with self ._wl :
609617 return self ._e .add_named_policies (ptype , rules )
610618
619+ def add_named_policies_ex (self , ptype , rules ):
620+ """adds authorization rules to the current named policy, ignoring duplicates.
621+
622+ If the rule already exists, it will be skipped.
623+ Other non-existent rules are added.
624+ """
625+ with self ._wl :
626+ return self ._e .add_named_policies_ex (ptype , rules )
627+
611628 def remove_policies (self , rules ):
612629 """removes authorization rules from the current policy."""
613630 with self ._wl :
@@ -627,6 +644,16 @@ def add_grouping_policies(self, rules):
627644 with self ._wl :
628645 return self ._e .add_grouping_policies (rules )
629646
647+ def add_grouping_policies_ex (self , rules ):
648+ """adds grouping rules to the current policy, ignoring duplicates.
649+
650+ This is a wrapper for add_named_grouping_policies_ex with policy type "g".
651+ If the rule already exists, it will be skipped.
652+ Other non-existent rules are added.
653+ """
654+ with self ._wl :
655+ return self ._e .add_named_grouping_policies_ex ("g" , rules )
656+
630657 def add_named_grouping_policies (self , ptype , rules ):
631658 """ "adds named role inheritance rules to the current policy.
632659
@@ -635,6 +662,15 @@ def add_named_grouping_policies(self, ptype, rules):
635662 with self ._wl :
636663 return self ._e .add_named_grouping_policies (ptype , rules )
637664
665+ def add_named_grouping_policies_ex (self , ptype , rules ):
666+ """adds grouping rules to the specified policy type, ignoring duplicates.
667+
668+ If the rule already exists, it will be skipped.
669+ Other non-existent rules are added.
670+ """
671+ with self ._wl :
672+ return self ._e .add_named_grouping_policies_ex (ptype , rules )
673+
638674 def remove_grouping_policies (self , rules ):
639675 """removes role inheritance rules from the current policy."""
640676 with self ._wl :
@@ -685,3 +721,12 @@ def get_implicit_users_for_resource_by_domain(self, resource, domain):
685721 Compared to GetImplicitUsersForResource, domain is supported"""
686722 with self ._rl :
687723 return self ._e .get_implicit_users_for_resource_by_domain (resource , domain )
724+
725+ def self_add_policies_ex (self , sec , ptype , rules ):
726+ """adds authorization rules to the internal model without notifying the watcher.
727+
728+ If the rule already exists, it will be skipped.
729+ Other non-existent rules are added.
730+ """
731+ with self ._wl :
732+ return self ._e .self_add_policies_ex (sec , ptype , rules )
0 commit comments