Allow search on objects
Implements search_objects, which can take a JMESPath expression or a dict of object attributes to filter objects in. Story: #2003695 Task: #26339 Change-Id: I7cda29f778acdcdeb8da737d001e957674e9284b
This commit is contained in:
parent
c340e203e4
commit
f96b13210c
@ -7771,6 +7771,23 @@ class OpenStackCloud(_normalize.Normalizer):
|
||||
container, params=dict(format='json'))
|
||||
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):
|
||||
"""Delete an object from a container.
|
||||
|
||||
|
6
releasenotes/notes/object-search-a5f5ec4b2df3e045.yaml
Normal file
6
releasenotes/notes/object-search-a5f5ec4b2df3e045.yaml
Normal 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.
|
Loading…
Reference in New Issue
Block a user