Skip to content

Commit 92c6fc6

Browse files
committed
updated saved search history method
- added support for passing additional arguments in saved search history method
1 parent 27f8fbf commit 92c6fc6

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

splunklib/client.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3212,12 +3212,15 @@ def fired_alerts(self):
32123212
item=AlertGroup)
32133213
return c
32143214

3215-
def history(self):
3215+
def history(self, **kwargs):
32163216
"""Returns a list of search jobs corresponding to this saved search.
32173217
3218+
:param `kwargs`: Additional arguments (optional).
3219+
:type kwargs: ``dict``
3220+
32183221
:return: A list of :class:`Job` objects.
32193222
"""
3220-
response = self.get("history")
3223+
response = self.get("history", **kwargs)
32213224
entries = _load_atom_entries(response)
32223225
if entries is None: return []
32233226
jobs = []

tests/test_saved_search.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,27 @@ def test_history(self):
170170
finally:
171171
job.cancel()
172172

173+
def test_history_with_options(self):
174+
try:
175+
old_jobs = self.saved_search.history()
176+
old_jobs_cnt = len(old_jobs)
177+
178+
curr_job_cnt = 50
179+
for _ in range(curr_job_cnt):
180+
job = self.saved_search.dispatch()
181+
while not job.is_ready():
182+
sleep(0.1)
183+
184+
# fetching all the jobs
185+
history = self.saved_search.history(count=0)
186+
self.assertEqual(len(history), old_jobs_cnt + curr_job_cnt)
187+
188+
# fetching 3 jobs
189+
history = self.saved_search.history(count=3)
190+
self.assertEqual(len(history), 3)
191+
finally:
192+
job.cancel()
193+
173194
def test_scheduled_times(self):
174195
self.saved_search.update(cron_schedule='*/5 * * * *', is_scheduled=True)
175196
scheduled_times = self.saved_search.scheduled_times()

0 commit comments

Comments
 (0)