# -*- encoding: utf-8 -*- ''' First, install the latest release of Python wrapper: $ pip install ovh ''' import json import ovh import argparse parser = argparse.ArgumentParser() parser.add_argument('--ip', help='foo help') args = parser.parse_args() # Instanciate an OVH Client. # You can generate new credentials with full access to your account on # the token creation page client = ovh.Client( endpoint='ovh-eu', # Endpoint of API OVH Europe (List of available endpoints) application_key='{{ application_key }}', # Application Key application_secret='{{ application_secret }}', # Application Secret consumer_key='{{ consumer_key }}', # Consumer Key ) result = client.get('/domain/zone/valczeryba.ovh/record', fieldType='A', subDomain='api', ) # Pretty print if len(result) > 0: for idDns in result: result = client.get('/domain/zone/valczeryba.ovh/record/{0}'.format(idDns)) if result["target"] != args.ip: result = client.put('/domain/zone/valczeryba.ovh/record/{0}'.format(idDns), subDomain='api', target=args.ip, ) print(result) else: result = client.post('/domain/zone/valczeryba.ovh/record', fieldType='A', subDomain='api', target=args.ip, ttl=None, ) print(result)