benkonrath / transip-api

Python implementation for the TransIP API
https://transip-api.readthedocs.io/en/latest/
MIT License
23 stars 23 forks source link

Fix order_vps method in VpsService #30

Closed roaldnefs closed 6 years ago

roaldnefs commented 6 years ago

Partially fix the order_vps method is VpsService. It's now possible to order a Vps without addons. If addons are specified anyway, an NotImplementedError will be raised.

The signature error was caused by the addons not being added to the OrderedDict in transip.client.Client._build_signature_message. The _build_signature_message method only adds list items if they are an instance of SudsObject.

This MR has been tested by manually ordering a number of vps.

Example usage:

from transip.service.vps import VpsService

client = VpsService('accountname')

# The order_vps method succeeds when no addons are specified:
client.order_vps('vps-bladevps-x1', None, 'ubuntu-18.04', 'hostname')
client.order_vps('vps-bladevps-x1', [], 'ubuntu-18.04', 'hostname')

# The order_vps will raise a NotImplementedError when addons are specified:
client.order_vps('vps-bladevps-x1', ['nonexisting'], 'ubuntu-18.04', 'hostname')
benkonrath commented 6 years ago

Looks good. Thanks.