Commit b758e547 authored by Stavros Sachtouris's avatar Stavros Sachtouris
Browse files

Added full pithos support to list_containers

In pithos, added full support for optional parameters and headers supported
in Pithos API in list_containers() (account get)
parent 6657ec8c
......@@ -142,9 +142,11 @@ class PithosClient(StorageClient):
r = self.post(path, success=202)
def get_account_info(self, until = None, if_modified_since=None, if_unmodified_since=None):
""" @param until (string): optional timestamp
@param if_modified_since (string): Retrieve if account has changed since provided timestamp
@param if_unmodified_since (string): Retrieve if account has not changed since provided timestamp
""" --- Optional request parameters ---
@param until (string): optional timestamp
--- --- optional request headers ---
@param if_modified_since (string): Retrieve if account has changed since provided timestamp
@param if_unmodified_since (string): Retrieve if account has not changed since provided timestamp
"""
self.assert_account()
path = path4url(self.account)
......@@ -192,6 +194,40 @@ class PithosClient(StorageClient):
self.set_header('X-Account-Policy-Versioning', versioning)
self.post(path, success=202)
def list_containers(self,
limit=None, marker=None, format='json', show_only_shared=False, until=None,
if_modified_since=None, if_unmodified_since=None):
"""
@param limit (integer): The amount of results requested (server qill use default value if None)
@param marker (string): Return containers with name lexicographically after marker
@param format (string): reply format can be json or xml (default: json)
@param shared (bool): If true, only shared containers will be included in results
@param until (string): optional timestamp
--- --- optional request headers ---
@param if_modified_since (string): Retrieve if account has changed since provided timestamp
@param if_unmodified_since (string): Retrieve if account has not changed since provided timestamp
"""
self.assert_account()
param_dict = dict(format=format)
if limit is not None:
param_dict['limit'] = limit
if marker is not None:
param_dict['marker'] = marker
if show_only_shared:
param_dict['shared'] = None
if until is not None:
param_dict['until'] = until
path = path4url(self.account)+params4url(param_dict)
if if_modified_since is not None:
self.set_header('If-Modified-Since', if_modified_since)
if if_unmodified_since is not None:
self.set_header('If-Unmodified-Since', if_unmodified_since)
r = self.get(path, success = (200, 204))
return r.json
def get_container_versioning(self, container):
return filter_in(self.get_container_info(container), 'X-Container-Policy-Versioning')
......
......@@ -88,7 +88,7 @@ def params4url(params):
dlmtr = '?'
for name in params:
result = result + dlmtr + name
result = result + '=' + params[name] if params[name] is not None else result
result = result + '=' + unicode(params[name]) if params[name] is not None else result
dlmtr = '&'
return result
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment