[ https://issues.apache.org/jira/browse/LIBCLOUD-992?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16431786#comment-16431786 ]
Yaroslav Surzhikov commented on LIBCLOUD-992: --------------------------------------------- Well, i've allready tested this code: for my requirements i use custom godaddy driver which inherits libcloud driver and it works as expected. As for contributing: if you could provide some information about test requirements and branch in git repo which i should use to open pull request - i think i could add this by myself. > 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 > Priority: Minor > > 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)