My company has a training site for the Esri training that is ArcGIS Online based, but isn't attached to our Organization account. One of our developers generated a list of users for me from the site using Python and I have taken that list and compared it to our HR Database to find users who have left the company (over 1000 of them). I have exported that list into a comma separated file by email address. We are using SAML for authentication. Now, what I would like to do is to use Jupyter Notebooks to learn how to properly use the Python API for ArcGIS to remove these users. I am out of touch with writing code so that is why I am trying to relearn using Jupyter.
I reviewed this site for other users who are trying to remove users from ArcGIS Online, but my site is more simple, the accounts only have access to the training, no content. To remove them, I want to connect to the site, import the CSV file I have, loop through the file and delete the users.
This is my code so far, I know it isn't working because the users are still on the site, so I am aware I am missing proper execution.
from arcgis.gis import GIS
import csv
gis = GIS("https://****.maps.arcgis.com", "****", "***")
csvPath = r'Myfile path'
userDelete[]
^^^^^ This code below I copied from another post^^^
with open(csvPath) as f_input:
csv_input = csv.reader(f_input, delimiter=",")
for row in csv_input:
users = gis.users.search("username:{}".format(row[0]))
if (len(users)>0): # only append if there are search results
userDelete.append(users[0])
As a novice any help in understanding what I need to do to make this work would be appreciated. I want to be more self sufficient with working with Python like this and since I don't code everyday, that takes a lot of relearning.
Thanks.