I'm looking for a way to find all the Feature Layers in our Portal that are shared publicly (with everyone) and have editing capabilities enabled. I'm using Jupyter notebook and Portal 10.8.1.
Solved! Go to Solution.
The following code snippet extracts a list of publicly shared items which are also editable:
items = gis.content.search("*", item_type='Feature Service', max_items=1000, outside_org=True,)
for item in items:
try:
layers = item.layers
if 'Editing' in layers[0].properties.capabilities:
print(f"Editable Layer: {item.title}, Capabilities: {layers[0].properties.capabilities}, Share Type: {item.shared_with}")
continue
except:
pass
This is set to 1000 items and you can also change it.
I hope that's helpful.
Hi @JennieCatalano1
The code sample here is a good guide for how to search for "FeatureService" from a Jupyter notebook:
https://developers.arcgis.com/python/guide/accessing-and-creating-content/
Also, from the API for Python doco, adding here link to the "Item" class property "shared_with" which can indicate how the Feature Service item is shared: https://developers.arcgis.com/python/api-reference/arcgis.gis.toc.html?highlight=item#arcgis.gis.Ite...
So, the typical workflow would be to query Portal content and get all feature services, then loop over the list and find which is shared publicly.
The following code snippet extracts a list of publicly shared items which are also editable:
items = gis.content.search("*", item_type='Feature Service', max_items=1000, outside_org=True,)
for item in items:
try:
layers = item.layers
if 'Editing' in layers[0].properties.capabilities:
print(f"Editable Layer: {item.title}, Capabilities: {layers[0].properties.capabilities}, Share Type: {item.shared_with}")
continue
except:
pass
This is set to 1000 items and you can also change it.
I hope that's helpful.