/** * Encodes a hash map of {@code String:String} or {@code String:String[]} * into a single UTF8-encoded string. * * @param args The hash map. * @return The string. */ public static String encode(Map<String, Object> args) { return Args.create(args).encode(); }
/** * Creates a license pool. * * @param name The name of the new license pool. * @param quota The indexing quota of this license pool, specified as: * <ul><li><i>number</i></li> * <li><i>number</i> followed by "MB" or "GB" (for example, "10GB")</li> * <li>"MAX" (Only one license pool can have "MAX" size in a stack.)</li> * </ul> * @param stackId The stack ID corresponding to this license pool. * @param args Optional arguments ("description" and "slaves"). * @return The new license pool. */ public LicensePool create(String name, String quota, String stackId, Map args) { args = Args.create(args); args.put("quota", quota); args.put("stack_id", stackId); return create(name, args); } }
/** * {@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); }
/** * Creates an asynchronous search job using the given query and * search arguments. * * @param query The search query. * @param args The search arguments. * @return The search job. */ public Job search(String query, Map<String, Object> args) { args = Args.create(args); return this.getJobs().create(query, 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); }
/** * {@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); }
/** * 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); } }
/** * 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); } }
/** * {@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 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); }
/** * 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; }
/** * Class constructor. * * @param service The connected {@code Service} instance. * @param path The target endpoint. * @param args Arguments to use when you instantiate the entity. */ Resource(Service service, String path, Args args) { // Clone the original argument list, since it will be modified args = Args.create(args); Args namespace = extractNamespaceFrom(args); if (!args.containsKey("count")) { args.put("count", "-1"); } this.service = service; this.path = service.fullpath( path, namespace.size() == 0 ? null : namespace); this.refreshArgs = args; }