Hi -
We had a couple of times where our user credit default assignment in ArcGIS Online wasn't able to be applied to new users because we were temporarily out of credits. Therefore, they got assigned the maximum, instead of our default allocation. We have over 1400 users in ArcGIS Online, and this has happened a few times (so in the neighborhood if hundreds of users with the wrong credit amount).
I tried writing a loop to see if users had unlimited credits, but that doesn't appear to be working. I can report the number of credits a user has assigned to them but I don't see a way to check the current allocation?
I used example code to try and figure this out, but I couldn't find anything in the documentation about what I am trying to do?
Here is my example:
from arcgis.gis import GIS
gis = GIS("https://*.maps.arcgis.com", "userid", "pwd")
gis.admin.credits.credits
gis.admin.credits.is_enabled
cm = gis.admin.credits
and here is the loop I tired, as you can see it is incomplete because it doesn't work and I can't find what I need to solve it.
source_users = gis.users.search('!esri_ & !admin')
for user in source_users:
if cm.??? == -1:
#print(user.username + "\t:\t" + str(user.availableCredits))
cm.allocate(user,10)
cm
Nothing is returned, but where I have the question marks are what I know is incorrect.
Anyone have any insight on this?
Solved! Go to Solution.
Hi Joe,
How about this?
from arcgis.gis import GIS
gis = GIS("home") # Initiate GIS object
cm = gis.admin.credits # Initate credit manager object
source_users = gis.users.search(query=None, outside_org=False, max_users=400) # Return all users from ArcGIS Online org
for user in source_users:
# If a users credit limit is unlimited, change it to 10
if user.assignedCredits == -1 and user.role != "org_admin":
cm.allocate(user.username, 10)
print("Allocated {} 10 credits".format(user.username))
Hi Joe,
How about this?
from arcgis.gis import GIS
gis = GIS("home") # Initiate GIS object
cm = gis.admin.credits # Initate credit manager object
source_users = gis.users.search(query=None, outside_org=False, max_users=400) # Return all users from ArcGIS Online org
for user in source_users:
# If a users credit limit is unlimited, change it to 10
if user.assignedCredits == -1 and user.role != "org_admin":
cm.allocate(user.username, 10)
print("Allocated {} 10 credits".format(user.username))
Thank you, that was exactly what I was missing.