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
298 stars 81 forks source link

help with add of a DomainNS #5

Closed ghost closed 9 years ago

ghost commented 9 years ago

hello as API subscriber I am trying to automate a change of secondary DNS

my application_key=vBdLGPsBNVvzWiWP

and my code

client = ovh.Client()
#for example
dns = client.get('/domain/mydomain.com/nameServer')
for ns in dns:
    dnssec = client.get('/domain/mydomain.com/nameServer/' + str(ns))
    # i am able to delete a record
#NS = {'host' : 'ns2.myns.it', 'ip' : '123.123.123.123'}
#NS = ['ns2.myns.it']
#NS = {u'host': u'ns2.myns.it', u'ip': None, u'toDelete': False, u'isUsed': True}
#NS = {'host': 'ns2.myns.it'}
NS = {
    'namespace': "domain",
    'id': "DomainNs",
    'description': "Name server", 'properties':
        {
            'host': 'ns2.myns.it'
        }
    }

client.post('/domain/italiancasinoonline.com/nameServer', nameServer=NS)

PROBLEM IS HERE as you can see, I have tried list, dict, tuple ... no luck for me

Traceback (most recent call last): File "C:\Users\user\Documents\NetBeansProjects\ovhape\src\ovhape.py", line 63, in client.post('/domain/italiancasinoonline.com/nameServer', nameServer=NS) File "c:\Python27\lib\site-packages\ovh\client.py", line 305, in post return self.call('POST', _target, kwargs, _need_auth) File "c:\Python27\lib\site-packages\ovh\client.py", line 394, in call raise BadParametersError(json_result.get('message')) ovh.exceptions.BadParametersError: [nameServer] DomainNs Data is not an array for an array type

How can I add a name server to a domain? How can I create correctly a DomainNs Data??

Thanks Francesco

ghost commented 9 years ago

solved the argument must be passed as list of dict so this is the richt one

NS = [{'host': 'ns2.myns.it'}]