{
- /**
- * Indicates whether the results are a preview from an unfinished search.
- * @return {@code true} if the results are a preview, {@code false} if not.
- */
- public boolean isPreview();
-
- /**
- * Returns a collection of field names from the results.
- * @return A collection of field names.
- *
- * Note that any given result will contain a subset of these fields.
- */
- public Collection getFields();
-}
+/*
+ * Copyright 2012 Splunk, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"): you may
+ * not use this file except in compliance with the License. You may obtain
+ * a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ */
+
+package com.splunk;
+
+import java.util.Collection;
+
+/**
+ * The {@code SearchResults} interface represents Splunk search results.
+ */
+public interface SearchResults extends Iterable {
+ /**
+ * Indicates whether the results are a preview from an unfinished search.
+ * @return {@code true} if the results are a preview, {@code false} if not.
+ */
+ public boolean isPreview();
+
+ /**
+ * Returns a collection of field names from the results.
+ * @return A collection of field names.
+ *
+ * Note that any given result will contain a subset of these fields.
+ */
+ public Collection getFields();
+}
diff --git a/splunk/src/main/java/com/splunk/Service.java b/splunk/src/main/java/com/splunk/Service.java
index 3af59b62..adedc790 100644
--- a/splunk/src/main/java/com/splunk/Service.java
+++ b/splunk/src/main/java/com/splunk/Service.java
@@ -1,1481 +1,1486 @@
-/*
- * Copyright 2012 Splunk, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"): you may
- * not use this file except in compliance with the License. You may obtain
- * a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations
- * under the License.
- */
-
-package com.splunk;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.UnsupportedEncodingException;
-import java.net.*;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-/**
- * The {@code Service} class represents a Splunk service instance at a given
- * address (host:port), accessed using the {@code http} or {@code https}
- * protocol scheme.
- *
- * A {@code Service} instance also captures an optional namespace context
- * consisting of an optional owner name (or "-" wildcard) and optional app name
- * (or "-" wildcard).
- *
- * To access {@code Service} members, the {@code Service} instance must be
- * authenticated by presenting credentials using the {@code login} method, or
- * by constructing the {@code Service} instance using the {@code connect}
- * method, which both creates and authenticates the instance.
- */
-public class Service extends BaseService {
- /** The current app context. */
- protected String app = null;
-
- /** The current session token. */
- protected String token = null;
-
- /** The current owner context. A value of "nobody" means that all users
- * have access to the resource.
- */
- protected String owner = null;
-
- /** The Splunk account username, which is used to authenticate the Splunk
- * instance. */
- protected String username = null;
-
- /** The password, which is used to authenticate the Splunk instance. */
- protected String password = null;
-
- /** The default simple receiver endpoint. */
- protected String simpleReceiverEndPoint = "/services/receivers/simple";
-
- /** The default password endpoint, can change over Splunk versions. */
- protected String passwordEndPoint = "admin/passwords";
-
- /** The version of this Splunk instance, once logged in. */
- public String version = null;
-
- /** The type of this Splunk instance, once logged in. */
- public String instanceType = null;
-
- /** The default host name, which is used when a host name is not provided.*/
- public static String DEFAULT_HOST = "localhost";
-
- /** The default port number, which is used when a port number is not
- * provided. */
- public static int DEFAULT_PORT = 8089;
-
- /** The default scheme, which is used when a scheme is not provided. */
- public static String DEFAULT_SCHEME = "https";
-
- /** Flag to notify SDK to try for re-login if the session has expired API call*/
- protected boolean autologin = false;
-
- /**
- * Creates a new {@code Service} instance using a host.
- *
- * @param host The host name.
- */
- public Service(String host) {
- super(host);
- }
-
- /**
- * Creates a new {@code Service} instance using a host and port.
- *
- * @param host The host name.
- * @param port The port number.
- */
- public Service(String host, int port) {
- super(host, port);
- }
-
- /**
- * Creates a new {@code Service} instance using a host, port, and
- * scheme for accessing the service ({@code http} or {@code https}).
- *
- * @param host The host name.
- * @param port The port number.
- * @param scheme The scheme ({@code http} or {@code https}).
- */
- public Service(String host, int port, String scheme) {
- super(host, port, scheme);
- }
-
- /**
- * Constructs a new {@code Service} instance using the given host,
- * port, and scheme, and instructing it to use the specified HTTPS handler.
- *
- * @param host The host name of the service.
- * @param port The port number of the service.
- * @param scheme Scheme for accessing the service ({@code http} or
- * {@code https}).
- * @param httpsHandler The URLStreamHandler instance
- */
- public Service(String host, int port, String scheme,
- URLStreamHandler httpsHandler) {
- this.host = host;
- this.port = port;
- this.scheme = scheme;
- this.httpsHandler = httpsHandler;
- }
-
- /**
- * Creates a new {@code Service} instance using a collection of arguments.
- *
- * @param args The {@code ServiceArgs} to initialize the service.
- */
- // NOTE: This overload exists primarily to provide better documentation
- // for the "args" parameter.
- @SuppressWarnings("deprecation")
- public Service(ServiceArgs args) {
- super();
- // NOTE: Must read the deprecated fields for backward compatibility.
- // (Consider the case where the fields are initialized directly,
- // rather than using the new setters.)
- // NOTE: Must also read the underlying dictionary for forward compatibility.
- // (Consider the case where the user calls Map.put() directly,
- // rather than using the new setters.)
- this.app = Args.get(args, "app", args.app != null ? args.app : null);
- this.host = Args.get(args, "host", args.host != null ? args.host : DEFAULT_HOST);
- this.owner = Args.get(args, "owner", args.owner != null ? args.owner : null);
- this.port = Args.get(args, "port", args.port != null ? args.port : DEFAULT_PORT);
- this.scheme = Args.get(args, "scheme", args.scheme != null ? args.scheme : DEFAULT_SCHEME);
- this.token = Args.get(args, "token", args.token != null ? args.token : null);
- this.username = (String)args.get("username");
- this.password = (String)args.get("password");
- this.autologin = Args.get(args, "autologin", false);
- this.httpsHandler = Args.get(args, "httpsHandler", null);
- this.setSslSecurityProtocol(Args.get(args, "SSLSecurityProtocol", Service.getSslSecurityProtocol()));
- this.addCookie((String)args.get("cookie"));
- this.setCustomHeaders((Map) args.get("customHeaders"));
- }
-
- /**
- * Creates a new {@code Service} instance using a map of arguments.
- *
- * @param args A {@code Map} of arguments to initialize the service.
- */
- public Service(Map args) {
- super();
- this.app = Args.get(args, "app", null);
- this.host = Args.get(args, "host", DEFAULT_HOST);
- this.owner = Args.get(args, "owner", null);
- this.port = Args.get(args, "port", DEFAULT_PORT);
- this.scheme = Args.get(args, "scheme", DEFAULT_SCHEME);
- this.token = Args.get(args, "token", null);
- this.username = (String)args.get("username");
- this.password = (String)args.get("password");
- this.autologin = Args.get(args, "autologin", false);
- this.httpsHandler = Args.get(args, "httpsHandler", null);
- this.setSslSecurityProtocol(Args.get(args, "SSLSecurityProtocol", Service.getSslSecurityProtocol()));
- this.addCookie((String)args.get("cookie"));
- this.connectTimeout = Args.get(args, "connectTimeout", null);
- this.readTimeout = Args.get(args, "readTimeout", null);
- }
-
- /**
- * Establishes a connection to a Splunk service using a map of arguments.
- * This member creates a new {@code Service} instance and authenticates
- * the session using credentials passed in from the {@code args} map.
- *
- * @param args The {@code args} map.
- * @return A new {@code Service} instance.
- */
- public static Service connect(Map