Browse Source

Add CAA support for NS1

pull/103/head
Ross McFarland 8 years ago
parent
commit
22591ae84b
No known key found for this signature in database GPG Key ID: 61C10C4FC8FE4A89
1 changed files with 21 additions and 2 deletions
  1. +21
    -2
      octodns/provider/ns1.py

+ 21
- 2
octodns/provider/ns1.py View File

@ -23,8 +23,8 @@ class Ns1Provider(BaseProvider):
api_key: env/NS1_API_KEY api_key: env/NS1_API_KEY
''' '''
SUPPORTS_GEO = False SUPPORTS_GEO = False
SUPPORTS = set(('A', 'AAAA', 'ALIAS', 'CNAME', 'MX', 'NAPTR', 'NS', 'PTR',
'SPF', 'SRV', 'TXT'))
SUPPORTS = set(('A', 'AAAA', 'ALIAS', 'CAA', 'CNAME', 'MX', 'NAPTR', 'NS',
'PTR', 'SPF', 'SRV', 'TXT'))
ZONE_NOT_FOUND_MESSAGE = 'server error: zone not found' ZONE_NOT_FOUND_MESSAGE = 'server error: zone not found'
@ -53,6 +53,21 @@ class Ns1Provider(BaseProvider):
_data_for_TXT = _data_for_SPF _data_for_TXT = _data_for_SPF
def _data_for_CAA(self, _type, record):
values = []
for answer in record['short_answers']:
flags, tag, value = answer.split(' ', 2)
values.append({
'flags': flags,
'tag': tag,
'value': value,
})
return {
'ttl': record['ttl'],
'type': _type,
'values': values,
}
def _data_for_CNAME(self, _type, record): def _data_for_CNAME(self, _type, record):
return { return {
'ttl': record['ttl'], 'ttl': record['ttl'],
@ -159,6 +174,10 @@ class Ns1Provider(BaseProvider):
_params_for_TXT = _params_for_SPF _params_for_TXT = _params_for_SPF
def _params_for_CAA(self, record):
values = [(v.flags, v.tag, v.value) for v in record.values]
return {'answers': values, 'ttl': record.ttl}
def _params_for_CNAME(self, record): def _params_for_CNAME(self, record):
return {'answers': [record.value], 'ttl': record.ttl} return {'answers': [record.value], 'ttl': record.ttl}


Loading…
Cancel
Save