Hi,

I modified my code for adding (LDAP) user groups to access policies. The code 
below worked for adding users to policies.
But when I try to run this snipplet I get the error :

security.py", line 559, in add_user_group_to_access_policy  assert 
user_group_id not in policy_user_group_ids

Can someone help me to understand what I am doing wrong here ?
Nipyapi version : 0.19.1


import nipyapi

class updatenifipolicy:
    def __init__(self,user):
        self.usergroup=user

    def devtest(self):
        test = "GSAPN1D_00000sm_IPA_GLO_OPS"
        nifi_reg_usergroup = 
nipyapi.security.get_service_user_group(test,identifier_type='identity', 
service='nifi')
        print("nifi usergroup : ", nifi_reg_usergroup.id)

        nifi_access_policies = [
            ("read", "/flow"),
            ]
        for action, resource in nifi_access_policies:
            pol = nipyapi.security.get_access_policy_for_resource(
                resource=resource,
                action=action,
                service='nifi',
                auto_create=False
            )
            try:
              nipyapi.security.add_user_group_to_access_policy(
                user_group=nifi_reg_usergroup,
                policy=pol,
                service='nifi',
                refresh=True,
              )
            except ValueError:
              print ("Nifi : Usergroup", self.usergroup, "Already added to 
policy")


Thanks in advance,

Jasper van der Marel

-----------------------------------------------------------------
ATTENTION:
The information in this e-mail is confidential and only meant for the intended 
recipient. If you are not the intended recipient, don't use or disclose it in 
any way. Please let the sender know and delete the message immediately.
-----------------------------------------------------------------

Reply via email to