Did some "kicking" around in python, I don't python that much so "readers beware"
How did i figure it out, the french blog from here was useful, but only showed listing methods. I was still very confused as to how to call the vm.stop and which parameters it took.
Enter xo-cli
xo-cli uses jsonrpc but is CLi only, but you can get very nice info from it just have to register and call "list-methods". should be available on your xo VM
xo-cli register http://[yourXO].example.com [yourusername]
#after registering/authenticating
xo-cli list-commands | egrep 'vm\.' --color=always
here you will get a nice list of all "methods" in jsonrpc related to vm and a line about vm.stop:
vm.stop id=<string> [force=<boolean>] [forceShutdownDelay=<number>] [bypassBlockedOperation=<boolean>]
which was enough information to alter the french guy's (Baron) example into this:
import aiohttp
import asyncio
from jsonrpc_websocket import Server
async def routine():
async with aiohttp.ClientSession() as client:
server = Server('ws://[yourXO]/api/', client)
await server.ws_connect()
# signIn required
result = await server.session.signIn(username='[xoAdmin]', password='[xoAdmin]') # email attribute is working in place of username
#hard shutdown
#result = await server.vm.stop(id='3f32beeb-ab3f-a8ac-087d-fdc7ed061b58', force=(bool(1)))
#clean Shutdown
result = await server.vm.stop(id='3f32beeb-ab3f-a8ac-087d-fdc7ed061b58', force=(bool(0)))
print (result)
asyncio.get_event_loop().run_until_complete(routine())