Short story:
I would like AGOL to use the layer alias names, not the feature class names, when I publish from a file GDB.
Long story:
I am publishing a set of 20 feature classes contained in a file GDB to AGOL. This ends up as a feature layer collection after processing. The online layers are created with the feature class names instead of the alias. I would like the online layers to use the feature class alias as there are spaces and punctuation in the names that the users prefer. That punctuation is not allowed in the feature class names in the GDB but is OK for the AGOL names.
Also, the AGOL feature service will subsequently be updated with an overwrite, so the names either need to be 'sticky' or the same question goes to the overwrite process. How to use the alias name instead of the feature class name?
Publish code I am using...
gis = GIS(userName, passWord)
service_properties = {
'title': 'A Name',
'type': 'File Geodatabase',
'itemType': 'file',
'tags': ['tags'],
'typeKeywords': ['File', 'Geodatabase'],
'description': 'A description',
'snippet': 'A snippet',
'spatialReference': '3857'
}
content_zipped = r'C:\ZippedUpFileGDB.zip'
new_item = gis.content.add(
item_properties = service_properties,
data = content_zipped
)
publish_properties = {
'name': 'Service name',
'description': 'Description',
'layerInfo': {"capabilities": 'Query'},
'targetSR': {"wkid": 3857}
}
published_item = new_item.publish(
publish_parameters = publish_properties,
file_type = 'filegeodatabase',
overwrite=True
)
Update/overwrite code:
fs_id = 'TheGUID'
content_zipped = r'C:\ZippedUpFileGDB.zip'
agol_item = gis.content.get(fs_id)
agol_flc = FeatureLayerCollection.fromitem(agol_item)
results = agol_flc.manager.overwrite(content_zipped)
I know I can rename the AGOL layers like this...
fs_id = 'TheGUID'
agol_item = gis.content.get(fs_id)
fs_layers = agol_item.layers
lyr_renames = {'fc_name': 'fc_alias'}
for layer in fs_layers:
current_name = layer.properties.name
if current_name in lyr_renames:
update_name = {
"name": lyr_renames[current_name]
}
response = layer.manager.update_definition(update_name)
...but that breaks the update/overwrite.