From notifications-return-14520-archive-asf-public=cust-asf.ponee.io@libcloud.apache.org Tue Apr 10 01:26:06 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id 2223C180645 for ; Tue, 10 Apr 2018 01:26:05 +0200 (CEST) Received: (qmail 45873 invoked by uid 500); 9 Apr 2018 23:26:05 -0000 Mailing-List: contact notifications-help@libcloud.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@libcloud.apache.org Delivered-To: mailing list notifications@libcloud.apache.org Received: (qmail 45864 invoked by uid 99); 9 Apr 2018 23:26:05 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 09 Apr 2018 23:26:05 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id AE7D0C0C5E for ; Mon, 9 Apr 2018 23:26:04 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -102.3 X-Spam-Level: X-Spam-Status: No, score=-102.3 tagged_above=-999 required=6.31 tests=[RCVD_IN_DNSWL_MED=-2.3, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id iekzB4MMtkSC for ; Mon, 9 Apr 2018 23:26:01 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTP id B73F85FB95 for ; Mon, 9 Apr 2018 23:26:00 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 5EA52E01AD for ; Mon, 9 Apr 2018 23:26:00 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 18916241C7 for ; Mon, 9 Apr 2018 23:26:00 +0000 (UTC) Date: Mon, 9 Apr 2018 23:26:00 +0000 (UTC) From: "Yaroslav Surzhikov (JIRA)" To: notifications@libcloud.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Created] (LIBCLOUD-992) Godaddy DNS driver: add lazy iteration to list_zones method MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 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 i= s not documented and was found empirically) - the corresponding method ( Go= DaddyDNSDriver.list_zones ) will return maximum of 100 records. So, my suggestion is: Instead of this:=C2=A0 {code} def list_zones(self): """ Return a list of zones (purchased domains) :return: ``list`` of :class:`Zone` """ result =3D self.connection.request( '/v1/domains/').object zones =3D self._to_zones(result) return zones {code} Use something like this: {code} def list_zones_helper(self, marker=3D''): """ Lazy recursive generator of zones (purchased domains) :param marker: Domain to use as the offset in results :return: ``generator`` of result items """ result =3D self.connection.request( '/v1/domains/?marker=3D{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 -= =C2=A0it=C2=A0can raise KeyError if domain=C2=A0was expired or cancelled an= d 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)