From 244fb87f4ad10b5ca4d44bcca1174f758087709e Mon Sep 17 00:00:00 2001 From: Brian Curtin Date: Fri, 6 Nov 2015 12:13:25 -0600 Subject: [PATCH] Adjust object_store to use upload/download names object_store had been using create_object and save_object names, but we've previously aggreed to use upload and download for those types of calls. Change-Id: I59a17cc29a989096820093ac7e6dba87c1f58b66 Partial-Bug: #1488631 --- doc/source/users/guides/object_store.rst | 12 ++++++------ openstack/object_store/v1/_proxy.py | 8 ++++---- openstack/tests/unit/object_store/v1/test_proxy.py | 6 +++--- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/doc/source/users/guides/object_store.rst b/doc/source/users/guides/object_store.rst index e777a525..da8c57e2 100644 --- a/doc/source/users/guides/object_store.rst +++ b/doc/source/users/guides/object_store.rst @@ -154,21 +154,21 @@ the data stored inside of it with the Hello, world! Additionally, if you want to save the object to disk, the -:meth:`~openstack.object_store.v1._proxy.Proxy.save_object` convenience +:meth:`~openstack.object_store.v1._proxy.Proxy.download_object` convenience method takes an :class:`~openstack.object_store.v1.obj.Object` and a ``path`` to write the contents to. :: - >>> conn.object_store.save_object(ob, "the_message.txt") + >>> conn.object_store.download_object(ob, "the_message.txt") -Creating Objects -**************** +Uploading Objects +***************** Once you have data you'd like to store in the Object Store service, you use -the :meth:`~openstack.object_store.v1._proxy.Proxy.create_object` method. +the :meth:`~openstack.object_store.v1._proxy.Proxy.upload_object` method. This method takes the ``data`` to be stored, along with at least an object ``name`` and the ``container`` it is to be stored in. :: - >>> hello = conn.object_store.create_object(container="messages", + >>> hello = conn.object_store.upload_object(container="messages", name="helloworld.txt", data="Hello, world!") >>> print hello diff --git a/openstack/object_store/v1/_proxy.py b/openstack/object_store/v1/_proxy.py index aac49fe0..ec3199f7 100644 --- a/openstack/object_store/v1/_proxy.py +++ b/openstack/object_store/v1/_proxy.py @@ -162,8 +162,8 @@ class Proxy(proxy.BaseProxy): return self._get(_obj.Object, value, path_args={"container": container_name}) - def save_object(self, obj, path): - """Save the data contained inside an object to disk. + def download_object(self, obj, path): + """Download the data contained inside an object to disk. :param obj: The object to save to disk. :type obj: :class:`~openstack.object_store.v1.obj.Object` @@ -172,8 +172,8 @@ class Proxy(proxy.BaseProxy): with open(path, "w") as out: out.write(self.get_object(obj)) - def create_object(self, **attrs): - """Create a new object from attributes + def upload_object(self, **attrs): + """Upload a new object from attributes :param dict attrs: Keyword arguments which will be used to create a :class:`~openstack.object_store.v1.obj.Object`, diff --git a/openstack/tests/unit/object_store/v1/test_proxy.py b/openstack/tests/unit/object_store/v1/test_proxy.py index 9377a10a..67856b15 100644 --- a/openstack/tests/unit/object_store/v1/test_proxy.py +++ b/openstack/tests/unit/object_store/v1/test_proxy.py @@ -78,13 +78,13 @@ class TestObjectStoreProxy(test_proxy_base.TestProxyBase): expected_kwargs.pop("container") self._verify2("openstack.proxy.BaseProxy._create", - self.proxy.create_object, + self.proxy.upload_object, method_kwargs=method_kwargs, expected_args=[obj.Object], expected_kwargs=expected_kwargs) def test_object_create_no_container(self): - self.assertRaises(ValueError, self.proxy.create_object) + self.assertRaises(ValueError, self.proxy.upload_object) def test_object_get(self): self.verify_get(self.proxy.get_object, obj.Object, @@ -275,7 +275,7 @@ class Test_save_object(TestObjectStoreProxy): file_path = "blarga/somefile" with mock.patch("openstack.object_store.v1._proxy.open", fake_open, create=True): - self.proxy.save_object(ob, file_path) + self.proxy.download_object(ob, file_path) fake_open.assert_called_once_with(file_path, "w") fake_handle = fake_open()