'Query a domain name for an authoritative SOA record.
:param str domain_name: The domain name to query for an SOA record.
:returns: True if found, False otherwise.
:rtype: bool
:raises certbot.errors.PluginError: if no response is received.'

def _query_soa(self, domain_name):

    domain = dns.name.from_text(domain_name)
    request = dns.message.make_query(domain, dns.rdatatype.SOA, dns.rdataclass.IN)
    request.flags ^= dns.flags.RD
    try:
        response = dns.query.udp(request, self.server)
        rcode = response.rcode()
        if ((rcode == dns.rcode.NOERROR) and (len(response.answer) > 0) and (response.flags & dns.flags.AA)):
            logger.debug('Received    authoritative    SOA    response    for    %s', domain_name)
            return True
        logger.debug('No    authoritative    SOA    record    found    for    %s', domain_name)
        return False
    except Exception as e:
        raise errors.PluginError('Encountered    error    when    making    query:    {0}'.format(e))
