Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added 'kwrgs' parameter for Saved Search History function #467

Merged
merged 1 commit into from Jul 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 5 additions & 2 deletions splunklib/client.py
Expand Up @@ -3212,12 +3212,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