From f49d37c2909b047a3315ebbda524f914547cda67 Mon Sep 17 00:00:00 2001 From: Abhi Shah Date: Tue, 19 Apr 2022 16:33:22 +0530 Subject: [PATCH] Documentation changes updated the comments and changes for JSONResultsReader class to be added in the generated docs --- docs/results.rst | 2 +- splunklib/binding.py | 3 --- splunklib/client.py | 2 +- splunklib/results.py | 12 ++++++++---- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/docs/results.rst b/docs/results.rst index 571fba1f7..007e881ce 100644 --- a/docs/results.rst +++ b/docs/results.rst @@ -5,4 +5,4 @@ splunklib.results .. autoclass:: Message -.. autoclass:: ResultsReader +.. autoclass:: JSONResultsReader diff --git a/splunklib/binding.py b/splunklib/binding.py index 6bf4f0714..5f76a829e 100644 --- a/splunklib/binding.py +++ b/splunklib/binding.py @@ -800,9 +800,6 @@ def request(self, path_segment, method="GET", headers=None, body={}, :type app: ``string`` :param sharing: The sharing mode of the namespace (optional). :type sharing: ``string`` - :param query: All other keyword arguments, which are used as query - parameters. - :type query: ``string`` :return: The response from the server. :rtype: ``dict`` with keys ``body``, ``headers``, ``reason``, and ``status`` diff --git a/splunklib/client.py b/splunklib/client.py index 0979140c2..563824846 100644 --- a/splunklib/client.py +++ b/splunklib/client.py @@ -3029,7 +3029,7 @@ def itemmeta(self): def oneshot(self, query, **params): """Run a oneshot search and returns a streaming handle to the results. - The ``InputStream`` object streams XML fragments from the server. To parse this stream into usable Python + The ``InputStream`` object streams fragments from the server. To parse this stream into usable Python objects, pass the handle to :class:`splunklib.results.JSONResultsReader` along with the query param "output_mode='json'" :: diff --git a/splunklib/results.py b/splunklib/results.py index 5f3966859..8543ab0df 100644 --- a/splunklib/results.py +++ b/splunklib/results.py @@ -23,7 +23,7 @@ accessing search results while avoiding buffering the result set, which can be very large. -To use the reader, instantiate :class:`ResultsReader` on a search result stream +To use the reader, instantiate :class:`JSONResultsReader` on a search result stream as follows::: reader = ResultsReader(result_stream) @@ -55,7 +55,8 @@ __all__ = [ "ResultsReader", - "Message" + "Message", + "JSONResultsReader" ] @@ -308,11 +309,14 @@ class JSONResultsReader(object): :class:`Message` object for Splunk messages. This class has one field, ``is_preview``, which is ``True`` when the results are a preview from a running search, or ``False`` when the results are from a completed search. + This function has no network activity other than what is implicit in the stream it operates on. - :param `stream`: The stream to read from (any object that supports - ``.read()``). + + :param `stream`: The stream to read from (any object that supports``.read()``). + **Example**:: + import results response = ... # the body of an HTTP response reader = results.JSONResultsReader(response)