Last active
April 26, 2019 21:03
-
-
Save nommuna2/009d3d33f48598af87cd1e509a239232 to your computer and use it in GitHub Desktop.
(ArcGIS API for Python) Deleting all content from a user [Python API]
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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