Skip to content

Instantly share code, notes, and snippets.

@nommuna2
Last active April 26, 2019 21:03
Show Gist options
  • Save nommuna2/009d3d33f48598af87cd1e509a239232 to your computer and use it in GitHub Desktop.
Save nommuna2/009d3d33f48598af87cd1e509a239232 to your computer and use it in GitHub Desktop.
(ArcGIS API for Python) Deleting all content from a user [Python API]
import arcgis
import json
from arcgis.gis import GIS
gis = GIS(None,'username', 'password', verify_cert=False)
#This function takes in a username and a item [type] for deletion
def deleteContent(owner, itemType):
try:
#Search the user content for any items of a specfic type. This returns a list.
result = gis.content.search(query='owner:{}'.format(owner), item_type='File Geodatabase')
#Delete all the items in the list
gis.content.delete_items(result)
except Exception as e:
print(e)
deleteContent('username', itemType=None)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment