linode-python
linode-python copied to clipboard
Would be great to encode structured parameters as JSON
For example, linode.disk.createfromstackscript takes a parameter StackScriptUDFResponses
:
StackScriptUDFResponses - string (required) JSON encoded name/value pairs, answering this StackScript's User Defined Fields
It's not clear whether it's allowed to pass actual JSON data to this parameter. In fact, it doesn't work, and the following code fails:
env.api.linode_disk_createfromstackscript(
StackScriptUDFResponses={'hostname': env.target_host}, ...)
If I encode the structured data as a string first, then it works:
env.api.linode_disk_createfromstackscript(
StackScriptUDFResponses=json.dumps({'hostname': env.target_host}), ...)
But it would be great if linode-python could either warn me that I'm trying to pass a non-string value for a parameter, or automatically encode it as JSON for me. What do you think?