Access Level Change

561
5
Jump to solution
02-08-2018 08:49 AM
RenéTénière
New Contributor III

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'
0 Kudos
1 Solution

Accepted Solutions
JohnYaist1
Esri Contributor

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.

View solution in original post

5 Replies
JohnYaist1
Esri Contributor

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.

RenéTénière
New Contributor III

Thank you. That worked for me!

0 Kudos
RenéTénière
New Contributor III

How do you apply this on the WebMap level?

0 Kudos
JohnYaist1
Esri Contributor

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'])
RenéTénière
New Contributor III

Thanks. That worked as well...