Revision a298f2ab kamaki/clients/pithos.py
b/kamaki/clients/pithos.py | ||
---|---|---|
260 | 260 |
success = kwargs.pop('success', 202) |
261 | 261 |
return self.post(path, *args, success=success, **kwargs) |
262 | 262 |
|
263 |
def container_delete(self, until=None, *args, **kwargs): |
|
263 |
def container_delete(self, until=None, delimiter=None, *args, **kwargs):
|
|
264 | 264 |
""" Full Pithos+ DELETE at container level |
265 | 265 |
--- request parameters --- |
266 | 266 |
@param until (timestamp string): if defined, container is purged up to that time |
267 | 267 |
""" |
268 | 268 |
self.assert_container() |
269 |
path=path4url(self.account, self.container) |
|
270 |
path += '' if until is None else params4url(dict(until=until)) |
|
269 |
param_dict = {} |
|
270 |
if until is not None: |
|
271 |
param_dict['until']=until |
|
272 |
if delimiter is not None: |
|
273 |
param_dict['delimiter'] = delimiter |
|
274 |
path=path4url(self.account, self.container)+params4url(param_dict) |
|
271 | 275 |
success = kwargs.pop('success', 204) |
272 | 276 |
return self.delete(path, success=success) |
273 | 277 |
|
... | ... | |
564 | 568 |
success=kwargs.pop('success', (202, 204)) |
565 | 569 |
return self.post(path, *args, success=success, **kwargs) |
566 | 570 |
|
567 |
def object_delete(self, object, until=None, *args, **kwargs): |
|
571 |
def object_delete(self, object, until=None, delimiter=None, *args, **kwargs):
|
|
568 | 572 |
""" Full Pithos+ DELETE at object level |
569 | 573 |
--- request parameters --- |
570 | 574 |
@param until (string): Optional timestamp |
571 | 575 |
""" |
572 | 576 |
self.assert_container() |
573 |
path = path4url(self.account, self.container, object) |
|
574 |
path += '' if until is None else params4url(dict(until=until)) |
|
577 |
param_dict = {} |
|
578 |
if until is not None: |
|
579 |
param_dict['until']=until |
|
580 |
if delimiter is not None: |
|
581 |
param_dict['delimiter'] = delimiter |
|
582 |
path = path4url(self.account, self.container, object)+params4url(param_dict) |
|
575 | 583 |
success = kwargs.pop('success', 204) |
576 | 584 |
return self.delete(path, *args, success=success, **kwargs) |
577 | 585 |
|
... | ... | |
775 | 783 |
r = self.account_get() |
776 | 784 |
return r.json |
777 | 785 |
|
786 |
def del_container(self, until=None, delimiter=None): |
|
787 |
self.assert_container() |
|
788 |
r = self.container_delete(until=until, delimiter=delimiter, success=(204, 404, 409)) |
|
789 |
if r.status_code == 404: |
|
790 |
raise ClientError('Container "%s" does not exist'%self.container, r.status_code) |
|
791 |
elif r.status_code == 409: |
|
792 |
raise ClientError('Container "%s" is not empty'%self.container, r.status_code) |
|
793 |
|
|
778 | 794 |
def get_container_versioning(self, container): |
779 | 795 |
return filter_in(self.get_container_info(container), 'X-Container-Policy-Versioning') |
780 | 796 |
|
... | ... | |
800 | 816 |
def set_container_versioning(self, versioning): |
801 | 817 |
self.container_post(update=True, versioning=versioning) |
802 | 818 |
|
819 |
def del_object(self, obj, until=None, delimiter=None): |
|
820 |
self.assert_container() |
|
821 |
self.object_delete(obj, until=until, delimiter=delimiter) |
|
822 |
|
|
803 | 823 |
def set_object_meta(self, object, metapairs): |
804 | 824 |
assert(type(metapairs) is dict) |
805 | 825 |
self.object_post(object, update=True, metadata=metapairs) |
Also available in: Unified diff