Skip to content

Commit

Permalink
Merge pull request #467 from splunk/DVPL-11246
Browse files Browse the repository at this point in the history
Added 'kwrgs' parameter for Saved Search History function
  • Loading branch information
akaila-splunk committed Jul 12, 2022
2 parents 66a8741 + 92c6fc6 commit 9753de9
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
7 changes: 5 additions & 2 deletions splunklib/client.py
Expand Up @@ -3291,12 +3291,15 @@ def fired_alerts(self):
item=AlertGroup)
return c

def history(self):
def history(self, **kwargs):
"""Returns a list of search jobs corresponding to this saved search.
:param `kwargs`: Additional arguments (optional).
:type kwargs: ``dict``
:return: A list of :class:`Job` objects.
"""
response = self.get("history")
response = self.get("history", **kwargs)
entries = _load_atom_entries(response)
if entries is None: return []
jobs = []
Expand Down
21 changes: 21 additions & 0 deletions tests/test_saved_search.py
Expand Up @@ -170,6 +170,27 @@ def test_history(self):
finally:
job.cancel()

def test_history_with_options(self):
try:
old_jobs = self.saved_search.history()
old_jobs_cnt = len(old_jobs)

curr_job_cnt = 50
for _ in range(curr_job_cnt):
job = self.saved_search.dispatch()
while not job.is_ready():
sleep(0.1)

# fetching all the jobs
history = self.saved_search.history(count=0)
self.assertEqual(len(history), old_jobs_cnt + curr_job_cnt)

# fetching 3 jobs
history = self.saved_search.history(count=3)
self.assertEqual(len(history), 3)
finally:
job.cancel()

def test_scheduled_times(self):
self.saved_search.update(cron_schedule='*/5 * * * *', is_scheduled=True)
scheduled_times = self.saved_search.scheduled_times()
Expand Down

0 comments on commit 9753de9

Please sign in to comment.