From 71066a4d716ebc437f998fd333c201362b333a16 Mon Sep 17 00:00:00 2001 From: Daniel <31691611+DanielPerezJensen@users.noreply.github.com> Date: Wed, 15 May 2024 14:16:06 +0200 Subject: [PATCH 1/3] fix: delete in binding.py now same as get/post Currently you can not pass custom headers to delete, as they are overwritten with default self._auth_headers. Replaced that with all_headers as in get and put. --- splunklib/binding.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/splunklib/binding.py b/splunklib/binding.py index 958be96e..0f94ee35 100644 --- a/splunklib/binding.py +++ b/splunklib/binding.py @@ -662,8 +662,9 @@ def delete(self, path_segment, owner=None, app=None, sharing=None, **query): """ 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 From 46c027cb669549c3f54298d4ec9eb645664d661f Mon Sep 17 00:00:00 2001 From: Daniel <31691611+DanielPerezJensen@users.noreply.github.com> Date: Wed, 15 May 2024 14:19:16 +0200 Subject: [PATCH 2/3] fix: Added headers that can be customly sent to .delete request --- splunklib/binding.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/splunklib/binding.py b/splunklib/binding.py index 0f94ee35..f4eef576 100644 --- a/splunklib/binding.py +++ b/splunklib/binding.py @@ -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. @@ -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 From 085f4e455203a3982dd4203fd22f8105610f809c Mon Sep 17 00:00:00 2001 From: Daniel <31691611+DanielPerezJensen@users.noreply.github.com> Date: Wed, 15 May 2024 14:20:26 +0200 Subject: [PATCH 3/3] fix: headers is empty list in case arg is None --- splunklib/binding.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/splunklib/binding.py b/splunklib/binding.py index f4eef576..434a7250 100644 --- a/splunklib/binding.py +++ b/splunklib/binding.py @@ -661,7 +661,10 @@ def delete(self, path_segment, owner=None, app=None, headers=None, sharing=None, 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