I have been trying to change the access level of map layers with no luck. I have used 'org' as the access value, however, it keeps showing up as private after it is created. Here is a code sample:
layerProperties_Wildlife = { 'title':'Wildlife Areas', 'description':'This layer contains data for moose and deer management zones, Significant Habitats, Wetlands, and Special Management Practices for Atlantic Coastal Plain Flora Buffers, Marten, Lynx, and Mainland Moose.', 'snippet':'Wildlife Areas layer', 'tags':'wildlife,wetlands,moose,deer,habitat,marten,lynx,moose,NSGI,GeoNOVA', 'licenseInfo':licInfo, 'accessInformation':'Nova Scotia Department of Natural Resources', 'type':'Map Service', 'access':'org', 'url':os.path.join(devURL,'BIO/'+svcName_Wildlife+'/MapServer') } layer = gis.content.add(item_properties=layerProperties_Wildlife, thumbnail=thumbnailPath, owner=layerOwner, folder=layerFolder) layer.access->'private'
Solved! Go to Solution.
Hi René -
Use the item.share, method to change the access property for the item.
layer_item.share(everyone=False, org=True)
The method returns a dictionary with itemId and notSharedWith keys:
{'itemId': '<item ID value>', 'notSharedWith': [] }
The `notSharedWith` key will list the entities on which the sharing was not successful. If the 'notSharedWith` list is empty that means the operation was a success. Next time you retrieve the item and return it's `access` property, you'll see the correct value.
Hi René -
Use the item.share, method to change the access property for the item.
layer_item.share(everyone=False, org=True)
The method returns a dictionary with itemId and notSharedWith keys:
{'itemId': '<item ID value>', 'notSharedWith': [] }
The `notSharedWith` key will list the entities on which the sharing was not successful. If the 'notSharedWith` list is empty that means the operation was a success. Next time you retrieve the item and return it's `access` property, you'll see the correct value.
Thank you. That worked for me!
How do you apply this on the WebMap level?
Glad that worked, René -
Updating the access property for a Web Map would look the exact same. Retrieve the Web Map Item from your portal and use the share method:
search_results = a_gis.content.search("*", item_type = "Web Map")
web_map_item = search_results[0] #use the appropriate index value for the Web Map you want to update
web_map_item.share(everyone=False, org=True, groups=['group name 1', 'group name 2'])
Thanks. That worked as well...