Skip to content

Commit

Permalink
Merge fd68a96 into 067f7fe
Browse files Browse the repository at this point in the history
  • Loading branch information
AnalogJ committed Jul 30, 2016
2 parents 067f7fe + fd68a96 commit 3c62df0
Show file tree
Hide file tree
Showing 30 changed files with 892 additions and 16 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ Potential providers are as follows. If you would like to contribute one, please
- AuroraDNS ([docs](https://www.pcextreme.com/aurora/dns))
- AHNames ([docs](https://ahnames.com/en/resellers?tab=2))
- AWS Route53 ([docs](https://docs.aws.amazon.com/Route53/latest/APIReference/Welcome.html))
- BuddyDNS ([docs](https://www.buddyns.com/support/api/v2/))
- ClouDNS ([docs](https://www.cloudns.net/wiki/article/56/))
- DurableDNS ([docs](https://durabledns.com/wiki/doku.php/ddns))
- ~~BuddyDNS ([docs](https://www.buddyns.com/support/api/v2/))~~
- ~~ClouDNS ([docs](https://www.cloudns.net/wiki/article/56/))~~ Requires paid account
- ~~DurableDNS ([docs](https://durabledns.com/wiki/doku.php/ddns))~~ Can't set TXT records
- Dyn ([docs](https://help.dyn.com/dns-api-knowledge-base/))
- EntryDNS ([docs](https://entrydns.net/help))
- Google Cloud DNS ([docs](https://cloud.google.com/dns/api/v1/))
Expand Down
2 changes: 1 addition & 1 deletion lexicon/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def BaseProviderParser():

parser.add_argument("--name", help="specify the record name")
parser.add_argument("--content", help="specify the record content")
parser.add_argument("--ttl", help="specify the record time-to-live")
parser.add_argument("--ttl", type=int, help="specify the record time-to-live")
parser.add_argument("--priority", help="specify the record priority")
parser.add_argument("--identifier", help="specify the record for update or delete actions")
return parser
Expand Down
4 changes: 3 additions & 1 deletion lexicon/providers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ class Provider(object):
def __init__(self, options):
self.provider_name = 'example',
self.options = options
self.default_ttl = 3600

# Authenicate against provider,
# Make any requests required to get the domain's id for this provider, so it can be used in subsequent calls.
Expand Down Expand Up @@ -69,4 +70,5 @@ def _clean_TXT_record(self, record):
if record['type'] == 'TXT':
# some providers have quotes around the TXT records, so we're going to remove those extra quotes
record['content'] = record['content'][1:-1]
return record
return record

7 changes: 6 additions & 1 deletion lexicon/providers/cloudflare.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ def authenticate(self):

# Create record. If record already exists with the same content, do nothing'
def create_record(self, type, name, content):
payload = self._post('/zones/{0}/dns_records'.format(self.domain_id), {'type': type, 'name': self._full_name(name), 'content': content})
data = {'type': type, 'name': self._full_name(name), 'content': content}
if self.options.get('ttl'):
data['ttl'] = self.options.get('ttl')
payload = self._post('/zones/{0}/dns_records'.format(self.domain_id), data)

print 'create_record: {0}'.format(payload['success'])
return payload['success']
Expand Down Expand Up @@ -73,6 +76,8 @@ def update_record(self, identifier, type=None, name=None, content=None):
data['name'] = self._full_name(name)
if content:
data['content'] = content
if self.options.get('ttl'):
data['ttl'] = self.options.get('ttl')

payload = self._put('/zones/{0}/dns_records/{1}'.format(self.domain_id, identifier), data)

Expand Down
6 changes: 5 additions & 1 deletion lexicon/providers/cloudxns.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@ def create_record(self, type, name, content):
'host': self._relative_name(name),
'value': content,
'type': type,
'line_id': 1
'line_id': 1,
}
if self.options.get('ttl'):
record['ttl'] = self.options.get('ttl')

payload = self._post('/record', record)

Expand Down Expand Up @@ -92,6 +94,8 @@ def update_record(self, identifier, type=None, name=None, content=None):
'value': content,
'type': type
}
if self.options.get('ttl'):
data['ttl'] = self.options.get('ttl')

payload = self._put('/record/' + identifier, data)

Expand Down
4 changes: 4 additions & 0 deletions lexicon/providers/dnsimple.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ def create_record(self, type, name, content):
'content': content
}
}
if self.options.get('ttl'):
record['record']['ttl'] = self.options.get('ttl')
payload = {}
try:
payload = self._post('/domains/{0}/records'.format(self.domain_id), record)
Expand Down Expand Up @@ -79,6 +81,8 @@ def update_record(self, identifier, type=None, name=None, content=None):
data['record']['name'] = self._relative_name(name)
if content:
data['record']['content'] = content
if self.options.get('ttl'):
data['record']['ttl'] = self.options.get('ttl')

payload = self._put('/domains/{0}/records/{1}'.format(self.domain_id, identifier), data)

Expand Down
4 changes: 2 additions & 2 deletions lexicon/providers/dnsmadeeasy.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def create_record(self, type, name, content):
'type': type,
'name': self._relative_name(name),
'value': content,
'ttl': 86400
'ttl': self.options.get('ttl',self.default_ttl)
}
payload = {}
try:
Expand Down Expand Up @@ -79,7 +79,7 @@ def update_record(self, identifier, type=None, name=None, content=None):

data = {
'id': identifier,
'ttl': 86400
'ttl': self.options.get('ttl',self.default_ttl)
}

if name:
Expand Down
2 changes: 1 addition & 1 deletion lexicon/providers/dnspark.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def list_records(self, type=None, name=None, content=None):
def update_record(self, identifier, type=None, name=None, content=None):

data = {
'ttl': 300
'ttl': self.options.get('ttl',self.default_ttl)
}
if type:
data['rtype'] = type
Expand Down
4 changes: 4 additions & 0 deletions lexicon/providers/dnspod.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ def create_record(self, type, name, content):
'record_line': '默认',
'value': content
}
if self.options.get('ttl'):
record['ttl'] = self.options.get('ttl')

payload = self._post('/Record.Create', record)

Expand Down Expand Up @@ -83,6 +85,8 @@ def update_record(self, identifier, type=None, name=None, content=None):
'record_line': '默认',
'value': content
}
if self.options.get('ttl'):
data['ttl'] = self.options.get('ttl')
print data
payload = self._post('/Record.Modify', data)
print payload
Expand Down
4 changes: 2 additions & 2 deletions lexicon/providers/easydns.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def create_record(self, type, name, content):
'type': type,
'domain': self.domain_id,
'host': self._relative_name(name),
'ttl': 300,
'ttl': self.options.get('ttl',self.default_ttl),
'prio': 0,
'rdata': content
}
Expand Down Expand Up @@ -77,7 +77,7 @@ def list_records(self, type=None, name=None, content=None):
def update_record(self, identifier, type=None, name=None, content=None):

data = {
'ttl': 300
'ttl': self.options.get('ttl',self.default_ttl)
}
if type:
data['type'] = type
Expand Down
4 changes: 2 additions & 2 deletions lexicon/providers/luadns.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def authenticate(self):

# Create record. If record already exists with the same content, do nothing'
def create_record(self, type, name, content):
payload = self._post('/zones/{0}/records'.format(self.domain_id), {'type': type, 'name': self._fqdn_name(name), 'content': content, 'ttl': 300})
payload = self._post('/zones/{0}/records'.format(self.domain_id), {'type': type, 'name': self._fqdn_name(name), 'content': content, 'ttl': self.options.get('ttl',self.default_ttl)})

print 'create_record: {0}'.format(True)
return True
Expand Down Expand Up @@ -63,7 +63,7 @@ def list_records(self, type=None, name=None, content=None):
def update_record(self, identifier, type=None, name=None, content=None):

data = {
'ttl': 300
'ttl': self.options.get('ttl',self.default_ttl)
}
if type:
data['type'] = type
Expand Down
4 changes: 4 additions & 0 deletions lexicon/providers/namesilo.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ def create_record(self, type, name, content):
'rrtype': type,
'rrvalue': content
}
if self.options.get('ttl'):
record['rrttl'] = self.options.get('ttl')
payload = self._get('/dnsAddRecord', record)
print 'create_record: {0}'.format(True)
return True
Expand Down Expand Up @@ -72,6 +74,8 @@ def update_record(self, identifier, type=None, name=None, content=None):
data['rrhost'] = self._relative_name(name)
if content:
data['rdata'] = content
if self.options.get('ttl'):
data['rrttl'] = self.options.get('ttl')

payload = self._get('/dnsUpdateRecord', data)

Expand Down
5 changes: 5 additions & 0 deletions lexicon/providers/rage4.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ def create_record(self, type, name, content):
'content': content,
'type': type
}
if self.options.get('ttl'):
record['ttl'] = self.options.get('ttl')

payload = {}
try:
payload = self._post('/createrecord/',{},record)
Expand Down Expand Up @@ -78,6 +81,8 @@ def update_record(self, identifier, type=None, name=None, content=None):
data['name'] = self._full_name(name)
if content:
data['content'] = content
if self.options.get('ttl'):
data['ttl'] = self.options.get('ttl')
# if type:
# raise 'Type updating is not supported by this provider.'

Expand Down
6 changes: 4 additions & 2 deletions lexicon/providers/vultr.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ def create_record(self, type, name, content):
record['data'] = "\"{0}\"".format(content)
else:
record['data'] = content
if self.options.get('ttl'):
record['ttl'] = self.options.get('ttl')
payload = self._post('/dns/create_record', record)

print 'create_record: {0}'.format(True)
Expand All @@ -51,7 +53,7 @@ def list_records(self, type=None, name=None, content=None):
processed_record = {
'type': record['type'],
'name': "{0}.{1}".format(record['name'], self.domain_id),
'ttl': record.get('ttl', 300),
'ttl': record.get('ttl', self.options.get('ttl',self.default_ttl)),
'content': record['data'],
'id': record['RECORDID']
}
Expand All @@ -74,7 +76,7 @@ def update_record(self, identifier, type=None, name=None, content=None):
data = {
'domain': self.domain_id,
'RECORDID': identifier,
'ttl': 300
'ttl': self.options.get('ttl',self.default_ttl)
}
# if type:
# data['type'] = type
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
interactions:
- request:
body: '{}'
headers:
Accept: ['*/*']
Accept-Encoding: ['gzip, deflate']
Connection: [keep-alive]
Content-Length: ['2']
Content-Type: [application/json]
User-Agent: [python-requests/2.9.1]
method: GET
uri: https://api.cloudflare.com/client/v4/zones?status=active&name=capsulecd.com
response:
body: {string: !!python/unicode '{"result":[{"id":"fac516c650e5a737bdc3e1e3dc1047f3","name":"capsulecd.com","status":"active","paused":false,"type":"full","development_mode":0,"name_servers":["dawn.ns.cloudflare.com","owen.ns.cloudflare.com"],"original_name_servers":["ns1glr.name.com","ns2bls.name.com","ns3nrz.name.com","ns4hny.name.com"],"original_registrar":null,"original_dnshost":null,"modified_on":"2016-07-30T20:59:34.628808Z","created_on":"2016-03-09T07:39:40.476430Z","meta":{"step":4,"wildcard_proxiable":false,"custom_certificate_quota":0,"page_rule_quota":3,"phishing_detected":false,"multiple_railguns_allowed":false},"owner":{"type":"user","id":"521a961001d9333c8191f53a9f70eb31","email":"darkmethodz@gmail.com"},"permissions":["#analytics:read","#billing:edit","#billing:read","#cache_purge:edit","#dns_records:edit","#dns_records:read","#lb:edit","#lb:read","#logs:read","#organization:edit","#organization:read","#ssl:edit","#ssl:read","#waf:edit","#waf:read","#zone:edit","#zone:read","#zone_settings:edit","#zone_settings:read"],"plan":{"id":"0feeeeeeeeeeeeeeeeeeeeeeeeeeeeee","name":"Free
Website","price":0,"currency":"USD","frequency":"","legacy_id":"free","legacy_discount":false,"is_subscribed":null,"can_subscribe":null,"externally_managed":false}}],"result_info":{"page":1,"per_page":20,"total_pages":1,"count":1,"total_count":1},"success":true,"errors":[],"messages":[]}'}
headers:
cache-control: ['no-store, no-cache, must-revalidate, post-check=0, pre-check=0']
cf-ray: [2cabd520f7ad2840-SJC]
connection: [keep-alive]
content-length: ['1365']
content-type: [application/json]
date: ['Sat, 30 Jul 2016 21:16:35 GMT']
expires: ['Sun, 25 Jan 1981 05:00:00 GMT']
pragma: [no-cache]
server: [cloudflare-nginx]
set-cookie: ['__cfduid=dd9d24e707e22b025cd9a50565acc2e7b1469913395; expires=Sun,
30-Jul-17 21:16:35 GMT; path=/; domain=.cloudflare.com; HttpOnly']
strict-transport-security: [max-age=31536000]
x-content-type-options: [nosniff]
x-frame-options: [SAMEORIGIN]
status: {code: 200, message: OK}
- request:
body: '{"content": "ttlshouldbe3600", "type": "TXT", "name": "ttl.fqdn.capsulecd.com",
"ttl": 3600}'
headers:
Accept: ['*/*']
Accept-Encoding: ['gzip, deflate']
Connection: [keep-alive]
Content-Length: ['92']
Content-Type: [application/json]
User-Agent: [python-requests/2.9.1]
method: POST
uri: https://api.cloudflare.com/client/v4/zones/fac516c650e5a737bdc3e1e3dc1047f3/dns_records
response:
body: {string: !!python/unicode '{"result":{"id":"d8228669d592e95dae643af3f02b3121","type":"TXT","name":"ttl.fqdn.capsulecd.com","content":"ttlshouldbe3600","proxiable":false,"proxied":false,"ttl":3600,"locked":false,"zone_id":"fac516c650e5a737bdc3e1e3dc1047f3","zone_name":"capsulecd.com","modified_on":"2016-07-30T21:16:37.708905Z","created_on":"2016-07-30T21:16:37.708905Z","meta":{"auto_added":false}},"success":true,"errors":[],"messages":[]}'}
headers:
cache-control: ['no-store, no-cache, must-revalidate, post-check=0, pre-check=0']
cf-ray: [2cabd52f886e2840-SJC]
connection: [keep-alive]
content-length: ['414']
content-type: [application/json]
date: ['Sat, 30 Jul 2016 21:16:37 GMT']
expires: ['Sun, 25 Jan 1981 05:00:00 GMT']
pragma: [no-cache]
server: [cloudflare-nginx]
set-cookie: ['__cfduid=dc4936330fb57b49d96db3db72b9c73471469913397; expires=Sun,
30-Jul-17 21:16:37 GMT; path=/; domain=.cloudflare.com; HttpOnly']
strict-transport-security: [max-age=31536000]
x-content-type-options: [nosniff]
x-frame-options: [SAMEORIGIN]
status: {code: 200, message: OK}
- request:
body: '{}'
headers:
Accept: ['*/*']
Accept-Encoding: ['gzip, deflate']
Connection: [keep-alive]
Content-Length: ['2']
Content-Type: [application/json]
User-Agent: [python-requests/2.9.1]
method: GET
uri: https://api.cloudflare.com/client/v4/zones/fac516c650e5a737bdc3e1e3dc1047f3/dns_records?per_page=100&type=TXT&name=ttl.fqdn.capsulecd.com
response:
body: {string: !!python/unicode '{"result":[{"id":"d8228669d592e95dae643af3f02b3121","type":"TXT","name":"ttl.fqdn.capsulecd.com","content":"ttlshouldbe3600","proxiable":false,"proxied":false,"ttl":3600,"locked":false,"zone_id":"fac516c650e5a737bdc3e1e3dc1047f3","zone_name":"capsulecd.com","modified_on":"2016-07-30T21:16:37.708905Z","created_on":"2016-07-30T21:16:37.708905Z","meta":{"auto_added":false}}],"result_info":{"page":1,"per_page":100,"total_pages":1,"count":1,"total_count":1},"success":true,"errors":[],"messages":[]}'}
headers:
cache-control: ['no-store, no-cache, must-revalidate, post-check=0, pre-check=0']
cf-ray: [2cabd53e19080669-SJC]
connection: [keep-alive]
content-length: ['498']
content-type: [application/json]
date: ['Sat, 30 Jul 2016 21:16:40 GMT']
expires: ['Sun, 25 Jan 1981 05:00:00 GMT']
pragma: [no-cache]
server: [cloudflare-nginx]
set-cookie: ['__cfduid=dc94c57a150fef3b606be0709cb6fed481469913400; expires=Sun,
30-Jul-17 21:16:40 GMT; path=/; domain=.cloudflare.com; HttpOnly']
strict-transport-security: [max-age=31536000]
transfer-encoding: [chunked]
x-content-type-options: [nosniff]
x-frame-options: [SAMEORIGIN]
status: {code: 200, message: OK}
version: 1

0 comments on commit 3c62df0

Please sign in to comment.