Greetings,
I have looked through the forum and I have not found a definitive answer. If I need to find all content/items for all users in our AGOL subscription is the proper method to loop through each user, or is there a better way?
We have some feature services set up in AGOL which use our ArcGIS Server services as their data source. We are going to retire several of our ArcGIS Server services. Minimally I need to identify all content that references the to be retired services. Ideally I would like to update the references with new service names.
I think I have a pretty good handle generally on finding items, and the update process looks logical.
Thanks for any insight,
Bob
Solved! Go to Solution.
Hello Bob,
To find all content for each user in a AGOL organization, you would just search for each user account and then loop through their items. Here is an example....
import arcgis
from arcgis.gis import GIS
# Log into AGOL account [admin level]
gis = GIS(None,'username', 'password', verify_cert=False)
# This function will show all content from all users in a AGOL subscription
def findItems():
try:
# Accounts is a list of all user objects
Accounts = gis.users.search(query= None, max_users =50)
# For each user in the org, give me a list of the items they own
for user in Accounts:
userItem = user.items(max_items=10)
if userItem: #checks to see if there are items in the current list
for item in userItem:
print("The item {0} is of type {1} and is owned by {2}".format(item.title,item.type,item.owner))
except Exception as e:
print(e)
findItems()
I think this is what you are trying to do.
Hello Bob,
To find all content for each user in a AGOL organization, you would just search for each user account and then loop through their items. Here is an example....
import arcgis
from arcgis.gis import GIS
# Log into AGOL account [admin level]
gis = GIS(None,'username', 'password', verify_cert=False)
# This function will show all content from all users in a AGOL subscription
def findItems():
try:
# Accounts is a list of all user objects
Accounts = gis.users.search(query= None, max_users =50)
# For each user in the org, give me a list of the items they own
for user in Accounts:
userItem = user.items(max_items=10)
if userItem: #checks to see if there are items in the current list
for item in userItem:
print("The item {0} is of type {1} and is owned by {2}".format(item.title,item.type,item.owner))
except Exception as e:
print(e)
findItems()
I think this is what you are trying to do.
Thank you for the response. This is roughly the method I am using. I am working through finding URLs that contain a specific string.