Skip to content

Commit e32cb40

Browse files
author
Shakeel Mohamed
committed
add getJob(String sid) to Service
1 parent a8b8826 commit e32cb40

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

examples/com/splunk/examples/get_job/Program.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,21 @@ public static void main(String[] args) {
3636

3737
// Now job is done
3838
System.out.println(job.getEventCount());
39+
40+
41+
// Using service.getJob();
42+
43+
Job job2 = service.getJob(sid);
44+
45+
while (!job2.isDone()) {
46+
job2.refresh();
47+
try {
48+
Thread.sleep(1000);
49+
} catch (Exception e) {
50+
System.out.println(e.getMessage());
51+
}
52+
}
53+
54+
System.out.println(job2.getEventCount());
3955
}
4056
}

splunk/com/splunk/Service.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -629,6 +629,16 @@ public JobCollection getJobs(Args args) {
629629
return new JobCollection(this, args);
630630
}
631631

632+
/**
633+
* Returns a Job by the provided sid.
634+
*
635+
* @param sid The sid for a job.
636+
* @return A Job.
637+
*/
638+
public Job getJob(String sid) {
639+
return new Job(this, "search/jobs/" + sid);
640+
}
641+
632642
/**
633643
* Returns a collection of license group configurations.
634644
*

0 commit comments

Comments
 (0)