Skip to content

Commit

Permalink
Merge pull request #398 from splunk/DVPL-10032
Browse files Browse the repository at this point in the history
Updated kvstore method
  • Loading branch information
ashah-splunk committed Sep 23, 2021
2 parents ba05bb9 + a4039cd commit cd742c8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
6 changes: 5 additions & 1 deletion examples/kvstore.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,11 @@ def main():

query = json.dumps({"otherkey": "bar"})
print("Should return third item with auto-generated _key: %s" % json.dumps(collection.data.query(query=query), indent=1))


# passing query data as dict
query = {"somekey": {"$gt": 1}}
print("Should return item2 and item3: %s" % json.dumps(collection.data.query(query=query), indent=1))

# Let's delete the collection
collection.delete()

Expand Down
5 changes: 5 additions & 0 deletions splunklib/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -3640,6 +3640,11 @@ def query(self, **query):
:return: Array of documents retrieved by query.
:rtype: ``array``
"""

for key, value in query.items():
if isinstance(query[key], dict):
query[key] = json.dumps(value)

return json.loads(self._get('', **query).body.read().decode('utf-8'))

def query_by_id(self, id):
Expand Down

0 comments on commit cd742c8

Please sign in to comment.