Can someone please let me know if there is a way that we can set/unset a service Lock Database Schema by using ArcGIS ArcGIS API for Python
Solved! Go to Solution.
This IS possible, but you have to be very careful that you provide the exact JSON representation of your service (plus the update to the "schemaLockingEnabled" property) as a dict. I tested the below with good results, but I suggest you carefully review the service properties for correctness and use a test service to start.
from arcgis.gis import GIS
gis = GIS("https://machine.domain.com/portal", "user", "pass")
hosting_server = gis.admin.servers.get(role="HOSTING_SERVER")[0]
services = hosting_server.services.list()
service = services[0]
# You can get the required dict for the edit from service.properties
# Review for accuracy as this update could break your service if there are
# any errors present
edit_dict = service.properties.__dict__["_mapping"]
edit_dict["properties"]["schemaLockingEnabled"] = "false"
service.edit(edit_dict)
This IS possible, but you have to be very careful that you provide the exact JSON representation of your service (plus the update to the "schemaLockingEnabled" property) as a dict. I tested the below with good results, but I suggest you carefully review the service properties for correctness and use a test service to start.
from arcgis.gis import GIS
gis = GIS("https://machine.domain.com/portal", "user", "pass")
hosting_server = gis.admin.servers.get(role="HOSTING_SERVER")[0]
services = hosting_server.services.list()
service = services[0]
# You can get the required dict for the edit from service.properties
# Review for accuracy as this update could break your service if there are
# any errors present
edit_dict = service.properties.__dict__["_mapping"]
edit_dict["properties"]["schemaLockingEnabled"] = "false"
service.edit(edit_dict)