Skip to content

Commit 1215d2a

Browse files
author
Frederick Ross
committed
Added segmentation=none to all results methods. Added namespace to export list in client.py.
1 parent 8a5a2ef commit 1215d2a

File tree

1 file changed

+36
-6
lines changed

1 file changed

+36
-6
lines changed

splunklib/client.py

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@
7676
"NotSupportedError",
7777
"OperationError",
7878
"IncomparableException",
79-
"Service"
79+
"Service",
80+
"namespace"
8081
]
8182

8283
PATH_APPS = "apps/local/"
@@ -2423,7 +2424,12 @@ def events(self, **kwargs):
24232424
24242425
:return: The ``InputStream`` IO handle to this job's events.
24252426
"""
2426-
return self.get("events", **kwargs).body
2427+
if 'segmentation' not in kwargs:
2428+
segmentation = 'none'
2429+
else:
2430+
segmentation = kwargs.pop('segmentation')
2431+
return self.get("events", segmentation=segmentation,
2432+
**kwargs).body
24272433

24282434
def finalize(self):
24292435
"""Stops the job and provides intermediate results for retrieval.
@@ -2508,7 +2514,12 @@ def results(self, **query_params):
25082514
25092515
:return: The ``InputStream`` IO handle to this job's results.
25102516
"""
2511-
return self.get("results", **query_params).body
2517+
if 'segmentation' not in query_params:
2518+
segmentation = 'none'
2519+
else:
2520+
segmentation = query_params.pop('segmentation')
2521+
return self.get("results", segmentation=segmentation,
2522+
**query_params).body
25122523

25132524
def preview(self, **query_params):
25142525
"""Returns a streaming handle to this job's preview search results.
@@ -2550,7 +2561,12 @@ def preview(self, **query_params):
25502561
25512562
:return: The ``InputStream`` IO handle to this job's preview results.
25522563
"""
2553-
return self.get("results_preview", **query_params).body
2564+
if 'segmentation' not in query_params:
2565+
segmentation = 'none'
2566+
else:
2567+
segmentation = query_params.pop('segmentation')
2568+
return self.get("results_preview", segmentation=segmentation,
2569+
**query_params).body
25542570

25552571
def searchlog(self, **kwargs):
25562572
"""Returns a streaming handle to this job's search log.
@@ -2717,7 +2733,14 @@ def export(self, query, **params):
27172733
"""
27182734
if "exec_mode" in params:
27192735
raise TypeError("Cannot specify an exec_mode to export.")
2720-
return self.post(path_segment="export", search=query, **params).body
2736+
if 'segmentation' not in params:
2737+
segmentation = 'none'
2738+
else:
2739+
segmentation = params.pop('segmentation')
2740+
return self.post(path_segment="export",
2741+
search=query,
2742+
segmentation=segmentation,
2743+
**params).body
27212744

27222745
def itemmeta(self):
27232746
"""There is no metadata available for class:``Jobs``.
@@ -2777,7 +2800,14 @@ def oneshot(self, query, **params):
27772800
"""
27782801
if "exec_mode" in params:
27792802
raise TypeError("Cannot specify an exec_mode to oneshot.")
2780-
return self.post(search=query, exec_mode="oneshot", **params).body
2803+
if 'segmentation' not in params:
2804+
segmentation = 'none'
2805+
else:
2806+
segmentation = params.pop('segmentation')
2807+
return self.post(search=query,
2808+
exec_mode="oneshot",
2809+
segmentation=segmentation,
2810+
**params).body
27812811

27822812

27832813
class Loggers(Collection):

0 commit comments

Comments
 (0)