Device Management with an EMM

If you decide to pursue this direction, this could help you Using the Remote Connector Server to access on premises APIs from Identity Cloud
It might be good to hold the heavy lifting into a separate service (eventually use a message queue) - and keep the connector script light, merely the “communication pipe”.