Go ahead and check out the Python Script I wrote.
For MSP Admin Change:
1. Lists all Admins in All the Orgs
2. You can Add/Remove/Update Per Network privileges of the admin
Snippet is given below. The whole Code is here(https://drive.google.com/open?id=19Pr_7b4UP0A0zpcXCjn23S-6AbbTQa1B).
iter_org = int(0)
for entryOrg in orgs.json():
bool_inOrgBeforeSubmit = False
bool_inOrgAfterSubmit = False
str_adminId = None
#Find if the admin was an existing admin in the org
for entry in multiOrgAdminList:
if entry['orgId'] == entryOrg['id']:
bool_inOrgBeforeSubmit = True
str_adminId = str(entry['adminId'])
iter_org += 1
orgAccess = str(win.getOptionBox(str(entryOrg['id'])))
if orgAccess != "none":
bool_inOrgAfterSubmit = True
url = base_url + entryOrg['id'] + "/networks"
networks = requests.get(url, headers=header)
submitNetworkAccessList = []
for entryNw in networks.json():
networkAcess = str(win.getOptionBox(str(entryNw['id'])))
if networkAcess != "none":
bool_inOrgAfterSubmit = True
temp = {'id': entryNw['id'], 'access': networkAcess}
submitNetworkAccessList.append(temp)
if bool_inOrgAfterSubmit:
str_email = win.getEntry("multiAdmin_email")
str_userName = win.getEntry("multiAdmin_name")
#Verify if the admin is in the org
#if the admin is in the org and access privilege changes, UPDATE
for entry in multiOrgAdminList:
if entry['orgId'] == entryOrg['id']:
if str(entry['networks']) != str(submitNetworkAccessList):
url = base_url + str(entryOrg['id']) + "/admins/" + str_adminId
payload = {'name': str_userName, 'email': str_email, 'orgAccess': orgAccess,
'networks': submitNetworkAccessList}
temp = requests.put(url, json.dumps(payload), headers=header)
print("Updated in the Org:", entryOrg['name'])
print(temp)
#If the admin is not in the org, ADD
if bool_inOrgBeforeSubmit == False:
url = base_url + str(entryOrg['id']) + "/admins"
payload = {'name': str_userName, 'email': str_email, 'orgAccess': orgAccess,
'networks': submitNetworkAccessList}
temp = requests.post(url, json.dumps(payload), headers=header)
print("Add to the Org:", entryOrg['name'])
print(temp)
#print(orgAccess, submitNetworkAccessList)
elif bool_inOrgBeforeSubmit:
#If the admin was there and now there now, DELETE
url = base_url + str(entryOrg['id']) + "/admins/" + str_adminId
temp = requests.delete(url, headers=header)
print("Removed from the Org:", entryOrg['name'])
print(temp)
else:
#Admin was not in the org before submit and after submit
print("No change in the Org:", entryOrg['name'])