Convert v2 images list method to generator
We will want this to be a generator as soon as we implement pagination. Let's establish the interface now. Related to bp glance-client-v2 Change-Id: Ib98e912a7af0bb570b4fd738733edd9b837d1a07
This commit is contained in:
@@ -20,14 +20,16 @@ class Controller(object):
|
||||
self.model = model
|
||||
|
||||
def list(self):
|
||||
"""Retrieve a listing of Image objects
|
||||
|
||||
:returns generator over list of Images
|
||||
"""
|
||||
resp, body = self.http_client.json_request('GET', '/v2/images')
|
||||
images = []
|
||||
for image in body['images']:
|
||||
#NOTE(bcwaldon): remove 'self' for now until we have an elegant
|
||||
# way to pass it into the model constructor without conflict
|
||||
image.pop('self', None)
|
||||
images.append(self.model(**image))
|
||||
return images
|
||||
yield self.model(**image)
|
||||
|
||||
def get(self, image_id):
|
||||
url = '/v2/images/%s' % image_id
|
||||
|
||||
Reference in New Issue
Block a user