in pygenie/client.py [0:0]
def get_applications(self, filters=None, req_size=1000):
"""
Get a list of applications.
Args:
filters (dict): a dictionary of filters to use in the query.
req_size (int): the number of items to return per request.
Yields:
dict: an application
Example:
>>> print([i for i in get_applications()])
>>> [{'id':'test3'}, {'id':'test2'}]
"""
params = filters or {}
_verify_filters(params, ['name', 'user', 'size', 'status', 'tag',
'type', 'page'])
# Iterate through any responses until we get to the end
params['page'] = 0
params['size'] = req_size
while True:
resp = self.call(self.path_application, method='GET', params=params)
if resp:
for app in resp['response'].get('applicationList', []):
yield DotDict(app)
else:
yield None
# Break if we're at the end
if (resp['page']['totalPages']) <= (resp['page']['number'] + 1):
break
# Get the next result
params['page'] += 1
logger.info('Fetching additional applications from genie [%s/%s]',
params['page'], resp['page']['totalPages'] - 1)