Documentation and API bug for dedicated servers
fpoyer opened this issue · comments
Hi!
Sorry, this is not strictly speaking a python-ovh related issue, but I found it using the client and don't know how to contact the server-side developpers... feel free to transfer the issue to whomever is better qualified to handle it.
First bug is a documentation bug on the web interface of the API (https://eu.api.ovh.com/console/#/dedicated/server/%7BserviceName%7D/serviceInfos#PUT), the python tab show the following code (using "my-server" as service name placeholder):
result = client.put('/dedicated/server/my-server/serviceInfos',
renew='{"manualPayment":true,"forced":false,"automatic":false,"deleteAtExpiration":false}', // Way of handling the renew (type: service.RenewType)
)
but this doesn't work!
Actual working code is:
client.put('/dedicated/server/my-server/serviceInfos',
renew={"manualPayment":True,"forced":False,"automatic":False,"deleteAtExpiration":False}
)
(using correct python structure that will be turned into json by the client, instead of json string that I guess will be turned into "json-ified" json \{\"manualPayment\":true,\"forced\":false,\"automatic\":false,\"deleteAtExpiration\":false\}
)
Second bug is in the API itself and is made of several smaller problems:
- first: the
manualPayment
anddeleteAtExpiration
do not work as expected. When trying to switch a server that is on automatic payment (call toGET /dedicated/server/my-server/serviceInfos
returns"automatic":true,"manualPayment":false,"deleteAtExpiration":false,"period":1}
), I would expect to passrenew={"manualPayment":True,"forced":False,"automatic":False,"deleteAtExpiration":True}
toPUT /dedicated/server/my-server/serviceInfos
but then I getovh.exceptions.BadParametersError: Arguments conflicting
. Indeed I have to passrenew={"manualPayment":True,"forced":False,"automatic":False,"deleteAtExpiration":False}
which does toggle the state of the server to manual payment AND delete at expiration (call toGET /dedicated/server/my-server/serviceInfos
returns"automatic":false,"manualPayment":true,"deleteAtExpiration":true,"period":1}
). But calling the exact same code again (manual: true, deleteAtExpiration: false) will toggle the server back to automatic payment! - second:
automatic
andmanualPayment
parameters (for the same endpoint) are mutually exclusive (if it is automatic, it can't be manual, and vice-versa) so this is redundant at best, error-prone at worst. - third (as bonus):
forced
is useless, as it can't be changed but is mandatory all the same.ovh.exceptions.BadParametersError: Can not change forced field of the service
if you try to change it,ovh.exceptions.BadParametersError: [renew] Missing properties: (forced) for type RenewType
if missing
Please contact the official OVH API mailing-list for this non-related python-ovh issue.
Mailing list information are available here: https://github.com/ovh/python-ovh/blob/master/README.rst#ovh-europe