'Find the managed zone for a given domain.
:param str domain: The domain for which to find the managed zone.
:returns: The ID of the managed zone, if found.
:rtype: str
:raises certbot.errors.PluginError: if the managed zone cannot be found.'

def _find_managed_zone_id(self, domain):

    zone_dns_name_guesses = dns_common.base_domain_name_guesses(domain)
    mz = self.dns.managedZones()
    for zone_name in zone_dns_name_guesses:
        try:
            request = mz.list(project=self.project_id, dnsName=(zone_name + '.'))
            response = request.execute()
            zones = response['managedZones']
        except googleapiclient_errors.Error as e:
            raise errors.PluginError('Encountered    error    finding    managed    zone:    {0}'.format(e))
        if (len(zones) > 0):
            zone_id = zones[0]['id']
            logger.debug('Found    id    of    %s    for    %s    using    name    %s', zone_id, domain, zone_name)
            return zone_id
    raise errors.PluginError('Unable    to    determine    managed    zone    for    {0}    using    zone    names:    {1}.'.format(domain, zone_dns_name_guesses))
