postUrl = postUrl + "?index=" + indexName; if (args != null && args.size() > 0) { postUrl = postUrl + ((indexName == null) ? "?" : "&"); postUrl = postUrl + args.encode();
/** * Logs an event to this index through HTTP POST. * * @param indexName The index to write to. * @param data A string containing event data. * @param args Optional arguments for this stream. Valid parameters are: * "host", "host_regex", "source", and "sourcetype". */ public void submit(String indexName, Args args, String data) { String sendString = ""; RequestMessage request = new RequestMessage("POST"); request.setContent(data); if (indexName !=null) { sendString = String.format("?index=%s", indexName); } if (args != null && args.size() > 0) { sendString = sendString + ((indexName == null) ? "?" : "&"); sendString = sendString + args.encode(); } ResponseMessage response = service.send(service.simpleReceiverEndPoint + sendString, request); try { response.getContent().close(); } catch (IOException e) { // noop } }
/** * 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; }