Fetch a resource.

        Method to fetch and to iterate over the contents of a
        type of resource. The method returns a generator of
        pages for that resource and parameters.

        :param resource: type of the resource
        :param params: parameters to filter

        :returns: a generator of pages for the requested resource

def _fetch(self, resource, params):
        """Fetch a resource.

        Method to fetch and to iterate over the contents of a
        type of resource. The method returns a generator of
        pages for that resource and parameters.

        :param resource: type of the resource
        :param params: parameters to filter

        :returns: a generator of pages for the requested resource
        """
        url = urijoin(self.base_url, 'v3', resource)

        do_fetch = True

        while do_fetch:
            logger.debug("Puppet forge client calls resource: %s params: %s",
                         resource, str(params))

            r = self.fetch(url, payload=params)
            yield r.text

            json_data = r.json()

            if 'pagination' in json_data:
                next_url = json_data['pagination']['next']

                if next_url:
                    # Params are already included in the URL
                    url = urijoin(self.base_url, next_url)
                    params = {}
                else:
                    do_fetch = False
            else:
                do_fetch = False