Add new 'Member Categories' as a property to arcgis.gis.User in the ArcGIS API for Python

1509
10
03-23-2022 11:50 AM
Status: Open
AaronKoelker
Occasional Contributor III

The March 2022 update brought Member Categories to ArcGIS Online. It would be great if this property was accessible via the ArcGIS API for Python, in the user class of the gis module.

We have a decent-sized organization with many decentralized divisions within when it comes to GIS, so updates like Member Categories are much appreciated. By exposing this info via the API, we can build Dashboards updated via Notebooks to help track our user base.

Also would love to get to something like what was previously suggested in another Idea post, for tying custom role permissions to something like member categories.

10 Comments
mada
by

I'm also interested in this. Please share with us Aaron if you find a way.

r3weber

This should definitely be in the api docs.  There is an id property on the user so I tried applying a category to a user using the same method as if it were a content item and it failed.  Anyway this needs to be added in order for us to really make use of it.

John_Spence

This is a great idea and one, ironically, I was looking at just now too. I built a script that pulls a users data via LDAP and was going to use that to auto set the category of the user (department). Too bad it is not a readily available option yet.

Egelkroutk

@AaronKoelker Do you know if this functionality was ever added to the user class of the gis module?

AaronKoelker

@Egelkroutk 

I haven't had a chance to check since the ArcGIS Online update occurred last night (11/9), but I didn't see anything on the release note blog mentioning it. I also don't see it in the documentation yet, either: https://developers.arcgis.com/python/api-reference/arcgis.gis.toc.html#user

AaronKoelker

@Egelkroutk, @mada@r3weber , @John_Spence 

 

Looks like this info is available via the UserManager: https://developers.arcgis.com/python/api-reference/arcgis.gis.toc.html#arcgis.gis.UserManager.catego...

 

Not sure how long it's been there, I kept expecting to find it under the gis.user class with those other properties.

 

Example (Using AGO Notebooks):

 

from arcgis.gis import GIS
gis = GIS("home")

users = gis.users.search(max_users=10) #just using first 10 as example
for user in users:
    print(user.categories)

 

 

John_Spence

@AaronKoelker I don't know about the others, but I was wanting to assign a category to a user. Not seeing that as an option currently, but I need to take a closer look.

Thanks for keeping an eye out.

AaronKoelker

@John_Spence 

I haven't tried it yet, but looks like you can use assign_categories( users, categories)

https://developers.arcgis.com/python/api-reference/arcgis.gis.toc.html#arcgis.gis.UserManager.assign...

John_Spence

@AaronKoelker , same boat here. Looked like it, but the more I looked at it it appeared to be adding categories to be assigned, but not to the specific user.

It just didn't fit the flow of the documentation otherwise.

I need to look closer at it though.

tigerwoulds

Using the update method worked for me

user = gis.users.get(username='testuser')
user.update(categories = ["/Categories/TestCategory"])