def iter(self, **kwargs): """ Return all instance resources using an iterator This will fetch a page of resources from the API and yield them in turn. When the page is exhausted, this will make a request to the API to retrieve the next page. Hence you may notice a pattern - the library will loop through 50 objects very quickly, but there will be a delay retrieving the 51st as the library must make another request to the API for resources. Example usage: .. code-block:: python for message in client.messages: print message.sid """ params = transform_params(kwargs) while True: resp, page = self.request("GET", self.uri, params=params) if self.key not in page: raise StopIteration() for ir in page[self.key]: yield self.load_instance(ir) if not page.get('next_page_uri', ''): raise StopIteration() o = urlparse(page['next_page_uri']) params.update(parse_qs(o.query))
def iter(self, **kwargs): """ Return all instance resources using an iterator This will fetch a page of resources from the API and yield them in turn. When the page is exhausted, this will make a request to the API to retrieve the next page. Hence you may notice a pattern - the library will loop through 50 objects very quickly, but there will be a delay retrieving the 51st as the library must make another request to the API for resources. Example usage: .. code-block:: python for message in client.messages: print message.sid """ params = transform_params(kwargs) while True: resp, page = self.request("GET", self.uri, params=params) if self.key not in page: raise StopIteration() for ir in page[self.key]: yield self.load_instance(ir) if not page.get('next_page_uri', ''): raise StopIteration() o = urlparse(page['next_page_uri']) params.update(parse_qs(o.query))
def iter(self, **kwargs): """ Return all instance resources using an iterator """ params = transform_params(kwargs) while True: resp, page = self.request("GET", self.uri, params=params) if self.key not in page: raise StopIteration() for ir in page[self.key]: yield self.load_instance(ir) if not page.get('next_page_uri', ''): raise StopIteration() o = urlparse(page['next_page_uri']) params.update(parse_qs(o.query))
def iter(self, **kwargs): """ Return all instance resources using an iterator """ params = transform_params(kwargs) while True: resp, page = self.request("GET", self.uri, params=params) if self.key not in page: raise StopIteration() for ir in page[self.key]: yield self.load_instance(ir) if not page.get('next_page_uri', ''): raise StopIteration() o = urlparse(page['next_page_uri']) params.update(parse_qs(o.query))