Skip to content

Commit 9753de9

Browse files
Merge pull request #467 from splunk/DVPL-11246
Added 'kwrgs' parameter for Saved Search History function
2 parents 66a8741 + 92c6fc6 commit 9753de9

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
@@ -3291,12 +3291,15 @@ def fired_alerts(self):
32913291
item=AlertGroup)
32923292
return c
32933293

3294-
def history(self):
3294+
def history(self, **kwargs):
32953295
"""Returns a list of search jobs corresponding to this saved search.
32963296
3297+
:param `kwargs`: Additional arguments (optional).
3298+
:type kwargs: ``dict``
3299+
32973300
:return: A list of :class:`Job` objects.
32983301
"""
3299-
response = self.get("history")
3302+
response = self.get("history", **kwargs)
33003303
entries = _load_atom_entries(response)
33013304
if entries is None: return []
33023305
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)