Hi - I am trying to use the new Sharing Module at 2.4 like this (I still like to use the IDLE for testing):
from arcgis.gis import GIS
from arcgis.gis._impl._content_manager import SharingLevel
gis = GIS("...myorg.net/portal", "myUsername", "myPassword", verify_cert=False)
try:
portItems = gis.content.search(query="owner:myUsername", item_type="Feature Layer", sort_field="title", sort_order="asc", max_items=5000)
for portItem in portItems:
if (portItem.title == "SchoolBoardDistrict4"):
portItem_sharing = portItem.sharing
portItem_grp = portItem_sharing.groups
type(portItem_grp)
print(type(portItem_grp))
# I am getting the correct type
<class 'arcgis.gis._impl._content_manager.sharing.api.SharingGroupManager'>
org_group = ["Planning Layers Group"]
# This works
portItem_sharing.sharing_level = SharingLevel.EVERYONE
#portItem_grp.add(group=org_group)
portItem_grp.remove(org_group)
# won't remove the item from the group
portItem_grp.list()
print(portItem_grp.list())
# [<Group title:"Planning Layers Group" owner:dmcoley_portal>]
except Exception:
# If an error occurred, print line number and error message
import traceback, sys
tb = sys.exc_info()[2]
e = sys.exc_info()[1]
print(e.args[0])
print ("Line %i" % tb.tb_lineno)
message = message + "\n" + "Line %i" % tb.tb_lineno
message = message + "\n" + str(e)Based on this sample from the Sharing Group Manager in the API reference:
# Usage example:
>>> from arcgis.gis import GIS
>>> gis = GIS(profile="your_organization_profile")
>>> org_item = gis.content.get("<item_id>")
>>> org_group = gis.groups.search("Storm Data Group")[0]
>>> item_sharing_mgr = org_item.sharing
>>> item_grp_sharing_mgr = item_sharing_mgr.groups
>>> item_grp_sharing_mgr.list()
[]
>>> item_grp_sharing_mgr.add(group=org_group)
True
>>> item_grp_sharing_mgr.list()
[<Group title:"Storm Data Group" owner:web_gis_user1>] It just doesn't seem to want to take the org_group object I am setting up.
Any Ideas?
@jcarlson
@JakeSkinner