'Create a new record.
There are two PowerDNS-specific quirks here. Firstly, this method will
silently clobber any pre-existing records that might already exist. For
example, if PowerDNS already contains a "test.example.com" A record,
and you create that record using this function, then the old A record
will be replaced with your new one.
Secondly, PowerDNS requires that you provide a ttl for all new records.
In other words, the "extra" parameter must be ``{\'ttl\':
<some-integer>}`` at a minimum.
:param name: FQDN of the new record, for example "www.example.com".
:type  name: ``str``
:param zone: Zone where the requested record is created.
:type  zone: :class:`Zone`
:param type: DNS record type (A, AAAA, ...).
:type  type: :class:`RecordType`
:param data: Data for the record (depends on the record type).
:type  data: ``str``
:param extra: Extra attributes (driver specific, e.g. \'ttl\').
Note that PowerDNS *requires* a ttl value for every
record.
:type extra: ``dict``
:rtype: :class:`Record`'

def create_record(self, name, zone, type, data, extra=None):

    action = ('%s/servers/%s/zones/%s' % (self.api_root, self.ex_server, zone.id))
    if ((extra is None) or (extra.get('ttl', None) is None)):
        raise ValueError('PowerDNS    requires    a    ttl    value    for    every    record')
    record = {'content': data, 'disabled': False, 'name': name, 'ttl': extra['ttl'], 'type': type}
    payload = {'rrsets': [{'name': name, 'type': type, 'changetype': 'REPLACE', 'records': [record]}]}
    try:
        self.connection.request(action=action, data=json.dumps(payload), method='PATCH')
    except BaseHTTPError:
        e = sys.exc_info()[1]
        if ((e.code == httplib.UNPROCESSABLE_ENTITY) and e.message.startswith('Could    not    find    domain')):
            raise ZoneDoesNotExistError(zone_id=zone.id, driver=self, value=e.message)
        raise e
    return Record(id=None, name=name, data=data, type=type, zone=zone, driver=self, ttl=extra['ttl'])
