Skip to content

Commit cad805f

Browse files
committed
Added a handling function for different type of URL encoded names.
1 parent 540b53e commit cad805f

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

splunklib/client.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1956,9 +1956,18 @@ def __init__(self, service, kindmap=None):
19561956
Collection.__init__(self, service, PATH_INPUTS, item=Input)
19571957

19581958
def __getitem__(self, key):
1959+
# The key needed to retrieve the input needs it's parenthesis to be URL encoded
1960+
# based on the REST API for input
1961+
# <http://docs.splunk.com/Documentation/Splunk/latest/RESTAPI/RESTinput>
1962+
def checkKey(url):
1963+
while True:
1964+
if url is urllib.unquote(url): break
1965+
else: url = urllib.unquote(url)
1966+
return urllib.quote(url,'')
19591967
if isinstance(key, tuple) and len(key) == 2:
19601968
# Fetch a single kind
19611969
key, kind = key
1970+
key = checkKey(key)
19621971
try:
19631972
response = self.get(self.kindpath(kind) + "/" + key)
19641973
entries = self._load_list(response)
@@ -1975,6 +1984,7 @@ def __getitem__(self, key):
19751984
raise
19761985
else:
19771986
# Iterate over all the kinds looking for matches.
1987+
key = checkKey(key)
19781988
kind = None
19791989
candidate = None
19801990
for kind in self.kinds:

0 commit comments

Comments
 (0)