Enable "Export Data" with the ArcGIS API for Python

1127
7
Jump to solution
04-08-2019 11:01 PM
davehorsey1
New Contributor III

Is it possible to toggle on/off the "Export Data - Allow others to export to different formats" option for a hosted feature layer from the ArcGIS API for Python?

0 Kudos
1 Solution

Accepted Solutions
JakeSkinner
Esri Esteemed Contributor

Hi David,

Yes, you can do this with the following:

from arcgis.gis import GIS
from arcgis.features import FeatureLayerCollection
gis = GIS("https://www.arcgis.com","jskinner_CountySandbox", "*******")

search_results = gis.content.search('title: MD_Traffic_Cameras', 'Feature Layer')
traffic_cameras_item = search_results[0]
trafficCameras_flc = FeatureLayerCollection.fromitem(traffic_cameras_item)

print(trafficCameras_flc.properties)

update_dict = {'capabilities':'Query,Extract'}
trafficCameras_flc.manager.update_definition(update_dict)

print(trafficCameras_flc.properties)

The service previously only had 'Query' capabilities.  The above code will now enable 'Extract' which will allow others to export the data.

View solution in original post

7 Replies
JakeSkinner
Esri Esteemed Contributor

Hi David,

Yes, you can do this with the following:

from arcgis.gis import GIS
from arcgis.features import FeatureLayerCollection
gis = GIS("https://www.arcgis.com","jskinner_CountySandbox", "*******")

search_results = gis.content.search('title: MD_Traffic_Cameras', 'Feature Layer')
traffic_cameras_item = search_results[0]
trafficCameras_flc = FeatureLayerCollection.fromitem(traffic_cameras_item)

print(trafficCameras_flc.properties)

update_dict = {'capabilities':'Query,Extract'}
trafficCameras_flc.manager.update_definition(update_dict)

print(trafficCameras_flc.properties)

The service previously only had 'Query' capabilities.  The above code will now enable 'Extract' which will allow others to export the data.

davehorsey1
New Contributor III

That's great, thanks Jake Skinner

0 Kudos
MarceloRosensaft
New Contributor III

Hello!

What would be the way to add/publish a feature layer without the export capabilities?

Thanks,

Marcelo

0 Kudos
dcafdg
by
Occasional Contributor II

I'd assume you follow Jake's example above, but just set it to "Query".

0 Kudos
dcafdg
by
Occasional Contributor II

@JakeSkinner  - Where can I find documentation on these options? If I go to the documentation for FeatureLayerCollectionManager, that has the update_definition method, which says it's just like the 'properties' property, but that documentation is missing.

dcafdg_0-1647625795010.png

I'd love to know more about this specifically, but in general, I often find myself in cases like this where I'm passing in JSON or a dict and it's real guesswork as to what all the options are. After hitting a dead end on the documentation, I end up googling for an answer, which leads me here to GeoNet or to the samples. Sometimes, these solve the problem, but not always, so I'm wondering if there's a better way. thanks. 

 

0 Kudos
JakeSkinner
Esri Esteemed Contributor

@dcafdg I'm having trouble locating the documentation as well.  One way is to print the properties of a feature layer collection.  A good example of this can be found here:

https://developers.arcgis.com/python/guide/updating-feature-layer-properties/

0 Kudos
dcafdg
by
Occasional Contributor II

@JakeSkinner  - Yeah, I often put my IDE into debug mode to view the properties of something. When it's an object with properties, that's usually all I need (in this case it's a free-form dict, so not helpful). Or if I can, I use AGOL Assistant on an item with the properties I want to emulate (in this case, you have to guess that extract means export). Or I use Google and find other users wandering around in the dark helping each other. But none of those would be necessary if there were even a base level of documentation! Can you tag some people at Esri or forward a link to this thread to show them how frustrating this can be? The screenshot I posted above perfectly illustrates how much documentation is missing. 

 

0 Kudos