I'm serializing portal data so two instances of arcgis portal can be compared and the serialized data can be searched for specific keywords. More specifically, I need to retrieve all layers (and their properties etc) included in each "Web Mapping Application" and "Web Map" running on each server.
So far with help from this site I've had luck doing this for Map Services and Feature Services, but I can't seem to find any documentation for how to retrieve layers belonging to a "Web Mapping Application" or a "Web Map"
I've tried using dependent_upon(), layers[] and a few other things but I haven't had any luck so far.
Below is a simplified example of how I'm doing it now (minus the looping over users and items)
from arcgis import GIS
source = GIS(url, username, password)
server_string=""
search_result = source.content.search(
query="title:Data Feed App",
item_type="Web Mapping Application")
item=search_result[0]
itemstring = str(item.__dict__)
layers=[]
try:
layers=getattr(item, "layers",[])
except Exception as layerError:
print('"layer_error":"unable to fetch layers"')
if(layers != []):
if isinstance(item.layers,list):
itemstring+="["
for layer in layers:
try:
itemstring+=str(layer.__dict__)
if(hasattr(layer, 'properties')):
itemstring+="\n"+str(layer.properties.__dict__)
except Exception as ex:
print('"layer_error":"'+str(ex)+'"')
itemstring+="]"