You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I wrote this function which i find useful, thought others might too:
if you are doing a lot of additions/updates it is better to generate exist first and pass it in rather than have each call get the existing records.
defadd_or_update(domain, ip, value, record_type='A', exist=None):
ifnotexist:
exist=client.get_records(domain, record_type=record_type)
names= [x['name'] forxinexist]
ifvalueinnames:
ifexist[names.index(value)]['data'] !=ip:
client.update_record_ip(ip, domain,value,record_type)
print(f'Updated {value}.{domain} to point to {ip}.')
else:
print(f'{value}.{domain} already points to {ip}. Not changing anything.')
else:
client.add_record(domain,
{
'data': ip,
'name': value,
'ttl':3600,
'type':record_type
})
print(f'Added record for {value}.{domain} to point to {ip}.')
The text was updated successfully, but these errors were encountered:
The API isn't the cleanest for GoDaddy to be honest. But at least it is stable, haha. If I get some free time soon, I'm looking at polishing up this library and adding quite a few things I've been collecting.
This is a great library. Thanks!
I wrote this function which i find useful, thought others might too:
if you are doing a lot of additions/updates it is better to generate
exist
first and pass it in rather than have each call get the existing records.The text was updated successfully, but these errors were encountered: