Does anyone know how to find the keys in the SDdraft file? They are used in the scripts that are posted for updating AGOL by Esri and used by many people. See here: arcrest.common.servicedef — ArcREST 3.5.4 documentation The script uses the keys to set up things like feature access and turning off caching but Esri support will not give me list of the keys. I am pretty sure some of the other settings I would like to set are in as keys but I don't know how to figure out what they are. Does anyone either know how to read the keys from the SDfile or have a list of what the keys are?
For example,
root_elem = doc.getroot() if root_elem.tag != "SVCManifest": raise ValueError("Root tag is incorrect. Is {} a .sddraft file?".format(SDDraft)) # The following 6 code pieces modify the SDDraft from a new MapService # with caching capabilities to a FeatureService with Query,Create, # Update,Delete,Uploads,Editing capabilities as well as the ability # to set the max records on the service. # The first two lines (commented out) are no longer necessary as the FS # is now being deleted and re-published, not truly overwritten as is the # case when publishing from Desktop. # The last three pieces change Map to Feature Service, disable caching # and set appropriate capabilities. You can customize the capabilities by # removing items. # Note you cannot disable Query from a Feature Service. # doc.find("./Type").text = "esriServiceDefinitionType_Replacement" # doc.find("./State").text = "esriSDState_Published" # Change service type from map service to feature service for config in doc.findall("./Configurations/SVCConfiguration/TypeName"): if config.text == "MapServer": config.text = "FeatureServer" # Turn off caching for prop in doc.findall("./Configurations/SVCConfiguration/Definition/" + "ConfigurationProperties/PropertyArray/" + "PropertySetProperty"): if prop.find("Key").text == 'isCached': prop.find("Value").text = "false" if prop.find("Key").text == 'maxRecordCount': prop.find("Value").text = maxRecords # Turn on feature access capabilities for prop in doc.findall("./Configurations/SVCConfiguration/Definition/Info/PropertyArray/PropertySetProperty"): if prop.find("Key").text == 'WebCapabilities' prop.find("Value").text = "Query,Create,Update,Delete,Uploads,Editing"
It looks like that script is using xml.etree.ElementTree, so you can follow the documentation on how to work with keys and tags. For example, taking the following section out of an SDDraft:
<Configurations xsi:type="typens:ArrayOfSVCConfiguration" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <SVCExtension xsi:type="typens:SVCExtension"> <Enabled>false</Enabled> <Info xsi:type="typens:PropertySet"> <PropertyArray xsi:type="typens:ArrayOfPropertySetProperty"> <PropertySetProperty xsi:type="typens:PropertySetProperty"> <Key>WebEnabled</Key> <Value xsi:type="xs:string">true</Value> </PropertySetProperty> <PropertySetProperty xsi:type="typens:PropertySetProperty"> <Key>WebCapabilities</Key> <Value xsi:type="xs:string">Query</Value> </PropertySetProperty> </PropertyArray> </Info> <Props xsi:type="typens:PropertySet"> <PropertyArray xsi:type="typens:ArrayOfPropertySetProperty"/> </Props> <TypeName>SchematicsServer</TypeName> </SVCExtension> </Configurations>
And doing something like:
import xml.etree.ElementTree as ET doc = ET.parse(r"C:\Temp\XML.xml") root = doc.getroot() for child in root: for gchild in child: print(gchild.tag, gchild.text) for ggchild in gchild: print(" ",ggchild.tag, ggchild.text) for gggchild in ggchild: print(" ",gggchild.tag, gggchild.text) for ggggchild in gggchild: print(" ",ggggchild.tag,ggggchild.text)
Will return
Enabled false
Info None
PropertyArray None
PropertySetProperty None
Key WebEnabled
Value true
PropertySetProperty None
Key WebCapabilities
Value Query
Props None
PropertyArray None
TypeName SchematicsServer
Not a very pretty example, but hopefully it helps.