arcgis-python-api icon indicating copy to clipboard operation
arcgis-python-api copied to clipboard

Allow enabling "offline mode" on a "VectorTileLayer" hosted on ArcGIS Enterprise

Open Biboba opened this issue 2 years ago • 1 comments
trafficstars

Is your feature request related to a problem? Please describe.

I am facing the following issue: how to enable "offline mode" on a "VectorTileLayer" hosted on ArcGIS Enterprise ?

Currently, it seems to me that it is only available on VectorTileLayerManager by specifying the "export_tiles_allowed" parameter of the "edit_tile_service" method but this method is not available on EnterpriseVectorTileLayerManager class for VectorTileLayer hosted on ArcGIS Enterprise 11.0

Using "arcgis" module v2.0.1:

vector_tile_layer = VectorTileLayer.fromitem(vtpk_layer)
vector_tile_layer.manager.edit_tile_service(export_tiles_allowed = True)

does not work as "edit_tile_service" does not exist:

AttributeError: 'EnterpriseVectorTileLayerManager' object has no attribute 'edit_tile_service'

Using "arcgis" module v2.1.0, the property manager is even broken itself when web adaptor has administrative access disabled (cf. https://github.com/Esri/arcgis-python-api/issues/1470).

Describe the solution you'd like I would like to be able to enable "offline mode" on VectorTileLayer hosted on ArcGIS Enterprise.

Describe alternatives you've considered I am considering doing the request to update the property manually.

Additional context

My workflow is to weekly update a vectorTileLayer which is already enabled for "offline mode". The problem is that when using the "replace_service" method, at the end, the "offline mode" property is reset and disabled so I would need to update it.

Note that on my setup, ArcGIS Webadaptor has administrative access disabled so I guess it should be clever enough to use ArcGIS Enterprise proxy just like it's done on the web interface.

Thanks for listening !

Biboba avatar Feb 22 '23 08:02 Biboba

In the meantime, for anyone interested, here is a sample code to do it "manually":

import json

layer_name = "foo"

# Retrieve service from hosting server admin directory API
hosting_server = gis.admin.servers.get(role="HOSTING_SERVER")[0]
service_admin = [service for service in hosting_server.services.list("hosted") if service.properties["serviceName"] == layer_name][0]

# Edit "exportTilesAllowed" property and update it
service_properties = service_admin.properties
service_properties["properties"]["exportTilesAllowed"] = 'true'
service_admin.edit(json.loads(str(service_properties)))

NB: this snippet is running against admin API directly on port 6443 which is fine for me as this administrative script is running within our network. If required to be run outside ArcGIS Enterprise network, then it would require to use "Portal for ArcGIS" proxy just like it's done on "Portal for ArcGIS" web interface.

Biboba avatar Feb 22 '23 14:02 Biboba