Esri / arcgis-python-api

Documentation and samples for ArcGIS API for Python
https://developers.arcgis.com/python/
Apache License 2.0
1.89k stars 1.1k forks source link

Question: What determines a valid definition for the `capabilities` property of a `FeatureLayerCollection`? #2110

Open ccone-pattern opened 1 week ago

ccone-pattern commented 1 week ago

Is your feature request related to a problem? Please describe. FeatureLayerCollection.manager.update_definition is not working like I'd expect it to when I provide a list of capabilities that I want to configure for a given Feature Service that I own in our AGOL portal. The definition seems to be valid according to all the documentation that I've read on the syntax of this part of a FLC definition.

capabilities = dict(capabilities=",".join(["Create", "Delete", "Update", "Editing", "Query", "Sync", "Extract"]), allowGeometryUpdates=False)

for i, item in enumerate(new_items):
    if item.type == "Feature Service":
        try:
            flc = FeatureLayerCollection.fromitem(item)
            print(flc, ":")
            current_props = {key: flc.properties[key] for key in ["capabilities", "allowGeometryUpdates"]}
            print(current_props)
            msg = flc.manager.update_definition(capabilities)
            print("Update: ", msg)
        except Exception as e:
            print(f"Error raised for layer: {flc}")
            print(e)

Describe the solution you'd like Understanding of how to reliably update the capabilities of Feature Layer Services using the python api.

Describe alternatives you've considered token generation + REST calls w/requests

Additional context image This is an output of the results I got from running the above code snippet. Seems there is only one layer that failed in this test (it was more before I manually set Editing capabilities in AGOL). Do I need to add editing capabilities first, then update exact permissions perhaps?

nanaeaubry commented 6 days ago
update_dict = {"capabilities": "Create,Editing,Uploads,Delete,Query"}
test_flc.manager.update_definition(update_dict)

The capabilities of a Feature Service can be found through the REST API doc or in some of our samples in the python api doc (code snippet above).

Here is where you can get more info of capabilities: https://developers.arcgis.com/rest/services-reference/enterprise/feature-service/

If you search the page you will get information such as: The capabilities property returns Create, Delete, Extract, Query, Update, Sync, and Uploads capabilities. The Uploads capability is included if Create, Delete, or Update is enabled for a feature service. The Editing capability is included if Create, Delete, and Update is enabled and allowGeometryUpdates is true. The Sync capability allows editors to make local edits and periodically sync with the feature service. The Extract capability allows editors to create a local copy of data without the ability to sync with the feature service.

There are also advancedEditingCapabilities that might have to be set depending on what you would like to do. The capabilities of the service depend on the service itself and I would highly recommend looking through the link to understand the combination necessary to update your service. For example for append capability you need to set supportAppend to True as well.

We are not able to know every case for each service so if you need further help I would reach out to Esri Support since they can better assist.