Select to view content in your preferred language

Sharing Options for Python Map Image Layer Automation

1414
2
Jump to solution
03-22-2020 03:54 PM
ClintonCooper2
Occasional Contributor

Having been referred to the overwrite option for sharing a map image layer in python, I am wondering if there is an option to allow for sharing with a group or, within the organization or, with everyone.  In the documentation for the method, there does not seem to be a sharing parameter option.  I was thinking about a solution like where I search for the layer and then update the parameter was  available option if there is no method in the other sharing option.  However i cannot get this code to actually update that parameter.   Here is the code I am trying:

from arcgis.gis import GIS
portal = "https://sdc01acgicpw01s.corp.company.com/portal/home/content.html"
user = "      "
password = "     "
service = "WebUpdate"
gis = GIS(portal, user, password)
print("Search for original SD on portal…")
search_results = gis.content.search("{} AND owner:{}".format(service, user), item_type="Map Image Layer")[0]
print("Found SD: {}, ID: {} ".format(search_results.title, search_results.id))
feature_layer_item = search_results[0]
print("Setting sharing options…")
feature_layer_item.share(everyone=True)
print("Finished updating: {} – ID: {}".format(feature_layer_item.title, feature_layer_item.id))

Anything I can do to through code to change the sharing for a map image layer?

0 Kudos
1 Solution

Accepted Solutions
ClintonCooper2
Occasional Contributor

This worked, thank you!

View solution in original post

0 Kudos
2 Replies
JakeSkinner
Esri Esteemed Contributor

Hey Clinton,

Try the below:

from arcgis.gis import GIS

# Varibales
portal = 'https://sdc01acgicpw01s.corp.company.com/portal'
username = 'gisuser'
password = '******'
mapImageLayer = 'WebUpdate'  # Service Name

# Connect to Portal
gis = GIS(portal, username, password)

# Search and share map service
search_results = gis.content.search('title: {0} AND owner: {1}'.format(mapImageLayer, username), item_type = 'Map Image Layer')
map_image_item = search_results[0]
map_image_item.share(everyone=True)
print("Finished")‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
ClintonCooper2
Occasional Contributor

This worked, thank you!

0 Kudos