Merge "Adding SDK support for `glance md-namespace-objects-delete
`"
This commit is contained in:
commit
9892f1f9d5
@ -1314,6 +1314,22 @@ class Proxy(proxy.Proxy):
|
||||
**attrs,
|
||||
)
|
||||
|
||||
def delete_all_metadef_objects(self, namespace):
|
||||
"""Delete all objects
|
||||
|
||||
:param namespace: The value can be either the name of a metadef
|
||||
namespace or a
|
||||
:class:`~openstack.image.v2.metadef_namespace.MetadefNamespace`
|
||||
instance.
|
||||
:returns: ``None``
|
||||
:raises: :class:`~openstack.exceptions.ResourceNotFound` when no
|
||||
resource can be found.
|
||||
"""
|
||||
namespace = self._get_resource(
|
||||
_metadef_namespace.MetadefNamespace, namespace
|
||||
)
|
||||
return namespace.delete_all_objects(self)
|
||||
|
||||
# ====== METADEF RESOURCE TYPES ======
|
||||
def metadef_resource_types(self, **query):
|
||||
"""Return a generator of metadef resource types
|
||||
|
@ -86,5 +86,15 @@ class MetadefNamespace(resource.Resource):
|
||||
:param session: The session to use for making this request
|
||||
:returns: The server response
|
||||
"""
|
||||
|
||||
url = utils.urljoin(self.base_path, self.id, 'properties')
|
||||
return self._delete_all(session, url)
|
||||
|
||||
def delete_all_objects(self, session):
|
||||
"""Delete all objects in a namespace.
|
||||
|
||||
:param session: The session to use for making this request
|
||||
:returns: The server response
|
||||
"""
|
||||
url = utils.urljoin(self.base_path, self.id, 'objects')
|
||||
return self._delete_all(session, url)
|
||||
|
@ -87,3 +87,13 @@ class TestMetadefNamespace(base.TestCase):
|
||||
session.delete.assert_called_with(
|
||||
'metadefs/namespaces/OS::Cinder::Volumetype/properties'
|
||||
)
|
||||
|
||||
@mock.patch.object(exceptions, 'raise_from_response', mock.Mock())
|
||||
def test_delete_all_objects(self):
|
||||
sot = metadef_namespace.MetadefNamespace(**EXAMPLE)
|
||||
session = mock.Mock(spec=adapter.Adapter)
|
||||
sot._translate_response = mock.Mock()
|
||||
sot.delete_all_objects(session)
|
||||
session.delete.assert_called_with(
|
||||
'metadefs/namespaces/OS::Cinder::Volumetype/objects'
|
||||
)
|
||||
|
@ -624,6 +624,20 @@ class TestMetadefObject(TestImageProxy):
|
||||
expected_kwargs={"namespace_name": "test_namespace_name"},
|
||||
)
|
||||
|
||||
@mock.patch.object(proxy_base.Proxy, '_get_resource')
|
||||
def test_delete_all_metadef_objects(self, mock_get_resource):
|
||||
fake_object = _metadef_namespace.MetadefNamespace()
|
||||
mock_get_resource.return_value = fake_object
|
||||
self._verify(
|
||||
"openstack.image.v2.metadef_namespace.MetadefNamespace.delete_all_objects",
|
||||
self.proxy.delete_all_metadef_objects,
|
||||
method_args=['test_namespace'],
|
||||
expected_args=[self.proxy],
|
||||
)
|
||||
mock_get_resource.assert_called_once_with(
|
||||
_metadef_namespace.MetadefNamespace, 'test_namespace'
|
||||
)
|
||||
|
||||
|
||||
class TestMetadefResourceType(TestImageProxy):
|
||||
def test_metadef_resource_types(self):
|
||||
|
@ -0,0 +1,5 @@
|
||||
---
|
||||
features:
|
||||
- |
|
||||
Add support for deleting all objects inside
|
||||
a namespace.
|
Loading…
Reference in New Issue
Block a user