Select to view content in your preferred language

Programmatic Access to Editing Properties of Feature Service

421
4
Jump to solution
09-16-2024 06:16 AM
Labels (1)
McKinneyPatrick_PA
Emerging Contributor

I am writing a script to identify if publicly-shared services have editing enabled.  I would like this to correspond to the "Update" option listed under "What kind of editing is allowed" on an item's page in ArcGIS Online/Portal.

According to the REST API, I thought that checking for "Editing" or "Update" in the layer or tables "properties.capabilities" would return this information.

However, after testing my script, I learned that these do not match up.  Is there a way to use the Python API to get a listing of what is enabled for editing that matches what is listed on the item's page? 

1 Solution

Accepted Solutions
Clubdebambos
Frequent Contributor

Hi @McKinneyPatrick_PA 

Is the below what you are looking for?

from arcgis.gis import GIS
from arcgis.features import FeatureLayerCollection

## access ArcGIS Online
agol = GIS("home")

## get the Feature Service as an Item object
item = agol.content.get("ITEM_ID")

## FLC represents a Feature Service
flc = FeatureLayerCollection.fromitem(item)

print(flc.properties)

 

From these you can get the information from the settings page that acts as a master control for all layers and tables in the Feature Service. You can also use the API and the FeatureLayer object to update some capabilities for individual layers and tables.

##  Create - Create a feature (editing)
##  Query -    Query attributes of a feature
##  Update - Update feature attributes and geometry (editing)
##  Editing - All editing capabilities (Create,Update,Delete)
##  Extract - Extract data in various formats
##  Sync - Used for offline data use and collaborations
##  Delete - Delete a feature (editing)
##  ChangeTracking - keep track of editing changes
"capabilities": "Create,Delete,Query,Update,Editing,Sync,ChangeTracking"

"allowGeometryUpdates": true

"allowTrueCurvesUpdates": true
"onlyAllowTrueCurveUpdatesByTrueCurveClients": false

## only availabkle if Editor Tracking has been enabled
"editorTrackingInfo": {
    "enableEditorTracking": true,
    "enableOwnershipAccessControl": false,
    "allowOthersToQuery": true,
    "allowOthersToUpdate": true,
    "allowOthersToDelete": true,
    "allowAnonymousToQuery": true,
    "allowAnonymousToUpdate": true,
    "allowAnonymousToDelete": true
}

## only available of Change Tracking is enabled
"extractChangesCapabilities": {
    "supportsReturnIdsOnly": true,
    "supportsReturnExtentOnly": true,
    "supportsReturnAttachments": true,
    "supportsLayerQueries": true,
    "supportsGeometry": true,
    "supportsFeatureReturn": true,
    "supportsReturnHasGeometryUpdates": false,
    "supportsReturnDeletedFeatures": true,
    "supportsServerGens": true,
    "supportsFieldsToCompare": true
}

 

I would recommend turning on and off different settings and printing the properties and looking for changes/additions to the output JSON to see what is affected.

All the best,

Glen

~ learn.finaldraftmapping.com

View solution in original post

0 Kudos
4 Replies
Clubdebambos
Frequent Contributor

Hi @McKinneyPatrick_PA 

Is the below what you are looking for?

from arcgis.gis import GIS
from arcgis.features import FeatureLayerCollection

## access ArcGIS Online
agol = GIS("home")

## get the Feature Service as an Item object
item = agol.content.get("ITEM_ID")

## FLC represents a Feature Service
flc = FeatureLayerCollection.fromitem(item)

print(flc.properties)

 

From these you can get the information from the settings page that acts as a master control for all layers and tables in the Feature Service. You can also use the API and the FeatureLayer object to update some capabilities for individual layers and tables.

##  Create - Create a feature (editing)
##  Query -    Query attributes of a feature
##  Update - Update feature attributes and geometry (editing)
##  Editing - All editing capabilities (Create,Update,Delete)
##  Extract - Extract data in various formats
##  Sync - Used for offline data use and collaborations
##  Delete - Delete a feature (editing)
##  ChangeTracking - keep track of editing changes
"capabilities": "Create,Delete,Query,Update,Editing,Sync,ChangeTracking"

"allowGeometryUpdates": true

"allowTrueCurvesUpdates": true
"onlyAllowTrueCurveUpdatesByTrueCurveClients": false

## only availabkle if Editor Tracking has been enabled
"editorTrackingInfo": {
    "enableEditorTracking": true,
    "enableOwnershipAccessControl": false,
    "allowOthersToQuery": true,
    "allowOthersToUpdate": true,
    "allowOthersToDelete": true,
    "allowAnonymousToQuery": true,
    "allowAnonymousToUpdate": true,
    "allowAnonymousToDelete": true
}

## only available of Change Tracking is enabled
"extractChangesCapabilities": {
    "supportsReturnIdsOnly": true,
    "supportsReturnExtentOnly": true,
    "supportsReturnAttachments": true,
    "supportsLayerQueries": true,
    "supportsGeometry": true,
    "supportsFeatureReturn": true,
    "supportsReturnHasGeometryUpdates": false,
    "supportsReturnDeletedFeatures": true,
    "supportsServerGens": true,
    "supportsFieldsToCompare": true
}

 

I would recommend turning on and off different settings and printing the properties and looking for changes/additions to the output JSON to see what is affected.

All the best,

Glen

~ learn.finaldraftmapping.com
0 Kudos
McKinneyPatrick_PA
Emerging Contributor

The issue is that the "capabilities" property does not match the "Add/Delete/Update" checkboxes on the item's page.

I was expecting if "Add" shows up on the item page, it would also show up in "capabilites."  But things did not match up this way.

0 Kudos
Clubdebambos
Frequent Contributor

Ahh, right. I haven't seen that behaviour before. 

~ learn.finaldraftmapping.com
0 Kudos
McKinneyPatrick_PA
Emerging Contributor

The issue was on my mis-understanding of capabilities.  I was originally checking for either "Editing" or "Update."

After re-reading @Clubdebambos comments, I realized I should only have been checking for "Update" capability.