Removed my api key from the public github repo (oops!) :)

This commit is contained in:
John Shaver 2014-09-01 09:38:47 -06:00
parent 7bfec6689b
commit eeb1c84bac
3 changed files with 14 additions and 11 deletions

1
.gitignore vendored
View file

@ -1,3 +1,4 @@
apikey.py
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]

2
apikey.py.example Normal file
View file

@ -0,0 +1,2 @@
API_EMAIL='myemail@example.org'
API_KEY='myalphanumericapikey'

View file

@ -3,17 +3,14 @@
from dnsimple import DNSimple
from urllib import urlopen
from sys import stderr, exit
from apikey import API_EMAIL, API_KEY
domains = [{"domain": 'jshaver.net', "names": ["", "bc"]},
{"domain": 'theamazingshavers.com', "names": [""]}]
token = "esnmgLubCqZkRKiNsbwVQ"
email = "bobjohnbob@gmail.com"
ttl = 600
dns = DNSimple(email=email, api_token = token)
dns = DNSimple(email=API_EMAIL, api_token=API_KEY)
response = urlopen("http://icanhazip.com/")
@ -25,22 +22,25 @@ ip = response.readline().rstrip()
def get_a_record(domain, name):
records = dns.records(domain)
for record in records:
for entry in records:
record = entry["record"]
if record["name"] is name and ["record_type"] is 'A':
return record
return None
def update_record(domain, name, record, ip):
new = {"record": {"name": name, "content": ip}}
new = {"name": name, "content": ip}
response = dns.update_record(domain, record["id"], new)
return response["record"]
def create_record(domain, name, ip):
new = {"record": {
new = {
"name": name,
"content",: ip,
"content": ip,
"record_type": "A",
"ttl": ttl}}
"ttl": ttl}
print new
print domain
response = dns.add_record(domain, new)
return response["record"]
@ -58,7 +58,7 @@ def update_domain_ip(domain, name, ip):
def main(domainList, ip):
for domain in domainList:
for name in domain["names"]:
update_domain_ip(domain, name, ip)
update_domain_ip(domain["domain"], name, ip)
main(domains, ip)