-
Notifications
You must be signed in to change notification settings - Fork 121
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
Adding Args option fro Saved Search history method #126
Comments
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 |
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;
} |
Hi @BalasubramanyamEvani, thank you for the sharing the code change. |
@BalasubramanyamEvani, @vineethsoma |
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.
I would also be happy to do these changes.
Thanks,
-Vineeth
The text was updated successfully, but these errors were encountered: