summaryrefslogtreecommitdiff
path: root/openstackclient/api
diff options
context:
space:
mode:
Diffstat (limited to 'openstackclient/api')
-rw-r--r--openstackclient/api/api.py3
-rw-r--r--openstackclient/api/object_store_v1.py32
2 files changed, 28 insertions, 7 deletions
diff --git a/openstackclient/api/api.py b/openstackclient/api/api.py
index 7e2fe38f..d4772f94 100644
--- a/openstackclient/api/api.py
+++ b/openstackclient/api/api.py
@@ -13,11 +13,10 @@
"""Base API Library"""
-import simplejson as json
-
from keystoneauth1 import exceptions as ks_exceptions
from keystoneauth1 import session as ks_session
from osc_lib import exceptions
+import simplejson as json
from openstackclient.i18n import _
diff --git a/openstackclient/api/object_store_v1.py b/openstackclient/api/object_store_v1.py
index d1e5dfaf..c8514a57 100644
--- a/openstackclient/api/object_store_v1.py
+++ b/openstackclient/api/object_store_v1.py
@@ -19,12 +19,16 @@ import os
import sys
from osc_lib import utils
-import six
from six.moves import urllib
from openstackclient.api import api
+GLOBAL_READ_ACL = ".r:*"
+LIST_CONTENTS_ACL = ".rlistings"
+PUBLIC_CONTAINER_ACLS = [GLOBAL_READ_ACL, LIST_CONTENTS_ACL]
+
+
class APIv1(api.BaseAPI):
"""Object Store v1 API"""
@@ -34,15 +38,32 @@ class APIv1(api.BaseAPI):
def container_create(
self,
container=None,
+ public=False,
+ storage_policy=None
):
"""Create a container
:param string container:
name of container to create
+ :param bool public:
+ Boolean value indicating if the container should be publicly
+ readable. Defaults to False.
+ :param string storage_policy:
+ Name of the a specific storage policy to use. If not specified
+ swift will use its default storage policy.
:returns:
dict of returned headers
"""
- response = self.create(urllib.parse.quote(container), method='PUT')
+
+ headers = {}
+ if public:
+ headers['x-container-read'] = ",".join(PUBLIC_CONTAINER_ACLS)
+ if storage_policy is not None:
+ headers['x-storage-policy'] = storage_policy
+
+ response = self.create(
+ urllib.parse.quote(container), method='PUT', headers=headers)
+
data = {
'account': self._find_account_id(),
'container': container,
@@ -174,7 +195,8 @@ class APIv1(api.BaseAPI):
'object_count': response.headers.get(
'x-container-object-count'
),
- 'bytes_used': response.headers.get('x-container-bytes-used')
+ 'bytes_used': response.headers.get('x-container-bytes-used'),
+ 'storage_policy': response.headers.get('x-storage-policy'),
}
if 'x-container-read' in response.headers:
@@ -559,7 +581,7 @@ class APIv1(api.BaseAPI):
log = logging.getLogger(__name__ + '._set_properties')
headers = {}
- for k, v in six.iteritems(properties):
+ for k, v in properties.items():
if not utils.is_ascii(k) or not utils.is_ascii(v):
log.error('Cannot set property %s to non-ascii value', k)
continue
@@ -572,7 +594,7 @@ class APIv1(api.BaseAPI):
# Add in properties as a top level key, this is consistent with other
# OSC commands
properties = {}
- for k, v in six.iteritems(headers):
+ for k, v in headers.items():
if k.lower().startswith(header_tag):
properties[k[len(header_tag):]] = v
return properties