Return all resource records for a specific Route53 zone

        Args:
            zone_id (`str`): Name / ID of the hosted zone

        Returns:
            `dict`
169505
def __fetch_route53_zone_records(self, zone_id):
        
        route53 = self.session.client('route53')

        done = False
        nextName = nextType = None
        records = {}

        try:
            while not done:
                if nextName and nextType:
                    response = route53.list_resource_record_sets(
                        HostedZoneId=zone_id,
                        StartRecordName=nextName,
                        StartRecordType=nextType
                    )
                else:
                    response = route53.list_resource_record_sets(HostedZoneId=zone_id)

                if response['IsTruncated']:
                    nextName = response['NextRecordName']
                    nextType = response['NextRecordType']
                else:
                    done = True

                if 'ResourceRecordSets' in response:
                    for record in response['ResourceRecordSets']:
                        # Cannot make this a list, due to a race-condition in the AWS api that might return the same
                        # record more than once, so we use a dict instead to ensure that if we get duplicate records
                        # we simply just overwrite the one already there with the same info.
                        record_id = self._get_resource_hash(zone_id, record)
                        if 'AliasTarget' in record:
                            value = record['AliasTarget']['DNSName']
                            records[record_id] = {
                                'id': record_id,
                                'name': record['Name'].rstrip('.'),
                                'type': 'ALIAS',
                                'ttl': 0,
                                'value': [value]
                            }
                        else:
                            value = [y['Value'] for y in record['ResourceRecords']]
                            records[record_id] = {
                                'id': record_id,
                                'name': record['Name'].rstrip('.'),
                                'type': record['Type'],
                                'ttl': record['TTL'],
                                'value': value
                            }

            return list(records.values())
        finally:
            del route53
694532
def list_availability_zones(self, retrieve_all=True, **_params):
        """"""
        return self.list('availability_zones', self.availability_zones_path,
                         retrieve_all, **_params)
77057
def get_instance_route53_names(self, instance):
        '''  '''

        instance_attributes = [ 'public_dns_name', 'private_dns_name',
                                'ip_address', 'private_ip_address' ]

        name_list = set()

        for attrib in instance_attributes:
            try:
                value = getattr(instance, attrib)
            except AttributeError:
                continue

            if value in self.route53_records:
                name_list.update(self.route53_records[value])

        return list(name_list)
644838
def list(gandi, domain, zone_id, output, format, limit):
    """"""
    options = {
        'items_per_page': limit,
    }
    output_keys = ['name', 'type', 'value', 'ttl']

    if not zone_id:
        result = gandi.domain.info(domain)
        zone_id = result['zone_id']

    if not zone_id:
        gandi.echo('No zone records found, domain %s doesn\'t seems to be '
                   'managed at Gandi.' % domain)
        return

    records = gandi.record.list(zone_id, options)

    if not output and not format:
        for num, rec in enumerate(records):
            if num:
                gandi.separator_line()
            output_generic(gandi, rec, output_keys, justify=12)
    elif output:
        zone_filename = domain + "_" + str(zone_id)
        if os.path.isfile(zone_filename):
            open(zone_filename, 'w').close()
        for record in records:
            format_record = ('%s %s IN %s %s' %
                             (record['name'], record['ttl'],
                              record['type'], record['value']))
            with open(zone_filename, 'ab') as zone_file:
                zone_file.write(format_record + '\n')
        gandi.echo('Your zone file have been writen in %s' % zone_filename)
    elif format:
        if format == 'text':
            for record in records:
                format_record = ('%s %s IN %s %s' %
                                 (record['name'], record['ttl'],
                                  record['type'], record['value']))
                gandi.echo(format_record)
        if format == 'json':
            format_record = json.dumps(records, sort_keys=True,
                                       indent=4, separators=(',', ': '))
            gandi.echo(format_record)

    return records
386056
def __fetch_route53_zones(self):
        
        done = False
        marker = None
        zones = {}
        route53 = self.session.client('route53')

        try:
            while not done:
                if marker:
                    response = route53.list_hosted_zones(Marker=marker)
                else:
                    response = route53.list_hosted_zones()

                if response['IsTruncated']:
                    marker = response['NextMarker']
                else:
                    done = True

                for zone_data in response['HostedZones']:
                    zones[get_resource_id('r53z', zone_data['Id'])] = {
                        'name': zone_data['Name'].rstrip('.'),
                        'source': 'AWS/{}'.format(self.account),
                        'comment': zone_data['Config']['Comment'] if 'Comment' in zone_data['Config'] else None,
                        'zone_id': zone_data['Id'],
                        'private_zone': zone_data['Config']['PrivateZone'],
                        'tags': self.__fetch_route53_zone_tags(zone_data['Id'])
                    }

            return zones
        finally:
            del route53
615288
def list_address(self, domain):
        " "

        try:
            response = self.get('/REST/ARecord/%s/%s' % (
                self.zone, domain))
        except self.NotFoundError:
            return []

        # Return a generator with the addresses.
        addresses = response.content['data']
        return [Address.from_url(self, uri) for uri in addresses]
1071472
def atlasdb_get_zonefile_by_txid( txid, con=None, path=None ):
    
    ret = None
    with AtlasDBOpen(con=con, path=path) as dbcon:

        sql = "SELECT * FROM zonefiles WHERE txid = ?;"
        args = (txid,)

        cur = dbcon.cursor()
        res = atlasdb_query_execute( cur, sql, args )

        for zfinfo in res:
            ret = {}
            ret.update(zfinfo)
            break

    return ret
36472
def get_resource_by_id(resource_id, api_version, extract_value=None):
    '''
    
    '''
    ret = {}

    try:
        resconn = get_conn(client_type='resource')
        resource_query = resconn.resources.get_by_id(
            resource_id=resource_id,
            api_version=api_version
        )
        resource_dict = resource_query.as_dict()
        if extract_value is not None:
            ret = resource_dict[extract_value]
        else:
            ret = resource_dict
    except CloudError as exc:
        __utils__['azurearm.log_cloud_error']('resource', exc.message)
        ret = {'Error': exc.message}

    return ret
700078
def get_resource_id(resource, name=None, resource_id=None, region=None,
                    key=None, keyid=None, profile=None):
    '''
    

    '''

    try:
        return {'id': _get_resource_id(resource, name, region=region, key=key,
                                       keyid=keyid, profile=profile)}
    except BotoServerError as e:
        return {'error': __utils__['boto.get_error'](e)}
1225666
def parse_hosted_zones(self, hosted_zone, params):
        
        # When resuming upon throttling error, skip if already fetched
        hosted_zone_id = hosted_zone.pop('Id')
        hosted_zone['name'] = hosted_zone.pop('Name')
        api_client = params['api_client']
        record_sets = handle_truncated_response(api_client.list_resource_record_sets, {'HostedZoneId': hosted_zone_id}, ['ResourceRecordSets'])
        hosted_zone.update(record_sets)
        #print(str(record_sets))
        #record_sets = api_client.list_resource_record_sets()
        #hosted_zone['RecordSets'] = record_sets['Resourc']
        self.hosted_zones[hosted_zone_id] = hosted_zone
783447
def get_all_zones(self):
        """"""
        zones = {'HostedZones': []}

        new_zones = self.route53.list_hosted_zones(MaxItems='100')
        while new_zones['IsTruncated']:
            zones['HostedZones'] += new_zones['HostedZones']
            new_zones = self.route53.list_hosted_zones(Marker=new_zones['NextMarker'], MaxItems='100')

        zones['HostedZones'] += new_zones['HostedZones']
        return zones
95907
def get_zone(self, zone_id, records=True):
        
        mask = None
        if records:
            mask = 'resourceRecords'
        return self.service.getObject(id=zone_id, mask=mask)
292321
def list(cls, zone_id, options=None):
        """"""
        options = options if options else {}
        return cls.call('domain.zone.record.list', zone_id, 0, options)
1129851
def create_record(self, zone_name, params):
        
        self.log.debug('Create record: zone: %s, id %s', zone_name,
                       params)
        return self._client.post('/domain/zone/{}/record'.format(zone_name),
                                 **params)
920514
def _update_limits_from_api(self):
        
        logger.info("Querying Route53 GetHostedZoneLimits for limits")
        self.connect()
        self._find_limit_hosted_zone()
        logger.debug('Done setting limits from API.')
212871
def get_zone(name)
      params = {
          'command' => 'listZones',
          'available' => 'true'
      }
      json = send_request(params)

      networks = json['zone']
      return nil unless networks

      networks.each { |z|
        if name.is_uuid? then
          return z if z['id'] == name
        else
          return z if z['name'] == name
        end
      }
      nil
    end
339434
def _get_resource_id(resource, name, region=None, key=None,
                     keyid=None, profile=None):
    '''
    
    '''

    _id = _cache_id(name, sub_resource=resource,
                    region=region, key=key,
                    keyid=keyid, profile=profile)
    if _id:
        return _id

    r = _get_resource(resource, name=name, region=region, key=key,
                      keyid=keyid, profile=profile)

    if r:
        return r.id