Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions splunklib/binding.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,13 +234,15 @@ def fullpath(self, path, **kwargs):

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

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

# Convert the given path into a fully qualified URL by first qualifying
# the given path with namespace segments if necessarry and then prefixing
Expand Down
13 changes: 12 additions & 1 deletion splunklib/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,18 @@ def state(self):
return self._state

def update(self, **kwargs):
"""Updates the entity with the arguments you provide."""
"""Updates the entity with the arguments you provide.

Note that you cannot update the ``name`` field of an Entity,
due to a peculiarity of the REST API.
"""
# The peculiarity in question: the REST API creates a new
# Entity if we pass name in the dictionary, instead of the
# expected behavior of updating this Entity. Therefore we
# check for 'name' in kwargs and throw an error if it is
# there.
if 'name' in kwargs:
raise ValueError("Cannot update the name of an Entity via the REST API.")
self.post(**kwargs)
return self

Expand Down
2 changes: 2 additions & 0 deletions tests/test_saved_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ def test_crud(self):
saved_search.refresh()
self.check_content(saved_search, is_visible=0)

self.assertRaises(ValueError, saved_search.update, saved_search, name="Anything")

saved_searches.delete('sdk-test1')
self.assertFalse('sdk-test1' in saved_searches)

Expand Down