Select to view content in your preferred language

Group Category Manager

730
2
03-06-2020 06:02 AM
AmandaReich3
New Contributor

I have created a group in my Enterprise portal and shared about 1500 images to this group. I have been trying to write a script to assign categories to each image based on the country code in the image name. According to the ArcGIS Python API, Group objects should have a 'categories' property, but when I attempt to access this via the following (generalized) example:

MyGroup = portal.groups.get('GroupIdNumber')

MyGroup.categories

I get an error stating: 'Group' object has no attribute 'categories'

It appears I should be able to get the CategorySchemaManager through this property and then use the assign_to_items function to complete the process.

I can access the group and its content just fine, but I cannot seem to find a way to access the categories property in order to assign items to the categories.

Is there another way that I can use to assign categories to each item shared with a group?

Thank you!

2 Replies
FredericPoliart_EsriAU
Frequent Contributor

Good question,

I have the same challenge, I want to enumerate the sub-categories of a Group 
and then list the layers within that groups' category. 

THis code doesn't give me any object called "categories"

base = gis._con.baseurl.rstrip("/") + "/community/groups/{gid}/category".format(gid=group_id)
params = {"f": "json", "token": gis._con.token}
r = requests.get(base, params=params, verify=gis._con._verify_cert)
r.raise_for_status()
data = r.json()
# data example has 'categorySchema' with nested nodes: {title, categories:[...]}
paths = []


 And running   group.categories.schema[0]['categories']   seem to enumerate every category

What I need is a programmatical (.py) method to enumerate the Portal > Groups > My Organization's Groups > {select the group} > then select Content  > and on the left, I see the categories with a number of layers in each.

FredericPoliart_EsriAU_1-1755667926357.png

 


HOW DO I GET THIS IN PYTHON!?






0 Kudos
FredericPoliart_EsriAU
Frequent Contributor

I found a solution!

0 Kudos