diff options
| author | Steve Martinelli <stevemar@ca.ibm.com> | 2014-08-03 02:19:29 -0400 |
|---|---|---|
| committer | Steve Martinelli <stevemar@ca.ibm.com> | 2014-08-03 03:52:04 -0400 |
| commit | be83ae763ffbcd3208ba1df9fe8b22cfe3fa6fa2 (patch) | |
| tree | 460e8addbf416eee8ff4b9c7d946c0eb251abe4f /openstackclient/object/v1/lib/container.py | |
| parent | 75e8490e54bf442b36534ea9c8b53c203b6a9938 (diff) | |
| download | python-openstackclient-be83ae763ffbcd3208ba1df9fe8b22cfe3fa6fa2.tar.gz | |
Add container create and delete support
Add basic container create and delete support to OSC.
Change-Id: Ia104db9d7e580d33097ea33a5690998f817995d1
implements: bp swift-client
Diffstat (limited to 'openstackclient/object/v1/lib/container.py')
| -rw-r--r-- | openstackclient/object/v1/lib/container.py | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/openstackclient/object/v1/lib/container.py b/openstackclient/object/v1/lib/container.py index 72e97d4e..bd509555 100644 --- a/openstackclient/object/v1/lib/container.py +++ b/openstackclient/object/v1/lib/container.py @@ -22,6 +22,45 @@ except ImportError: from urlparse import urlparse # noqa +def create_container( + api, + url, + container, +): + """Create a container + + :param api: a restapi object + :param url: endpoint + :param container: name of container to create + :returns: dict of returned headers + """ + + response = api.put("%s/%s" % (url, container)) + url_parts = urlparse(url) + data = { + 'account': url_parts.path.split('/')[-1], + 'container': container, + } + data['x-trans-id'] = response.headers.get('x-trans-id', None) + + return data + + +def delete_container( + api, + url, + container, +): + """Delete a container + + :param api: a restapi object + :param url: endpoint + :param container: name of container to delete + """ + + api.delete("%s/%s" % (url, container)) + + def list_containers( api, url, |
