Skip to content

Commit b4644fa

Browse files
authored
Merge pull request #190 from splunk/Release/1.9.0
Release/1.9.0
2 parents 7222d59 + de3d402 commit b4644fa

File tree

15 files changed

+121
-33
lines changed

15 files changed

+121
-33
lines changed

.github/workflows/release.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ jobs:
1919
server-id: splunk-artifactory
2020
- name: build
2121
run: mvn package --file pom.xml -DskipTests=true
22+
- name: Create temp artifacts apidocs folder
23+
run: mkdir apidocs
2224
- name: Create GitHub Release
2325
uses: softprops/action-gh-release@v1
2426
with:
@@ -32,3 +34,12 @@ jobs:
3234
env:
3335
MAVEN_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }}
3436
MAVEN_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }}
37+
38+
- name: Zip docs
39+
run: zip -r apidocs/docs.zip splunk/target/apidocs
40+
41+
- name: Upload Artifact
42+
uses: actions/upload-artifact@v3
43+
with:
44+
name: apidocs
45+
path: apidocs/docs.zip

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
java-version:
1414
- 1.8
1515
splunk-version:
16-
- "8.0"
16+
- "8.2"
1717
- "latest"
1818
runs-on: ${{ matrix.os }}
1919

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Splunk Enterprise SDK for Java Changelog
22

3+
## Version 1.9.0
4+
5+
### New Features and APIs
6+
* SDK Support for splunkd search API changes, for Splunk 9.0+. (Github PR [#189](https://github.com/splunk/splunk-sdk-java/pull/189))
7+
8+
### Minor Changes
9+
* Automated docs generation using GitHub actions. (Github PR [#184](https://github.com/splunk/splunk-sdk-java/pull/184))
10+
311
## Version 1.8.0
412

513
### New Features and APIs

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[![Java SDK Test](https://github.com/splunk/splunk-sdk-java/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/splunk/splunk-sdk-java/actions/workflows/test.yml)
22
# The Splunk Software Development Kit for Java
33

4-
#### Version 1.8.0
4+
#### Version 1.9.0
55

66
The Splunk Software Development Kit (SDK) for Java contains library code and
77
examples designed to enable developers to build applications using Splunk.
@@ -40,7 +40,7 @@ Here's what you need to get going with the Splunk SDK for Java.
4040
If you haven't already installed Splunk, download it
4141
[here](http://www.splunk.com/download). For more about installing and running
4242
Splunk and system requirements, see
43-
[Installing & Running Splunk](http://dev.splunk.com/view/SP-CAAADRV). The Splunk SDK for Java has been tested with Splunk Enterprise 8.0 and 8.2.0.
43+
[Installing & Running Splunk](http://dev.splunk.com/view/SP-CAAADRV). The Splunk SDK for Java has been tested with Splunk Enterprise 9.0 and 8.2.
4444

4545
#### Splunk SDK for Java
4646

@@ -75,7 +75,7 @@ To add the Splunk SDK for Java `.JAR` file as a dependency:
7575
<dependency>
7676
<groupId>com.splunk</groupId>
7777
<artifactId>splunk</artifactId>
78-
<version>1.8.0</version>
78+
<version>1.9.0</version>
7979
</dependency>
8080
</dependencies>
8181
```

deploy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
declare -r scriptDirectory="$(dirname $(readlink -e $0))"
44
declare -r scriptName="$(basename $0)"
5-
declare -r version="1.8.0"
5+
declare -r version="1.9.0"
66

77
if [[ $# -ne 1 ]]; then
88
echo 1>&2 "Usage: ${scriptName} {local|staging||production}"

deploy.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ deploy \<repository-name>
99

1010
##DESCRIPTION
1111

12-
Deploy transmits **target/splunk-1.8.0.jar**, **target/splunk-1.8.0-javadoc.jar**, and
13-
**target/splunk-1.8.0-sources.jar** to the **local**, **staging**, or **production**
12+
Deploy transmits **target/splunk-1.9.0.jar**, **target/splunk-1.9.0-javadoc.jar**, and
13+
**target/splunk-1.9.0-sources.jar** to the **local**, **staging**, or **production**
1414
maven repository. Repository names are mapped to locations as follows.
1515

1616
| repository-name | location |
@@ -21,18 +21,18 @@ maven repository. Repository names are mapped to locations as follows.
2121

2222
After deployment you should find this tree structure at the location of your repository
2323

24-
com/splunk/splunk/1.8.0/
25-
├── splunk-1.8.0-javadoc.jar
26-
├── splunk-1.8.0-javadoc.jar.md5
27-
├── splunk-1.8.0-javadoc.jar.sha1
28-
├── splunk-1.8.0-sources.jar
29-
├── splunk-1.8.0-sources.jar.md5
30-
├── splunk-1.8.0-sources.jar.sha1
31-
├── splunk-1.8.0.jar
32-
├── splunk-1.8.0.jar.md5
33-
├── splunk-1.8.0.jar.sha1
34-
├── splunk-1.8.0.pom
35-
├── splunk-1.8.0.pom.md5
36-
└── splunk-1.8.0.pom.sha1
24+
com/splunk/splunk/1.9.0/
25+
├── splunk-1.9.0-javadoc.jar
26+
├── splunk-1.9.0-javadoc.jar.md5
27+
├── splunk-1.9.0-javadoc.jar.sha1
28+
├── splunk-1.9.0-sources.jar
29+
├── splunk-1.9.0-sources.jar.md5
30+
├── splunk-1.9.0-sources.jar.sha1
31+
├── splunk-1.9.0.jar
32+
├── splunk-1.9.0.jar.md5
33+
├── splunk-1.9.0.jar.sha1
34+
├── splunk-1.9.0.pom
35+
├── splunk-1.9.0.pom.md5
36+
└── splunk-1.9.0.pom.sha1
3737

3838
Verify this structure prior to release.

examples/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
<dependency>
3838
<groupId>com.splunk</groupId>
3939
<artifactId>splunk</artifactId>
40-
<version>1.8.0</version>
40+
<version>1.9.0</version>
4141
<scope>provided</scope>
4242
</dependency>
4343
<dependency>

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<modelVersion>4.0.0</modelVersion>
77

88
<properties>
9-
<version.number>1.8.0</version.number>
9+
<version.number>1.9.0</version.number>
1010
<maven.resources.overwrite>true</maven.resources.overwrite>
1111
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1212
<maven.compiler.source>8</maven.compiler.source>

splunk/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<modelVersion>4.0.0</modelVersion>
66

77
<artifactId>splunk</artifactId>
8-
<version>1.8.0</version>
8+
<version>1.9.0</version>
99
<parent>
1010
<artifactId>splunk-sdk-java</artifactId>
1111
<groupId>com.splunk</groupId>
@@ -71,7 +71,7 @@
7171
<plugin>
7272
<groupId>org.jacoco</groupId>
7373
<artifactId>jacoco-maven-plugin</artifactId>
74-
<version>0.8.7</version>
74+
<version>0.8.8</version>
7575
<executions>
7676
<execution>
7777
<goals>

splunk/src/main/java/com/splunk/HttpService.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public boolean verify(String s, SSLSession sslSession) {
8989
private String prefix = null;
9090

9191
static Map<String, String> defaultHeader = new HashMap<String, String>() {{
92-
put("User-Agent", "splunk-sdk-java/1.8.0");
92+
put("User-Agent", "splunk-sdk-java/1.9.0");
9393
put("Accept", "*/*");
9494
}};
9595

@@ -208,7 +208,7 @@ public int getPort() {
208208
/**
209209
* Sets Custom Headers of this service
210210
*
211-
* @param headers
211+
* @param headers The custom headers.
212212
*/
213213
public void setCustomHeaders(Map<String, String> headers) {
214214
if (Objects.nonNull(headers)) {

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

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ public class Job extends Entity {
3535
*
3636
* @param service The connected {@code Service} instance.
3737
* @param path The search jobs endpoint.
38+
* @param sid The sid of the job.
3839
*/
3940
Job(Service service, String path) {
4041
super(service, path);
@@ -367,7 +368,19 @@ private InputStream getEventsMethod(String methodPath, Map args) {
367368
args.put("segmentation", "none");
368369
}
369370

370-
ResponseMessage response = service.get(path + methodPath, args);
371+
// Splunk version pre-9.0 doesn't support v2
372+
// 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+
}
383+
371384
return response.getContent();
372385
}
373386

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,14 @@ 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";
3031
/**
3132
* Class constructor.
3233
*
3334
* @param service The connected {@code Service} instance.
3435
*/
3536
JobCollection(Service service) {
36-
super(service, REST_PATH, Job.class);
37+
super(service, service.versionIsAtLeast("9.0") ? REST_PATH_V2 : REST_PATH, Job.class);
3738
this.refreshArgs.put("count", "0");
3839
}
3940

@@ -45,7 +46,7 @@ public class JobCollection extends EntityCollection<Job> {
4546
* return and how to sort them (see {@link CollectionArgs}).
4647
*/
4748
JobCollection(Service service, Args args) {
48-
super(service, REST_PATH, Job.class, args);
49+
super(service, service.versionIsAtLeast("9.0") ? REST_PATH_V2 : REST_PATH, Job.class, args);
4950
this.refreshArgs.put("count", "0");
5051
}
5152

@@ -86,7 +87,8 @@ public Job create(String query, Map args) {
8687
.item(0)
8788
.getTextContent();
8889

89-
Job job = new Job(service, REST_PATH + "/" + sid);
90+
String path = service.versionIsAtLeast("9.0") ? REST_PATH_V2 : REST_PATH;
91+
Job job = new Job(service, path + "/" + sid);
9092
job.refresh();
9193

9294
return job;

splunk/src/main/java/com/splunk/OutputServer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public String getStatus() {
9292
/**
9393
* Returns client certificate path.
9494
*
95-
* @return
95+
* @return Path of client certificate.
9696
*/
9797
public String getClientCert() {
9898
return getString("clientCert", "");

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

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,13 @@ public InputStream export(String search, Map args) {
223223
if (!args.containsKey("segmentation")) {
224224
args.put("segmentation", "none");
225225
}
226-
ResponseMessage response = get(JobCollection.REST_PATH + "/export", args);
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+
}
227233
return new ExportResultsStream(response.getContent());
228234
}
229235

@@ -1251,7 +1257,11 @@ public ResponseMessage parse(String query) {
12511257
*/
12521258
public ResponseMessage parse(String query, Map args) {
12531259
args = Args.create(args).add("q", query);
1254-
return get("search/parser", args);
1260+
1261+
if (versionIsAtLeast("9.0"))
1262+
return post("search/v2/parser", args);
1263+
else
1264+
return get("search/parser", args);
12551265
}
12561266

12571267
/**

splunk/src/test/java/com/splunk/SearchJobTest.java

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,18 @@ public void testEventsFromJob() {
6262
job.cancel();
6363
}
6464

65+
@Test
66+
public void testEventsWithSearchParams() {
67+
Job job = jobs.create(QUERY);
68+
waitUntilDone(job);
69+
70+
Map args = new HashMap<String, Object>();
71+
args.put("search","| head 1");
72+
Assert.assertEquals(1, countEvents(job.getEvents(args)));
73+
74+
job.cancel();
75+
}
76+
6577
@Test
6678
public void testResultsFromJob() {
6779
Job job = jobs.create(QUERY);
@@ -71,6 +83,18 @@ public void testResultsFromJob() {
7183

7284
job.cancel();
7385
}
86+
87+
@Test
88+
public void testResultsWithSearchParams() {
89+
Job job = jobs.create(QUERY);
90+
waitUntilDone(job);
91+
92+
Map args = new HashMap<String, Object>();
93+
args.put("search","| head 1");
94+
Assert.assertEquals(1, countEvents(job.getResults(args)));
95+
96+
job.cancel();
97+
}
7498

7599
@Test
76100
public void testGetJobBySid() {
@@ -584,6 +608,26 @@ public void testPreview() throws InterruptedException {
584608
job.cancel();
585609
}
586610

611+
@Test
612+
public void testPreviewWithSearchParams() throws InterruptedException {
613+
JobArgs args = new JobArgs();
614+
args.put("field_list", "source,host,sourcetype");
615+
args.setStatusBuckets(100);
616+
617+
Job job = jobs.create(QUERY, args);
618+
619+
while (!job.isReady()) {
620+
Thread.sleep(100);
621+
}
622+
623+
Map argsSearchQuery = new HashMap<String, Object>();
624+
argsSearchQuery.put("search","| head 1");
625+
// Assert.assertTrue(1 >= countEvents(job.getResultsPreview(args)));
626+
Assert.assertEquals(1, countEvents(job.getResultsPreview(argsSearchQuery)));
627+
628+
job.cancel();
629+
}
630+
587631
@Test
588632
public void testSearchLog() {
589633
Job job = jobs.create(QUERY);

0 commit comments

Comments
 (0)