summaryrefslogtreecommitdiff
path: root/godaddy_del_txt.py
blob: cdf8ef44ef93e4653ee79fd3439e2d066c775d32 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/env python3
import requests
import json
from os import environ

if not 'CERTBOT_DOMAIN' in environ:
    print("Environment variable CERTBOT_DOMAIN is not set.\nMake sure you're running this script as a certbot hook.")
    exit(1)

domain = environ['CERTBOT_DOMAIN']

key = 'e4NBykPszU4u_AQSkww3bDD4mBYUn4jERAL'
secret = 'Wg9Pr9Du82cPU3FP6H6CNr'

s = requests.session()
s.headers.update({
    'Authorization' : "sso-key {}:{}".format(key, secret)
    })

records = s.get("https://api.godaddy.com/v1/domains/{}/records/TXT".format(domain)).json()

for rnum, r in enumerate(records):
    if r['name'] == "_acme-challenge":
        records.pop(rnum)

re = s.put("https://api.godaddy.com/v1/domains/{}/records/TXT".format(domain), json = records)