ovh / python-ovh

Thin wrapper around OVH's APIs. Handles all the hard work including credential creation and requests signing.
https://pypi.org/project/ovh/
Other
297 stars 81 forks source link

FirewallOptionTCP Data is not a hash for a complex type #83

Closed hieu-n closed 4 years ago

hieu-n commented 4 years ago

I tried to create a rule authorising TCP protocol on all the IPs with an established option, as following:

rule = {'action': 'permit', 'protocol': 'tcp', 'sequence': 0, 'tcpOption': 'established'}
ip = 'xxx.xxx.xxx.xxx'
ovh_client.post(f'/ip/{ip}/firewall/{ip}/rule', **rule)

That raised the following exception:

 File "/miniconda/lib/python3.7/site-packages/ovh/client.py", line 377, in post
    return self.call('POST', _target, kwargs, _need_auth)
  File "/miniconda/lib/python3.7/site-packages/ovh/client.py", line 446, in call
    response=result)
ovh.exceptions.BadParametersError: [tcpOption] FirewallOptionTCP Data is not a hash for a complex type

What is the appropriate value to pass to tcpOption parameter?

rbeuque74 commented 4 years ago

Hello, Your issue seems not be related with the python-ovh wrapper itself, but tend to be on API usage. Support for API usage is done on api@ml.ovh.net (subscribe using api-subscribe@ml.ovh.net)

For your current problem, code should be like this:

rule = {'action': 'permit', 'protocol': 'tcp', 'sequence': 0, 'tcpOption': {'option':'established'}}
ip = 'xxx.xxx.xxx.xxx'
ovh_client.post(f'/ip/{ip}/firewall/{ip}/rule', **rule)

as tcpOption is a complex type named ip.FirewallOptionTCP.

Closing this issue, feel free to re-open if you think this issue is linked to a bug with python-ovh wrapper. Thanks Romain