/** * Issues an HTTP request to list the contents of the collection resource. * * @return The list response message. */ public ResponseMessage list() { return service.get(path, this.refreshArgs); }
/** * Returns the job's response. * * @return The job's response. */ @Override public ResponseMessage list() { return service.get(path, this.refreshArgs); }
/** * Reloads the deployment client from the configuration file. */ public void reload() { service.get(path + "/deployment-client/Reload"); invalidate(); }
private InputStream getEventsMethod(String methodPath, Map args) { checkReady(); if (args == null) { args = new HashMap<String, Object>(); } if (!args.containsKey("segmentation")) { // By default, don't include notations in the results to highlight // search terms (i.e., <sg> elements in XML output). args.put("segmentation", "none"); } ResponseMessage response = service.get(path + methodPath, args); return response.getContent(); }
/** * Returns the {@code InputStream} IO handle to the search log for this job. * * @param args Optional argument ("attachment"). * @return The search log {@code InputStream} IO handle. */ public InputStream getSearchLog(Map args) { checkReady(); ResponseMessage response = service.get(path + "/search.log", args); return response.getContent(); }
/** * Returns the {@code InputStream} IO handle for the timeline for this job. * * @param args Optional arguments ("output_time_format" and "time_format"). * @return The timeline {@code InputStream} IO handle. */ public InputStream getTimeline(Map args) { checkReady(); ResponseMessage response = service.get(path + "/timeline", args); return response.getContent(); }
/** * Parses a search query with additional arguments and returns a semantic * map for the search in JSON format. * * @param query The search query. * @param args Additional parse arguments. * @return The parse response message. */ public ResponseMessage parse(String query, Map args) { args = Args.create(args).add("q", query); return get("search/parser", args); }
/** * Returns the {@code InputStream} IO handle for the summary for this job. * * @param args Optional arguments. * For a list of possible parameters, see the Request parameters for the * <a href="http://docs.splunk.com/Documentation/Splunk/latest/RESTAPI/RESTsearch#GET_search.2Fjobs.2F.7Bsearch_id.7D.2Fsummary" * target="_blank">GET search/jobs/{search_id}/summary</a> * endpoint in the REST API documentation. * @return The summary {@code InputStream} IO handle. */ public InputStream getSummary(Map args) { checkReady(); ResponseMessage response = service.get(path + "/summary", args); return response.getContent(); }
/** {@inheritDoc} */ @Override public Entity refresh() { // Update any attribute values set by a setter method that has not // yet been written to the object. ResponseMessage response = service.get(path); assert(response.getStatus() == 200); AtomFeed feed; try { feed = AtomFeed.parseStream(response.getContent()); } catch (Exception e) { throw new RuntimeException(e); } int count = feed.entries.size(); if (count > 1) { throw new IllegalStateException("Expected 0 or 1 Atom entries; found " + feed.entries.size()); } AtomEntry entry = count == 0 ? null : feed.entries.get(0); load(entry); return this; }
/** * Returns an array of search jobs created from this saved search. * * @return An array of search jobs. */ public Job[] history() { ResponseMessage response = service.get(actionPath("history")); AtomFeed feed; try { feed = AtomFeed.parseStream(response.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; }
/** * Runs an export search with arguments (using the {@code search/jobs/export} * endpoint), and streams results back in an input stream. * * @param search The search query to run. * @param args Additional search arguments. * For a list of possible parameters, see * <a href="http://dev.splunk.com/view/SP-CAAAEHQ#savedsearchparams" * target="_blank">Saved search parameters</a> on * <a href="http://dev.splunk.com/view/SP-CAAAEHQ" * target="_blank">dev.splunk.com</a>. * @return The {@code InputStream} object that contains the search results. */ public InputStream export(String search, Map args) { args = Args.create(args).add("search", search); // By default don't highlight search terms in the output. if (!args.containsKey("segmentation")) { args.put("segmentation", "none"); } ResponseMessage response = get(JobCollection.REST_PATH + "/export", args); return new ExportResultsStream(response.getContent()); }
ResponseMessage response = service.get(this.path + "/" + Util.join("/", subPath)); AtomFeed feed = AtomFeed.parseStream(response.getContent()); for (AtomEntry entry : feed.entries) {
/** * Refreshes this job. * * @return The search job. */ @Override public Job refresh() { update(); ResponseMessage response = service.get(path); if (response.getStatus() == 204) { isReady = false; return this; } AtomEntry entry; try { entry = AtomEntry.parseStream(response.getContent()); } catch (Exception e) { throw new RuntimeException(e); } load(entry); if (getString("dispatchState").equals("QUEUED") || getString("dispatchState").equals("PARSING")) { isReady = false; } else { isReady = true; } return this; }
ResponseMessage response; try { response = service.get(inputs);
/** * Query Splunk for SPL queries corresponding to this pivot. * * @return a Pivot object encapsulating the returned queries. */ public Pivot pivot() { Service service = this.dataModelObject.getDataModel().getService(); Args args = new Args(); args.put("pivot_json", toJson()); if (this.accelerationNamespace != null) { args.put("namespace", this.accelerationNamespace); } ResponseMessage response = service.get( "datamodel/pivot/" + this.dataModelObject.getDataModel().getName(), args ); if (response.getStatus() != 200) { throw HttpException.create(response); } else { return Pivot.parseStream(service, response.getContent()); } } }