Yaroslav Surzhikov created LIBCLOUD-992: -------------------------------------------
Summary: Godaddy DNS driver: add lazy iteration to list_zones method Key: LIBCLOUD-992 URL: https://issues.apache.org/jira/browse/LIBCLOUD-992 Project: Libcloud Issue Type: Improvement Components: DNS Reporter: Yaroslav Surzhikov Because [/v1/domains|https://developer.godaddy.com/doc/endpoint/domains#/v1/list] has a limit key, which is the default of 100 ( Unfortunately, this is not documented and was found empirically) - the corresponding method ( GoDaddyDNSDriver.list_zones ) will return maximum of 100 records. So, my suggestion is: Instead of this: {code} def list_zones(self): """ Return a list of zones (purchased domains) :return: ``list`` of :class:`Zone` """ result = self.connection.request( '/v1/domains/').object zones = self._to_zones(result) return zones {code} Use something like this: {code} def list_zones_helper(self, marker=''): """ Lazy recursive generator of zones (purchased domains) :param marker: Domain to use as the offset in results :return: ``generator`` of result items """ result = self.connection.request( '/v1/domains/?marker={0}'.format(marker) ).object if result: yield from result yield from self.list_zones_helper(result[-1]['domain']) def list_zones(self): """ Return a list of zones (purchased domains) :return: ``list`` of :class:`Zone` """ return self._to_zones(self.list_zones_helper()) {code} In addition, there is a possible vulnerability in the "_to_zones" method - it can raise KeyError if domain was expired or cancelled and has no "expires" key in dictionary. P.S. Sorry for any mistakes. English is not my native language -- This message was sent by Atlassian JIRA (v7.6.3#76005)