示例#1
0
    def test_limit_url(self):
        url_ = "test-url"
        limit_ = None
        marker_ = None
        self.assertEqual(url_, common.limit_url(url_))

        limit_ = "test-limit"
        marker_ = "test-marker"
        expected = "test-url?marker=test-marker&limit=test-limit"
        self.assertEqual(expected,
                         common.limit_url(url_, limit=limit_, marker=marker_))
    def test_limit_url(self):
        url_ = "test-url"
        limit_ = None
        marker_ = None
        self.assertEqual(url_, common.limit_url(url_))

        limit_ = "test-limit"
        marker_ = "test-marker"
        expected = "test-url?marker=test-marker&limit=test-limit"
        self.assertEqual(expected,
                         common.limit_url(url_, limit=limit_, marker=marker_))
 def _list(self, url, response_key, limit=None, marker=None):
     resp, body = self.api.client.get(limit_url(url, limit, marker))
     if not body:
         raise Exception("Call to " + url + " did not return a body.")
     links = body.get("links", [])
     next_links = [link["href"] for link in links if link["rel"] == "next"]
     next_marker = None
     for link in next_links:
         # Extract the marker from the url.
         parsed_url = urlparse.urlparse(link)
         query_dict = dict(urlparse.parse_qsl(parsed_url.query))
         next_marker = query_dict.get("marker", None)
     instances = body[response_key]
     instances = [self.resource_class(self, res) for res in instances]
     return Paginated(instances, next_marker=next_marker, links=links)
示例#4
0
 def _list(self, url, response_key, limit=None, marker=None):
     resp, body = self.api.client.get(limit_url(url, limit, marker))
     if not body:
         raise Exception("Call to " + url + " did not return a body.")
     links = body.get('links', [])
     next_links = [link['href'] for link in links if link['rel'] == 'next']
     next_marker = None
     for link in next_links:
         # Extract the marker from the url.
         parsed_url = urlparse.urlparse(link)
         query_dict = dict(urlparse.parse_qsl(parsed_url.query))
         next_marker = query_dict.get('marker', None)
     instances = body[response_key]
     instances = [self.resource_class(self, res) for res in instances]
     return Paginated(instances, next_marker=next_marker, links=links)
示例#5
0
 def _list(self, url, response_key, limit=None, marker=None):
     resp, body = self.api.client.get(limit_url(url, limit, marker))
     check_for_exceptions(resp, body)
     if not body:
         raise Exception("Call to " + url +
                         " did not return a body.")
     links = body.get('links', [])
     next_links = [link['href'] for link in links if link['rel'] == 'next']
     next_marker = None
     for link in next_links:
         # Extract the marker from the url.
         parsed_url = urlparse.urlparse(link)
         query_dict = dict(urlparse.parse_qsl(parsed_url.query))
         next_marker = query_dict.get('marker', None)
     users = [self.resource_class(self, res) for res in body[response_key]]
     return Paginated(users, next_marker=next_marker, links=links)