Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: delete in binding.py now same as get/post #575

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
12 changes: 9 additions & 3 deletions splunklib/binding.py
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,7 @@ def connect(self):

@_authentication
@_log_duration
def delete(self, path_segment, owner=None, app=None, sharing=None, **query):
def delete(self, path_segment, owner=None, app=None, headers=None, sharing=None, **query):
"""Performs a DELETE operation at the REST path segment with the given
namespace and query.

Expand All @@ -633,6 +633,8 @@ def delete(self, path_segment, owner=None, app=None, sharing=None, **query):
:type owner: ``string``
:param app: The app context of the namespace (optional).
:type app: ``string``
:param app: The additional headers to pass to the delete request (optional).
:type app: ``list``
:param sharing: The sharing mode of the namespace (optional).
:type sharing: ``string``
:param query: All other keyword arguments, which are used as query
Expand All @@ -659,11 +661,15 @@ def delete(self, path_segment, owner=None, app=None, sharing=None, **query):
c.delete('nonexistant/path') # raises HTTPError
c.logout()
c.delete('apps/local') # raises AuthenticationError
"""
"""
if headers is None:
headers = []

path = self.authority + self._abspath(path_segment, owner=owner,
app=app, sharing=sharing)
all_headers = headers + self.additional_headers + self._auth_headers
logger.debug("DELETE request to %s (body: %s)", path, mask_sensitive_data(query))
response = self.http.delete(path, self._auth_headers, **query)
response = self.http.delete(path, all_headers, **query)
return response

@_authentication
Expand Down