Automate On-boarding of O365 Tenant via API

If I wanted to automate the federation of an O365 domain via WS-Fed, would the following process work?

  1. User Supplies Domain name they want to federate (or script grabs any new domains inside O365 tenancy)
  2. Okta Apps API is called to provision the O365 domain via the WS-Fed template
  3. Microsoft Graphs API is used with existing credentials to connect to the O365 tenancy and federate the domain inside O365.

I know Steps 1) and 2) should work. But I can’t find whether 3) is possible via the Graphs API. I know 3) could be done via powershell but the application is built on google’s app engine so if powershell is needed, a VM would need to be stood up just to do this.