@@ -2767,9 +2767,8 @@ def pause(self):
27672767 return self
27682768
27692769 def results (self , ** query_params ):
2770- """Returns a streaming handle to this job's search results. To get a
2771- nice, Pythonic iterator, pass the handle to :class:`splunklib.results.ResultsReader`,
2772- as in::
2770+ """Returns a streaming handle to this job's search results. To get a nice, Pythonic iterator, pass the handle
2771+ to :class:`splunklib.results.JSONResultsReader` along with the query param "output_mode='json'", as in::
27732772
27742773 import splunklib.client as client
27752774 import splunklib.results as results
@@ -2778,7 +2777,7 @@ def results(self, **query_params):
27782777 job = service.jobs.create("search * | head 5")
27792778 while not job.is_done():
27802779 sleep(.2)
2781- rr = results.ResultsReader (job.results())
2780+ rr = results.JSONResultsReader (job.results(output_mode='json' ))
27822781 for result in rr:
27832782 if isinstance(result, results.Message):
27842783 # Diagnostic messages may be returned in the results
@@ -2808,19 +2807,17 @@ def results(self, **query_params):
28082807 def preview (self , ** query_params ):
28092808 """Returns a streaming handle to this job's preview search results.
28102809
2811- Unlike :class:`splunklib.results.ResultsReader`, which requires a job to
2812- be finished to
2813- return any results, the ``preview`` method returns any results that have
2814- been generated so far, whether the job is running or not. The
2815- returned search results are the raw data from the server. Pass
2816- the handle returned to :class:`splunklib.results.ResultsReader` to get a
2817- nice, Pythonic iterator over objects, as in::
2810+ Unlike :class:`splunklib.results.JSONResultsReader`along with the query param "output_mode='json'",
2811+ which requires a job to be finished to return any results, the ``preview`` method returns any results that
2812+ have been generated so far, whether the job is running or not. The returned search results are the raw data
2813+ from the server. Pass the handle returned to :class:`splunklib.results.JSONResultsReader` to get a nice,
2814+ Pythonic iterator over objects, as in::
28182815
28192816 import splunklib.client as client
28202817 import splunklib.results as results
28212818 service = client.connect(...)
28222819 job = service.jobs.create("search * | head 5")
2823- rr = results.ResultsReader (job.preview())
2820+ rr = results.JSONResultsReader (job.preview(output_mode='json' ))
28242821 for result in rr:
28252822 if isinstance(result, results.Message):
28262823 # Diagnostic messages may be returned in the results
@@ -2975,15 +2972,15 @@ def create(self, query, **kwargs):
29752972 return Job (self .service , sid )
29762973
29772974 def export (self , query , ** params ):
2978- """Runs a search and immediately starts streaming preview events.
2979- This method returns a streaming handle to this job's events as an XML
2980- document from the server. To parse this stream into usable Python objects,
2981- pass the handle to :class:`splunklib.results.ResultsReader` ::
2975+ """Runs a search and immediately starts streaming preview events. This method returns a streaming handle to
2976+ this job's events as an XML document from the server. To parse this stream into usable Python objects,
2977+ pass the handle to :class:`splunklib.results.JSONResultsReader` along with the query param
2978+ "output_mode='json'" ::
29822979
29832980 import splunklib.client as client
29842981 import splunklib.results as results
29852982 service = client.connect(...)
2986- rr = results.ResultsReader (service.jobs.export("search * | head 5"))
2983+ rr = results.JSONResultsReader (service.jobs.export("search * | head 5",output_mode='json' ))
29872984 for result in rr:
29882985 if isinstance(result, results.Message):
29892986 # Diagnostic messages may be returned in the results
@@ -3032,14 +3029,14 @@ def itemmeta(self):
30323029 def oneshot (self , query , ** params ):
30333030 """Run a oneshot search and returns a streaming handle to the results.
30343031
3035- The ``InputStream`` object streams XML fragments from the server. To
3036- parse this stream into usable Python objects,
3037- pass the handle to :class:`splunklib.results.ResultsReader` ::
3032+ The ``InputStream`` object streams XML fragments from the server. To parse this stream into usable Python
3033+ objects, pass the handle to :class:`splunklib.results.JSONResultsReader` along with the query param
3034+ "output_mode='json'" ::
30383035
30393036 import splunklib.client as client
30403037 import splunklib.results as results
30413038 service = client.connect(...)
3042- rr = results.ResultsReader (service.jobs.oneshot("search * | head 5"))
3039+ rr = results.JSONResultsReader (service.jobs.oneshot("search * | head 5",output_mode='json' ))
30433040 for result in rr:
30443041 if isinstance(result, results.Message):
30453042 # Diagnostic messages may be returned in the results
0 commit comments