/** * {@inheritDoc} */ @Override public void update(Map<String, Object> args) { // Add required arguments if not already present if (!args.containsKey("name")) { args = Args.create(args).add("name", "tcpout"); } super.update(args); }
/** * 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); }
/** * {@inheritDoc} */ @Override public void update(Map<String, Object> args) { // If not present in the update keys, add required attributes if (!args.containsKey("classes")) args = Args.create(args).add("classes", getClasses()); if (!args.containsKey("interval")) args = Args.create(args).add("interval", getInterval()); if (!args.containsKey("lookup_host")) args = Args.create(args).add( "lookup_host", getLookupHost()); super.update(args); }
/** * {@inheritDoc} */ @Override public void update(Map<String, Object> args) { // Add required arguments if not already present if (!args.containsKey("monitorSubtree")) { args = Args.create(args).add( "monitorSubtree", getMonitorSubtree()); } super.update(args); }
/** * {@inheritDoc} */ @Override public void update(Map<String, Object> args) { // Add required arguments if not already present if (!args.containsKey("servers")) { args = Args.create(args).add("servers", getString("servers")); } super.update(args); }
/** * Creates an entity in this collection. * * @param name The name of the entity. * @param args Arguments for creating the entity. * @return The entity. */ @Override public DataModel create(String name, Map args) { Args revisedArgs = Args.create(args); // concise=0 forces the server to return all details of the newly // created data model. if (!args.containsKey("concise")) { revisedArgs = revisedArgs.add("concise", "0"); } return super.create(name, revisedArgs); } }
/** * Creates an event type. * * @param name The name of the event type. * @param search The search string of the event type. * @param args Optional arguments: "description", "disabled", and * "priority". * @return The event type. */ public EventType create(String name, String search, Map args) { args = Args.create(args).add("search", search); return create(name, args); } }
/** * {@inheritDoc} */ @Override public void update(Map<String, Object> args) { // Add required arguments if not already present if (!args.containsKey("lookup_host")) { args = Args.create(args).add("lookup_host", getLookupHost()); } super.update(args); }
/** * {@inheritDoc} */ @Override public void update(Map<String, Object> args) { // Add required arguments if not already present if (!args.containsKey("search")) { args = Args.create(args).add("search", getSearch()); } super.update(args); }
/** * {@inheritDoc} */ @Override public void update(Map<String, Object> args) { // Add required arguments if not already present if (!args.containsKey("search")) { args = Args.create(args).add("search", getSearch()); } super.update(args); }
/** * Creates a saved search from a name, search query, and * additional arguments. * * @param name The name for the search. * @param search The search query. * @param args Additional 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 new saved search. */ public SavedSearch create(String name, String search, Map args) { args = Args.create(args).add("search", search); return create(name, args); } }
/** * {@inheritDoc} */ @Override public void update(Map<String, Object> args) { // Add required arguments if not already present if (!args.containsKey("baseline")) { args = Args.create(args).add("baseline", getBaseline()); } if (!args.containsKey("hive")) { args = Args.create(args).add("hive", getHive()); } if (!args.containsKey("proc")) { args = Args.create(args).add("proc", getProc()); } if (!args.containsKey("type")) { args = Args.create(args).add("type", Util.join("|", getType())); } super.update(args); }
/** * 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()); }
/** * Creates a search. * <p> * <b>Note:</b> You can't create a "oneshot" search using this method. * Instead, use the {@link Service#oneshotSearch} method. * * @param query The search query. * @param args Additional arguments for this job (see {@link JobArgs}). * @return The unique search identifier (SID). */ public Job create(String query, Map args) { if (args != null && args.containsKey("exec_mode")) { if (args.get("exec_mode").equals("oneshot")) throw new RuntimeException(oneShotNotAllowed); } args = Args.create(args).add("search", query); ResponseMessage response = service.post(path, args); assert(response.getStatus() == 201); String sid = Xml.parse(response.getContent()) .getElementsByTagName("sid") .item(0) .getTextContent(); Job job = new Job(service, REST_PATH + "/" + sid); job.refresh(); return job; }
/** * Creates a new stanza in the current configuration file with attributes. * * @param name The name of the stanza to create. * @param args Optional. A set of attributes as key-value pairs to put in * the new stanza. * @return The name of the new stanza. */ public EntityCollection<Entity> create(String name, Map args) { args = Args.create(args).add("__conf", name); service.post(path, args); invalidate(); return get(name); }
/** * Uploads a file to this index as an event stream. * <p> * <b>Note:</b> This file must be directly accessible by the Splunk server. * * @param filename The path and filename. * * @param args Optional arguments for this request. Valid parameters are: * "host", "sourcetype", "rename-source". More found at: * http://docs.splunk.com/Documentation/Splunk/latest/RESTAPI/RESTinput#data.2Finputs.2Foneshot * */ public void upload(String filename, Args args) { EntityCollection<Upload> uploads = service.getUploads(); if(args.containsKey("index")){ throw new IllegalArgumentException("The 'index' parameter cannot be passed to an index's oneshot upload."); } args.add("index", getName()); uploads.create(filename, args); } }
/** * Creates an entity in this collection. * * @param name The name of the entity. * @param args Arguments for creating the entity. * @return The entity. */ public T create(String name, Map args) { args = Args.create(args).add("name", name); service.post(path, args); invalidate(); return get(name); }
/** * Performs the requested action on this job. Valid values are: "pause", * "unpause", "finalize", "cancel", "touch", "setttl", "setpriority", * "enablepreview", and "disablepreview". * * @param action The action to perform. * @param args Optional arguments for this action ("ttl" and "priority"). * @return The search job. */ public Job control(String action, Map args) { args = Args.create(args).add("action", action); service.post(actionPath("control"), args); invalidate(); return this; }
args = Args.create(args).add("name", name); String path = this.path + "/" + kind.getRelativePath(); service.post(path, args);