Added parameters to the "list-backups" python api

Added the following parameters: limit, offset,
search (can contain: time_before, time_after)

Change-Id: If43ac22b580ae387d85a4dc024a259ca2634a856
This commit is contained in:
Jonas Pfannschmidt 2015-05-01 17:24:31 +01:00 committed by Fausto Marzi
parent 1d08dc72c6
commit 40430ca3e9
1 changed files with 17 additions and 2 deletions

View File

@ -52,8 +52,23 @@ class BackupsManager(object):
raise exceptions.MetadataDeleteFailure(
"[*] Error {0}".format(r.status_code))
def list(self):
r = requests.get(self.endpoint, headers=self.headers)
def list(self, limit=10, offset=0, search=None):
"""
Retrieves a list of backup infos
:param limit: number of result to return (optional, default 10)
:param offset: order of first document (optional, default 0)
:param search: structured query (optional)
can contain:
* "time_before": timestamp
* "time_after": timestamp
Example:
{ "time_before": 1428529956 }
"""
data = json.dumps(search) if search else None
query = {'limit': int(limit), 'offset': int(offset)}
r = requests.get(self.endpoint, headers=self.headers,
params=query, data=data)
if r.status_code != 200:
raise exceptions.MetadataGetFailure(
"[*] Error {0}".format(r.status_code))