Skip to content

Commit 7adbaba

Browse files
committed
v2 Search API changes reverted
1 parent cf26ad8 commit 7adbaba

File tree

3 files changed

+31
-27
lines changed

3 files changed

+31
-27
lines changed

splunk/src/main/java/com/splunk/Job.java

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -368,18 +368,19 @@ private InputStream getEventsMethod(String methodPath, Map args) {
368368
args.put("segmentation", "none");
369369
}
370370

371+
ResponseMessage response = service.get(path + methodPath, args);
371372
// Splunk version pre-9.0 doesn't support v2
372373
// v1(GET), v2(POST)
373-
String fullPath;
374-
ResponseMessage response;
375-
if (service.versionIsEarlierThan("9.0")) {
376-
fullPath = path.replace(JobCollection.REST_PATH_V2, JobCollection.REST_PATH) + methodPath;
377-
response = service.get(fullPath, args);
378-
}
379-
else {
380-
fullPath = path.replace(JobCollection.REST_PATH, JobCollection.REST_PATH_V2) + methodPath;
381-
response = service.post(fullPath, args);
382-
}
374+
// String fullPath;
375+
// ResponseMessage response;
376+
// if (service.versionIsEarlierThan("9.0")) {
377+
// fullPath = path.replace(JobCollection.REST_PATH_V2, JobCollection.REST_PATH) + methodPath;
378+
// response = service.get(fullPath, args);
379+
// }
380+
// else {
381+
// fullPath = path.replace(JobCollection.REST_PATH, JobCollection.REST_PATH_V2) + methodPath;
382+
// response = service.post(fullPath, args);
383+
// }
383384

384385
return response.getContent();
385386
}

splunk/src/main/java/com/splunk/JobCollection.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,15 @@ public class JobCollection extends EntityCollection<Job> {
2727
static String oneShotNotAllowed = String.format(
2828
"Oneshot not allowed, use service oneshot search method");
2929
static final String REST_PATH = "search/jobs";
30-
static final String REST_PATH_V2 = "search/v2/jobs";
30+
//static final String REST_PATH_V2 = "search/v2/jobs";
3131
/**
3232
* Class constructor.
3333
*
3434
* @param service The connected {@code Service} instance.
3535
*/
3636
JobCollection(Service service) {
37-
super(service, service.versionIsAtLeast("9.0") ? REST_PATH_V2 : REST_PATH, Job.class);
37+
super(service, REST_PATH, Job.class);
38+
//super(service, service.versionIsAtLeast("9.0") ? REST_PATH_V2 : REST_PATH, Job.class);
3839
this.refreshArgs.put("count", "0");
3940
}
4041

@@ -46,7 +47,8 @@ public class JobCollection extends EntityCollection<Job> {
4647
* return and how to sort them (see {@link CollectionArgs}).
4748
*/
4849
JobCollection(Service service, Args args) {
49-
super(service, service.versionIsAtLeast("9.0") ? REST_PATH_V2 : REST_PATH, Job.class, args);
50+
super(service, REST_PATH, Job.class);
51+
//super(service, service.versionIsAtLeast("9.0") ? REST_PATH_V2 : REST_PATH, Job.class, args);
5052
this.refreshArgs.put("count", "0");
5153
}
5254

@@ -87,8 +89,9 @@ public Job create(String query, Map args) {
8789
.item(0)
8890
.getTextContent();
8991

90-
String path = service.versionIsAtLeast("9.0") ? REST_PATH_V2 : REST_PATH;
91-
Job job = new Job(service, path + "/" + sid);
92+
Job job = new Job(service, REST_PATH + "/" + sid);
93+
//String path = service.versionIsAtLeast("9.0") ? REST_PATH_V2 : REST_PATH;
94+
//Job job = new Job(service, path + "/" + sid);
9295
job.refresh();
9396

9497
return job;

splunk/src/main/java/com/splunk/Service.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -223,13 +223,13 @@ public InputStream export(String search, Map args) {
223223
if (!args.containsKey("segmentation")) {
224224
args.put("segmentation", "none");
225225
}
226-
ResponseMessage response;
227-
228-
if (versionIsAtLeast("9.0"))
229-
response = post(JobCollection.REST_PATH_V2 + "/export", args);
230-
else {
231-
response = post(JobCollection.REST_PATH + "/export", args);
232-
}
226+
ResponseMessage response = get(JobCollection.REST_PATH + "/export", args);
227+
// ResponseMessage response;
228+
// if (versionIsAtLeast("9.0"))
229+
// response = post(JobCollection.REST_PATH_V2 + "/export", args);
230+
// else {
231+
// response = post(JobCollection.REST_PATH + "/export", args);
232+
// }
233233
return new ExportResultsStream(response.getContent());
234234
}
235235

@@ -1257,11 +1257,11 @@ public ResponseMessage parse(String query) {
12571257
*/
12581258
public ResponseMessage parse(String query, Map args) {
12591259
args = Args.create(args).add("q", query);
1260-
1261-
if (versionIsAtLeast("9.0"))
1262-
return post("search/v2/parser", args);
1263-
else
1264-
return get("search/parser", args);
1260+
return get("search/parser", args);
1261+
// if (versionIsAtLeast("9.0"))
1262+
// return post("search/v2/parser", args);
1263+
// else
1264+
// return get("search/parser", args);
12651265
}
12661266

12671267
/**

0 commit comments

Comments
 (0)