I'm trying to write a Python script that queries a hosted feature layer in AGOL, and then use returned records as the input for some arcpy geoprocessing commands to update a mosaic dataset. I am able to do the query in Pro if I manually the hosted feature layer to a map, and then just use the layer name as the input for arcpy.management.SelectLayerByAttribute.
However I'm having trouble figuring out how to create a "layer" object in Arcpy from a hosted feature layer. "Make Feature Layer" seems to work only for feature classes.
I'd prefer not to run the script as a Notebook using ArcGIS Python API as there are some local file system tasks that I want to handle.