From 130c5c9ab9933266d4f6610b71fb760d92f59b27 Mon Sep 17 00:00:00 2001 From: Leo Li Date: Wed, 2 Nov 2016 08:25:28 +0800 Subject: [PATCH 1/2] remove Inputs.kind check to reduce performance impact on each rest call --- splunklib/client.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/splunklib/client.py b/splunklib/client.py index 9c7260a57..2acd5d3bf 100644 --- a/splunklib/client.py +++ b/splunklib/client.py @@ -2432,15 +2432,12 @@ def kindpath(self, kind): :return: The relative endpoint path. :rtype: ``string`` """ - if kind in self.kinds: - return UrlEncoded(kind, skip_encode=True) - # Special cases - elif kind == 'tcp': + if kind == 'tcp': return UrlEncoded('tcp/raw', skip_encode=True) elif kind == 'splunktcp': return UrlEncoded('tcp/cooked', skip_encode=True) else: - raise ValueError("No such kind on server: %s" % kind) + return UrlEncoded(kind, skip_encode=True) def list(self, *kinds, **kwargs): """Returns a list of inputs that are in the :class:`Inputs` collection. From 4cc3c22879b5a0215b2d10a1f2f03e1ceb24e094 Mon Sep 17 00:00:00 2001 From: Shakeel Mohamed Date: Mon, 19 Dec 2016 15:42:27 -0800 Subject: [PATCH 2/2] Add test coverage for unknown input types --- tests/test_input.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/test_input.py b/tests/test_input.py index 417f76ff5..ddfed8d46 100755 --- a/tests/test_input.py +++ b/tests/test_input.py @@ -131,6 +131,14 @@ def test_read_kind(self): def test_inputs_list_on_one_kind(self): self.service.inputs.list('monitor') + def test_read_invalid_input(self): + name = testlib.tmpname() + try: + self.service.inputs.get(name) + self.fail("Expected a 404 HTTPError") + except HTTPError as he: + self.assertTrue("HTTP 404 Not Found" in str(he)) + def test_inputs_list_on_one_kind_with_count(self): N = 10 expected = [x.name for x in self.service.inputs.list('monitor')[:10]]