I'm trying to convert an old portalpy/excalibur script that 'wipes' an ArcGIS Online organisation based on a role, but I'm struggling to recreate it in Python API. Every week or so my current script seems to fail or present a new error, so I figure now is the time to update it.
The steps the script takes are as follows:
- Sign in as an administrator for the organisation
- Get a list of all users who have a particular role
- Remove any licenses that the users have assigned
- Remove any delete-protection on items
- Delete any content (including folders, and then groups)
- Delete the users
- Recreate the users (based on a csv list)
- Re-invite the user to predetermined groups
I've been using notebooks so far as it fits my limited knowledge of code and allows me to see where things are going wrong. Trouble is, it's going wrong everywhere!
I can get a list of users, and then find and delete their content, but I can't seem to work out how to delete their folders and any groups that they're a member of. It's possibly a very simple answer, but I figure I may as well ask in case it's also useful for anyone else.
Does anyone have an example script (using the Python API) or any tips to fully deleting users?