You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Adding Args option fro Saved Search history method #126
Hello,
I have a use-case where I need to get the latest run of a scheduled saved search.
I know SavedSearch class has a history method which gets me all the old jobs runs. But it looks like the results are being paginated to the earliest 30 results.
The history method itself doesn't have any options to pass arguments for the GET call.
Is there any other way to achieve this? I know the REST API does support sort_dir=desc option for getting the history jobs in descending order.
This is a reasonable feature request. We're open to a pull request, and the change is pretty small to add support for this feature.
In SavedSearch we'd want to add an overload for history() that takes an Args map and passes it as the second argument to service.get(). Then in your code, you'd be able to pass in a map to the new history() overload with count set to whatever value you want (0 for all).
Hi @BalasubramanyamEvani, thank you for the sharing the code change. @vineethsoma we have added the Args option and the same will be available in the Next SDK release.
@BalasubramanyamEvani, @vineethsoma
we have added the "args" option for the Saved Search History method and it is available in the latest SDK. Hence closing this issue, please reopen the issue if you still face any issue regarding this.
Activity
shakeelmohamed commentedon May 23, 2018
Hi @vineethsoma,
This is a reasonable feature request. We're open to a pull request, and the change is pretty small to add support for this feature.
In
SavedSearchwe'd want to add an overload forhistory()that takes anArgsmap and passes it as the second argument toservice.get(). Then in your code, you'd be able to pass in a map to the newhistory()overload withcountset to whatever value you want (0for all).BalasubramanyamEvani commentedon Nov 19, 2021
I have made some changes. I think this should suffice. Please let me know if this works.
public Job[] history() { ResponseMessage response = service.get(actionPath("history")); - AtomFeed feed; + return parseHistoryResponse(response); + } + + /** + * Returns an array of search jobs based on passed search arguments + * + * @param args + * @return An array of search jobs + */ + public Job[] history(Map<String, Object> args) { + ResponseMessage response = service.get(actionPath("history"), args); + return parseHistoryResponse(response); + } + + /** + * Parses response message from history action path + * + * @param responseMessage + * @return result An array of Job + */ + private Job[] parseHistoryResponse(final ResponseMessage responseMessage) { + AtomFeed feed; try { - feed = AtomFeed.parseStream(response.getContent()); + feed = AtomFeed.parseStream(responseMessage.getContent()); } catch (Exception e) { throw new RuntimeException(e); } int count = feed.entries.size(); Job[] result = new Job[count]; for (int i = 0; i < count; ++i) { String sid = feed.entries.get(i).title; result[i] = new Job(service, JobCollection.REST_PATH + "/" + sid); } return result; }ashah-splunk commentedon Jul 12, 2022
Hi @BalasubramanyamEvani, thank you for the sharing the code change.
@vineethsoma we have added the Args option and the same will be available in the Next SDK release.
ashah-splunk commentedon Oct 6, 2022
@BalasubramanyamEvani, @vineethsoma
we have added the "args" option for the Saved Search History method and it is available in the latest SDK. Hence closing this issue, please reopen the issue if you still face any issue regarding this.