@@ -820,8 +820,12 @@ def get(self, path_segment="", owner=None, app=None, sharing=None, **query):
820820 # Search API v2+ fallback to v1:
821821 # - In v2+, /results_preview, /events and /results do not support search params.
822822 # - Fallback from v2+ to v1 if Splunk Version is < 9.
823- if api_version >= 2 and ('search' in query and path .endswith (tuple (["results_preview" , "events" , "results" ])) or self .service .splunk_version < (9 ,)):
823+ # if api_version >= 2 and ('search' in query and path.endswith(tuple(["results_preview", "events", "results"])) or self.service.splunk_version < (9,)):
824+ # path = path.replace(PATH_JOBS_V2, PATH_JOBS)
825+
826+ if api_version == 1 :
824827 path = path .replace (PATH_JOBS_V2 , PATH_JOBS )
828+
825829 return self .service .get (path ,
826830 owner = owner , app = app , sharing = sharing ,
827831 ** query )
@@ -888,8 +892,12 @@ def post(self, path_segment="", owner=None, app=None, sharing=None, **query):
888892 # Search API v2+ fallback to v1:
889893 # - In v2+, /results_preview, /events and /results do not support search params.
890894 # - Fallback from v2+ to v1 if Splunk Version is < 9.
891- if api_version >= 2 and ('search' in query and path .endswith (tuple (["results_preview" , "events" , "results" ])) or self .service .splunk_version < (9 ,)):
895+ # if api_version >= 2 and ('search' in query and path.endswith(tuple(["results_preview", "events", "results"])) or self.service.splunk_version < (9,)):
896+ # path = path.replace(PATH_JOBS_V2, PATH_JOBS)
897+
898+ if api_version == 1 :
892899 path = path .replace (PATH_JOBS_V2 , PATH_JOBS )
900+
893901 return self .service .post (path , owner = owner , app = app , sharing = sharing , ** query )
894902
895903
@@ -2761,7 +2769,11 @@ def events(self, **kwargs):
27612769 :return: The ``InputStream`` IO handle to this job's events.
27622770 """
27632771 kwargs ['segmentation' ] = kwargs .get ('segmentation' , 'none' )
2764- return self .get ("events" , ** kwargs ).body
2772+
2773+ # Search API v1(GET) and v2(POST)
2774+ if self .service .splunk_version < (9 ,):
2775+ return self .get ("events" , ** kwargs ).body
2776+ return self .post ("events" , ** kwargs ).body
27652777
27662778 def finalize (self ):
27672779 """Stops the job and provides intermediate results for retrieval.
@@ -2849,7 +2861,11 @@ def results(self, **query_params):
28492861 :return: The ``InputStream`` IO handle to this job's results.
28502862 """
28512863 query_params ['segmentation' ] = query_params .get ('segmentation' , 'none' )
2852- return self .get ("results" , ** query_params ).body
2864+
2865+ # Search API v1(GET) and v2(POST)
2866+ if self .service .splunk_version < (9 ,):
2867+ return self .get ("results" , ** query_params ).body
2868+ return self .post ("results" , ** query_params ).body
28532869
28542870 def preview (self , ** query_params ):
28552871 """Returns a streaming handle to this job's preview search results.
@@ -2890,7 +2906,11 @@ def preview(self, **query_params):
28902906 :return: The ``InputStream`` IO handle to this job's preview results.
28912907 """
28922908 query_params ['segmentation' ] = query_params .get ('segmentation' , 'none' )
2893- return self .get ("results_preview" , ** query_params ).body
2909+
2910+ # Search API v1(GET) and v2(POST)
2911+ if self .service .splunk_version < (9 ,):
2912+ return self .get ("results_preview" , ** query_params ).body
2913+ return self .post ("results_preview" , ** query_params ).body
28942914
28952915 def searchlog (self , ** kwargs ):
28962916 """Returns a streaming handle to this job's search log.
0 commit comments