Skip to content

Commit 7b5619d

Browse files
author
Fred Ross
committed
Merge branch 'fross-feature/preincrement-fixes' into develop
2 parents 3fca0c4 + d5dd4b2 commit 7b5619d

3 files changed

Lines changed: 18 additions & 3 deletions

File tree

‎splunklib/binding.py‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,13 +234,15 @@ def fullpath(self, path, **kwargs):
234234

235235
# If no app or owner are specified, then use the /services endpoint
236236
if ns.app is None and ns.owner is None:
237-
return "/services/%s" % path
237+
return "/services/%s" % urllib.quote(path)
238238

239239
# At least one of app or owner is specified, so use the /serviceNS
240240
# endpoint and if only one is specified, then wildcard the other.
241241
oname = "-" if ns.owner is None else ns.owner
242242
aname = "-" if ns.app is None else ns.app
243-
return "/servicesNS/%s/%s/%s" % (oname, aname, path)
243+
return "/servicesNS/%s/%s/%s" % (urllib.quote(oname),
244+
urllib.quote(aname),
245+
urllib.quote(path))
244246

245247
# Convert the given path into a fully qualified URL by first qualifying
246248
# the given path with namespace segments if necessarry and then prefixing

‎splunklib/client.py‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,18 @@ def state(self):
391391
return self._state
392392

393393
def update(self, **kwargs):
394-
"""Updates the entity with the arguments you provide."""
394+
"""Updates the entity with the arguments you provide.
395+
396+
Note that you cannot update the ``name`` field of an Entity,
397+
due to a peculiarity of the REST API.
398+
"""
399+
# The peculiarity in question: the REST API creates a new
400+
# Entity if we pass name in the dictionary, instead of the
401+
# expected behavior of updating this Entity. Therefore we
402+
# check for 'name' in kwargs and throw an error if it is
403+
# there.
404+
if 'name' in kwargs:
405+
raise ValueError("Cannot update the name of an Entity via the REST API.")
395406
self.post(**kwargs)
396407
return self
397408

‎tests/test_saved_search.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ def test_crud(self):
8888
saved_search.refresh()
8989
self.check_content(saved_search, is_visible=0)
9090

91+
self.assertRaises(ValueError, saved_search.update, saved_search, name="Anything")
92+
9193
saved_searches.delete('sdk-test1')
9294
self.assertFalse('sdk-test1' in saved_searches)
9395

0 commit comments

Comments
 (0)