Merge "Allow search on objects"

This commit is contained in:
Zuul 2018-09-25 23:08:49 +00:00 committed by Gerrit Code Review
commit 6432c42778
2 changed files with 23 additions and 0 deletions

View File

@ -7839,6 +7839,23 @@ class OpenStackCloud(_normalize.Normalizer):
container, params=dict(format='json')) container, params=dict(format='json'))
return self._get_and_munchify(None, data) return self._get_and_munchify(None, data)
def search_objects(self, container, name=None, filters=None):
"""Search objects.
:param string name: object name.
:param filters: a dict containing additional filters to use.
OR
A string containing a jmespath expression for further filtering.
Example:: "[?last_name==`Smith`] | [?other.gender]==`Female`]"
:returns: a list of ``munch.Munch`` containing the objects.
:raises: ``OpenStackCloudException``: if something goes wrong during
the OpenStack API call.
"""
objects = self.list_objects(container)
return _utils._filter_list(objects, name, filters)
def delete_object(self, container, name, meta=None): def delete_object(self, container, name, meta=None):
"""Delete an object from a container. """Delete an object from a container.

View File

@ -0,0 +1,6 @@
---
features:
- |
Objects are now searchable both with a JMESPath expression or a dict of
object attributes via the
``openstack.connection.Connection.search_object`` function.