Hi,
I don't have a server here, but I'll try to help you:
if your Virtual Machine is in a variable named vm:
vm.config.hardware.device contains all the devices. You have to iterate all the devices to get the one you want. Access their backing, and use the vm.reconfig to set the new backing. Have a look at some workflows in the library, you will find samples...